@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,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration tests for the rich text editor rebuild
|
|
3
|
+
*
|
|
4
|
+
* These tests focus on cross-component data flow and integration points
|
|
5
|
+
* that span multiple modules, filling gaps not covered by individual
|
|
6
|
+
* module tests from Task Groups 2-14.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect, vi } from "vitest";
|
|
10
|
+
|
|
11
|
+
// ===========================================================================
|
|
12
|
+
// 1. Cross-component data flow: getEditorStateFromTiptap text alignment
|
|
13
|
+
// ===========================================================================
|
|
14
|
+
|
|
15
|
+
describe("getEditorStateFromTiptap text alignment paths", () => {
|
|
16
|
+
it("maps center, right, and justify alignment from Tiptap editor", async () => {
|
|
17
|
+
const { getEditorStateFromTiptap } = await import("./editor/useEditorState");
|
|
18
|
+
|
|
19
|
+
const createMockEditor = (activeAlign: string) => ({
|
|
20
|
+
isActive: (type: string | Record<string, any>, attrs?: any) => {
|
|
21
|
+
if (typeof type === "object" && type.textAlign) {
|
|
22
|
+
return type.textAlign === activeAlign;
|
|
23
|
+
}
|
|
24
|
+
if (attrs?.textAlign) {
|
|
25
|
+
return attrs.textAlign === activeAlign;
|
|
26
|
+
}
|
|
27
|
+
if (type === "paragraph") return true;
|
|
28
|
+
return false;
|
|
29
|
+
},
|
|
30
|
+
getAttributes: () => ({}),
|
|
31
|
+
can: () => ({ undo: () => false, redo: () => false }),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const centerState = getEditorStateFromTiptap(createMockEditor("center"));
|
|
35
|
+
expect(centerState.textAlign).toBe("center");
|
|
36
|
+
|
|
37
|
+
const rightState = getEditorStateFromTiptap(createMockEditor("right"));
|
|
38
|
+
expect(rightState.textAlign).toBe("right");
|
|
39
|
+
|
|
40
|
+
const justifyState = getEditorStateFromTiptap(createMockEditor("justify"));
|
|
41
|
+
expect(justifyState.textAlign).toBe("justify");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// ===========================================================================
|
|
46
|
+
// 2. getEditorCSS default minHeight
|
|
47
|
+
// ===========================================================================
|
|
48
|
+
|
|
49
|
+
describe("getEditorCSS defaults", () => {
|
|
50
|
+
it("applies 150px default minHeight when no options are provided", async () => {
|
|
51
|
+
const { getEditorCSS } = await import("./editor/editorStyles");
|
|
52
|
+
|
|
53
|
+
const css = getEditorCSS();
|
|
54
|
+
expect(css).toContain("min-height: 150px");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// ===========================================================================
|
|
59
|
+
// 3. ToolbarButton disabled state from context
|
|
60
|
+
// ===========================================================================
|
|
61
|
+
|
|
62
|
+
vi.mock("@multiplatform.one/forms", () => ({
|
|
63
|
+
Button: (props: any) => (
|
|
64
|
+
<button
|
|
65
|
+
role="button"
|
|
66
|
+
aria-label={props["aria-label"]}
|
|
67
|
+
disabled={props.disabled}
|
|
68
|
+
onClick={props.onPress}
|
|
69
|
+
data-active={props.theme === "active" ? "true" : undefined}
|
|
70
|
+
>
|
|
71
|
+
{props.children}
|
|
72
|
+
</button>
|
|
73
|
+
),
|
|
74
|
+
Field: ({ children, ...props }: any) => {
|
|
75
|
+
const field = {
|
|
76
|
+
state: { value: props.defaultValue ?? "", meta: { errors: [] } },
|
|
77
|
+
handleChange: vi.fn(),
|
|
78
|
+
handleBlur: vi.fn(),
|
|
79
|
+
};
|
|
80
|
+
return <div data-testid="tanstack-field">{children(field)}</div>;
|
|
81
|
+
},
|
|
82
|
+
FieldLayout: ({ children, label, error, ..._props }: any) => (
|
|
83
|
+
<div data-testid="field-layout" data-label={label} data-error={error || undefined}>
|
|
84
|
+
{children}
|
|
85
|
+
</div>
|
|
86
|
+
),
|
|
87
|
+
Skeleton: ({ variant, width, height }: any) => (
|
|
88
|
+
<div data-testid="skeleton" data-variant={variant} style={{ width, height }} />
|
|
89
|
+
),
|
|
90
|
+
getFieldError: (field: any, propError: any) => {
|
|
91
|
+
const fieldError = field.state.meta.errors.length
|
|
92
|
+
? String(field.state.meta.errors[0])
|
|
93
|
+
: undefined;
|
|
94
|
+
return propError ?? fieldError;
|
|
95
|
+
},
|
|
96
|
+
useFormField: ({ form }: any) => ({
|
|
97
|
+
resolvedForm: form || undefined,
|
|
98
|
+
knobProps: {
|
|
99
|
+
body: {},
|
|
100
|
+
borderRadius: { borderRadius: "$3", borderWidth: 1 },
|
|
101
|
+
elevation: undefined,
|
|
102
|
+
sizeToken: "$4",
|
|
103
|
+
outlined: false,
|
|
104
|
+
inputBackground: "$color2",
|
|
105
|
+
textAccentColor: "$color",
|
|
106
|
+
transition: undefined,
|
|
107
|
+
heading: {},
|
|
108
|
+
gap: { gap: "$2" },
|
|
109
|
+
},
|
|
110
|
+
id: "test-id",
|
|
111
|
+
}),
|
|
112
|
+
useResolvedValidators: (
|
|
113
|
+
required: boolean | undefined,
|
|
114
|
+
validators: any,
|
|
115
|
+
label: any,
|
|
116
|
+
name: any,
|
|
117
|
+
isEmpty?: (v: unknown) => boolean,
|
|
118
|
+
) => {
|
|
119
|
+
if (!required) return validators;
|
|
120
|
+
const check = isEmpty || ((v: unknown) => v == null || v === "");
|
|
121
|
+
const requiredValidator = ({ value }: { value: unknown }) =>
|
|
122
|
+
check(value)
|
|
123
|
+
? `${typeof label === "string" ? label : name || "Field"} is required`
|
|
124
|
+
: undefined;
|
|
125
|
+
if (!validators) return { onSubmit: requiredValidator };
|
|
126
|
+
return { ...validators, onSubmit: requiredValidator };
|
|
127
|
+
},
|
|
128
|
+
mergeFieldHandler: (field: any, name: string, handler: any) => {
|
|
129
|
+
return (...args: any[]) => {
|
|
130
|
+
(field[name] as Function)(...args);
|
|
131
|
+
handler?.(...args);
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
clampRadiusForLargeComponent: (radiusToken: string | undefined, maxTokenNum = 4) => {
|
|
135
|
+
if (!radiusToken) return "$3";
|
|
136
|
+
if (radiusToken === "$0") return 0;
|
|
137
|
+
if (typeof radiusToken === "string" && radiusToken.startsWith("$")) {
|
|
138
|
+
const num = Number.parseInt(radiusToken.slice(1), 10);
|
|
139
|
+
return num > maxTokenNum ? `$${maxTokenNum}` : radiusToken;
|
|
140
|
+
}
|
|
141
|
+
return radiusToken;
|
|
142
|
+
},
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
vi.mock("@multiplatform.one/components", () => ({
|
|
146
|
+
Tooltip: ({ children }: any) => children,
|
|
147
|
+
}));
|
|
148
|
+
|
|
149
|
+
vi.mock("@multiplatform.one/theme", () => ({
|
|
150
|
+
useResolvedKnobs: () => ({
|
|
151
|
+
knobProps: {
|
|
152
|
+
body: {},
|
|
153
|
+
borderRadius: { borderRadius: "$3", borderWidth: 1 },
|
|
154
|
+
elevation: undefined,
|
|
155
|
+
sizeToken: "$4",
|
|
156
|
+
outlined: false,
|
|
157
|
+
inputBackground: "$color2",
|
|
158
|
+
textAccentColor: "$color",
|
|
159
|
+
transition: undefined,
|
|
160
|
+
heading: {},
|
|
161
|
+
},
|
|
162
|
+
control: {
|
|
163
|
+
hoverKnobProps: undefined,
|
|
164
|
+
pressKnobProps: undefined,
|
|
165
|
+
focusKnobProps: undefined,
|
|
166
|
+
focusVisibleKnobProps: undefined,
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
vi.mock("@tiptap/react/menus", () => ({
|
|
172
|
+
BubbleMenu: ({ children }: any) => <div data-testid="bubble-menu">{children}</div>,
|
|
173
|
+
}));
|
|
174
|
+
|
|
175
|
+
const mockEditor = {
|
|
176
|
+
isActive: vi.fn().mockReturnValue(false),
|
|
177
|
+
getAttributes: vi.fn().mockReturnValue({}),
|
|
178
|
+
can: vi.fn().mockReturnValue({ undo: () => false, redo: () => false }),
|
|
179
|
+
getHTML: vi.fn().mockReturnValue("<p></p>"),
|
|
180
|
+
getJSON: vi.fn().mockReturnValue({ type: "doc", content: [] }),
|
|
181
|
+
chain: vi.fn().mockReturnValue({
|
|
182
|
+
focus: vi.fn().mockReturnValue({
|
|
183
|
+
toggleBold: vi.fn().mockReturnValue({ run: vi.fn() }),
|
|
184
|
+
}),
|
|
185
|
+
}),
|
|
186
|
+
commands: {
|
|
187
|
+
setContent: vi.fn(),
|
|
188
|
+
focus: vi.fn(),
|
|
189
|
+
blur: vi.fn(),
|
|
190
|
+
},
|
|
191
|
+
setEditable: vi.fn(),
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
vi.mock("@tiptap/react", () => ({
|
|
195
|
+
useEditor: vi.fn().mockReturnValue(mockEditor),
|
|
196
|
+
EditorContent: ({ editor: _editor }: any) => <div data-testid="editor-content">Editor</div>,
|
|
197
|
+
}));
|
|
198
|
+
|
|
199
|
+
vi.mock("@tiptap/starter-kit", () => ({
|
|
200
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
201
|
+
}));
|
|
202
|
+
vi.mock("@tiptap/extension-underline", () => ({ default: {} }));
|
|
203
|
+
vi.mock("@tiptap/extension-link", () => ({
|
|
204
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
205
|
+
}));
|
|
206
|
+
vi.mock("@tiptap/extension-placeholder", () => ({
|
|
207
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
208
|
+
}));
|
|
209
|
+
vi.mock("@tiptap/extension-text-align", () => ({
|
|
210
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
211
|
+
}));
|
|
212
|
+
vi.mock("@tiptap/extension-color", () => ({ Color: {} }));
|
|
213
|
+
vi.mock("@tiptap/extension-text-style", () => ({ TextStyle: {} }));
|
|
214
|
+
vi.mock("@tiptap/extension-highlight", () => ({
|
|
215
|
+
Highlight: { configure: vi.fn().mockReturnValue({}) },
|
|
216
|
+
}));
|
|
217
|
+
vi.mock("@tiptap/extension-subscript", () => ({ Subscript: {} }));
|
|
218
|
+
vi.mock("@tiptap/extension-superscript", () => ({ Superscript: {} }));
|
|
219
|
+
vi.mock("@tiptap/extension-task-list", () => ({ default: {} }));
|
|
220
|
+
vi.mock("@tiptap/extension-task-item", () => ({
|
|
221
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
222
|
+
}));
|
|
223
|
+
vi.mock("@tiptap/extension-image", () => ({
|
|
224
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
225
|
+
}));
|
|
226
|
+
|
|
227
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
228
|
+
import { RichEditorContext } from "./context";
|
|
229
|
+
import { defaultEditorState } from "./types";
|
|
230
|
+
import type { EditorCommand, EditorState, ToolbarSection } from "./types";
|
|
231
|
+
|
|
232
|
+
const { ToolbarButton } = await import("./toolbar/ToolbarButton");
|
|
233
|
+
const { FixedToolbar } = await import("./toolbar/FixedToolbar");
|
|
234
|
+
const { RichEditor } = await import("./RichEditor");
|
|
235
|
+
const { RichTextEditor } = await import("./RichTextEditor/index");
|
|
236
|
+
|
|
237
|
+
describe("ToolbarButton disabled state from context", () => {
|
|
238
|
+
it("inherits disabled state from RichEditorContext", () => {
|
|
239
|
+
const { getByRole } = renderWithProviders(
|
|
240
|
+
<RichEditorContext.Provider size="$true" compact={false} disabled>
|
|
241
|
+
<ToolbarButton onPress={() => {}} aria-label="Test">
|
|
242
|
+
T
|
|
243
|
+
</ToolbarButton>
|
|
244
|
+
</RichEditorContext.Provider>,
|
|
245
|
+
);
|
|
246
|
+
const button = getByRole("button");
|
|
247
|
+
expect(button.getAttribute("disabled")).not.toBeNull();
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// ===========================================================================
|
|
252
|
+
// 4. EditorState flows to FixedToolbar and reflects active states
|
|
253
|
+
// ===========================================================================
|
|
254
|
+
|
|
255
|
+
describe("EditorState flows to FixedToolbar active states", () => {
|
|
256
|
+
it("reflects bold active state in the Bold toolbar button", () => {
|
|
257
|
+
const boldActiveState: EditorState = {
|
|
258
|
+
...defaultEditorState,
|
|
259
|
+
isBold: true,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const { container } = renderWithProviders(
|
|
263
|
+
<RichEditorContext.Provider size="$true" compact={false} disabled={false}>
|
|
264
|
+
<FixedToolbar editorRef={{ current: null }} state={boldActiveState} />
|
|
265
|
+
</RichEditorContext.Provider>,
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
const buttons = container.querySelectorAll("[role='button']");
|
|
269
|
+
const boldButton = Array.from(buttons).find((b) => b.getAttribute("aria-label") === "Bold");
|
|
270
|
+
expect(boldButton).toBeTruthy();
|
|
271
|
+
expect(boldButton?.getAttribute("data-active")).toBe("true");
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// ===========================================================================
|
|
276
|
+
// 5. Sections with empty array hides all groups
|
|
277
|
+
// ===========================================================================
|
|
278
|
+
|
|
279
|
+
describe("FixedToolbar sections edge case", () => {
|
|
280
|
+
it("hides all groups when sections is an empty array", () => {
|
|
281
|
+
const { container } = renderWithProviders(
|
|
282
|
+
<RichEditorContext.Provider size="$true" compact={false} disabled={false}>
|
|
283
|
+
<FixedToolbar
|
|
284
|
+
editorRef={{ current: null }}
|
|
285
|
+
state={defaultEditorState}
|
|
286
|
+
sections={[] as ToolbarSection[]}
|
|
287
|
+
/>
|
|
288
|
+
</RichEditorContext.Provider>,
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
const buttons = container.querySelectorAll("[role='button']");
|
|
292
|
+
expect(buttons.length).toBe(0);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// ===========================================================================
|
|
297
|
+
// 6. RichEditor compound component forwards ref to TiptapEditor
|
|
298
|
+
// ===========================================================================
|
|
299
|
+
|
|
300
|
+
describe("RichEditor ref forwarding", () => {
|
|
301
|
+
it("forwards ref through compound component to TiptapEditor", () => {
|
|
302
|
+
const { createRef } = require("react");
|
|
303
|
+
const ref = createRef();
|
|
304
|
+
|
|
305
|
+
renderWithProviders(<RichEditor ref={ref} />);
|
|
306
|
+
|
|
307
|
+
expect(ref.current).toBeTruthy();
|
|
308
|
+
expect(typeof ref.current?.executeCommand).toBe("function");
|
|
309
|
+
expect(typeof ref.current?.getHTML).toBe("function");
|
|
310
|
+
expect(typeof ref.current?.getState).toBe("function");
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// ===========================================================================
|
|
315
|
+
// 7. RichTextEditor custom empty check integration
|
|
316
|
+
// ===========================================================================
|
|
317
|
+
|
|
318
|
+
describe("RichTextEditor form validation with custom empty check", () => {
|
|
319
|
+
it("uses richTextIsEmpty so '<p></p>' triggers required validation", () => {
|
|
320
|
+
const mockForm = { store: {} } as any;
|
|
321
|
+
const { getByTestId } = renderWithProviders(
|
|
322
|
+
<RichTextEditor
|
|
323
|
+
form={mockForm}
|
|
324
|
+
name="content"
|
|
325
|
+
label="Content"
|
|
326
|
+
required
|
|
327
|
+
defaultValue="<p></p>"
|
|
328
|
+
/>,
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
const field = getByTestId("tanstack-field");
|
|
332
|
+
expect(field).toBeTruthy();
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// ===========================================================================
|
|
337
|
+
// 8. Bridge state mapping consistency between tiptap and bridge
|
|
338
|
+
// ===========================================================================
|
|
339
|
+
|
|
340
|
+
describe("EditorState shape consistency between platforms", () => {
|
|
341
|
+
it("getEditorStateFromTiptap and getEditorStateFromBridge produce the same shape", async () => {
|
|
342
|
+
const { getEditorStateFromTiptap, getEditorStateFromBridge } =
|
|
343
|
+
await import("./editor/useEditorState");
|
|
344
|
+
|
|
345
|
+
const tiptapState = getEditorStateFromTiptap(null);
|
|
346
|
+
const bridgeState = getEditorStateFromBridge(null);
|
|
347
|
+
|
|
348
|
+
const tiptapKeys = Object.keys(tiptapState).sort();
|
|
349
|
+
const bridgeKeys = Object.keys(bridgeState).sort();
|
|
350
|
+
|
|
351
|
+
expect(tiptapKeys).toEqual(bridgeKeys);
|
|
352
|
+
expect(tiptapState).toEqual(bridgeState);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// ===========================================================================
|
|
357
|
+
// 9. NATIVE_SUPPORTED_COMMANDS completeness matches EditorCommand type
|
|
358
|
+
// ===========================================================================
|
|
359
|
+
|
|
360
|
+
describe("NATIVE_SUPPORTED_COMMANDS completeness", () => {
|
|
361
|
+
it("has an entry for every EditorCommand and each value is a boolean", async () => {
|
|
362
|
+
const { NATIVE_SUPPORTED_COMMANDS } = await import("./constants");
|
|
363
|
+
|
|
364
|
+
// All EditorCommand union values must have an entry in the map
|
|
365
|
+
const allCommands: EditorCommand[] = [
|
|
366
|
+
"bold",
|
|
367
|
+
"italic",
|
|
368
|
+
"underline",
|
|
369
|
+
"strike",
|
|
370
|
+
"code",
|
|
371
|
+
"subscript",
|
|
372
|
+
"superscript",
|
|
373
|
+
"heading1",
|
|
374
|
+
"heading2",
|
|
375
|
+
"heading3",
|
|
376
|
+
"heading4",
|
|
377
|
+
"heading5",
|
|
378
|
+
"heading6",
|
|
379
|
+
"paragraph",
|
|
380
|
+
"bulletList",
|
|
381
|
+
"orderedList",
|
|
382
|
+
"taskList",
|
|
383
|
+
"blockquote",
|
|
384
|
+
"codeBlock",
|
|
385
|
+
"link",
|
|
386
|
+
"image",
|
|
387
|
+
"undo",
|
|
388
|
+
"redo",
|
|
389
|
+
"alignLeft",
|
|
390
|
+
"alignCenter",
|
|
391
|
+
"alignRight",
|
|
392
|
+
"alignJustify",
|
|
393
|
+
"textColor",
|
|
394
|
+
"highlight",
|
|
395
|
+
"horizontalRule",
|
|
396
|
+
"clearFormatting",
|
|
397
|
+
];
|
|
398
|
+
|
|
399
|
+
for (const cmd of allCommands) {
|
|
400
|
+
expect(
|
|
401
|
+
typeof NATIVE_SUPPORTED_COMMANDS[cmd],
|
|
402
|
+
`NATIVE_SUPPORTED_COMMANDS should have a boolean for "${cmd}"`,
|
|
403
|
+
).toBe("boolean");
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// No extra keys beyond what EditorCommand defines
|
|
407
|
+
const commandKeys = Object.keys(NATIVE_SUPPORTED_COMMANDS);
|
|
408
|
+
expect(commandKeys.length).toBe(allCommands.length);
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// ===========================================================================
|
|
413
|
+
// 10. RichEditor passes showBubbleToolbar through to TiptapEditor
|
|
414
|
+
// ===========================================================================
|
|
415
|
+
|
|
416
|
+
describe("RichEditor passes showBubbleToolbar to TiptapEditor", () => {
|
|
417
|
+
it("renders BubbleMenu when showBubbleToolbar is true", () => {
|
|
418
|
+
const { container } = renderWithProviders(<RichEditor showBubbleToolbar />);
|
|
419
|
+
|
|
420
|
+
const bubbleMenu = container.querySelector("[data-testid='bubble-menu']");
|
|
421
|
+
expect(bubbleMenu).toBeTruthy();
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it("does not render BubbleMenu when showBubbleToolbar is false", () => {
|
|
425
|
+
const { container } = renderWithProviders(<RichEditor showBubbleToolbar={false} />);
|
|
426
|
+
|
|
427
|
+
const bubbleMenu = container.querySelector("[data-testid='bubble-menu']");
|
|
428
|
+
expect(bubbleMenu).toBeNull();
|
|
429
|
+
});
|
|
430
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Mocks — must come before imports
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
vi.mock("@multiplatform.one/forms", () => ({
|
|
8
|
+
Button: (props: any) => (
|
|
9
|
+
<button
|
|
10
|
+
role="button"
|
|
11
|
+
aria-label={props["aria-label"]}
|
|
12
|
+
disabled={props.disabled}
|
|
13
|
+
onClick={props.onPress}
|
|
14
|
+
>
|
|
15
|
+
{props.children}
|
|
16
|
+
</button>
|
|
17
|
+
),
|
|
18
|
+
clampRadiusForLargeComponent: (radiusToken: string | undefined, maxTokenNum = 4) => {
|
|
19
|
+
if (!radiusToken) return "$3";
|
|
20
|
+
if (radiusToken === "$0") return 0;
|
|
21
|
+
if (typeof radiusToken === "string" && radiusToken.startsWith("$")) {
|
|
22
|
+
const num = Number.parseInt(radiusToken.slice(1), 10);
|
|
23
|
+
return num > maxTokenNum ? `$${maxTokenNum}` : radiusToken;
|
|
24
|
+
}
|
|
25
|
+
return radiusToken;
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
vi.mock("@multiplatform.one/components", () => ({
|
|
30
|
+
Tooltip: ({ children }: any) => children,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
vi.mock("@multiplatform.one/theme", () => ({
|
|
34
|
+
useResolvedKnobs: (_options?: any) => ({
|
|
35
|
+
knobProps: {
|
|
36
|
+
body: {},
|
|
37
|
+
borderRadius: { borderRadius: "$3", borderWidth: 1 },
|
|
38
|
+
elevation: undefined,
|
|
39
|
+
sizeToken: "$4",
|
|
40
|
+
outlined: false,
|
|
41
|
+
inputBackground: "$color2",
|
|
42
|
+
textAccentColor: "$color",
|
|
43
|
+
transition: undefined,
|
|
44
|
+
heading: {},
|
|
45
|
+
},
|
|
46
|
+
control: {
|
|
47
|
+
hoverKnobProps: undefined,
|
|
48
|
+
pressKnobProps: undefined,
|
|
49
|
+
focusKnobProps: undefined,
|
|
50
|
+
focusVisibleKnobProps: undefined,
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
vi.mock("@tiptap/react/menus", () => ({
|
|
56
|
+
BubbleMenu: ({ children }: any) => <div data-testid="bubble-menu">{children}</div>,
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
const mockEditor = {
|
|
60
|
+
isActive: vi.fn().mockReturnValue(false),
|
|
61
|
+
getAttributes: vi.fn().mockReturnValue({}),
|
|
62
|
+
can: vi.fn().mockReturnValue({ undo: () => false, redo: () => false }),
|
|
63
|
+
getHTML: vi.fn().mockReturnValue("<p></p>"),
|
|
64
|
+
getJSON: vi.fn().mockReturnValue({ type: "doc", content: [] }),
|
|
65
|
+
chain: vi.fn().mockReturnValue({
|
|
66
|
+
focus: vi.fn().mockReturnValue({
|
|
67
|
+
toggleBold: vi.fn().mockReturnValue({ run: vi.fn() }),
|
|
68
|
+
}),
|
|
69
|
+
}),
|
|
70
|
+
commands: {
|
|
71
|
+
setContent: vi.fn(),
|
|
72
|
+
focus: vi.fn(),
|
|
73
|
+
blur: vi.fn(),
|
|
74
|
+
},
|
|
75
|
+
setEditable: vi.fn(),
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
vi.mock("@tiptap/react", () => ({
|
|
79
|
+
useEditor: vi.fn().mockReturnValue(mockEditor),
|
|
80
|
+
EditorContent: ({ editor: _editor }: any) => <div data-testid="editor-content">Editor</div>,
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
vi.mock("@tiptap/starter-kit", () => ({
|
|
84
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
85
|
+
}));
|
|
86
|
+
vi.mock("@tiptap/extension-underline", () => ({ default: {} }));
|
|
87
|
+
vi.mock("@tiptap/extension-link", () => ({
|
|
88
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
89
|
+
}));
|
|
90
|
+
vi.mock("@tiptap/extension-placeholder", () => ({
|
|
91
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
92
|
+
}));
|
|
93
|
+
vi.mock("@tiptap/extension-text-align", () => ({
|
|
94
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
95
|
+
}));
|
|
96
|
+
vi.mock("@tiptap/extension-color", () => ({ Color: {} }));
|
|
97
|
+
vi.mock("@tiptap/extension-text-style", () => ({ TextStyle: {} }));
|
|
98
|
+
vi.mock("@tiptap/extension-highlight", () => ({
|
|
99
|
+
Highlight: { configure: vi.fn().mockReturnValue({}) },
|
|
100
|
+
}));
|
|
101
|
+
vi.mock("@tiptap/extension-subscript", () => ({ Subscript: {} }));
|
|
102
|
+
vi.mock("@tiptap/extension-superscript", () => ({ Superscript: {} }));
|
|
103
|
+
vi.mock("@tiptap/extension-task-list", () => ({ default: {} }));
|
|
104
|
+
vi.mock("@tiptap/extension-task-item", () => ({
|
|
105
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
106
|
+
}));
|
|
107
|
+
vi.mock("@tiptap/extension-image", () => ({
|
|
108
|
+
default: { configure: vi.fn().mockReturnValue({}) },
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
// Imports (after mocks)
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
116
|
+
import { defaultEditorState } from "./types";
|
|
117
|
+
|
|
118
|
+
const { RichEditor } = await import("./RichEditor");
|
|
119
|
+
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// Tests
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
describe("RichEditor compound component", () => {
|
|
125
|
+
it("provides RichEditorContext to children and renders without error", () => {
|
|
126
|
+
const { container } = renderWithProviders(<RichEditor />);
|
|
127
|
+
// The compound component should render its root EditorFrame
|
|
128
|
+
expect(container.firstChild).toBeTruthy();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("exposes FixedToolbar, BubbleToolbar, and Editor as static properties", () => {
|
|
132
|
+
expect(RichEditor.FixedToolbar).toBeDefined();
|
|
133
|
+
expect(RichEditor.BubbleToolbar).toBeDefined();
|
|
134
|
+
expect(RichEditor.Editor).toBeDefined();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("applies clampRadiusForLargeComponent max $4 via useResolvedKnobs", () => {
|
|
138
|
+
// Render with default props -- the component internally calls
|
|
139
|
+
// useResolvedKnobs and clampRadiusForLargeComponent
|
|
140
|
+
const { container } = renderWithProviders(<RichEditor />);
|
|
141
|
+
// It should render successfully (radius clamping applied internally)
|
|
142
|
+
expect(container.firstChild).toBeTruthy();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("manages EditorState via useState and passes state to toolbar", () => {
|
|
146
|
+
const handleStateChange = vi.fn();
|
|
147
|
+
const { container } = renderWithProviders(
|
|
148
|
+
<RichEditor showToolbar onStateChange={handleStateChange} />,
|
|
149
|
+
);
|
|
150
|
+
// The editor should render with a toolbar when showToolbar is true
|
|
151
|
+
expect(container.firstChild).toBeTruthy();
|
|
152
|
+
// Default state should be applied (no errors during render)
|
|
153
|
+
expect(defaultEditorState.isBold).toBe(false);
|
|
154
|
+
expect(defaultEditorState.isParagraph).toBe(true);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("hides toolbar when showToolbar is false", () => {
|
|
158
|
+
const { container: withToolbar } = renderWithProviders(<RichEditor showToolbar />);
|
|
159
|
+
const { container: withoutToolbar } = renderWithProviders(<RichEditor showToolbar={false} />);
|
|
160
|
+
// Both should render, but the one without toolbar should have fewer children
|
|
161
|
+
expect(withToolbar.firstChild).toBeTruthy();
|
|
162
|
+
expect(withoutToolbar.firstChild).toBeTruthy();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("applies disabled state when editable is false", () => {
|
|
166
|
+
const { container } = renderWithProviders(<RichEditor editable={false} />);
|
|
167
|
+
expect(container.firstChild).toBeTruthy();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
3
|
+
import {
|
|
4
|
+
EditorFrame,
|
|
5
|
+
ToolbarFrame,
|
|
6
|
+
ToolbarGroupFrame,
|
|
7
|
+
ToolbarSeparatorFrame,
|
|
8
|
+
DropdownMenuItemFrame,
|
|
9
|
+
} from "./styled";
|
|
10
|
+
|
|
11
|
+
describe("styled components", () => {
|
|
12
|
+
it("EditorFrame renders with name property", () => {
|
|
13
|
+
const { container } = renderWithProviders(<EditorFrame />);
|
|
14
|
+
expect(container.firstChild).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("EditorFrame applies hasError variant", () => {
|
|
18
|
+
const { container } = renderWithProviders(<EditorFrame hasError />);
|
|
19
|
+
expect(container.firstChild).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("ToolbarFrame renders", () => {
|
|
23
|
+
const { container } = renderWithProviders(<ToolbarFrame />);
|
|
24
|
+
expect(container.firstChild).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("ToolbarGroupFrame, ToolbarSeparatorFrame, and DropdownMenuItemFrame render", () => {
|
|
28
|
+
const { container } = renderWithProviders(
|
|
29
|
+
<>
|
|
30
|
+
<ToolbarGroupFrame />
|
|
31
|
+
<ToolbarSeparatorFrame />
|
|
32
|
+
<DropdownMenuItemFrame />
|
|
33
|
+
</>,
|
|
34
|
+
);
|
|
35
|
+
expect(container.children.length).toBeGreaterThanOrEqual(1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("DropdownMenuItemFrame applies active variant", () => {
|
|
39
|
+
const { container } = renderWithProviders(<DropdownMenuItemFrame active />);
|
|
40
|
+
expect(container.firstChild).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
});
|