Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions demo/stories/presets/Preset.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {StrictMode, memo, useCallback, useEffect, useState} from 'react';

import {
type MarkdownEditorMarkupConfig,
type MarkdownEditorMode,
type MarkdownEditorPreset,
MarkdownEditorView,
type MarkdownEditorWysiwygConfig,
type MarkupString,
type RenderPreview,
useMarkdownEditor,
Expand Down Expand Up @@ -41,6 +43,8 @@ export type PresetDemoProps = {
stickyToolbar?: boolean;
height?: React.CSSProperties['height'];
toolbarsPreset?: ToolbarsPreset;
wysiwygConfig?: MarkdownEditorWysiwygConfig;
markupConfig?: MarkdownEditorMarkupConfig;
};

export const Preset = memo<PresetDemoProps>((props) => {
Expand All @@ -55,6 +59,8 @@ export const Preset = memo<PresetDemoProps>((props) => {
stickyToolbar,
height,
toolbarsPreset,
wysiwygConfig,
markupConfig,
} = props;
const [editorMode, setEditorMode] = useState<MarkdownEditorMode>('wysiwyg');
const [mdRaw, setMdRaw] = useState<MarkupString>('');
Expand Down Expand Up @@ -96,11 +102,13 @@ export const Preset = memo<PresetDemoProps>((props) => {
parseInsertedUrlAsImage,
},
},
...wysiwygConfig,
},
markupConfig: {
splitMode: splitModeOrientation,
renderPreview,
parseInsertedUrlAsImage,
...markupConfig,
},
});

Expand Down
23 changes: 23 additions & 0 deletions demo/stories/presets/Presets.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import type {StoryObj} from '@storybook/react';

import {
textContextItemData,
wBoldItemData,
wHeading1ItemData,
wHeading2ItemData,
wItalicItemData,
wTextItemData,
wToggleHeadingFoldingItemData,
} from 'src/bundle';

import {Preset as component} from './Preset';
import {toolbarPresets} from './presets';

Expand Down Expand Up @@ -28,6 +38,19 @@ export const Full: StoryObj<typeof component> = {
export const Custom: StoryObj<typeof component> = {
args: {
toolbarsPreset: custom,
wysiwygConfig: {
extensionOptions: {
commandMenu: {
actions: [wTextItemData, wHeading1ItemData, wHeading2ItemData],
},
selectionContext: {
config: [
[wToggleHeadingFoldingItemData, textContextItemData],
[wBoldItemData, wItalicItemData],
],
},
},
},
},
};

Expand Down
Loading