@multiplatform.one/rich-text 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/cjs/RichEditor.cjs +132 -0
- package/dist/cjs/RichEditor.native.js +120 -0
- package/dist/cjs/RichEditor.native.js.map +1 -0
- package/dist/cjs/RichEditor.stories.cjs +327 -0
- package/dist/cjs/RichEditor.stories.native.js +342 -0
- package/dist/cjs/RichEditor.stories.native.js.map +1 -0
- package/dist/cjs/RichTextEditor/index.cjs +148 -0
- package/dist/cjs/RichTextEditor/index.native.js +160 -0
- package/dist/cjs/RichTextEditor/index.native.js.map +1 -0
- package/dist/cjs/constants.cjs +135 -0
- package/dist/cjs/constants.native.js +138 -0
- package/dist/cjs/constants.native.js.map +1 -0
- package/dist/cjs/context.cjs +33 -0
- package/dist/cjs/context.native.js +36 -0
- package/dist/cjs/context.native.js.map +1 -0
- package/dist/cjs/editor/BlockDragHandle.cjs +137 -0
- package/dist/cjs/editor/BlockDragHandle.native.js +142 -0
- package/dist/cjs/editor/BlockDragHandle.native.js.map +1 -0
- package/dist/cjs/editor/MarkdownPaste.cjs +65 -0
- package/dist/cjs/editor/MarkdownPaste.native.js +68 -0
- package/dist/cjs/editor/MarkdownPaste.native.js.map +1 -0
- package/dist/cjs/editor/SlashCommands.cjs +369 -0
- package/dist/cjs/editor/SlashCommands.native.js +424 -0
- package/dist/cjs/editor/SlashCommands.native.js.map +1 -0
- package/dist/cjs/editor/TentapEditor.native.js +242 -0
- package/dist/cjs/editor/TentapEditor.native.js.map +1 -0
- package/dist/cjs/editor/TiptapEditor.cjs +578 -0
- package/dist/cjs/editor/TiptapEditor.native.js +661 -0
- package/dist/cjs/editor/TiptapEditor.native.js.map +1 -0
- package/dist/cjs/editor/editorStyles.cjs +272 -0
- package/dist/cjs/editor/editorStyles.native.js +276 -0
- package/dist/cjs/editor/editorStyles.native.js.map +1 -0
- package/dist/cjs/editor/index.cjs +33 -0
- package/dist/cjs/editor/index.native.js +36 -0
- package/dist/cjs/editor/index.native.js.map +1 -0
- package/dist/cjs/editor/types.cjs +54 -0
- package/dist/cjs/editor/types.native.js +57 -0
- package/dist/cjs/editor/types.native.js.map +1 -0
- package/dist/cjs/editor/useEditorState.cjs +129 -0
- package/dist/cjs/editor/useEditorState.native.js +135 -0
- package/dist/cjs/editor/useEditorState.native.js.map +1 -0
- package/dist/cjs/index.cjs +30 -0
- package/dist/cjs/index.native.js +33 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/styled.cjs +173 -0
- package/dist/cjs/styled.native.js +185 -0
- package/dist/cjs/styled.native.js.map +1 -0
- package/dist/cjs/toolbar/BubbleToolbar.cjs +130 -0
- package/dist/cjs/toolbar/BubbleToolbar.native.js +159 -0
- package/dist/cjs/toolbar/BubbleToolbar.native.js.map +1 -0
- package/dist/cjs/toolbar/CodeBlockBubble.cjs +211 -0
- package/dist/cjs/toolbar/CodeBlockBubble.native.js +228 -0
- package/dist/cjs/toolbar/CodeBlockBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/ColorPicker.cjs +217 -0
- package/dist/cjs/toolbar/ColorPicker.native.js +234 -0
- package/dist/cjs/toolbar/ColorPicker.native.js.map +1 -0
- package/dist/cjs/toolbar/FixedToolbar.cjs +221 -0
- package/dist/cjs/toolbar/FixedToolbar.native.js +322 -0
- package/dist/cjs/toolbar/FixedToolbar.native.js.map +1 -0
- package/dist/cjs/toolbar/HeadingPicker.cjs +158 -0
- package/dist/cjs/toolbar/HeadingPicker.native.js +167 -0
- package/dist/cjs/toolbar/HeadingPicker.native.js.map +1 -0
- package/dist/cjs/toolbar/ImageBubble.cjs +156 -0
- package/dist/cjs/toolbar/ImageBubble.native.js +165 -0
- package/dist/cjs/toolbar/ImageBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/ImageDialog.cjs +115 -0
- package/dist/cjs/toolbar/ImageDialog.native.js +122 -0
- package/dist/cjs/toolbar/ImageDialog.native.js.map +1 -0
- package/dist/cjs/toolbar/LinkBubble.cjs +195 -0
- package/dist/cjs/toolbar/LinkBubble.native.js +204 -0
- package/dist/cjs/toolbar/LinkBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/LinkDialog.cjs +138 -0
- package/dist/cjs/toolbar/LinkDialog.native.js +146 -0
- package/dist/cjs/toolbar/LinkDialog.native.js.map +1 -0
- package/dist/cjs/toolbar/ListPicker.cjs +117 -0
- package/dist/cjs/toolbar/ListPicker.native.js +124 -0
- package/dist/cjs/toolbar/ListPicker.native.js.map +1 -0
- package/dist/cjs/toolbar/MoreDropdown.cjs +201 -0
- package/dist/cjs/toolbar/MoreDropdown.native.js +224 -0
- package/dist/cjs/toolbar/MoreDropdown.native.js.map +1 -0
- package/dist/cjs/toolbar/ResizeHandle.cjs +105 -0
- package/dist/cjs/toolbar/ResizeHandle.native.js +109 -0
- package/dist/cjs/toolbar/ResizeHandle.native.js.map +1 -0
- package/dist/cjs/toolbar/StatusBar.cjs +91 -0
- package/dist/cjs/toolbar/StatusBar.native.js +100 -0
- package/dist/cjs/toolbar/StatusBar.native.js.map +1 -0
- package/dist/cjs/toolbar/TableBubble.cjs +232 -0
- package/dist/cjs/toolbar/TableBubble.native.js +273 -0
- package/dist/cjs/toolbar/TableBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/ToolbarButton.cjs +105 -0
- package/dist/cjs/toolbar/ToolbarButton.native.js +97 -0
- package/dist/cjs/toolbar/ToolbarButton.native.js.map +1 -0
- package/dist/cjs/toolbar/ToolbarGroup.cjs +41 -0
- package/dist/cjs/toolbar/ToolbarGroup.native.js +45 -0
- package/dist/cjs/toolbar/ToolbarGroup.native.js.map +1 -0
- package/dist/cjs/toolbar/icons.cjs +601 -0
- package/dist/cjs/toolbar/icons.native.js +165 -0
- package/dist/cjs/toolbar/icons.native.js.map +1 -0
- package/dist/cjs/toolbar/shortcuts.cjs +62 -0
- package/dist/cjs/toolbar/shortcuts.native.js +66 -0
- package/dist/cjs/toolbar/shortcuts.native.js.map +1 -0
- package/dist/cjs/toolbar/useHorizontalScroll.cjs +250 -0
- package/dist/cjs/toolbar/useHorizontalScroll.native.js +260 -0
- package/dist/cjs/toolbar/useHorizontalScroll.native.js.map +1 -0
- package/dist/cjs/types.cjs +56 -0
- package/dist/cjs/types.native.js +59 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/esm/RichEditor.mjs +107 -0
- package/dist/esm/RichEditor.mjs.map +1 -0
- package/dist/esm/RichEditor.native.js +92 -0
- package/dist/esm/RichEditor.native.js.map +1 -0
- package/dist/esm/RichEditor.stories.mjs +291 -0
- package/dist/esm/RichEditor.stories.mjs.map +1 -0
- package/dist/esm/RichEditor.stories.native.js +303 -0
- package/dist/esm/RichEditor.stories.native.js.map +1 -0
- package/dist/esm/RichTextEditor/index.mjs +123 -0
- package/dist/esm/RichTextEditor/index.mjs.map +1 -0
- package/dist/esm/RichTextEditor/index.native.js +132 -0
- package/dist/esm/RichTextEditor/index.native.js.map +1 -0
- package/dist/esm/constants.mjs +108 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/constants.native.js +108 -0
- package/dist/esm/constants.native.js.map +1 -0
- package/dist/esm/context.mjs +8 -0
- package/dist/esm/context.mjs.map +1 -0
- package/dist/esm/context.native.js +8 -0
- package/dist/esm/context.native.js.map +1 -0
- package/dist/esm/editor/BlockDragHandle.mjs +112 -0
- package/dist/esm/editor/BlockDragHandle.mjs.map +1 -0
- package/dist/esm/editor/BlockDragHandle.native.js +114 -0
- package/dist/esm/editor/BlockDragHandle.native.js.map +1 -0
- package/dist/esm/editor/MarkdownPaste.mjs +40 -0
- package/dist/esm/editor/MarkdownPaste.mjs.map +1 -0
- package/dist/esm/editor/MarkdownPaste.native.js +40 -0
- package/dist/esm/editor/MarkdownPaste.native.js.map +1 -0
- package/dist/esm/editor/SlashCommands.mjs +333 -0
- package/dist/esm/editor/SlashCommands.mjs.map +1 -0
- package/dist/esm/editor/SlashCommands.native.js +385 -0
- package/dist/esm/editor/SlashCommands.native.js.map +1 -0
- package/dist/esm/editor/TentapEditor.native.js +214 -0
- package/dist/esm/editor/TentapEditor.native.js.map +1 -0
- package/dist/esm/editor/TiptapEditor.mjs +542 -0
- package/dist/esm/editor/TiptapEditor.mjs.map +1 -0
- package/dist/esm/editor/TiptapEditor.native.js +622 -0
- package/dist/esm/editor/TiptapEditor.native.js.map +1 -0
- package/dist/esm/editor/editorStyles.mjs +247 -0
- package/dist/esm/editor/editorStyles.mjs.map +1 -0
- package/dist/esm/editor/editorStyles.native.js +248 -0
- package/dist/esm/editor/editorStyles.native.js.map +1 -0
- package/dist/esm/editor/index.mjs +5 -0
- package/dist/esm/editor/index.mjs.map +1 -0
- package/dist/esm/editor/index.native.js +5 -0
- package/dist/esm/editor/index.native.js.map +1 -0
- package/dist/esm/editor/types.mjs +29 -0
- package/dist/esm/editor/types.mjs.map +1 -0
- package/dist/esm/editor/types.native.js +29 -0
- package/dist/esm/editor/types.native.js.map +1 -0
- package/dist/esm/editor/useEditorState.mjs +102 -0
- package/dist/esm/editor/useEditorState.mjs.map +1 -0
- package/dist/esm/editor/useEditorState.native.js +105 -0
- package/dist/esm/editor/useEditorState.native.js.map +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +4 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/styled.mjs +144 -0
- package/dist/esm/styled.mjs.map +1 -0
- package/dist/esm/styled.native.js +153 -0
- package/dist/esm/styled.native.js.map +1 -0
- package/dist/esm/toolbar/BubbleToolbar.mjs +105 -0
- package/dist/esm/toolbar/BubbleToolbar.mjs.map +1 -0
- package/dist/esm/toolbar/BubbleToolbar.native.js +131 -0
- package/dist/esm/toolbar/BubbleToolbar.native.js.map +1 -0
- package/dist/esm/toolbar/CodeBlockBubble.mjs +186 -0
- package/dist/esm/toolbar/CodeBlockBubble.mjs.map +1 -0
- package/dist/esm/toolbar/CodeBlockBubble.native.js +200 -0
- package/dist/esm/toolbar/CodeBlockBubble.native.js.map +1 -0
- package/dist/esm/toolbar/ColorPicker.mjs +191 -0
- package/dist/esm/toolbar/ColorPicker.mjs.map +1 -0
- package/dist/esm/toolbar/ColorPicker.native.js +205 -0
- package/dist/esm/toolbar/ColorPicker.native.js.map +1 -0
- package/dist/esm/toolbar/FixedToolbar.mjs +196 -0
- package/dist/esm/toolbar/FixedToolbar.mjs.map +1 -0
- package/dist/esm/toolbar/FixedToolbar.native.js +294 -0
- package/dist/esm/toolbar/FixedToolbar.native.js.map +1 -0
- package/dist/esm/toolbar/HeadingPicker.mjs +133 -0
- package/dist/esm/toolbar/HeadingPicker.mjs.map +1 -0
- package/dist/esm/toolbar/HeadingPicker.native.js +139 -0
- package/dist/esm/toolbar/HeadingPicker.native.js.map +1 -0
- package/dist/esm/toolbar/ImageBubble.mjs +131 -0
- package/dist/esm/toolbar/ImageBubble.mjs.map +1 -0
- package/dist/esm/toolbar/ImageBubble.native.js +137 -0
- package/dist/esm/toolbar/ImageBubble.native.js.map +1 -0
- package/dist/esm/toolbar/ImageDialog.mjs +90 -0
- package/dist/esm/toolbar/ImageDialog.mjs.map +1 -0
- package/dist/esm/toolbar/ImageDialog.native.js +94 -0
- package/dist/esm/toolbar/ImageDialog.native.js.map +1 -0
- package/dist/esm/toolbar/LinkBubble.mjs +170 -0
- package/dist/esm/toolbar/LinkBubble.mjs.map +1 -0
- package/dist/esm/toolbar/LinkBubble.native.js +176 -0
- package/dist/esm/toolbar/LinkBubble.native.js.map +1 -0
- package/dist/esm/toolbar/LinkDialog.mjs +112 -0
- package/dist/esm/toolbar/LinkDialog.mjs.map +1 -0
- package/dist/esm/toolbar/LinkDialog.native.js +117 -0
- package/dist/esm/toolbar/LinkDialog.native.js.map +1 -0
- package/dist/esm/toolbar/ListPicker.mjs +92 -0
- package/dist/esm/toolbar/ListPicker.mjs.map +1 -0
- package/dist/esm/toolbar/ListPicker.native.js +96 -0
- package/dist/esm/toolbar/ListPicker.native.js.map +1 -0
- package/dist/esm/toolbar/MoreDropdown.mjs +176 -0
- package/dist/esm/toolbar/MoreDropdown.mjs.map +1 -0
- package/dist/esm/toolbar/MoreDropdown.native.js +196 -0
- package/dist/esm/toolbar/MoreDropdown.native.js.map +1 -0
- package/dist/esm/toolbar/ResizeHandle.mjs +80 -0
- package/dist/esm/toolbar/ResizeHandle.mjs.map +1 -0
- package/dist/esm/toolbar/ResizeHandle.native.js +81 -0
- package/dist/esm/toolbar/ResizeHandle.native.js.map +1 -0
- package/dist/esm/toolbar/StatusBar.mjs +66 -0
- package/dist/esm/toolbar/StatusBar.mjs.map +1 -0
- package/dist/esm/toolbar/StatusBar.native.js +72 -0
- package/dist/esm/toolbar/StatusBar.native.js.map +1 -0
- package/dist/esm/toolbar/TableBubble.mjs +207 -0
- package/dist/esm/toolbar/TableBubble.mjs.map +1 -0
- package/dist/esm/toolbar/TableBubble.native.js +245 -0
- package/dist/esm/toolbar/TableBubble.native.js.map +1 -0
- package/dist/esm/toolbar/ToolbarButton.mjs +79 -0
- package/dist/esm/toolbar/ToolbarButton.mjs.map +1 -0
- package/dist/esm/toolbar/ToolbarButton.native.js +68 -0
- package/dist/esm/toolbar/ToolbarButton.native.js.map +1 -0
- package/dist/esm/toolbar/ToolbarGroup.mjs +16 -0
- package/dist/esm/toolbar/ToolbarGroup.mjs.map +1 -0
- package/dist/esm/toolbar/ToolbarGroup.native.js +17 -0
- package/dist/esm/toolbar/ToolbarGroup.native.js.map +1 -0
- package/dist/esm/toolbar/icons.mjs +554 -0
- package/dist/esm/toolbar/icons.mjs.map +1 -0
- package/dist/esm/toolbar/icons.native.js +115 -0
- package/dist/esm/toolbar/icons.native.js.map +1 -0
- package/dist/esm/toolbar/shortcuts.mjs +36 -0
- package/dist/esm/toolbar/shortcuts.mjs.map +1 -0
- package/dist/esm/toolbar/shortcuts.native.js +37 -0
- package/dist/esm/toolbar/shortcuts.native.js.map +1 -0
- package/dist/esm/toolbar/useHorizontalScroll.mjs +223 -0
- package/dist/esm/toolbar/useHorizontalScroll.mjs.map +1 -0
- package/dist/esm/toolbar/useHorizontalScroll.native.js +230 -0
- package/dist/esm/toolbar/useHorizontalScroll.native.js.map +1 -0
- package/dist/esm/types.mjs +31 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +31 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/jsx/RichEditor.mjs +107 -0
- package/dist/jsx/RichEditor.mjs.map +1 -0
- package/dist/jsx/RichEditor.native.js +120 -0
- package/dist/jsx/RichEditor.native.js.map +1 -0
- package/dist/jsx/RichEditor.stories.mjs +291 -0
- package/dist/jsx/RichEditor.stories.mjs.map +1 -0
- package/dist/jsx/RichEditor.stories.native.js +342 -0
- package/dist/jsx/RichEditor.stories.native.js.map +1 -0
- package/dist/jsx/RichTextEditor/index.mjs +123 -0
- package/dist/jsx/RichTextEditor/index.mjs.map +1 -0
- package/dist/jsx/RichTextEditor/index.native.js +160 -0
- package/dist/jsx/RichTextEditor/index.native.js.map +1 -0
- package/dist/jsx/constants.mjs +108 -0
- package/dist/jsx/constants.mjs.map +1 -0
- package/dist/jsx/constants.native.js +138 -0
- package/dist/jsx/constants.native.js.map +1 -0
- package/dist/jsx/context.mjs +8 -0
- package/dist/jsx/context.mjs.map +1 -0
- package/dist/jsx/context.native.js +36 -0
- package/dist/jsx/context.native.js.map +1 -0
- package/dist/jsx/editor/BlockDragHandle.mjs +112 -0
- package/dist/jsx/editor/BlockDragHandle.mjs.map +1 -0
- package/dist/jsx/editor/BlockDragHandle.native.js +142 -0
- package/dist/jsx/editor/BlockDragHandle.native.js.map +1 -0
- package/dist/jsx/editor/MarkdownPaste.mjs +40 -0
- package/dist/jsx/editor/MarkdownPaste.mjs.map +1 -0
- package/dist/jsx/editor/MarkdownPaste.native.js +68 -0
- package/dist/jsx/editor/MarkdownPaste.native.js.map +1 -0
- package/dist/jsx/editor/SlashCommands.mjs +333 -0
- package/dist/jsx/editor/SlashCommands.mjs.map +1 -0
- package/dist/jsx/editor/SlashCommands.native.js +424 -0
- package/dist/jsx/editor/SlashCommands.native.js.map +1 -0
- package/dist/jsx/editor/TentapEditor.native.js +242 -0
- package/dist/jsx/editor/TentapEditor.native.js.map +1 -0
- package/dist/jsx/editor/TiptapEditor.mjs +542 -0
- package/dist/jsx/editor/TiptapEditor.mjs.map +1 -0
- package/dist/jsx/editor/TiptapEditor.native.js +661 -0
- package/dist/jsx/editor/TiptapEditor.native.js.map +1 -0
- package/dist/jsx/editor/editorStyles.mjs +247 -0
- package/dist/jsx/editor/editorStyles.mjs.map +1 -0
- package/dist/jsx/editor/editorStyles.native.js +276 -0
- package/dist/jsx/editor/editorStyles.native.js.map +1 -0
- package/dist/jsx/editor/index.mjs +5 -0
- package/dist/jsx/editor/index.mjs.map +1 -0
- package/dist/jsx/editor/index.native.js +36 -0
- package/dist/jsx/editor/index.native.js.map +1 -0
- package/dist/jsx/editor/types.mjs +29 -0
- package/dist/jsx/editor/types.mjs.map +1 -0
- package/dist/jsx/editor/types.native.js +57 -0
- package/dist/jsx/editor/types.native.js.map +1 -0
- package/dist/jsx/editor/useEditorState.mjs +102 -0
- package/dist/jsx/editor/useEditorState.mjs.map +1 -0
- package/dist/jsx/editor/useEditorState.native.js +135 -0
- package/dist/jsx/editor/useEditorState.native.js.map +1 -0
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +4 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +33 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/styled.mjs +144 -0
- package/dist/jsx/styled.mjs.map +1 -0
- package/dist/jsx/styled.native.js +185 -0
- package/dist/jsx/styled.native.js.map +1 -0
- package/dist/jsx/toolbar/BubbleToolbar.mjs +105 -0
- package/dist/jsx/toolbar/BubbleToolbar.mjs.map +1 -0
- package/dist/jsx/toolbar/BubbleToolbar.native.js +159 -0
- package/dist/jsx/toolbar/BubbleToolbar.native.js.map +1 -0
- package/dist/jsx/toolbar/CodeBlockBubble.mjs +186 -0
- package/dist/jsx/toolbar/CodeBlockBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/CodeBlockBubble.native.js +228 -0
- package/dist/jsx/toolbar/CodeBlockBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/ColorPicker.mjs +191 -0
- package/dist/jsx/toolbar/ColorPicker.mjs.map +1 -0
- package/dist/jsx/toolbar/ColorPicker.native.js +234 -0
- package/dist/jsx/toolbar/ColorPicker.native.js.map +1 -0
- package/dist/jsx/toolbar/FixedToolbar.mjs +196 -0
- package/dist/jsx/toolbar/FixedToolbar.mjs.map +1 -0
- package/dist/jsx/toolbar/FixedToolbar.native.js +322 -0
- package/dist/jsx/toolbar/FixedToolbar.native.js.map +1 -0
- package/dist/jsx/toolbar/HeadingPicker.mjs +133 -0
- package/dist/jsx/toolbar/HeadingPicker.mjs.map +1 -0
- package/dist/jsx/toolbar/HeadingPicker.native.js +167 -0
- package/dist/jsx/toolbar/HeadingPicker.native.js.map +1 -0
- package/dist/jsx/toolbar/ImageBubble.mjs +131 -0
- package/dist/jsx/toolbar/ImageBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/ImageBubble.native.js +165 -0
- package/dist/jsx/toolbar/ImageBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/ImageDialog.mjs +90 -0
- package/dist/jsx/toolbar/ImageDialog.mjs.map +1 -0
- package/dist/jsx/toolbar/ImageDialog.native.js +122 -0
- package/dist/jsx/toolbar/ImageDialog.native.js.map +1 -0
- package/dist/jsx/toolbar/LinkBubble.mjs +170 -0
- package/dist/jsx/toolbar/LinkBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/LinkBubble.native.js +204 -0
- package/dist/jsx/toolbar/LinkBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/LinkDialog.mjs +112 -0
- package/dist/jsx/toolbar/LinkDialog.mjs.map +1 -0
- package/dist/jsx/toolbar/LinkDialog.native.js +146 -0
- package/dist/jsx/toolbar/LinkDialog.native.js.map +1 -0
- package/dist/jsx/toolbar/ListPicker.mjs +92 -0
- package/dist/jsx/toolbar/ListPicker.mjs.map +1 -0
- package/dist/jsx/toolbar/ListPicker.native.js +124 -0
- package/dist/jsx/toolbar/ListPicker.native.js.map +1 -0
- package/dist/jsx/toolbar/MoreDropdown.mjs +176 -0
- package/dist/jsx/toolbar/MoreDropdown.mjs.map +1 -0
- package/dist/jsx/toolbar/MoreDropdown.native.js +224 -0
- package/dist/jsx/toolbar/MoreDropdown.native.js.map +1 -0
- package/dist/jsx/toolbar/ResizeHandle.mjs +80 -0
- package/dist/jsx/toolbar/ResizeHandle.mjs.map +1 -0
- package/dist/jsx/toolbar/ResizeHandle.native.js +109 -0
- package/dist/jsx/toolbar/ResizeHandle.native.js.map +1 -0
- package/dist/jsx/toolbar/StatusBar.mjs +66 -0
- package/dist/jsx/toolbar/StatusBar.mjs.map +1 -0
- package/dist/jsx/toolbar/StatusBar.native.js +100 -0
- package/dist/jsx/toolbar/StatusBar.native.js.map +1 -0
- package/dist/jsx/toolbar/TableBubble.mjs +207 -0
- package/dist/jsx/toolbar/TableBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/TableBubble.native.js +273 -0
- package/dist/jsx/toolbar/TableBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/ToolbarButton.mjs +79 -0
- package/dist/jsx/toolbar/ToolbarButton.mjs.map +1 -0
- package/dist/jsx/toolbar/ToolbarButton.native.js +97 -0
- package/dist/jsx/toolbar/ToolbarButton.native.js.map +1 -0
- package/dist/jsx/toolbar/ToolbarGroup.mjs +16 -0
- package/dist/jsx/toolbar/ToolbarGroup.mjs.map +1 -0
- package/dist/jsx/toolbar/ToolbarGroup.native.js +45 -0
- package/dist/jsx/toolbar/ToolbarGroup.native.js.map +1 -0
- package/dist/jsx/toolbar/icons.mjs +554 -0
- package/dist/jsx/toolbar/icons.mjs.map +1 -0
- package/dist/jsx/toolbar/icons.native.js +165 -0
- package/dist/jsx/toolbar/icons.native.js.map +1 -0
- package/dist/jsx/toolbar/shortcuts.mjs +36 -0
- package/dist/jsx/toolbar/shortcuts.mjs.map +1 -0
- package/dist/jsx/toolbar/shortcuts.native.js +66 -0
- package/dist/jsx/toolbar/shortcuts.native.js.map +1 -0
- package/dist/jsx/toolbar/useHorizontalScroll.mjs +223 -0
- package/dist/jsx/toolbar/useHorizontalScroll.mjs.map +1 -0
- package/dist/jsx/toolbar/useHorizontalScroll.native.js +260 -0
- package/dist/jsx/toolbar/useHorizontalScroll.native.js.map +1 -0
- package/dist/jsx/types.mjs +31 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/dist/jsx/types.native.js +59 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/package.json +117 -0
- package/src/RichEditor.native.tsx +161 -0
- package/src/RichEditor.stories.tsx +324 -0
- package/src/RichEditor.tsx +185 -0
- package/src/RichTextEditor/index.tsx +245 -0
- package/src/RichTextEditor/richTextEditor.spec.tsx +239 -0
- package/src/constants.ts +100 -0
- package/src/context.spec.ts +9 -0
- package/src/context.ts +16 -0
- package/src/editor/BlockDragHandle.ts +141 -0
- package/src/editor/MarkdownPaste.ts +50 -0
- package/src/editor/SlashCommands.tsx +357 -0
- package/src/editor/TentapEditor.native.tsx +269 -0
- package/src/editor/TiptapEditor.tsx +616 -0
- package/src/editor/editorStyles.spec.ts +24 -0
- package/src/editor/editorStyles.ts +260 -0
- package/src/editor/index.ts +10 -0
- package/src/editor/tentapEditor.spec.ts +125 -0
- package/src/editor/tiptapEditor.spec.tsx +169 -0
- package/src/editor/types.ts +142 -0
- package/src/editor/useEditorState.spec.ts +93 -0
- package/src/editor/useEditorState.ts +125 -0
- package/src/exports.spec.ts +128 -0
- package/src/index.ts +13 -0
- package/src/integration.spec.tsx +430 -0
- package/src/richEditor.spec.tsx +169 -0
- package/src/styled.spec.tsx +42 -0
- package/src/styled.ts +177 -0
- package/src/toolbar/BubbleToolbar.tsx +151 -0
- package/src/toolbar/CodeBlockBubble.tsx +141 -0
- package/src/toolbar/ColorPicker.tsx +211 -0
- package/src/toolbar/FixedToolbar.native.tsx +381 -0
- package/src/toolbar/FixedToolbar.tsx +252 -0
- package/src/toolbar/HeadingPicker.tsx +169 -0
- package/src/toolbar/ImageBubble.tsx +126 -0
- package/src/toolbar/ImageDialog.tsx +93 -0
- package/src/toolbar/LinkBubble.tsx +166 -0
- package/src/toolbar/LinkDialog.tsx +124 -0
- package/src/toolbar/ListPicker.tsx +121 -0
- package/src/toolbar/MoreDropdown.tsx +185 -0
- package/src/toolbar/ResizeHandle.tsx +80 -0
- package/src/toolbar/StatusBar.tsx +76 -0
- package/src/toolbar/TableBubble.tsx +197 -0
- package/src/toolbar/ToolbarButton.native.tsx +105 -0
- package/src/toolbar/ToolbarButton.tsx +114 -0
- package/src/toolbar/ToolbarGroup.tsx +38 -0
- package/src/toolbar/bubbleToolbar.spec.tsx +93 -0
- package/src/toolbar/fixedToolbar.spec.tsx +127 -0
- package/src/toolbar/icons.native.tsx +112 -0
- package/src/toolbar/icons.tsx +417 -0
- package/src/toolbar/shortcuts.ts +42 -0
- package/src/toolbar/toolbarPrimitives.spec.tsx +118 -0
- package/src/toolbar/toolbarSubComponents.spec.tsx +115 -0
- package/src/toolbar/useHorizontalScroll.tsx +270 -0
- package/src/types.spec.ts +102 -0
- package/src/types.ts +217 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal block drag handle extension.
|
|
3
|
+
* Shows a grip icon to the left of the hovered top-level block.
|
|
4
|
+
* Dragging from the handle moves the entire block.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Extension } from "@tiptap/core";
|
|
8
|
+
import { Plugin, PluginKey, NodeSelection } from "@tiptap/pm/state";
|
|
9
|
+
|
|
10
|
+
const HANDLE_WIDTH = 20;
|
|
11
|
+
const HANDLE_HTML = `<svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor" opacity="0.35"><circle cx="4" cy="3" r="1.2"/><circle cx="10" cy="3" r="1.2"/><circle cx="4" cy="7" r="1.2"/><circle cx="10" cy="7" r="1.2"/><circle cx="4" cy="11" r="1.2"/><circle cx="10" cy="11" r="1.2"/></svg>`;
|
|
12
|
+
|
|
13
|
+
function createHandleElement(): HTMLDivElement {
|
|
14
|
+
const el = document.createElement("div");
|
|
15
|
+
el.className = "block-drag-handle";
|
|
16
|
+
el.draggable = true;
|
|
17
|
+
el.innerHTML = HANDLE_HTML;
|
|
18
|
+
Object.assign(el.style, {
|
|
19
|
+
position: "absolute",
|
|
20
|
+
width: `${HANDLE_WIDTH}px`,
|
|
21
|
+
height: `${HANDLE_WIDTH}px`,
|
|
22
|
+
display: "flex",
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
cursor: "grab",
|
|
26
|
+
borderRadius: "4px",
|
|
27
|
+
opacity: "0",
|
|
28
|
+
transition: "opacity 0.15s",
|
|
29
|
+
zIndex: "10",
|
|
30
|
+
userSelect: "none",
|
|
31
|
+
});
|
|
32
|
+
return el;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const BlockDragHandle = Extension.create({
|
|
36
|
+
name: "blockDragHandle",
|
|
37
|
+
|
|
38
|
+
addProseMirrorPlugins() {
|
|
39
|
+
const { editor } = this;
|
|
40
|
+
let handle: HTMLDivElement | null = null;
|
|
41
|
+
let currentBlockPos: number | null = null;
|
|
42
|
+
|
|
43
|
+
return [
|
|
44
|
+
new Plugin({
|
|
45
|
+
key: new PluginKey("blockDragHandle"),
|
|
46
|
+
|
|
47
|
+
view(editorView) {
|
|
48
|
+
handle = createHandleElement();
|
|
49
|
+
editorView.dom.parentElement?.appendChild(handle);
|
|
50
|
+
editorView.dom.parentElement!.style.position = "relative";
|
|
51
|
+
|
|
52
|
+
const onMouseMove = (event: MouseEvent) => {
|
|
53
|
+
if (!handle || !editorView.dom.contains(event.target as Node)) {
|
|
54
|
+
if (handle) handle.style.opacity = "0";
|
|
55
|
+
currentBlockPos = null;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const pos = editorView.posAtCoords({
|
|
60
|
+
left: event.clientX,
|
|
61
|
+
top: event.clientY,
|
|
62
|
+
});
|
|
63
|
+
if (!pos) {
|
|
64
|
+
handle.style.opacity = "0";
|
|
65
|
+
currentBlockPos = null;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const $pos = editorView.state.doc.resolve(pos.pos);
|
|
70
|
+
const depth = $pos.depth;
|
|
71
|
+
if (depth === 0) {
|
|
72
|
+
handle.style.opacity = "0";
|
|
73
|
+
currentBlockPos = null;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const topLevelPos = $pos.before(1);
|
|
78
|
+
const node = editorView.state.doc.nodeAt(topLevelPos);
|
|
79
|
+
if (!node) {
|
|
80
|
+
handle.style.opacity = "0";
|
|
81
|
+
currentBlockPos = null;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
currentBlockPos = topLevelPos;
|
|
86
|
+
|
|
87
|
+
const domNode = editorView.nodeDOM(topLevelPos) as HTMLElement | null;
|
|
88
|
+
if (!domNode) {
|
|
89
|
+
handle.style.opacity = "0";
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const editorRect = editorView.dom.parentElement!.getBoundingClientRect();
|
|
94
|
+
const blockRect = domNode.getBoundingClientRect();
|
|
95
|
+
|
|
96
|
+
handle.style.left = `${blockRect.left - editorRect.left - HANDLE_WIDTH - 2}px`;
|
|
97
|
+
handle.style.top = `${blockRect.top - editorRect.top + 2}px`;
|
|
98
|
+
handle.style.opacity = "1";
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const onMouseLeave = () => {
|
|
102
|
+
if (handle) handle.style.opacity = "0";
|
|
103
|
+
currentBlockPos = null;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const onDragStart = (event: DragEvent) => {
|
|
107
|
+
if (currentBlockPos == null) return;
|
|
108
|
+
const node = editorView.state.doc.nodeAt(currentBlockPos);
|
|
109
|
+
if (!node) return;
|
|
110
|
+
|
|
111
|
+
const sel = NodeSelection.create(editorView.state.doc, currentBlockPos);
|
|
112
|
+
editorView.dispatch(editorView.state.tr.setSelection(sel));
|
|
113
|
+
|
|
114
|
+
editorView.dragging = {
|
|
115
|
+
slice: sel.content(),
|
|
116
|
+
move: true,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
event.dataTransfer?.setDragImage(
|
|
120
|
+
editorView.nodeDOM(currentBlockPos) as HTMLElement,
|
|
121
|
+
0,
|
|
122
|
+
0,
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
handle.addEventListener("dragstart", onDragStart);
|
|
127
|
+
editorView.dom.addEventListener("mousemove", onMouseMove);
|
|
128
|
+
editorView.dom.addEventListener("mouseleave", onMouseLeave);
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
destroy() {
|
|
132
|
+
handle?.remove();
|
|
133
|
+
editorView.dom.removeEventListener("mousemove", onMouseMove);
|
|
134
|
+
editorView.dom.removeEventListener("mouseleave", onMouseLeave);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
];
|
|
140
|
+
},
|
|
141
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension that intercepts paste events containing markdown-formatted plain
|
|
3
|
+
* text and converts it to HTML before insertion. If the clipboard already
|
|
4
|
+
* contains HTML (e.g. from a web page), the default paste behavior is used.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Extension } from "@tiptap/core";
|
|
8
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
9
|
+
import { marked } from "marked";
|
|
10
|
+
|
|
11
|
+
const MARKDOWN_PATTERN = /(?:^#{1,6}\s|^\*\s|^-\s|^\d+\.\s|```|^\[.+\]\(.+\)|^\*\*|^>\s)/m;
|
|
12
|
+
|
|
13
|
+
function looksLikeMarkdown(text: string): boolean {
|
|
14
|
+
return MARKDOWN_PATTERN.test(text);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const MarkdownPaste = Extension.create({
|
|
18
|
+
name: "markdownPaste",
|
|
19
|
+
|
|
20
|
+
addProseMirrorPlugins() {
|
|
21
|
+
const { editor } = this;
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
new Plugin({
|
|
25
|
+
key: new PluginKey("markdownPaste"),
|
|
26
|
+
props: {
|
|
27
|
+
handlePaste(view, event) {
|
|
28
|
+
const clipboardData = event.clipboardData;
|
|
29
|
+
if (!clipboardData) return false;
|
|
30
|
+
|
|
31
|
+
const hasHTML = clipboardData.types.includes("text/html");
|
|
32
|
+
if (hasHTML) return false;
|
|
33
|
+
|
|
34
|
+
const text = clipboardData.getData("text/plain");
|
|
35
|
+
if (!text || !looksLikeMarkdown(text)) return false;
|
|
36
|
+
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
|
|
39
|
+
const html = marked.parse(text, { async: false }) as string;
|
|
40
|
+
editor.commands.insertContent(html, {
|
|
41
|
+
parseOptions: { preserveWhitespace: false },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return true;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
];
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash commands extension -- type "/" to open a menu of block types.
|
|
3
|
+
* Uses @tiptap/suggestion for trigger/matching and a React component for the popup.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Extension } from "@tiptap/core";
|
|
7
|
+
import { ReactRenderer } from "@tiptap/react";
|
|
8
|
+
import Suggestion from "@tiptap/suggestion";
|
|
9
|
+
import type { Editor, Range } from "@tiptap/core";
|
|
10
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
11
|
+
|
|
12
|
+
// ===========================================================================
|
|
13
|
+
// Slash Command Items
|
|
14
|
+
// ===========================================================================
|
|
15
|
+
|
|
16
|
+
export interface SlashCommandItem {
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
icon: string;
|
|
20
|
+
command: (props: { editor: Editor; range: Range }) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const SLASH_ITEMS: SlashCommandItem[] = [
|
|
24
|
+
{
|
|
25
|
+
title: "Heading 1",
|
|
26
|
+
description: "Large section heading",
|
|
27
|
+
icon: "H1",
|
|
28
|
+
command: ({ editor, range }) =>
|
|
29
|
+
editor.chain().focus().deleteRange(range).setHeading({ level: 1 }).run(),
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: "Heading 2",
|
|
33
|
+
description: "Medium section heading",
|
|
34
|
+
icon: "H2",
|
|
35
|
+
command: ({ editor, range }) =>
|
|
36
|
+
editor.chain().focus().deleteRange(range).setHeading({ level: 2 }).run(),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: "Heading 3",
|
|
40
|
+
description: "Small section heading",
|
|
41
|
+
icon: "H3",
|
|
42
|
+
command: ({ editor, range }) =>
|
|
43
|
+
editor.chain().focus().deleteRange(range).setHeading({ level: 3 }).run(),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: "Bullet List",
|
|
47
|
+
description: "Unordered list with bullets",
|
|
48
|
+
icon: "•",
|
|
49
|
+
command: ({ editor, range }) =>
|
|
50
|
+
editor.chain().focus().deleteRange(range).toggleBulletList().run(),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: "Numbered List",
|
|
54
|
+
description: "Ordered list with numbers",
|
|
55
|
+
icon: "1.",
|
|
56
|
+
command: ({ editor, range }) =>
|
|
57
|
+
editor.chain().focus().deleteRange(range).toggleOrderedList().run(),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: "Task List",
|
|
61
|
+
description: "List with checkboxes",
|
|
62
|
+
icon: "☑",
|
|
63
|
+
command: ({ editor, range }) =>
|
|
64
|
+
editor.chain().focus().deleteRange(range).toggleTaskList().run(),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
title: "Code Block",
|
|
68
|
+
description: "Fenced code with syntax highlighting",
|
|
69
|
+
icon: "<>",
|
|
70
|
+
command: ({ editor, range }) =>
|
|
71
|
+
editor.chain().focus().deleteRange(range).toggleCodeBlock().run(),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: "Blockquote",
|
|
75
|
+
description: "Quoted text block",
|
|
76
|
+
icon: "❝",
|
|
77
|
+
command: ({ editor, range }) =>
|
|
78
|
+
editor.chain().focus().deleteRange(range).toggleBlockquote().run(),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
title: "Horizontal Rule",
|
|
82
|
+
description: "Visual divider line",
|
|
83
|
+
icon: "—",
|
|
84
|
+
command: ({ editor, range }) =>
|
|
85
|
+
editor.chain().focus().deleteRange(range).setHorizontalRule().run(),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: "Table",
|
|
89
|
+
description: "Insert a 3×3 table",
|
|
90
|
+
icon: "⊞",
|
|
91
|
+
command: ({ editor, range }) =>
|
|
92
|
+
editor
|
|
93
|
+
.chain()
|
|
94
|
+
.focus()
|
|
95
|
+
.deleteRange(range)
|
|
96
|
+
.insertTable({ rows: 3, cols: 3, withHeaderRow: true })
|
|
97
|
+
.run(),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
title: "Image",
|
|
101
|
+
description: "Insert image from URL",
|
|
102
|
+
icon: "🖼",
|
|
103
|
+
command: ({ editor, range }) => {
|
|
104
|
+
const url = window.prompt("Image URL:");
|
|
105
|
+
if (url) {
|
|
106
|
+
editor.chain().focus().deleteRange(range).setImage({ src: url }).run();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
// ===========================================================================
|
|
113
|
+
// SlashCommandsList (React popup)
|
|
114
|
+
// ===========================================================================
|
|
115
|
+
|
|
116
|
+
interface SlashCommandsListProps {
|
|
117
|
+
items: SlashCommandItem[];
|
|
118
|
+
command: (item: SlashCommandItem) => void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface SlashCommandsListRef {
|
|
122
|
+
onKeyDown: (props: { event: KeyboardEvent }) => boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const SlashCommandsList = forwardRef<SlashCommandsListRef, SlashCommandsListProps>(
|
|
126
|
+
({ items, command }, ref) => {
|
|
127
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
128
|
+
const listRef = useRef<HTMLDivElement>(null);
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
setSelectedIndex(0);
|
|
132
|
+
}, [items]);
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const el = listRef.current?.children[selectedIndex] as HTMLElement | undefined;
|
|
136
|
+
el?.scrollIntoView({ block: "nearest" });
|
|
137
|
+
}, [selectedIndex]);
|
|
138
|
+
|
|
139
|
+
const selectItem = useCallback(
|
|
140
|
+
(index: number) => {
|
|
141
|
+
const item = items[index];
|
|
142
|
+
if (item) command(item);
|
|
143
|
+
},
|
|
144
|
+
[items, command],
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
useImperativeHandle(ref, () => ({
|
|
148
|
+
onKeyDown: ({ event }: { event: KeyboardEvent }) => {
|
|
149
|
+
if (event.key === "ArrowUp") {
|
|
150
|
+
setSelectedIndex((i) => (i + items.length - 1) % items.length);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
if (event.key === "ArrowDown") {
|
|
154
|
+
setSelectedIndex((i) => (i + 1) % items.length);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
if (event.key === "Enter") {
|
|
158
|
+
selectItem(selectedIndex);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
},
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
if (items.length === 0) {
|
|
166
|
+
return (
|
|
167
|
+
<div style={styles.container}>
|
|
168
|
+
<div style={styles.empty}>No results</div>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<div style={styles.container} ref={listRef}>
|
|
175
|
+
{items.map((item, index) => (
|
|
176
|
+
<button
|
|
177
|
+
key={item.title}
|
|
178
|
+
style={{
|
|
179
|
+
...styles.item,
|
|
180
|
+
...(index === selectedIndex ? styles.itemSelected : {}),
|
|
181
|
+
}}
|
|
182
|
+
onClick={() => selectItem(index)}
|
|
183
|
+
onMouseEnter={() => setSelectedIndex(index)}
|
|
184
|
+
type="button"
|
|
185
|
+
>
|
|
186
|
+
<span style={styles.icon}>{item.icon}</span>
|
|
187
|
+
<span style={styles.textGroup}>
|
|
188
|
+
<span style={styles.title}>{item.title}</span>
|
|
189
|
+
<span style={styles.description}>{item.description}</span>
|
|
190
|
+
</span>
|
|
191
|
+
</button>
|
|
192
|
+
))}
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
},
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
SlashCommandsList.displayName = "SlashCommandsList";
|
|
199
|
+
|
|
200
|
+
const styles: Record<string, React.CSSProperties> = {
|
|
201
|
+
container: {
|
|
202
|
+
background: "var(--background, #fff)",
|
|
203
|
+
border: "1px solid var(--borderColor, #e0e0e0)",
|
|
204
|
+
borderRadius: "8px",
|
|
205
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
|
|
206
|
+
padding: "4px",
|
|
207
|
+
maxHeight: "320px",
|
|
208
|
+
overflowY: "auto",
|
|
209
|
+
minWidth: "220px",
|
|
210
|
+
},
|
|
211
|
+
item: {
|
|
212
|
+
display: "flex",
|
|
213
|
+
alignItems: "center",
|
|
214
|
+
gap: "10px",
|
|
215
|
+
padding: "8px 10px",
|
|
216
|
+
border: "none",
|
|
217
|
+
background: "none",
|
|
218
|
+
width: "100%",
|
|
219
|
+
textAlign: "left",
|
|
220
|
+
cursor: "pointer",
|
|
221
|
+
borderRadius: "6px",
|
|
222
|
+
fontSize: "13px",
|
|
223
|
+
lineHeight: "1.3",
|
|
224
|
+
},
|
|
225
|
+
itemSelected: {
|
|
226
|
+
background: "var(--color4, #f0f0f0)",
|
|
227
|
+
},
|
|
228
|
+
icon: {
|
|
229
|
+
width: "28px",
|
|
230
|
+
height: "28px",
|
|
231
|
+
display: "flex",
|
|
232
|
+
alignItems: "center",
|
|
233
|
+
justifyContent: "center",
|
|
234
|
+
borderRadius: "4px",
|
|
235
|
+
background: "var(--color3, #f5f5f5)",
|
|
236
|
+
fontWeight: "700",
|
|
237
|
+
fontSize: "12px",
|
|
238
|
+
flexShrink: 0,
|
|
239
|
+
},
|
|
240
|
+
textGroup: {
|
|
241
|
+
display: "flex",
|
|
242
|
+
flexDirection: "column",
|
|
243
|
+
gap: "1px",
|
|
244
|
+
},
|
|
245
|
+
title: {
|
|
246
|
+
fontWeight: "600",
|
|
247
|
+
color: "var(--color12, #333)",
|
|
248
|
+
},
|
|
249
|
+
description: {
|
|
250
|
+
fontSize: "11px",
|
|
251
|
+
color: "var(--color9, #888)",
|
|
252
|
+
},
|
|
253
|
+
empty: {
|
|
254
|
+
padding: "8px 12px",
|
|
255
|
+
color: "var(--color9, #888)",
|
|
256
|
+
fontSize: "13px",
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// ===========================================================================
|
|
261
|
+
// SlashCommands Extension
|
|
262
|
+
// ===========================================================================
|
|
263
|
+
|
|
264
|
+
export const SlashCommands = Extension.create({
|
|
265
|
+
name: "slashCommands",
|
|
266
|
+
|
|
267
|
+
addOptions() {
|
|
268
|
+
return {
|
|
269
|
+
suggestion: {
|
|
270
|
+
char: "/",
|
|
271
|
+
startOfLine: false,
|
|
272
|
+
items: ({ query }: { query: string }) => {
|
|
273
|
+
const q = query.toLowerCase();
|
|
274
|
+
return SLASH_ITEMS.filter(
|
|
275
|
+
(item) =>
|
|
276
|
+
item.title.toLowerCase().includes(q) || item.description.toLowerCase().includes(q),
|
|
277
|
+
);
|
|
278
|
+
},
|
|
279
|
+
render: () => {
|
|
280
|
+
let component: ReactRenderer<SlashCommandsListRef> | null = null;
|
|
281
|
+
let popup: HTMLDivElement | null = null;
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
onStart: (props: any) => {
|
|
285
|
+
component = new ReactRenderer(SlashCommandsList, {
|
|
286
|
+
props,
|
|
287
|
+
editor: props.editor,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
popup = document.createElement("div");
|
|
291
|
+
popup.style.position = "absolute";
|
|
292
|
+
popup.style.zIndex = "50";
|
|
293
|
+
document.body.appendChild(popup);
|
|
294
|
+
popup.appendChild(component.element);
|
|
295
|
+
|
|
296
|
+
const { clientRect } = props;
|
|
297
|
+
if (clientRect) {
|
|
298
|
+
const rect = clientRect();
|
|
299
|
+
if (rect) {
|
|
300
|
+
popup.style.left = `${rect.left}px`;
|
|
301
|
+
popup.style.top = `${rect.bottom + 4}px`;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
onUpdate: (props: any) => {
|
|
306
|
+
component?.updateProps(props);
|
|
307
|
+
|
|
308
|
+
if (popup && props.clientRect) {
|
|
309
|
+
const rect = props.clientRect();
|
|
310
|
+
if (rect) {
|
|
311
|
+
popup.style.left = `${rect.left}px`;
|
|
312
|
+
popup.style.top = `${rect.bottom + 4}px`;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
onKeyDown: (props: any) => {
|
|
317
|
+
if (props.event.key === "Escape") {
|
|
318
|
+
popup?.remove();
|
|
319
|
+
component?.destroy();
|
|
320
|
+
popup = null;
|
|
321
|
+
component = null;
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
return component?.ref?.onKeyDown(props) ?? false;
|
|
325
|
+
},
|
|
326
|
+
onExit: () => {
|
|
327
|
+
popup?.remove();
|
|
328
|
+
component?.destroy();
|
|
329
|
+
popup = null;
|
|
330
|
+
component = null;
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
},
|
|
334
|
+
command: ({
|
|
335
|
+
editor,
|
|
336
|
+
range,
|
|
337
|
+
props,
|
|
338
|
+
}: {
|
|
339
|
+
editor: Editor;
|
|
340
|
+
range: Range;
|
|
341
|
+
props: SlashCommandItem;
|
|
342
|
+
}) => {
|
|
343
|
+
props.command({ editor, range });
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
addProseMirrorPlugins() {
|
|
350
|
+
return [
|
|
351
|
+
Suggestion({
|
|
352
|
+
editor: this.editor,
|
|
353
|
+
...this.options.suggestion,
|
|
354
|
+
}),
|
|
355
|
+
];
|
|
356
|
+
},
|
|
357
|
+
});
|