Skip to content

Commit d62b53a

Browse files
authored
chore(demo): updated custom toolbar story (#801)
1 parent b407ce4 commit d62b53a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

demo/stories/presets/Preset.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {StrictMode, memo, useCallback, useEffect, useState} from 'react';
22

33
import {
4+
type MarkdownEditorMarkupConfig,
45
type MarkdownEditorMode,
56
type MarkdownEditorPreset,
67
MarkdownEditorView,
8+
type MarkdownEditorWysiwygConfig,
79
type MarkupString,
810
type RenderPreview,
911
useMarkdownEditor,
@@ -41,6 +43,8 @@ export type PresetDemoProps = {
4143
stickyToolbar?: boolean;
4244
height?: React.CSSProperties['height'];
4345
toolbarsPreset?: ToolbarsPreset;
46+
wysiwygConfig?: MarkdownEditorWysiwygConfig;
47+
markupConfig?: MarkdownEditorMarkupConfig;
4448
};
4549

4650
export const Preset = memo<PresetDemoProps>((props) => {
@@ -55,6 +59,8 @@ export const Preset = memo<PresetDemoProps>((props) => {
5559
stickyToolbar,
5660
height,
5761
toolbarsPreset,
62+
wysiwygConfig,
63+
markupConfig,
5864
} = props;
5965
const [editorMode, setEditorMode] = useState<MarkdownEditorMode>('wysiwyg');
6066
const [mdRaw, setMdRaw] = useState<MarkupString>('');
@@ -96,11 +102,13 @@ export const Preset = memo<PresetDemoProps>((props) => {
96102
parseInsertedUrlAsImage,
97103
},
98104
},
105+
...wysiwygConfig,
99106
},
100107
markupConfig: {
101108
splitMode: splitModeOrientation,
102109
renderPreview,
103110
parseInsertedUrlAsImage,
111+
...markupConfig,
104112
},
105113
});
106114

demo/stories/presets/Presets.stories.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import type {StoryObj} from '@storybook/react';
22

3+
import {
4+
textContextItemData,
5+
wBoldItemData,
6+
wHeading1ItemData,
7+
wHeading2ItemData,
8+
wItalicItemData,
9+
wTextItemData,
10+
wToggleHeadingFoldingItemData,
11+
} from 'src/bundle';
12+
313
import {Preset as component} from './Preset';
414
import {toolbarPresets} from './presets';
515

@@ -28,6 +38,19 @@ export const Full: StoryObj<typeof component> = {
2838
export const Custom: StoryObj<typeof component> = {
2939
args: {
3040
toolbarsPreset: custom,
41+
wysiwygConfig: {
42+
extensionOptions: {
43+
commandMenu: {
44+
actions: [wTextItemData, wHeading1ItemData, wHeading2ItemData],
45+
},
46+
selectionContext: {
47+
config: [
48+
[wToggleHeadingFoldingItemData, textContextItemData],
49+
[wBoldItemData, wItalicItemData],
50+
],
51+
},
52+
},
53+
},
3154
},
3255
};
3356

0 commit comments

Comments
 (0)