@multiplatform.one/rich-text 6.0.4 → 6.3.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/README.md +60 -0
- package/dist/cjs/RichEditor.cjs +84 -9
- package/dist/cjs/RichEditor.native.js +422 -35
- package/dist/cjs/RichEditor.native.js.map +1 -1
- package/dist/cjs/RichTextEditor/index.cjs +18 -2
- package/dist/cjs/RichTextEditor/index.native.js +18 -2
- package/dist/cjs/RichTextEditor/index.native.js.map +1 -1
- package/dist/cjs/constants.cjs +52 -29
- package/dist/cjs/constants.native.js +59 -29
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/editor/BlockDragHandle.cjs +22 -7
- package/dist/cjs/editor/BlockDragHandle.native.js +41 -7
- package/dist/cjs/editor/BlockDragHandle.native.js.map +1 -1
- package/dist/cjs/editor/SlashCommands.cjs +249 -293
- package/dist/cjs/editor/SlashCommands.native.js +306 -340
- package/dist/cjs/editor/SlashCommands.native.js.map +1 -1
- package/dist/cjs/editor/TentapEditor.native.js +44 -12
- package/dist/cjs/editor/TentapEditor.native.js.map +1 -1
- package/dist/cjs/editor/TiptapEditor.cjs +140 -33
- package/dist/cjs/editor/TiptapEditor.native.js +153 -33
- package/dist/cjs/editor/TiptapEditor.native.js.map +1 -1
- package/dist/cjs/editor/blockAnchor.cjs +43 -0
- package/dist/cjs/editor/blockAnchor.native.js +68 -0
- package/dist/cjs/editor/blockAnchor.native.js.map +1 -0
- package/dist/cjs/editor/codeBlockPreview.cjs +230 -0
- package/dist/cjs/editor/codeBlockPreview.native.js +265 -0
- package/dist/cjs/editor/codeBlockPreview.native.js.map +1 -0
- package/dist/cjs/editor/editorStyles.cjs +203 -34
- package/dist/cjs/editor/editorStyles.native.js +203 -34
- package/dist/cjs/editor/editorStyles.native.js.map +1 -1
- package/dist/cjs/editor/emoji.cjs +128 -0
- package/dist/cjs/editor/emoji.native.js +184 -0
- package/dist/cjs/editor/emoji.native.js.map +1 -0
- package/dist/cjs/editor/lazyKatex.cjs +78 -0
- package/dist/cjs/editor/lazyKatex.native.js +117 -0
- package/dist/cjs/editor/lazyKatex.native.js.map +1 -0
- package/dist/cjs/editor/markdown.cjs +216 -0
- package/dist/cjs/editor/markdown.native.js +278 -0
- package/dist/cjs/editor/markdown.native.js.map +1 -0
- package/dist/cjs/editor/mathematics.cjs +168 -0
- package/dist/cjs/editor/mathematics.native.js +202 -0
- package/dist/cjs/editor/mathematics.native.js.map +1 -0
- package/dist/cjs/editor/media.cjs +138 -0
- package/dist/cjs/editor/media.native.js +172 -0
- package/dist/cjs/editor/media.native.js.map +1 -0
- package/dist/cjs/editor/mentions.cjs +73 -0
- package/dist/cjs/editor/mentions.native.js +84 -0
- package/dist/cjs/editor/mentions.native.js.map +1 -0
- package/dist/cjs/editor/pasteCleanup.cjs +83 -0
- package/dist/cjs/editor/pasteCleanup.native.js +175 -0
- package/dist/cjs/editor/pasteCleanup.native.js.map +1 -0
- package/dist/cjs/editor/suggestionPopup.cjs +297 -0
- package/dist/cjs/editor/suggestionPopup.native.js +327 -0
- package/dist/cjs/editor/suggestionPopup.native.js.map +1 -0
- package/dist/cjs/preview.cjs +263 -0
- package/dist/cjs/preview.native.js +294 -0
- package/dist/cjs/preview.native.js.map +1 -0
- package/dist/cjs/shared/t.cjs +53 -0
- package/dist/cjs/shared/t.native.js +56 -0
- package/dist/cjs/shared/t.native.js.map +1 -0
- package/dist/cjs/shared/url.cjs +35 -0
- package/dist/cjs/shared/url.native.js +38 -0
- package/dist/cjs/shared/url.native.js.map +1 -0
- package/dist/cjs/styled.cjs +13 -6
- package/dist/cjs/styled.native.js +13 -6
- package/dist/cjs/styled.native.js.map +1 -1
- package/dist/cjs/toolbar/BubbleToolbar.cjs +10 -8
- package/dist/cjs/toolbar/BubbleToolbar.native.js +10 -8
- package/dist/cjs/toolbar/BubbleToolbar.native.js.map +1 -1
- package/dist/cjs/toolbar/CodeBlockBubble.cjs +59 -23
- package/dist/cjs/toolbar/CodeBlockBubble.native.js +71 -25
- package/dist/cjs/toolbar/CodeBlockBubble.native.js.map +1 -1
- package/dist/cjs/toolbar/ColorPicker.cjs +19 -54
- package/dist/cjs/toolbar/ColorPicker.native.js +81 -179
- package/dist/cjs/toolbar/ColorPicker.native.js.map +1 -1
- package/dist/cjs/toolbar/FixedToolbar.cjs +33 -10
- package/dist/cjs/toolbar/FixedToolbar.native.js +46 -54
- package/dist/cjs/toolbar/FixedToolbar.native.js.map +1 -1
- package/dist/cjs/toolbar/HeadingPicker.cjs +32 -39
- package/dist/cjs/toolbar/HeadingPicker.native.js +61 -51
- package/dist/cjs/toolbar/HeadingPicker.native.js.map +1 -1
- package/dist/cjs/toolbar/ImageBubble.cjs +20 -43
- package/dist/cjs/toolbar/ImageBubble.native.js +20 -43
- package/dist/cjs/toolbar/ImageBubble.native.js.map +1 -1
- package/dist/cjs/toolbar/ImageDialog.cjs +5 -4
- package/dist/cjs/toolbar/ImageDialog.native.js +76 -65
- package/dist/cjs/toolbar/ImageDialog.native.js.map +1 -1
- package/dist/cjs/toolbar/LinkBubble.cjs +23 -70
- package/dist/cjs/toolbar/LinkBubble.native.js +23 -70
- package/dist/cjs/toolbar/LinkBubble.native.js.map +1 -1
- package/dist/cjs/toolbar/LinkDialog.cjs +19 -18
- package/dist/cjs/toolbar/LinkDialog.native.js +86 -83
- package/dist/cjs/toolbar/LinkDialog.native.js.map +1 -1
- package/dist/cjs/toolbar/ListPicker.cjs +32 -43
- package/dist/cjs/toolbar/ListPicker.native.js +43 -44
- package/dist/cjs/toolbar/ListPicker.native.js.map +1 -1
- package/dist/cjs/toolbar/MathBubble.cjs +159 -0
- package/dist/cjs/toolbar/MathBubble.native.js +169 -0
- package/dist/cjs/toolbar/MathBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/MoreDropdown.cjs +51 -98
- package/dist/cjs/toolbar/MoreDropdown.native.js +73 -98
- package/dist/cjs/toolbar/MoreDropdown.native.js.map +1 -1
- package/dist/cjs/toolbar/StatusBar.cjs +19 -10
- package/dist/cjs/toolbar/StatusBar.native.js +19 -10
- package/dist/cjs/toolbar/StatusBar.native.js.map +1 -1
- package/dist/cjs/toolbar/TableBubble.cjs +77 -95
- package/dist/cjs/toolbar/TableBubble.native.js +73 -71
- package/dist/cjs/toolbar/TableBubble.native.js.map +1 -1
- package/dist/cjs/toolbar/ToolbarButton.cjs +86 -21
- package/dist/cjs/toolbar/ToolbarButton.native.js +14 -4
- package/dist/cjs/toolbar/ToolbarButton.native.js.map +1 -1
- package/dist/cjs/toolbar/icons.cjs +111 -468
- package/dist/cjs/toolbar/shortcuts.cjs +73 -24
- package/dist/cjs/toolbar/shortcuts.native.js +73 -24
- package/dist/cjs/toolbar/shortcuts.native.js.map +1 -1
- package/dist/cjs/toolbar/useHorizontalScroll.cjs +25 -5
- package/dist/cjs/toolbar/useHorizontalScroll.native.js +25 -5
- package/dist/cjs/toolbar/useHorizontalScroll.native.js.map +1 -1
- package/dist/cjs/toolbar/useRovingFocus.cjs +80 -0
- package/dist/cjs/toolbar/useRovingFocus.native.js +113 -0
- package/dist/cjs/toolbar/useRovingFocus.native.js.map +1 -0
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/RichEditor.mjs +85 -10
- package/dist/esm/RichEditor.mjs.map +1 -1
- package/dist/esm/RichEditor.native.js +425 -38
- package/dist/esm/RichEditor.native.js.map +1 -1
- package/dist/esm/RichTextEditor/index.mjs +18 -2
- package/dist/esm/RichTextEditor/index.mjs.map +1 -1
- package/dist/esm/RichTextEditor/index.native.js +18 -2
- package/dist/esm/RichTextEditor/index.native.js.map +1 -1
- package/dist/esm/constants.mjs +47 -29
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +54 -29
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/editor/BlockDragHandle.mjs +22 -7
- package/dist/esm/editor/BlockDragHandle.mjs.map +1 -1
- package/dist/esm/editor/BlockDragHandle.native.js +41 -7
- package/dist/esm/editor/BlockDragHandle.native.js.map +1 -1
- package/dist/esm/editor/SlashCommands.mjs +250 -294
- package/dist/esm/editor/SlashCommands.mjs.map +1 -1
- package/dist/esm/editor/SlashCommands.native.js +307 -341
- package/dist/esm/editor/SlashCommands.native.js.map +1 -1
- package/dist/esm/editor/TentapEditor.native.js +45 -13
- package/dist/esm/editor/TentapEditor.native.js.map +1 -1
- package/dist/esm/editor/TiptapEditor.mjs +142 -35
- package/dist/esm/editor/TiptapEditor.mjs.map +1 -1
- package/dist/esm/editor/TiptapEditor.native.js +155 -35
- package/dist/esm/editor/TiptapEditor.native.js.map +1 -1
- package/dist/esm/editor/blockAnchor.mjs +18 -0
- package/dist/esm/editor/blockAnchor.mjs.map +1 -0
- package/dist/esm/editor/blockAnchor.native.js +40 -0
- package/dist/esm/editor/blockAnchor.native.js.map +1 -0
- package/dist/esm/editor/codeBlockPreview.mjs +190 -0
- package/dist/esm/editor/codeBlockPreview.mjs.map +1 -0
- package/dist/esm/editor/codeBlockPreview.native.js +222 -0
- package/dist/esm/editor/codeBlockPreview.native.js.map +1 -0
- package/dist/esm/editor/editorStyles.mjs +203 -34
- package/dist/esm/editor/editorStyles.mjs.map +1 -1
- package/dist/esm/editor/editorStyles.native.js +203 -34
- package/dist/esm/editor/editorStyles.native.js.map +1 -1
- package/dist/esm/editor/emoji.mjs +88 -0
- package/dist/esm/editor/emoji.mjs.map +1 -0
- package/dist/esm/editor/emoji.native.js +141 -0
- package/dist/esm/editor/emoji.native.js.map +1 -0
- package/dist/esm/editor/lazyKatex.mjs +40 -0
- package/dist/esm/editor/lazyKatex.mjs.map +1 -0
- package/dist/esm/editor/lazyKatex.native.js +76 -0
- package/dist/esm/editor/lazyKatex.native.js.map +1 -0
- package/dist/esm/editor/markdown.mjs +179 -0
- package/dist/esm/editor/markdown.mjs.map +1 -0
- package/dist/esm/editor/markdown.native.js +238 -0
- package/dist/esm/editor/markdown.native.js.map +1 -0
- package/dist/esm/editor/mathematics.mjs +142 -0
- package/dist/esm/editor/mathematics.mjs.map +1 -0
- package/dist/esm/editor/mathematics.native.js +173 -0
- package/dist/esm/editor/mathematics.native.js.map +1 -0
- package/dist/esm/editor/media.mjs +113 -0
- package/dist/esm/editor/media.mjs.map +1 -0
- package/dist/esm/editor/media.native.js +144 -0
- package/dist/esm/editor/media.native.js.map +1 -0
- package/dist/esm/editor/mentions.mjs +37 -0
- package/dist/esm/editor/mentions.mjs.map +1 -0
- package/dist/esm/editor/mentions.native.js +45 -0
- package/dist/esm/editor/mentions.native.js.map +1 -0
- package/dist/esm/editor/pasteCleanup.mjs +57 -0
- package/dist/esm/editor/pasteCleanup.mjs.map +1 -0
- package/dist/esm/editor/pasteCleanup.native.js +146 -0
- package/dist/esm/editor/pasteCleanup.native.js.map +1 -0
- package/dist/esm/editor/suggestionPopup.mjs +268 -0
- package/dist/esm/editor/suggestionPopup.mjs.map +1 -0
- package/dist/esm/editor/suggestionPopup.native.js +295 -0
- package/dist/esm/editor/suggestionPopup.native.js.map +1 -0
- package/dist/esm/preview.mjs +236 -0
- package/dist/esm/preview.mjs.map +1 -0
- package/dist/esm/preview.native.js +264 -0
- package/dist/esm/preview.native.js.map +1 -0
- package/dist/esm/shared/t.mjs +17 -0
- package/dist/esm/shared/t.mjs.map +1 -0
- package/dist/esm/shared/t.native.js +17 -0
- package/dist/esm/shared/t.native.js.map +1 -0
- package/dist/esm/shared/url.mjs +10 -0
- package/dist/esm/shared/url.mjs.map +1 -0
- package/dist/esm/shared/url.native.js +10 -0
- package/dist/esm/shared/url.native.js.map +1 -0
- package/dist/esm/styled.mjs +13 -6
- package/dist/esm/styled.mjs.map +1 -1
- package/dist/esm/styled.native.js +13 -6
- package/dist/esm/styled.native.js.map +1 -1
- package/dist/esm/toolbar/BubbleToolbar.mjs +11 -9
- package/dist/esm/toolbar/BubbleToolbar.mjs.map +1 -1
- package/dist/esm/toolbar/BubbleToolbar.native.js +11 -9
- package/dist/esm/toolbar/BubbleToolbar.native.js.map +1 -1
- package/dist/esm/toolbar/CodeBlockBubble.mjs +60 -24
- package/dist/esm/toolbar/CodeBlockBubble.mjs.map +1 -1
- package/dist/esm/toolbar/CodeBlockBubble.native.js +72 -26
- package/dist/esm/toolbar/CodeBlockBubble.native.js.map +1 -1
- package/dist/esm/toolbar/ColorPicker.mjs +21 -56
- package/dist/esm/toolbar/ColorPicker.mjs.map +1 -1
- package/dist/esm/toolbar/ColorPicker.native.js +82 -180
- package/dist/esm/toolbar/ColorPicker.native.js.map +1 -1
- package/dist/esm/toolbar/FixedToolbar.mjs +34 -11
- package/dist/esm/toolbar/FixedToolbar.mjs.map +1 -1
- package/dist/esm/toolbar/FixedToolbar.native.js +47 -55
- package/dist/esm/toolbar/FixedToolbar.native.js.map +1 -1
- package/dist/esm/toolbar/HeadingPicker.mjs +34 -41
- package/dist/esm/toolbar/HeadingPicker.mjs.map +1 -1
- package/dist/esm/toolbar/HeadingPicker.native.js +63 -53
- package/dist/esm/toolbar/HeadingPicker.native.js.map +1 -1
- package/dist/esm/toolbar/ImageBubble.mjs +20 -43
- package/dist/esm/toolbar/ImageBubble.mjs.map +1 -1
- package/dist/esm/toolbar/ImageBubble.native.js +20 -43
- package/dist/esm/toolbar/ImageBubble.native.js.map +1 -1
- package/dist/esm/toolbar/ImageDialog.mjs +5 -4
- package/dist/esm/toolbar/ImageDialog.mjs.map +1 -1
- package/dist/esm/toolbar/ImageDialog.native.js +75 -64
- package/dist/esm/toolbar/ImageDialog.native.js.map +1 -1
- package/dist/esm/toolbar/LinkBubble.mjs +23 -70
- package/dist/esm/toolbar/LinkBubble.mjs.map +1 -1
- package/dist/esm/toolbar/LinkBubble.native.js +23 -70
- package/dist/esm/toolbar/LinkBubble.native.js.map +1 -1
- package/dist/esm/toolbar/LinkDialog.mjs +17 -16
- package/dist/esm/toolbar/LinkDialog.mjs.map +1 -1
- package/dist/esm/toolbar/LinkDialog.native.js +84 -80
- package/dist/esm/toolbar/LinkDialog.native.js.map +1 -1
- package/dist/esm/toolbar/ListPicker.mjs +33 -44
- package/dist/esm/toolbar/ListPicker.mjs.map +1 -1
- package/dist/esm/toolbar/ListPicker.native.js +44 -45
- package/dist/esm/toolbar/ListPicker.native.js.map +1 -1
- package/dist/esm/toolbar/MathBubble.mjs +134 -0
- package/dist/esm/toolbar/MathBubble.mjs.map +1 -0
- package/dist/esm/toolbar/MathBubble.native.js +141 -0
- package/dist/esm/toolbar/MathBubble.native.js.map +1 -0
- package/dist/esm/toolbar/MoreDropdown.mjs +50 -97
- package/dist/esm/toolbar/MoreDropdown.mjs.map +1 -1
- package/dist/esm/toolbar/MoreDropdown.native.js +72 -97
- package/dist/esm/toolbar/MoreDropdown.native.js.map +1 -1
- package/dist/esm/toolbar/StatusBar.mjs +19 -10
- package/dist/esm/toolbar/StatusBar.mjs.map +1 -1
- package/dist/esm/toolbar/StatusBar.native.js +19 -10
- package/dist/esm/toolbar/StatusBar.native.js.map +1 -1
- package/dist/esm/toolbar/TableBubble.mjs +77 -95
- package/dist/esm/toolbar/TableBubble.mjs.map +1 -1
- package/dist/esm/toolbar/TableBubble.native.js +73 -71
- package/dist/esm/toolbar/TableBubble.native.js.map +1 -1
- package/dist/esm/toolbar/ToolbarButton.mjs +87 -22
- package/dist/esm/toolbar/ToolbarButton.mjs.map +1 -1
- package/dist/esm/toolbar/ToolbarButton.native.js +14 -4
- package/dist/esm/toolbar/ToolbarButton.native.js.map +1 -1
- package/dist/esm/toolbar/icons.mjs +109 -469
- package/dist/esm/toolbar/icons.mjs.map +1 -1
- package/dist/esm/toolbar/shortcuts.mjs +73 -24
- package/dist/esm/toolbar/shortcuts.mjs.map +1 -1
- package/dist/esm/toolbar/shortcuts.native.js +73 -24
- package/dist/esm/toolbar/shortcuts.native.js.map +1 -1
- package/dist/esm/toolbar/useHorizontalScroll.mjs +25 -6
- package/dist/esm/toolbar/useHorizontalScroll.mjs.map +1 -1
- package/dist/esm/toolbar/useHorizontalScroll.native.js +25 -6
- package/dist/esm/toolbar/useHorizontalScroll.native.js.map +1 -1
- package/dist/esm/toolbar/useRovingFocus.mjs +55 -0
- package/dist/esm/toolbar/useRovingFocus.mjs.map +1 -0
- package/dist/esm/toolbar/useRovingFocus.native.js +85 -0
- package/dist/esm/toolbar/useRovingFocus.native.js.map +1 -0
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/types.native.js.map +1 -1
- package/dist/jsx/RichEditor.mjs +85 -10
- package/dist/jsx/RichEditor.mjs.map +1 -1
- package/dist/jsx/RichEditor.native.js +422 -35
- package/dist/jsx/RichEditor.native.js.map +1 -1
- package/dist/jsx/RichTextEditor/index.mjs +18 -2
- package/dist/jsx/RichTextEditor/index.mjs.map +1 -1
- package/dist/jsx/RichTextEditor/index.native.js +18 -2
- package/dist/jsx/RichTextEditor/index.native.js.map +1 -1
- package/dist/jsx/constants.mjs +47 -29
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/constants.native.js +59 -29
- package/dist/jsx/constants.native.js.map +1 -1
- package/dist/jsx/editor/BlockDragHandle.mjs +22 -7
- package/dist/jsx/editor/BlockDragHandle.mjs.map +1 -1
- package/dist/jsx/editor/BlockDragHandle.native.js +41 -7
- package/dist/jsx/editor/BlockDragHandle.native.js.map +1 -1
- package/dist/jsx/editor/SlashCommands.mjs +250 -294
- package/dist/jsx/editor/SlashCommands.mjs.map +1 -1
- package/dist/jsx/editor/SlashCommands.native.js +306 -340
- package/dist/jsx/editor/SlashCommands.native.js.map +1 -1
- package/dist/jsx/editor/TentapEditor.native.js +44 -12
- package/dist/jsx/editor/TentapEditor.native.js.map +1 -1
- package/dist/jsx/editor/TiptapEditor.mjs +142 -35
- package/dist/jsx/editor/TiptapEditor.mjs.map +1 -1
- package/dist/jsx/editor/TiptapEditor.native.js +153 -33
- package/dist/jsx/editor/TiptapEditor.native.js.map +1 -1
- package/dist/jsx/editor/blockAnchor.mjs +18 -0
- package/dist/jsx/editor/blockAnchor.mjs.map +1 -0
- package/dist/jsx/editor/blockAnchor.native.js +68 -0
- package/dist/jsx/editor/blockAnchor.native.js.map +1 -0
- package/dist/jsx/editor/codeBlockPreview.mjs +190 -0
- package/dist/jsx/editor/codeBlockPreview.mjs.map +1 -0
- package/dist/jsx/editor/codeBlockPreview.native.js +265 -0
- package/dist/jsx/editor/codeBlockPreview.native.js.map +1 -0
- package/dist/jsx/editor/editorStyles.mjs +203 -34
- package/dist/jsx/editor/editorStyles.mjs.map +1 -1
- package/dist/jsx/editor/editorStyles.native.js +203 -34
- package/dist/jsx/editor/editorStyles.native.js.map +1 -1
- package/dist/jsx/editor/emoji.mjs +88 -0
- package/dist/jsx/editor/emoji.mjs.map +1 -0
- package/dist/jsx/editor/emoji.native.js +184 -0
- package/dist/jsx/editor/emoji.native.js.map +1 -0
- package/dist/jsx/editor/lazyKatex.mjs +40 -0
- package/dist/jsx/editor/lazyKatex.mjs.map +1 -0
- package/dist/jsx/editor/lazyKatex.native.js +117 -0
- package/dist/jsx/editor/lazyKatex.native.js.map +1 -0
- package/dist/jsx/editor/markdown.mjs +179 -0
- package/dist/jsx/editor/markdown.mjs.map +1 -0
- package/dist/jsx/editor/markdown.native.js +278 -0
- package/dist/jsx/editor/markdown.native.js.map +1 -0
- package/dist/jsx/editor/mathematics.mjs +142 -0
- package/dist/jsx/editor/mathematics.mjs.map +1 -0
- package/dist/jsx/editor/mathematics.native.js +202 -0
- package/dist/jsx/editor/mathematics.native.js.map +1 -0
- package/dist/jsx/editor/media.mjs +113 -0
- package/dist/jsx/editor/media.mjs.map +1 -0
- package/dist/jsx/editor/media.native.js +172 -0
- package/dist/jsx/editor/media.native.js.map +1 -0
- package/dist/jsx/editor/mentions.mjs +37 -0
- package/dist/jsx/editor/mentions.mjs.map +1 -0
- package/dist/jsx/editor/mentions.native.js +84 -0
- package/dist/jsx/editor/mentions.native.js.map +1 -0
- package/dist/jsx/editor/pasteCleanup.mjs +57 -0
- package/dist/jsx/editor/pasteCleanup.mjs.map +1 -0
- package/dist/jsx/editor/pasteCleanup.native.js +175 -0
- package/dist/jsx/editor/pasteCleanup.native.js.map +1 -0
- package/dist/jsx/editor/suggestionPopup.mjs +268 -0
- package/dist/jsx/editor/suggestionPopup.mjs.map +1 -0
- package/dist/jsx/editor/suggestionPopup.native.js +327 -0
- package/dist/jsx/editor/suggestionPopup.native.js.map +1 -0
- package/dist/jsx/preview.mjs +236 -0
- package/dist/jsx/preview.mjs.map +1 -0
- package/dist/jsx/preview.native.js +294 -0
- package/dist/jsx/preview.native.js.map +1 -0
- package/dist/jsx/shared/t.mjs +17 -0
- package/dist/jsx/shared/t.mjs.map +1 -0
- package/dist/jsx/shared/t.native.js +56 -0
- package/dist/jsx/shared/t.native.js.map +1 -0
- package/dist/jsx/shared/url.mjs +10 -0
- package/dist/jsx/shared/url.mjs.map +1 -0
- package/dist/jsx/shared/url.native.js +38 -0
- package/dist/jsx/shared/url.native.js.map +1 -0
- package/dist/jsx/styled.mjs +13 -6
- package/dist/jsx/styled.mjs.map +1 -1
- package/dist/jsx/styled.native.js +13 -6
- package/dist/jsx/styled.native.js.map +1 -1
- package/dist/jsx/toolbar/BubbleToolbar.mjs +11 -9
- package/dist/jsx/toolbar/BubbleToolbar.mjs.map +1 -1
- package/dist/jsx/toolbar/BubbleToolbar.native.js +10 -8
- package/dist/jsx/toolbar/BubbleToolbar.native.js.map +1 -1
- package/dist/jsx/toolbar/CodeBlockBubble.mjs +60 -24
- package/dist/jsx/toolbar/CodeBlockBubble.mjs.map +1 -1
- package/dist/jsx/toolbar/CodeBlockBubble.native.js +71 -25
- package/dist/jsx/toolbar/CodeBlockBubble.native.js.map +1 -1
- package/dist/jsx/toolbar/ColorPicker.mjs +21 -56
- package/dist/jsx/toolbar/ColorPicker.mjs.map +1 -1
- package/dist/jsx/toolbar/ColorPicker.native.js +81 -179
- package/dist/jsx/toolbar/ColorPicker.native.js.map +1 -1
- package/dist/jsx/toolbar/FixedToolbar.mjs +34 -11
- package/dist/jsx/toolbar/FixedToolbar.mjs.map +1 -1
- package/dist/jsx/toolbar/FixedToolbar.native.js +46 -54
- package/dist/jsx/toolbar/FixedToolbar.native.js.map +1 -1
- package/dist/jsx/toolbar/HeadingPicker.mjs +34 -41
- package/dist/jsx/toolbar/HeadingPicker.mjs.map +1 -1
- package/dist/jsx/toolbar/HeadingPicker.native.js +61 -51
- package/dist/jsx/toolbar/HeadingPicker.native.js.map +1 -1
- package/dist/jsx/toolbar/ImageBubble.mjs +20 -43
- package/dist/jsx/toolbar/ImageBubble.mjs.map +1 -1
- package/dist/jsx/toolbar/ImageBubble.native.js +20 -43
- package/dist/jsx/toolbar/ImageBubble.native.js.map +1 -1
- package/dist/jsx/toolbar/ImageDialog.mjs +5 -4
- package/dist/jsx/toolbar/ImageDialog.mjs.map +1 -1
- package/dist/jsx/toolbar/ImageDialog.native.js +76 -65
- package/dist/jsx/toolbar/ImageDialog.native.js.map +1 -1
- package/dist/jsx/toolbar/LinkBubble.mjs +23 -70
- package/dist/jsx/toolbar/LinkBubble.mjs.map +1 -1
- package/dist/jsx/toolbar/LinkBubble.native.js +23 -70
- package/dist/jsx/toolbar/LinkBubble.native.js.map +1 -1
- package/dist/jsx/toolbar/LinkDialog.mjs +17 -16
- package/dist/jsx/toolbar/LinkDialog.mjs.map +1 -1
- package/dist/jsx/toolbar/LinkDialog.native.js +86 -83
- package/dist/jsx/toolbar/LinkDialog.native.js.map +1 -1
- package/dist/jsx/toolbar/ListPicker.mjs +33 -44
- package/dist/jsx/toolbar/ListPicker.mjs.map +1 -1
- package/dist/jsx/toolbar/ListPicker.native.js +43 -44
- package/dist/jsx/toolbar/ListPicker.native.js.map +1 -1
- package/dist/jsx/toolbar/MathBubble.mjs +134 -0
- package/dist/jsx/toolbar/MathBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/MathBubble.native.js +169 -0
- package/dist/jsx/toolbar/MathBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/MoreDropdown.mjs +50 -97
- package/dist/jsx/toolbar/MoreDropdown.mjs.map +1 -1
- package/dist/jsx/toolbar/MoreDropdown.native.js +73 -98
- package/dist/jsx/toolbar/MoreDropdown.native.js.map +1 -1
- package/dist/jsx/toolbar/StatusBar.mjs +19 -10
- package/dist/jsx/toolbar/StatusBar.mjs.map +1 -1
- package/dist/jsx/toolbar/StatusBar.native.js +19 -10
- package/dist/jsx/toolbar/StatusBar.native.js.map +1 -1
- package/dist/jsx/toolbar/TableBubble.mjs +77 -95
- package/dist/jsx/toolbar/TableBubble.mjs.map +1 -1
- package/dist/jsx/toolbar/TableBubble.native.js +73 -71
- package/dist/jsx/toolbar/TableBubble.native.js.map +1 -1
- package/dist/jsx/toolbar/ToolbarButton.mjs +87 -22
- package/dist/jsx/toolbar/ToolbarButton.mjs.map +1 -1
- package/dist/jsx/toolbar/ToolbarButton.native.js +14 -4
- package/dist/jsx/toolbar/ToolbarButton.native.js.map +1 -1
- package/dist/jsx/toolbar/icons.mjs +109 -469
- package/dist/jsx/toolbar/icons.mjs.map +1 -1
- package/dist/jsx/toolbar/shortcuts.mjs +73 -24
- package/dist/jsx/toolbar/shortcuts.mjs.map +1 -1
- package/dist/jsx/toolbar/shortcuts.native.js +73 -24
- package/dist/jsx/toolbar/shortcuts.native.js.map +1 -1
- package/dist/jsx/toolbar/useHorizontalScroll.mjs +25 -6
- package/dist/jsx/toolbar/useHorizontalScroll.mjs.map +1 -1
- package/dist/jsx/toolbar/useHorizontalScroll.native.js +25 -5
- package/dist/jsx/toolbar/useHorizontalScroll.native.js.map +1 -1
- package/dist/jsx/toolbar/useRovingFocus.mjs +55 -0
- package/dist/jsx/toolbar/useRovingFocus.mjs.map +1 -0
- package/dist/jsx/toolbar/useRovingFocus.native.js +113 -0
- package/dist/jsx/toolbar/useRovingFocus.native.js.map +1 -0
- package/dist/jsx/types.mjs.map +1 -1
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +28 -13
- package/src/RichEditor.native.tsx +451 -49
- package/src/RichEditor.stories.tsx +158 -0
- package/src/RichEditor.tsx +121 -7
- package/src/RichTextEditor/index.tsx +41 -3
- package/src/RichTextEditor/richTextEditor.spec.tsx +11 -4
- package/src/constants.ts +86 -24
- package/src/editor/BlockDragHandle.ts +30 -5
- package/src/editor/SlashCommands.tsx +228 -293
- package/src/editor/TentapEditor.native.tsx +68 -17
- package/src/editor/TiptapEditor.tsx +187 -22
- package/src/editor/blockAnchor.spec.ts +70 -0
- package/src/editor/blockAnchor.ts +42 -0
- package/src/editor/codeBlockPreview.spec.ts +144 -0
- package/src/editor/codeBlockPreview.ts +266 -0
- package/src/editor/css.d.ts +2 -0
- package/src/editor/details.spec.ts +48 -0
- package/src/editor/editorStyles.spec.ts +25 -0
- package/src/editor/editorStyles.ts +218 -34
- package/src/editor/emoji.spec.ts +88 -0
- package/src/editor/emoji.ts +147 -0
- package/src/editor/emojilib.d.ts +16 -0
- package/src/editor/lazyKatex.spec.ts +38 -0
- package/src/editor/lazyKatex.ts +68 -0
- package/src/editor/markdown.spec.ts +196 -0
- package/src/editor/markdown.ts +249 -0
- package/src/editor/mathematics.spec.ts +97 -0
- package/src/editor/mathematics.ts +179 -0
- package/src/editor/media.spec.ts +121 -0
- package/src/editor/media.ts +133 -0
- package/src/editor/mentions.spec.ts +41 -0
- package/src/editor/mentions.ts +55 -0
- package/src/editor/pasteCleanup.spec.ts +84 -0
- package/src/editor/pasteCleanup.ts +124 -0
- package/src/editor/suggestionPopup.spec.tsx +105 -0
- package/src/editor/suggestionPopup.tsx +414 -0
- package/src/editor/tiptapEditor.spec.tsx +15 -8
- package/src/exports.spec.ts +4 -2
- package/src/index.ts +7 -1
- package/src/integration.spec.tsx +38 -9
- package/src/preview.spec.ts +130 -0
- package/src/preview.ts +287 -0
- package/src/richEditor.spec.tsx +10 -3
- package/src/shared/t.ts +25 -0
- package/src/shared/url.ts +16 -0
- package/src/styled.ts +13 -6
- package/src/toolbar/BubbleToolbar.tsx +11 -8
- package/src/toolbar/CodeBlockBubble.tsx +66 -28
- package/src/toolbar/ColorPicker.native.tsx +126 -0
- package/src/toolbar/ColorPicker.tsx +23 -67
- package/src/toolbar/FixedToolbar.native.tsx +51 -51
- package/src/toolbar/FixedToolbar.tsx +54 -10
- package/src/toolbar/HeadingPicker.tsx +46 -38
- package/src/toolbar/ImageBubble.tsx +26 -44
- package/src/toolbar/ImageDialog.native.tsx +97 -0
- package/src/toolbar/ImageDialog.tsx +5 -4
- package/src/toolbar/LinkBubble.tsx +27 -64
- package/src/toolbar/LinkDialog.native.tsx +117 -0
- package/src/toolbar/LinkDialog.tsx +28 -24
- package/src/toolbar/ListPicker.tsx +47 -43
- package/src/toolbar/MathBubble.tsx +140 -0
- package/src/toolbar/MoreDropdown.tsx +53 -60
- package/src/toolbar/StatusBar.tsx +13 -8
- package/src/toolbar/TableBubble.tsx +82 -94
- package/src/toolbar/ToolbarButton.native.tsx +14 -4
- package/src/toolbar/ToolbarButton.tsx +98 -19
- package/src/toolbar/bubbleToolbar.spec.tsx +2 -1
- package/src/toolbar/fixedToolbar.spec.tsx +4 -2
- package/src/toolbar/icons.tsx +113 -323
- package/src/toolbar/shortcuts.ts +77 -24
- package/src/toolbar/toolbarPrimitives.spec.tsx +29 -1
- package/src/toolbar/toolbarSubComponents.spec.tsx +4 -2
- package/src/toolbar/useHorizontalScroll.spec.ts +67 -0
- package/src/toolbar/useHorizontalScroll.tsx +39 -12
- package/src/toolbar/useRovingFocus.spec.tsx +100 -0
- package/src/toolbar/useRovingFocus.ts +82 -0
- package/src/types.spec.ts +40 -1
- package/src/types.ts +28 -0
- package/types/RichEditor.d.ts +51 -0
- package/types/RichEditor.d.ts.map +1 -0
- package/types/RichEditor.native.d.ts +59 -0
- package/types/RichEditor.native.d.ts.map +1 -0
- package/types/RichTextEditor/index.d.ts +71 -0
- package/types/RichTextEditor/index.d.ts.map +1 -0
- package/types/constants.d.ts +49 -0
- package/types/constants.d.ts.map +1 -0
- package/types/context.d.ts +10 -0
- package/types/context.d.ts.map +1 -0
- package/types/editor/BlockDragHandle.d.ts +8 -0
- package/types/editor/BlockDragHandle.d.ts.map +1 -0
- package/types/editor/MarkdownPaste.d.ts +8 -0
- package/types/editor/MarkdownPaste.d.ts.map +1 -0
- package/types/editor/SlashCommands.d.ts +24 -0
- package/types/editor/SlashCommands.d.ts.map +1 -0
- package/types/editor/TentapEditor.native.d.ts +21 -0
- package/types/editor/TentapEditor.native.d.ts.map +1 -0
- package/types/editor/TiptapEditor.d.ts +24 -0
- package/types/editor/TiptapEditor.d.ts.map +1 -0
- package/types/editor/blockAnchor.d.ts +25 -0
- package/types/editor/blockAnchor.d.ts.map +1 -0
- package/types/editor/codeBlockPreview.d.ts +51 -0
- package/types/editor/codeBlockPreview.d.ts.map +1 -0
- package/types/editor/editorStyles.d.ts +25 -0
- package/types/editor/editorStyles.d.ts.map +1 -0
- package/types/editor/emoji.d.ts +45 -0
- package/types/editor/emoji.d.ts.map +1 -0
- package/types/editor/index.d.ts +11 -0
- package/types/editor/index.d.ts.map +1 -0
- package/types/editor/lazyKatex.d.ts +33 -0
- package/types/editor/lazyKatex.d.ts.map +1 -0
- package/types/editor/markdown.d.ts +24 -0
- package/types/editor/markdown.d.ts.map +1 -0
- package/types/editor/mathematics.d.ts +44 -0
- package/types/editor/mathematics.d.ts.map +1 -0
- package/types/editor/media.d.ts +32 -0
- package/types/editor/media.d.ts.map +1 -0
- package/types/editor/mentions.d.ts +15 -0
- package/types/editor/mentions.d.ts.map +1 -0
- package/types/editor/pasteCleanup.d.ts +24 -0
- package/types/editor/pasteCleanup.d.ts.map +1 -0
- package/types/editor/suggestionPopup.d.ts +113 -0
- package/types/editor/suggestionPopup.d.ts.map +1 -0
- package/types/editor/types.d.ts +80 -0
- package/types/editor/types.d.ts.map +1 -0
- package/types/editor/useEditorState.d.ts +19 -0
- package/types/editor/useEditorState.d.ts.map +1 -0
- package/types/index.d.ts +11 -0
- package/types/index.d.ts.map +1 -0
- package/types/preview.d.ts +44 -0
- package/types/preview.d.ts.map +1 -0
- package/types/shared/t.d.ts +10 -0
- package/types/shared/t.d.ts.map +1 -0
- package/types/shared/url.d.ts +9 -0
- package/types/shared/url.d.ts.map +1 -0
- package/types/styled.d.ts +40 -0
- package/types/styled.d.ts.map +1 -0
- package/types/toolbar/BubbleToolbar.d.ts +23 -0
- package/types/toolbar/BubbleToolbar.d.ts.map +1 -0
- package/types/toolbar/CodeBlockBubble.d.ts +10 -0
- package/types/toolbar/CodeBlockBubble.d.ts.map +1 -0
- package/types/toolbar/ColorPicker.d.ts +15 -0
- package/types/toolbar/ColorPicker.d.ts.map +1 -0
- package/types/toolbar/ColorPicker.native.d.ts +20 -0
- package/types/toolbar/ColorPicker.native.d.ts.map +1 -0
- package/types/toolbar/FixedToolbar.d.ts +32 -0
- package/types/toolbar/FixedToolbar.d.ts.map +1 -0
- package/types/toolbar/FixedToolbar.native.d.ts +30 -0
- package/types/toolbar/FixedToolbar.native.d.ts.map +1 -0
- package/types/toolbar/HeadingPicker.d.ts +14 -0
- package/types/toolbar/HeadingPicker.d.ts.map +1 -0
- package/types/toolbar/ImageBubble.d.ts +10 -0
- package/types/toolbar/ImageBubble.d.ts.map +1 -0
- package/types/toolbar/ImageDialog.d.ts +12 -0
- package/types/toolbar/ImageDialog.d.ts.map +1 -0
- package/types/toolbar/ImageDialog.native.d.ts +15 -0
- package/types/toolbar/ImageDialog.native.d.ts.map +1 -0
- package/types/toolbar/LinkBubble.d.ts +10 -0
- package/types/toolbar/LinkBubble.d.ts.map +1 -0
- package/types/toolbar/LinkDialog.d.ts +20 -0
- package/types/toolbar/LinkDialog.d.ts.map +1 -0
- package/types/toolbar/LinkDialog.native.d.ts +18 -0
- package/types/toolbar/LinkDialog.native.d.ts.map +1 -0
- package/types/toolbar/ListPicker.d.ts +14 -0
- package/types/toolbar/ListPicker.d.ts.map +1 -0
- package/types/toolbar/MathBubble.d.ts +11 -0
- package/types/toolbar/MathBubble.d.ts.map +1 -0
- package/types/toolbar/MoreDropdown.d.ts +13 -0
- package/types/toolbar/MoreDropdown.d.ts.map +1 -0
- package/types/toolbar/ResizeHandle.d.ts +11 -0
- package/types/toolbar/ResizeHandle.d.ts.map +1 -0
- package/types/toolbar/StatusBar.d.ts +11 -0
- package/types/toolbar/StatusBar.d.ts.map +1 -0
- package/types/toolbar/TableBubble.d.ts +10 -0
- package/types/toolbar/TableBubble.d.ts.map +1 -0
- package/types/toolbar/ToolbarButton.d.ts +35 -0
- package/types/toolbar/ToolbarButton.d.ts.map +1 -0
- package/types/toolbar/ToolbarButton.native.d.ts +30 -0
- package/types/toolbar/ToolbarButton.native.d.ts.map +1 -0
- package/types/toolbar/ToolbarGroup.d.ts +14 -0
- package/types/toolbar/ToolbarGroup.d.ts.map +1 -0
- package/types/toolbar/icons.d.ts +52 -0
- package/types/toolbar/icons.d.ts.map +1 -0
- package/types/toolbar/icons.native.d.ts +41 -0
- package/types/toolbar/icons.native.d.ts.map +1 -0
- package/types/toolbar/shortcuts.d.ts +34 -0
- package/types/toolbar/shortcuts.d.ts.map +1 -0
- package/types/toolbar/useHorizontalScroll.d.ts +43 -0
- package/types/toolbar/useHorizontalScroll.d.ts.map +1 -0
- package/types/toolbar/useRovingFocus.d.ts +10 -0
- package/types/toolbar/useRovingFocus.d.ts.map +1 -0
- package/types/types.d.ts +125 -0
- package/types/types.d.ts.map +1 -0
- package/dist/cjs/RichEditor.stories.cjs +0 -327
- package/dist/cjs/RichEditor.stories.native.js +0 -342
- package/dist/cjs/RichEditor.stories.native.js.map +0 -1
- package/dist/esm/RichEditor.stories.mjs +0 -291
- package/dist/esm/RichEditor.stories.mjs.map +0 -1
- package/dist/esm/RichEditor.stories.native.js +0 -303
- package/dist/esm/RichEditor.stories.native.js.map +0 -1
- package/dist/jsx/RichEditor.stories.mjs +0 -291
- package/dist/jsx/RichEditor.stories.mjs.map +0 -1
- package/dist/jsx/RichEditor.stories.native.js +0 -342
- package/dist/jsx/RichEditor.stories.native.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "vitest";
|
|
2
2
|
|
|
3
|
-
vi.mock("@multiplatform.one/forms", () => ({
|
|
3
|
+
vi.mock("@multiplatform.one/forms", async (importOriginal) => ({
|
|
4
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
4
5
|
Button: (props: any) => (
|
|
5
6
|
<button
|
|
6
7
|
role="button"
|
|
@@ -13,7 +14,8 @@ vi.mock("@multiplatform.one/forms", () => ({
|
|
|
13
14
|
),
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
|
-
vi.mock("@multiplatform.one/components", () => ({
|
|
17
|
+
vi.mock("@multiplatform.one/components", async (importOriginal) => ({
|
|
18
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
17
19
|
Tooltip: ({ children }: any) => children,
|
|
18
20
|
}));
|
|
19
21
|
|
|
@@ -39,6 +41,10 @@ const mockEditor = {
|
|
|
39
41
|
blur: vi.fn(),
|
|
40
42
|
},
|
|
41
43
|
setEditable: vi.fn(),
|
|
44
|
+
storage: {
|
|
45
|
+
mediaUpload: { handlers: {} },
|
|
46
|
+
suggestionChrome: { value: null },
|
|
47
|
+
},
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
vi.mock("@tiptap/react", () => ({
|
|
@@ -127,18 +133,19 @@ describe("TiptapEditor", () => {
|
|
|
127
133
|
expect(container.querySelector("[data-testid='editor-content']")).toBeTruthy();
|
|
128
134
|
});
|
|
129
135
|
|
|
130
|
-
it("
|
|
131
|
-
// With showBubbleToolbar={true}
|
|
136
|
+
it("gates the formatting bubbles behind showBubbleToolbar (math bubble stays)", () => {
|
|
137
|
+
// With showBubbleToolbar={true}: formatting bubbles + math bubble
|
|
132
138
|
const { container: withBubble } = renderWithProviders(
|
|
133
139
|
withContext(<TiptapEditor showBubbleToolbar />),
|
|
134
140
|
);
|
|
135
|
-
expect(withBubble.
|
|
141
|
+
expect(withBubble.querySelectorAll("[data-testid='bubble-menu']").length).toBeGreaterThan(1);
|
|
136
142
|
|
|
137
|
-
// With showBubbleToolbar={false} (default)
|
|
143
|
+
// With showBubbleToolbar={false} (default): only the MathBubble stays
|
|
144
|
+
// mounted — it is the only edit path for inline math atoms.
|
|
138
145
|
const { container: withoutBubble } = renderWithProviders(
|
|
139
146
|
withContext(<TiptapEditor showBubbleToolbar={false} />),
|
|
140
147
|
);
|
|
141
|
-
expect(withoutBubble.
|
|
148
|
+
expect(withoutBubble.querySelectorAll("[data-testid='bubble-menu']").length).toBe(1);
|
|
142
149
|
});
|
|
143
150
|
|
|
144
151
|
it("exposes RichEditorRef methods via forwardRef and useImperativeHandle", () => {
|
|
@@ -164,6 +171,6 @@ describe("TiptapEditor", () => {
|
|
|
164
171
|
const cssContent = styleTag?.textContent ?? "";
|
|
165
172
|
// Should use CSS custom properties for theme-aware colors
|
|
166
173
|
expect(cssContent).toContain("var(--color12)");
|
|
167
|
-
expect(cssContent).toContain("var(--
|
|
174
|
+
expect(cssContent).toContain("var(--color10");
|
|
168
175
|
});
|
|
169
176
|
});
|
package/src/exports.spec.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { describe, it, expect, vi } from "vitest";
|
|
|
4
4
|
// Mocks -- must come before imports to prevent Tiptap module errors
|
|
5
5
|
// ---------------------------------------------------------------------------
|
|
6
6
|
|
|
7
|
-
vi.mock("@multiplatform.one/forms", () => ({
|
|
7
|
+
vi.mock("@multiplatform.one/forms", async (importOriginal) => ({
|
|
8
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
8
9
|
Field: () => null,
|
|
9
10
|
FieldLayout: ({ children }: any) => children,
|
|
10
11
|
Skeleton: () => null,
|
|
@@ -35,7 +36,8 @@ vi.mock("@multiplatform.one/components", () => ({
|
|
|
35
36
|
Tooltip: ({ children }: any) => children,
|
|
36
37
|
}));
|
|
37
38
|
|
|
38
|
-
vi.mock("@multiplatform.one/theme", () => ({
|
|
39
|
+
vi.mock("@multiplatform.one/theme", async (importOriginal) => ({
|
|
40
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
39
41
|
useResolvedKnobs: () => ({
|
|
40
42
|
knobProps: {
|
|
41
43
|
body: {},
|
package/src/index.ts
CHANGED
|
@@ -10,4 +10,10 @@ export type { RichEditorCombinedProps } from "./RichEditor";
|
|
|
10
10
|
export { RichTextEditor } from "./RichTextEditor";
|
|
11
11
|
export type { RichTextEditorProps } from "./RichTextEditor";
|
|
12
12
|
|
|
13
|
-
export type {
|
|
13
|
+
export type {
|
|
14
|
+
RichEditorRef,
|
|
15
|
+
RichEditorProps,
|
|
16
|
+
EditorCommand,
|
|
17
|
+
EditorState,
|
|
18
|
+
RichTextMentionOptions,
|
|
19
|
+
} from "./types";
|
package/src/integration.spec.tsx
CHANGED
|
@@ -59,11 +59,13 @@ describe("getEditorCSS defaults", () => {
|
|
|
59
59
|
// 3. ToolbarButton disabled state from context
|
|
60
60
|
// ===========================================================================
|
|
61
61
|
|
|
62
|
-
vi.mock("@multiplatform.one/forms", () => ({
|
|
62
|
+
vi.mock("@multiplatform.one/forms", async (importOriginal) => ({
|
|
63
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
63
64
|
Button: (props: any) => (
|
|
64
65
|
<button
|
|
65
66
|
role="button"
|
|
66
67
|
aria-label={props["aria-label"]}
|
|
68
|
+
aria-disabled={props["aria-disabled"]}
|
|
67
69
|
disabled={props.disabled}
|
|
68
70
|
onClick={props.onPress}
|
|
69
71
|
data-active={props.theme === "active" ? "true" : undefined}
|
|
@@ -117,7 +119,7 @@ vi.mock("@multiplatform.one/forms", () => ({
|
|
|
117
119
|
isEmpty?: (v: unknown) => boolean,
|
|
118
120
|
) => {
|
|
119
121
|
if (!required) return validators;
|
|
120
|
-
const check = isEmpty || ((v: unknown) => v
|
|
122
|
+
const check = isEmpty || ((v: unknown) => v === null || v === undefined || v === "");
|
|
121
123
|
const requiredValidator = ({ value }: { value: unknown }) =>
|
|
122
124
|
check(value)
|
|
123
125
|
? `${typeof label === "string" ? label : name || "Field"} is required`
|
|
@@ -142,11 +144,13 @@ vi.mock("@multiplatform.one/forms", () => ({
|
|
|
142
144
|
},
|
|
143
145
|
}));
|
|
144
146
|
|
|
145
|
-
vi.mock("@multiplatform.one/components", () => ({
|
|
147
|
+
vi.mock("@multiplatform.one/components", async (importOriginal) => ({
|
|
148
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
146
149
|
Tooltip: ({ children }: any) => children,
|
|
147
150
|
}));
|
|
148
151
|
|
|
149
|
-
vi.mock("@multiplatform.one/theme", () => ({
|
|
152
|
+
vi.mock("@multiplatform.one/theme", async (importOriginal) => ({
|
|
153
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
150
154
|
useResolvedKnobs: () => ({
|
|
151
155
|
knobProps: {
|
|
152
156
|
body: {},
|
|
@@ -189,6 +193,10 @@ const mockEditor = {
|
|
|
189
193
|
blur: vi.fn(),
|
|
190
194
|
},
|
|
191
195
|
setEditable: vi.fn(),
|
|
196
|
+
storage: {
|
|
197
|
+
mediaUpload: { handlers: {} },
|
|
198
|
+
suggestionChrome: { value: null },
|
|
199
|
+
},
|
|
192
200
|
};
|
|
193
201
|
|
|
194
202
|
vi.mock("@tiptap/react", () => ({
|
|
@@ -225,6 +233,7 @@ vi.mock("@tiptap/extension-image", () => ({
|
|
|
225
233
|
}));
|
|
226
234
|
|
|
227
235
|
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
236
|
+
import { fireEvent } from "@testing-library/react";
|
|
228
237
|
import { RichEditorContext } from "./context";
|
|
229
238
|
import { defaultEditorState } from "./types";
|
|
230
239
|
import type { EditorCommand, EditorState, ToolbarSection } from "./types";
|
|
@@ -236,15 +245,21 @@ const { RichTextEditor } = await import("./RichTextEditor/index");
|
|
|
236
245
|
|
|
237
246
|
describe("ToolbarButton disabled state from context", () => {
|
|
238
247
|
it("inherits disabled state from RichEditorContext", () => {
|
|
248
|
+
const onPress = vi.fn();
|
|
239
249
|
const { getByRole } = renderWithProviders(
|
|
240
250
|
<RichEditorContext.Provider size="$true" compact={false} disabled>
|
|
241
|
-
<ToolbarButton onPress={
|
|
251
|
+
<ToolbarButton onPress={onPress} aria-label="Test">
|
|
242
252
|
T
|
|
243
253
|
</ToolbarButton>
|
|
244
254
|
</RichEditorContext.Provider>,
|
|
245
255
|
);
|
|
246
256
|
const button = getByRole("button");
|
|
247
|
-
|
|
257
|
+
// DG-ST-03 / LC-40: an unavailable toolbar action is aria-disabled
|
|
258
|
+
// (stays focusable, swallows presses), never bare-`disabled`.
|
|
259
|
+
expect(button.getAttribute("aria-disabled")).toBe("true");
|
|
260
|
+
expect(button.getAttribute("disabled")).toBeNull();
|
|
261
|
+
fireEvent.click(button);
|
|
262
|
+
expect(onPress).not.toHaveBeenCalled();
|
|
248
263
|
});
|
|
249
264
|
});
|
|
250
265
|
|
|
@@ -394,6 +409,17 @@ describe("NATIVE_SUPPORTED_COMMANDS completeness", () => {
|
|
|
394
409
|
"highlight",
|
|
395
410
|
"horizontalRule",
|
|
396
411
|
"clearFormatting",
|
|
412
|
+
"insertTable",
|
|
413
|
+
"addColumnBefore",
|
|
414
|
+
"addColumnAfter",
|
|
415
|
+
"deleteColumn",
|
|
416
|
+
"addRowBefore",
|
|
417
|
+
"addRowAfter",
|
|
418
|
+
"deleteRow",
|
|
419
|
+
"deleteTable",
|
|
420
|
+
"mergeCells",
|
|
421
|
+
"splitCell",
|
|
422
|
+
"toggleHeaderRow",
|
|
397
423
|
];
|
|
398
424
|
|
|
399
425
|
for (const cmd of allCommands) {
|
|
@@ -421,10 +447,13 @@ describe("RichEditor passes showBubbleToolbar to TiptapEditor", () => {
|
|
|
421
447
|
expect(bubbleMenu).toBeTruthy();
|
|
422
448
|
});
|
|
423
449
|
|
|
424
|
-
it("
|
|
450
|
+
it("renders only the always-on MathBubble when showBubbleToolbar is false", () => {
|
|
425
451
|
const { container } = renderWithProviders(<RichEditor showBubbleToolbar={false} />);
|
|
426
452
|
|
|
427
|
-
|
|
428
|
-
|
|
453
|
+
// showBubbleToolbar gates the OPTIONAL formatting bubbles; the math
|
|
454
|
+
// bubble stays mounted because it is the only edit path for inline
|
|
455
|
+
// math atoms (a typed $x$ would otherwise be a dead end).
|
|
456
|
+
const bubbleMenus = container.querySelectorAll("[data-testid='bubble-menu']");
|
|
457
|
+
expect(bubbleMenus.length).toBe(1);
|
|
429
458
|
});
|
|
430
459
|
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { decodeEntities, isPreviewEmpty, parseHtmlPreview } from "./preview";
|
|
3
|
+
|
|
4
|
+
describe("decodeEntities", () => {
|
|
5
|
+
it("decodes named and numeric entities", () => {
|
|
6
|
+
expect(decodeEntities("a & b <c> "d" 'e' A")).toBe(
|
|
7
|
+
"a & b <c> \"d\" 'e' A",
|
|
8
|
+
);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("turns into a plain space", () => {
|
|
12
|
+
expect(decodeEntities("a b")).toBe("a b");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("leaves unknown entities alone", () => {
|
|
16
|
+
expect(decodeEntities("&bogus;")).toBe("&bogus;");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("isPreviewEmpty", () => {
|
|
21
|
+
it("treats null, empty string, and empty paragraph as empty", () => {
|
|
22
|
+
expect(isPreviewEmpty(null)).toBe(true);
|
|
23
|
+
expect(isPreviewEmpty("")).toBe(true);
|
|
24
|
+
expect(isPreviewEmpty("<p></p>")).toBe(true);
|
|
25
|
+
expect(isPreviewEmpty("<p> </p>")).toBe(true);
|
|
26
|
+
expect(isPreviewEmpty("<p><br></p>")).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("treats text and images as content", () => {
|
|
30
|
+
expect(isPreviewEmpty("<p>hi</p>")).toBe(false);
|
|
31
|
+
expect(isPreviewEmpty('<p><img src="x.png"></p>')).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("parseHtmlPreview", () => {
|
|
36
|
+
it("parses paragraphs into separate blocks", () => {
|
|
37
|
+
const { blocks } = parseHtmlPreview("<p>alpha</p><p>beta</p>");
|
|
38
|
+
expect(blocks).toHaveLength(2);
|
|
39
|
+
expect(blocks[0].kind).toBe("paragraph");
|
|
40
|
+
expect(blocks[0].spans).toEqual([{ text: "alpha" }]);
|
|
41
|
+
expect(blocks[1].spans).toEqual([{ text: "beta" }]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("skips empty paragraphs", () => {
|
|
45
|
+
const { blocks } = parseHtmlPreview("<p>alpha</p><p></p><p>beta</p>");
|
|
46
|
+
expect(blocks).toHaveLength(2);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("captures inline marks with nesting", () => {
|
|
50
|
+
const { blocks } = parseHtmlPreview(
|
|
51
|
+
"<p>plain <strong>bold <em>bolditalic</em></strong> <code>mono</code></p>",
|
|
52
|
+
);
|
|
53
|
+
expect(blocks[0].spans).toEqual([
|
|
54
|
+
{ text: "plain " },
|
|
55
|
+
{ text: "bold ", bold: true },
|
|
56
|
+
{ text: "bolditalic", bold: true, italic: true },
|
|
57
|
+
{ text: " " },
|
|
58
|
+
{ text: "mono", code: true },
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("maps heading levels", () => {
|
|
63
|
+
const { blocks } = parseHtmlPreview("<h1>one</h1><h2>two</h2><h3>three</h3>");
|
|
64
|
+
expect(blocks.map((b) => b.kind)).toEqual(["heading1", "heading2", "heading3"]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("numbers ordered lists and marks bullets", () => {
|
|
68
|
+
const { blocks } = parseHtmlPreview(
|
|
69
|
+
"<ul><li>a</li><li>b</li></ul><ol><li>x</li><li>y</li></ol>",
|
|
70
|
+
);
|
|
71
|
+
expect(blocks.map((b) => b.kind)).toEqual(["bullet", "bullet", "ordered", "ordered"]);
|
|
72
|
+
expect(blocks[2].index).toBe(1);
|
|
73
|
+
expect(blocks[3].index).toBe(2);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("tracks nested list indent", () => {
|
|
77
|
+
const { blocks } = parseHtmlPreview("<ul><li>a<ul><li>a1</li></ul></li></ul>");
|
|
78
|
+
expect(blocks[0].indent).toBe(0);
|
|
79
|
+
expect(blocks[1].indent).toBe(1);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("parses 10Tap task lists with checked state", () => {
|
|
83
|
+
const { blocks } = parseHtmlPreview(
|
|
84
|
+
'<ul data-type="taskList">' +
|
|
85
|
+
'<li data-checked="true" data-type="taskItem"><label><input type="checkbox" checked></label><div><p>done</p></div></li>' +
|
|
86
|
+
'<li data-checked="false" data-type="taskItem"><label><input type="checkbox"></label><div><p>todo</p></div></li>' +
|
|
87
|
+
"</ul>",
|
|
88
|
+
);
|
|
89
|
+
expect(blocks.map((b) => b.kind)).toEqual(["task", "task"]);
|
|
90
|
+
expect(blocks[0].checked).toBe(true);
|
|
91
|
+
expect(blocks[0].spans.map((s) => s.text).join("")).toBe("done");
|
|
92
|
+
expect(blocks[1].checked).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("flags blockquote content", () => {
|
|
96
|
+
const { blocks } = parseHtmlPreview("<blockquote><p>quoted</p></blockquote><p>after</p>");
|
|
97
|
+
expect(blocks[0].quote).toBe(true);
|
|
98
|
+
expect(blocks[0].spans[0].text).toBe("quoted");
|
|
99
|
+
expect(blocks[1].quote).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("decodes entities and collapses whitespace", () => {
|
|
103
|
+
const { blocks } = parseHtmlPreview("<p>\n a &\n\n b\n</p>");
|
|
104
|
+
expect(blocks[0].spans).toEqual([{ text: "a & b" }]);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("represents images with a token", () => {
|
|
108
|
+
const { blocks } = parseHtmlPreview('<p>look <img src="x.png"> here</p>');
|
|
109
|
+
expect(blocks[0].spans.map((s) => s.text).join("")).toBe("look [image] here");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("truncates at maxBlocks", () => {
|
|
113
|
+
const html = Array.from({ length: 9 }, (_, i) => `<p>p${i}</p>`).join("");
|
|
114
|
+
const { blocks, truncated } = parseHtmlPreview(html, 6);
|
|
115
|
+
expect(blocks).toHaveLength(6);
|
|
116
|
+
expect(truncated).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("does not flag truncation when content fits", () => {
|
|
120
|
+
const { blocks, truncated } = parseHtmlPreview("<p>a</p><p>b</p>", 6);
|
|
121
|
+
expect(blocks).toHaveLength(2);
|
|
122
|
+
expect(truncated).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("returns no blocks for empty input", () => {
|
|
126
|
+
expect(parseHtmlPreview("").blocks).toHaveLength(0);
|
|
127
|
+
expect(parseHtmlPreview("<p></p>").blocks).toHaveLength(0);
|
|
128
|
+
expect(parseHtmlPreview(null).blocks).toHaveLength(0);
|
|
129
|
+
});
|
|
130
|
+
});
|
package/src/preview.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight HTML -> preview-block parser for the native inline preview.
|
|
3
|
+
*
|
|
4
|
+
* The native RichEditor renders committed content as a compact, read-only
|
|
5
|
+
* preview surface (tap to open the fullscreen editor). A WebView per field is
|
|
6
|
+
* too heavy for that, so this parses the editor's own HTML output (Tiptap /
|
|
7
|
+
* 10Tap both emit a small, predictable tag set) into styled text blocks.
|
|
8
|
+
*
|
|
9
|
+
* Not a general HTML parser -- it understands exactly what the editor emits:
|
|
10
|
+
* p, h1-h6, ul/ol/li (incl. 10Tap taskList), blockquote, br, img and the
|
|
11
|
+
* inline marks strong/b, em/i, u, s/strike/del, code. Everything else is
|
|
12
|
+
* ignored (tags stripped, text kept).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ===========================================================================
|
|
16
|
+
// Types
|
|
17
|
+
// ===========================================================================
|
|
18
|
+
|
|
19
|
+
export interface PreviewSpan {
|
|
20
|
+
text: string;
|
|
21
|
+
bold?: boolean;
|
|
22
|
+
italic?: boolean;
|
|
23
|
+
underline?: boolean;
|
|
24
|
+
strike?: boolean;
|
|
25
|
+
code?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type PreviewBlockKind =
|
|
29
|
+
| "paragraph"
|
|
30
|
+
| "heading1"
|
|
31
|
+
| "heading2"
|
|
32
|
+
| "heading3"
|
|
33
|
+
| "heading4"
|
|
34
|
+
| "heading5"
|
|
35
|
+
| "heading6"
|
|
36
|
+
| "bullet"
|
|
37
|
+
| "ordered"
|
|
38
|
+
| "task";
|
|
39
|
+
|
|
40
|
+
export interface PreviewBlock {
|
|
41
|
+
kind: PreviewBlockKind;
|
|
42
|
+
spans: PreviewSpan[];
|
|
43
|
+
/** Inside a blockquote */
|
|
44
|
+
quote?: boolean;
|
|
45
|
+
/** Nested-list depth (0 = top level) */
|
|
46
|
+
indent?: number;
|
|
47
|
+
/** 1-based number for ordered list items */
|
|
48
|
+
index?: number;
|
|
49
|
+
/** Checked state for task list items */
|
|
50
|
+
checked?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface PreviewResult {
|
|
54
|
+
blocks: PreviewBlock[];
|
|
55
|
+
/** True when content was cut off at maxBlocks */
|
|
56
|
+
truncated: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ===========================================================================
|
|
60
|
+
// Entities
|
|
61
|
+
// ===========================================================================
|
|
62
|
+
|
|
63
|
+
const NAMED_ENTITIES: Record<string, string> = {
|
|
64
|
+
amp: "&",
|
|
65
|
+
lt: "<",
|
|
66
|
+
gt: ">",
|
|
67
|
+
quot: '"',
|
|
68
|
+
apos: "'",
|
|
69
|
+
nbsp: " ",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export function decodeEntities(text: string): string {
|
|
73
|
+
return text.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, entity: string) => {
|
|
74
|
+
if (entity[0] === "#") {
|
|
75
|
+
const code =
|
|
76
|
+
entity[1] === "x" || entity[1] === "X"
|
|
77
|
+
? Number.parseInt(entity.slice(2), 16)
|
|
78
|
+
: Number.parseInt(entity.slice(1), 10);
|
|
79
|
+
return Number.isFinite(code) ? String.fromCodePoint(code) : match;
|
|
80
|
+
}
|
|
81
|
+
return NAMED_ENTITIES[entity.toLowerCase()] ?? match;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ===========================================================================
|
|
86
|
+
// Empty check
|
|
87
|
+
// ===========================================================================
|
|
88
|
+
|
|
89
|
+
/** True when the HTML has no visible text and no image (e.g. "" or "<p></p>") */
|
|
90
|
+
export function isPreviewEmpty(html: string | null | undefined): boolean {
|
|
91
|
+
if (!html) return true;
|
|
92
|
+
if (/<img[\s>]/i.test(html)) return false;
|
|
93
|
+
return decodeEntities(html.replace(/<[^>]*>/g, "")).trim().length === 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ===========================================================================
|
|
97
|
+
// Parser
|
|
98
|
+
// ===========================================================================
|
|
99
|
+
|
|
100
|
+
const HEADING_KINDS: Record<string, PreviewBlockKind> = {
|
|
101
|
+
h1: "heading1",
|
|
102
|
+
h2: "heading2",
|
|
103
|
+
h3: "heading3",
|
|
104
|
+
h4: "heading4",
|
|
105
|
+
h5: "heading5",
|
|
106
|
+
h6: "heading6",
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
interface ListFrame {
|
|
110
|
+
type: "ul" | "ol" | "task";
|
|
111
|
+
counter: number;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function parseHtmlPreview(html: string | null | undefined, maxBlocks = 6): PreviewResult {
|
|
115
|
+
const blocks: PreviewBlock[] = [];
|
|
116
|
+
let truncated = false;
|
|
117
|
+
if (!html) return { blocks, truncated };
|
|
118
|
+
|
|
119
|
+
let current: PreviewBlock | null = null;
|
|
120
|
+
const marks = { bold: 0, italic: 0, underline: 0, strike: 0, code: 0 };
|
|
121
|
+
const listStack: ListFrame[] = [];
|
|
122
|
+
let quoteDepth = 0;
|
|
123
|
+
let liDepth = 0;
|
|
124
|
+
let capped = false;
|
|
125
|
+
|
|
126
|
+
const flush = () => {
|
|
127
|
+
if (!current) return;
|
|
128
|
+
const spans = current.spans;
|
|
129
|
+
// trim outer whitespace, drop blanks
|
|
130
|
+
if (spans.length > 0) {
|
|
131
|
+
spans[0].text = spans[0].text.replace(/^\s+/, "");
|
|
132
|
+
spans[spans.length - 1].text = spans[spans.length - 1].text.replace(/\s+$/, "");
|
|
133
|
+
}
|
|
134
|
+
const kept = spans.filter((s) => s.text.length > 0);
|
|
135
|
+
if (kept.some((s) => s.text.trim().length > 0)) {
|
|
136
|
+
current.spans = kept;
|
|
137
|
+
blocks.push(current);
|
|
138
|
+
if (blocks.length >= maxBlocks) capped = true;
|
|
139
|
+
}
|
|
140
|
+
current = null;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const open = (kind: PreviewBlockKind, extra?: Partial<PreviewBlock>) => {
|
|
144
|
+
flush();
|
|
145
|
+
if (capped) {
|
|
146
|
+
truncated = true;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
current = { kind, spans: [], ...(quoteDepth > 0 && { quote: true }), ...extra };
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const appendText = (raw: string) => {
|
|
153
|
+
const text = decodeEntities(raw).replace(/\s+/g, " ");
|
|
154
|
+
if (text.length === 0) return;
|
|
155
|
+
if (capped && !current) {
|
|
156
|
+
if (text.trim().length > 0) truncated = true;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (!current) {
|
|
160
|
+
if (text.trim().length === 0) return;
|
|
161
|
+
// stray text without a block wrapper (e.g. bare text at the root)
|
|
162
|
+
current = { kind: "paragraph", spans: [], ...(quoteDepth > 0 && { quote: true }) };
|
|
163
|
+
}
|
|
164
|
+
const span: PreviewSpan = {
|
|
165
|
+
text,
|
|
166
|
+
...(marks.bold > 0 && { bold: true }),
|
|
167
|
+
...(marks.italic > 0 && { italic: true }),
|
|
168
|
+
...(marks.underline > 0 && { underline: true }),
|
|
169
|
+
...(marks.strike > 0 && { strike: true }),
|
|
170
|
+
...(marks.code > 0 && { code: true }),
|
|
171
|
+
};
|
|
172
|
+
const last = current.spans[current.spans.length - 1];
|
|
173
|
+
if (
|
|
174
|
+
last &&
|
|
175
|
+
!!last.bold === !!span.bold &&
|
|
176
|
+
!!last.italic === !!span.italic &&
|
|
177
|
+
!!last.underline === !!span.underline &&
|
|
178
|
+
!!last.strike === !!span.strike &&
|
|
179
|
+
!!last.code === !!span.code
|
|
180
|
+
) {
|
|
181
|
+
last.text += span.text;
|
|
182
|
+
} else {
|
|
183
|
+
current.spans.push(span);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const tokens = html.match(/<[^>]*>|[^<]+/g) ?? [];
|
|
188
|
+
for (const token of tokens) {
|
|
189
|
+
if (token[0] !== "<") {
|
|
190
|
+
appendText(token);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const tagMatch = /^<\s*(\/?)\s*([a-zA-Z][a-zA-Z0-9]*)([^>]*)>$/.exec(token);
|
|
194
|
+
if (!tagMatch) continue;
|
|
195
|
+
const closing = tagMatch[1] === "/";
|
|
196
|
+
const name = tagMatch[2].toLowerCase();
|
|
197
|
+
const attrs = tagMatch[3] ?? "";
|
|
198
|
+
|
|
199
|
+
switch (name) {
|
|
200
|
+
case "p":
|
|
201
|
+
if (liDepth > 0) {
|
|
202
|
+
// paragraphs inside a list item flow into the item text
|
|
203
|
+
if (!closing) appendText(" ");
|
|
204
|
+
} else if (closing) {
|
|
205
|
+
flush();
|
|
206
|
+
} else {
|
|
207
|
+
open("paragraph");
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case "h1":
|
|
211
|
+
case "h2":
|
|
212
|
+
case "h3":
|
|
213
|
+
case "h4":
|
|
214
|
+
case "h5":
|
|
215
|
+
case "h6":
|
|
216
|
+
if (closing) flush();
|
|
217
|
+
else open(HEADING_KINDS[name]);
|
|
218
|
+
break;
|
|
219
|
+
case "br":
|
|
220
|
+
appendText(" ");
|
|
221
|
+
break;
|
|
222
|
+
case "ul":
|
|
223
|
+
if (closing) listStack.pop();
|
|
224
|
+
else {
|
|
225
|
+
listStack.push({
|
|
226
|
+
type: /data-type\s*=\s*["']taskList["']/i.test(attrs) ? "task" : "ul",
|
|
227
|
+
counter: 0,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
case "ol":
|
|
232
|
+
if (closing) listStack.pop();
|
|
233
|
+
else listStack.push({ type: "ol", counter: 0 });
|
|
234
|
+
break;
|
|
235
|
+
case "li": {
|
|
236
|
+
if (closing) {
|
|
237
|
+
liDepth = Math.max(0, liDepth - 1);
|
|
238
|
+
flush();
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
const frame = listStack[listStack.length - 1] ?? { type: "ul" as const, counter: 0 };
|
|
242
|
+
const indent = Math.max(0, listStack.length - 1);
|
|
243
|
+
if (frame.type === "ol") {
|
|
244
|
+
frame.counter += 1;
|
|
245
|
+
open("ordered", { indent, index: frame.counter });
|
|
246
|
+
} else if (frame.type === "task") {
|
|
247
|
+
open("task", { indent, checked: /data-checked\s*=\s*["']true["']/i.test(attrs) });
|
|
248
|
+
} else {
|
|
249
|
+
open("bullet", { indent });
|
|
250
|
+
}
|
|
251
|
+
liDepth += 1;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
case "blockquote":
|
|
255
|
+
flush();
|
|
256
|
+
quoteDepth = Math.max(0, quoteDepth + (closing ? -1 : 1));
|
|
257
|
+
break;
|
|
258
|
+
case "strong":
|
|
259
|
+
case "b":
|
|
260
|
+
marks.bold = Math.max(0, marks.bold + (closing ? -1 : 1));
|
|
261
|
+
break;
|
|
262
|
+
case "em":
|
|
263
|
+
case "i":
|
|
264
|
+
marks.italic = Math.max(0, marks.italic + (closing ? -1 : 1));
|
|
265
|
+
break;
|
|
266
|
+
case "u":
|
|
267
|
+
marks.underline = Math.max(0, marks.underline + (closing ? -1 : 1));
|
|
268
|
+
break;
|
|
269
|
+
case "s":
|
|
270
|
+
case "strike":
|
|
271
|
+
case "del":
|
|
272
|
+
marks.strike = Math.max(0, marks.strike + (closing ? -1 : 1));
|
|
273
|
+
break;
|
|
274
|
+
case "code":
|
|
275
|
+
marks.code = Math.max(0, marks.code + (closing ? -1 : 1));
|
|
276
|
+
break;
|
|
277
|
+
case "img":
|
|
278
|
+
if (!closing) appendText("[image]");
|
|
279
|
+
break;
|
|
280
|
+
default:
|
|
281
|
+
// input/label/div/span/a/mark/... -- structure ignored, text kept
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
flush();
|
|
286
|
+
return { blocks, truncated };
|
|
287
|
+
}
|
package/src/richEditor.spec.tsx
CHANGED
|
@@ -4,7 +4,8 @@ import { describe, it, expect, vi } from "vitest";
|
|
|
4
4
|
// Mocks — must come before imports
|
|
5
5
|
// ---------------------------------------------------------------------------
|
|
6
6
|
|
|
7
|
-
vi.mock("@multiplatform.one/forms", () => ({
|
|
7
|
+
vi.mock("@multiplatform.one/forms", async (importOriginal) => ({
|
|
8
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
8
9
|
Button: (props: any) => (
|
|
9
10
|
<button
|
|
10
11
|
role="button"
|
|
@@ -26,11 +27,13 @@ vi.mock("@multiplatform.one/forms", () => ({
|
|
|
26
27
|
},
|
|
27
28
|
}));
|
|
28
29
|
|
|
29
|
-
vi.mock("@multiplatform.one/components", () => ({
|
|
30
|
+
vi.mock("@multiplatform.one/components", async (importOriginal) => ({
|
|
31
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
30
32
|
Tooltip: ({ children }: any) => children,
|
|
31
33
|
}));
|
|
32
34
|
|
|
33
|
-
vi.mock("@multiplatform.one/theme", () => ({
|
|
35
|
+
vi.mock("@multiplatform.one/theme", async (importOriginal) => ({
|
|
36
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
34
37
|
useResolvedKnobs: (_options?: any) => ({
|
|
35
38
|
knobProps: {
|
|
36
39
|
body: {},
|
|
@@ -73,6 +76,10 @@ const mockEditor = {
|
|
|
73
76
|
blur: vi.fn(),
|
|
74
77
|
},
|
|
75
78
|
setEditable: vi.fn(),
|
|
79
|
+
storage: {
|
|
80
|
+
mediaUpload: { handlers: {} },
|
|
81
|
+
suggestionChrome: { value: null },
|
|
82
|
+
},
|
|
76
83
|
};
|
|
77
84
|
|
|
78
85
|
vi.mock("@tiptap/react", () => ({
|