@multiplatform.one/rich-text 6.1.0 → 6.4.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 +89 -9
- package/dist/cjs/RichEditor.native.js +444 -35
- package/dist/cjs/RichEditor.native.js.map +1 -1
- package/dist/cjs/RichTextEditor/index.cjs +20 -2
- package/dist/cjs/RichTextEditor/index.native.js +20 -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 +257 -294
- package/dist/cjs/editor/SlashCommands.native.js +320 -341
- package/dist/cjs/editor/SlashCommands.native.js.map +1 -1
- package/dist/cjs/editor/TentapEditor.native.js +59 -12
- package/dist/cjs/editor/TentapEditor.native.js.map +1 -1
- package/dist/cjs/editor/TiptapEditor.cjs +143 -240
- package/dist/cjs/editor/TiptapEditor.native.js +163 -289
- 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/capabilities.cjs +37 -0
- package/dist/cjs/editor/capabilities.native.js +41 -0
- package/dist/cjs/editor/capabilities.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/extensions.cjs +275 -0
- package/dist/cjs/editor/extensions.native.js +328 -0
- package/dist/cjs/editor/extensions.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/index.cjs +5 -2
- package/dist/cjs/index.native.js +4 -1
- package/dist/cjs/index.native.js.map +1 -1
- 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 +19 -14
- package/dist/cjs/toolbar/BubbleToolbar.native.js +22 -15
- 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 +39 -13
- 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 +54 -93
- package/dist/cjs/toolbar/MoreDropdown.native.js +80 -93
- 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 +91 -96
- package/dist/cjs/toolbar/TableBubble.native.js +90 -73
- 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 +90 -10
- package/dist/esm/RichEditor.mjs.map +1 -1
- package/dist/esm/RichEditor.native.js +447 -38
- package/dist/esm/RichEditor.native.js.map +1 -1
- package/dist/esm/RichTextEditor/index.mjs +20 -2
- package/dist/esm/RichTextEditor/index.mjs.map +1 -1
- package/dist/esm/RichTextEditor/index.native.js +20 -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 +258 -295
- package/dist/esm/editor/SlashCommands.mjs.map +1 -1
- package/dist/esm/editor/SlashCommands.native.js +321 -342
- package/dist/esm/editor/SlashCommands.native.js.map +1 -1
- package/dist/esm/editor/TentapEditor.native.js +60 -13
- package/dist/esm/editor/TentapEditor.native.js.map +1 -1
- package/dist/esm/editor/TiptapEditor.mjs +145 -231
- package/dist/esm/editor/TiptapEditor.mjs.map +1 -1
- package/dist/esm/editor/TiptapEditor.native.js +165 -280
- 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/capabilities.mjs +10 -0
- package/dist/esm/editor/capabilities.mjs.map +1 -0
- package/dist/esm/editor/capabilities.native.js +11 -0
- package/dist/esm/editor/capabilities.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/extensions.mjs +236 -0
- package/dist/esm/editor/extensions.mjs.map +1 -0
- package/dist/esm/editor/extensions.native.js +286 -0
- package/dist/esm/editor/extensions.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/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -1
- package/dist/esm/index.native.js.map +1 -1
- 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 +20 -15
- package/dist/esm/toolbar/BubbleToolbar.mjs.map +1 -1
- package/dist/esm/toolbar/BubbleToolbar.native.js +23 -16
- 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 +40 -14
- 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 +53 -92
- package/dist/esm/toolbar/MoreDropdown.mjs.map +1 -1
- package/dist/esm/toolbar/MoreDropdown.native.js +79 -92
- 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 +91 -96
- package/dist/esm/toolbar/TableBubble.mjs.map +1 -1
- package/dist/esm/toolbar/TableBubble.native.js +90 -73
- 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 +90 -10
- package/dist/jsx/RichEditor.mjs.map +1 -1
- package/dist/jsx/RichEditor.native.js +444 -35
- package/dist/jsx/RichEditor.native.js.map +1 -1
- package/dist/jsx/RichTextEditor/index.mjs +20 -2
- package/dist/jsx/RichTextEditor/index.mjs.map +1 -1
- package/dist/jsx/RichTextEditor/index.native.js +20 -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 +258 -295
- package/dist/jsx/editor/SlashCommands.mjs.map +1 -1
- package/dist/jsx/editor/SlashCommands.native.js +320 -341
- package/dist/jsx/editor/SlashCommands.native.js.map +1 -1
- package/dist/jsx/editor/TentapEditor.native.js +59 -12
- package/dist/jsx/editor/TentapEditor.native.js.map +1 -1
- package/dist/jsx/editor/TiptapEditor.mjs +145 -231
- package/dist/jsx/editor/TiptapEditor.mjs.map +1 -1
- package/dist/jsx/editor/TiptapEditor.native.js +163 -289
- 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/capabilities.mjs +10 -0
- package/dist/jsx/editor/capabilities.mjs.map +1 -0
- package/dist/jsx/editor/capabilities.native.js +41 -0
- package/dist/jsx/editor/capabilities.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/extensions.mjs +236 -0
- package/dist/jsx/editor/extensions.mjs.map +1 -0
- package/dist/jsx/editor/extensions.native.js +328 -0
- package/dist/jsx/editor/extensions.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/index.js +2 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +2 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +4 -1
- package/dist/jsx/index.native.js.map +1 -1
- 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 +20 -15
- package/dist/jsx/toolbar/BubbleToolbar.mjs.map +1 -1
- package/dist/jsx/toolbar/BubbleToolbar.native.js +22 -15
- 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 +40 -14
- 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 +53 -92
- package/dist/jsx/toolbar/MoreDropdown.mjs.map +1 -1
- package/dist/jsx/toolbar/MoreDropdown.native.js +80 -93
- 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 +91 -96
- package/dist/jsx/toolbar/TableBubble.mjs.map +1 -1
- package/dist/jsx/toolbar/TableBubble.native.js +90 -73
- 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 +471 -49
- package/src/RichEditor.stories.tsx +190 -0
- package/src/RichEditor.tsx +126 -7
- package/src/RichTextEditor/index.tsx +54 -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 +238 -293
- package/src/editor/TentapEditor.native.tsx +81 -17
- package/src/editor/TiptapEditor.tsx +202 -265
- package/src/editor/blockAnchor.spec.ts +70 -0
- package/src/editor/blockAnchor.ts +42 -0
- package/src/editor/capabilities.spec.ts +190 -0
- package/src/editor/capabilities.ts +76 -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/extensions.ts +315 -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 +10 -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 +48 -33
- 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 +73 -21
- 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 +79 -62
- package/src/toolbar/StatusBar.tsx +13 -8
- package/src/toolbar/TableBubble.tsx +136 -95
- 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 +56 -1
- 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 +77 -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/capabilities.d.ts +29 -0
- package/types/editor/capabilities.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/extensions.d.ts +41 -0
- package/types/editor/extensions.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 +12 -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 +25 -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 +34 -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 +15 -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 +13 -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 +147 -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
|
@@ -13,201 +13,39 @@ import {
|
|
|
13
13
|
memo,
|
|
14
14
|
useCallback,
|
|
15
15
|
useEffect,
|
|
16
|
+
useId,
|
|
16
17
|
useImperativeHandle,
|
|
17
18
|
useMemo,
|
|
18
19
|
useRef,
|
|
19
20
|
useState,
|
|
20
21
|
} from "react";
|
|
21
22
|
import { useEditor, EditorContent } from "@tiptap/react";
|
|
22
|
-
import {
|
|
23
|
-
import StarterKit from "@tiptap/starter-kit";
|
|
24
|
-
import Placeholder from "@tiptap/extension-placeholder";
|
|
25
|
-
import TextAlign from "@tiptap/extension-text-align";
|
|
26
|
-
import { Color } from "@tiptap/extension-color";
|
|
27
|
-
import { TextStyle } from "@tiptap/extension-text-style";
|
|
28
|
-
import { Highlight } from "@tiptap/extension-highlight";
|
|
29
|
-
import { Subscript } from "@tiptap/extension-subscript";
|
|
30
|
-
import { Superscript } from "@tiptap/extension-superscript";
|
|
31
|
-
import TaskList from "@tiptap/extension-task-list";
|
|
32
|
-
import TaskItem from "@tiptap/extension-task-item";
|
|
33
|
-
import Image from "@tiptap/extension-image";
|
|
34
|
-
import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
|
|
35
|
-
import Typography from "@tiptap/extension-typography";
|
|
36
|
-
import CharacterCount from "@tiptap/extension-character-count";
|
|
37
|
-
|
|
38
|
-
import { Table } from "@tiptap/extension-table";
|
|
39
|
-
import { TableRow } from "@tiptap/extension-table-row";
|
|
40
|
-
import { TableHeader } from "@tiptap/extension-table-header";
|
|
41
|
-
import { TableCell } from "@tiptap/extension-table-cell";
|
|
42
|
-
import { common, createLowlight } from "lowlight";
|
|
43
|
-
import TurndownService from "turndown";
|
|
44
|
-
import { marked } from "marked";
|
|
45
|
-
import { View, styled } from "tamagui";
|
|
23
|
+
import { View, getTokens, styled, useTheme, useThemeName } from "tamagui";
|
|
46
24
|
import { isWeb } from "@tamagui/constants";
|
|
25
|
+
import { menuRowFrame, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
26
|
+
import { clampRadiusForLargeComponent } from "@multiplatform.one/forms";
|
|
47
27
|
import type { RichEditorProps, RichEditorRef, EditorCommand } from "../types";
|
|
48
28
|
import { defaultEditorState } from "../types";
|
|
49
29
|
import { RichEditorContext } from "../context";
|
|
30
|
+
import { t } from "../shared/t";
|
|
50
31
|
import { getEditorCSS } from "./editorStyles";
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
32
|
+
import { buildEditorExtensions } from "./extensions";
|
|
33
|
+
import { isCommandInCapabilities } from "./capabilities";
|
|
34
|
+
import { createMentionExtension } from "./mentions";
|
|
35
|
+
import { setPreviewChrome } from "./codeBlockPreview";
|
|
36
|
+
import { htmlToMarkdown, markdownToHtml } from "./markdown";
|
|
37
|
+
import { cleanPastedHtml } from "./pasteCleanup";
|
|
38
|
+
import { fallbackSuggestionChrome, type SuggestionChrome } from "./suggestionPopup";
|
|
54
39
|
import { getEditorStateFromTiptap } from "./useEditorState";
|
|
55
40
|
import { BubbleToolbar } from "../toolbar/BubbleToolbar";
|
|
56
41
|
import { LinkBubble } from "../toolbar/LinkBubble";
|
|
57
42
|
import { CodeBlockBubble } from "../toolbar/CodeBlockBubble";
|
|
58
43
|
import { ImageBubble } from "../toolbar/ImageBubble";
|
|
59
44
|
import { TableBubble } from "../toolbar/TableBubble";
|
|
45
|
+
import { MathBubble } from "../toolbar/MathBubble";
|
|
60
46
|
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Tab / Shift-Tab indentation inside code blocks.
|
|
66
|
-
* Inserts or removes 2 spaces at the cursor (or start of each selected line).
|
|
67
|
-
*/
|
|
68
|
-
const CodeBlockTabIndent = Extension.create({
|
|
69
|
-
name: "codeBlockTabIndent",
|
|
70
|
-
addKeyboardShortcuts() {
|
|
71
|
-
return {
|
|
72
|
-
Tab: ({ editor }) => {
|
|
73
|
-
if (!editor.isActive("codeBlock")) return false;
|
|
74
|
-
const { state, dispatch } = editor.view;
|
|
75
|
-
const { from, to } = state.selection;
|
|
76
|
-
|
|
77
|
-
if (from === to) {
|
|
78
|
-
dispatch(state.tr.insertText(" ", from, to));
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const doc = state.doc;
|
|
83
|
-
const lines: { start: number }[] = [];
|
|
84
|
-
doc.nodesBetween(from, to, (node, pos) => {
|
|
85
|
-
if (node.isTextblock) {
|
|
86
|
-
lines.push({ start: pos + 1 });
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
if (lines.length === 0) {
|
|
90
|
-
dispatch(state.tr.insertText(" ", from, to));
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let tr = state.tr;
|
|
95
|
-
let offset = 0;
|
|
96
|
-
for (const line of lines) {
|
|
97
|
-
const lineStart = line.start + offset;
|
|
98
|
-
tr = tr.insertText(" ", lineStart);
|
|
99
|
-
offset += 2;
|
|
100
|
-
}
|
|
101
|
-
dispatch(tr);
|
|
102
|
-
return true;
|
|
103
|
-
},
|
|
104
|
-
"Shift-Tab": ({ editor }) => {
|
|
105
|
-
if (!editor.isActive("codeBlock")) return false;
|
|
106
|
-
const { state, dispatch } = editor.view;
|
|
107
|
-
const { from, to, $from } = state.selection;
|
|
108
|
-
|
|
109
|
-
if (from === to) {
|
|
110
|
-
const lineStart = from - $from.parentOffset;
|
|
111
|
-
const text = state.doc.textBetween(lineStart, from);
|
|
112
|
-
const leadingSpaces = text.match(/^ {1,2}/)?.[0];
|
|
113
|
-
if (leadingSpaces) {
|
|
114
|
-
dispatch(state.tr.delete(lineStart, lineStart + leadingSpaces.length));
|
|
115
|
-
}
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const doc = state.doc;
|
|
120
|
-
let tr = state.tr;
|
|
121
|
-
let offset = 0;
|
|
122
|
-
doc.nodesBetween(from, to, (node, pos) => {
|
|
123
|
-
if (node.isTextblock) {
|
|
124
|
-
const lineStart = pos + 1 + offset;
|
|
125
|
-
const text = tr.doc.textBetween(
|
|
126
|
-
lineStart,
|
|
127
|
-
Math.min(lineStart + node.content.size, tr.doc.content.size),
|
|
128
|
-
);
|
|
129
|
-
const leadingSpaces = text.match(/^ {1,2}/)?.[0];
|
|
130
|
-
if (leadingSpaces) {
|
|
131
|
-
tr = tr.delete(lineStart, lineStart + leadingSpaces.length);
|
|
132
|
-
offset -= leadingSpaces.length;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
dispatch(tr);
|
|
137
|
-
return true;
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Override Shift-Enter and Mod-Enter to create new paragraphs instead of
|
|
145
|
-
* hard breaks (<br>). Mirrors GitLab's approach: HardBreak node stays
|
|
146
|
-
* registered (so <br> in pasted HTML is preserved) but its keyboard
|
|
147
|
-
* shortcuts are replaced with the default enter (split paragraph) behavior.
|
|
148
|
-
*/
|
|
149
|
-
const ParagraphEnterKeys = Extension.create({
|
|
150
|
-
name: "paragraphEnterKeys",
|
|
151
|
-
priority: 1000,
|
|
152
|
-
addKeyboardShortcuts() {
|
|
153
|
-
return {
|
|
154
|
-
"Shift-Enter": ({ editor }) =>
|
|
155
|
-
editor.commands.first([
|
|
156
|
-
() => editor.commands.newlineInCode(),
|
|
157
|
-
() => editor.commands.splitListItem("listItem"),
|
|
158
|
-
() => editor.commands.createParagraphNear(),
|
|
159
|
-
() => editor.commands.liftEmptyBlock(),
|
|
160
|
-
() => editor.commands.splitBlock(),
|
|
161
|
-
]),
|
|
162
|
-
"Mod-Enter": ({ editor }) =>
|
|
163
|
-
editor.commands.first([
|
|
164
|
-
() => editor.commands.newlineInCode(),
|
|
165
|
-
() => editor.commands.createParagraphNear(),
|
|
166
|
-
() => editor.commands.liftEmptyBlock(),
|
|
167
|
-
() => editor.commands.splitBlock(),
|
|
168
|
-
]),
|
|
169
|
-
};
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Tab/Shift-Tab indent/dedent and Alt+Arrow move for list items.
|
|
175
|
-
* Tab sinks (indents), Shift-Tab lifts (dedents).
|
|
176
|
-
* Alt+Up/Down moves the list item up or down among siblings.
|
|
177
|
-
*/
|
|
178
|
-
const ListItemKeys = Extension.create({
|
|
179
|
-
name: "listItemKeys",
|
|
180
|
-
addKeyboardShortcuts() {
|
|
181
|
-
return {
|
|
182
|
-
Tab: ({ editor }) => {
|
|
183
|
-
if (editor.isActive("codeBlock")) return false;
|
|
184
|
-
if (
|
|
185
|
-
editor.isActive("bulletList") ||
|
|
186
|
-
editor.isActive("orderedList") ||
|
|
187
|
-
editor.isActive("taskList")
|
|
188
|
-
) {
|
|
189
|
-
return (
|
|
190
|
-
editor.commands.sinkListItem("listItem") || editor.commands.sinkListItem("taskItem")
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
return false;
|
|
194
|
-
},
|
|
195
|
-
"Shift-Tab": ({ editor }) => {
|
|
196
|
-
if (editor.isActive("codeBlock")) return false;
|
|
197
|
-
if (
|
|
198
|
-
editor.isActive("bulletList") ||
|
|
199
|
-
editor.isActive("orderedList") ||
|
|
200
|
-
editor.isActive("taskList")
|
|
201
|
-
) {
|
|
202
|
-
return (
|
|
203
|
-
editor.commands.liftListItem("listItem") || editor.commands.liftListItem("taskItem")
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
return false;
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
},
|
|
210
|
-
});
|
|
47
|
+
/** Enter/exit fade for bubbles and suggestion popups (0 when animation none) */
|
|
48
|
+
const MOTION_MS = 120;
|
|
211
49
|
|
|
212
50
|
// ===========================================================================
|
|
213
51
|
// Types
|
|
@@ -222,6 +60,8 @@ export interface TiptapEditorProps extends RichEditorProps {
|
|
|
222
60
|
headingFontFamily?: string;
|
|
223
61
|
/** Current editing mode: richtext (WYSIWYG) or markdown (raw source) */
|
|
224
62
|
editorMode?: "richtext" | "markdown";
|
|
63
|
+
/** Fullscreen mode: content fills the flex parent and scrolls internally */
|
|
64
|
+
fullscreen?: boolean;
|
|
225
65
|
}
|
|
226
66
|
|
|
227
67
|
// ===========================================================================
|
|
@@ -243,9 +83,10 @@ export const TiptapEditor = memo(
|
|
|
243
83
|
forwardRef<RichEditorRef, TiptapEditorProps>(
|
|
244
84
|
(
|
|
245
85
|
{
|
|
86
|
+
capabilities = "full",
|
|
246
87
|
initialContent = "",
|
|
247
88
|
initialJSON,
|
|
248
|
-
placeholder
|
|
89
|
+
placeholder: placeholderProp,
|
|
249
90
|
editable = true,
|
|
250
91
|
autoFocus = false,
|
|
251
92
|
onChange,
|
|
@@ -259,10 +100,15 @@ export const TiptapEditor = memo(
|
|
|
259
100
|
bodyFontFamily,
|
|
260
101
|
headingFontFamily,
|
|
261
102
|
editorMode = "richtext",
|
|
103
|
+
fullscreen = false,
|
|
104
|
+
onImageUpload,
|
|
105
|
+
onFileUpload,
|
|
106
|
+
mentions,
|
|
262
107
|
},
|
|
263
108
|
ref,
|
|
264
109
|
) => {
|
|
265
110
|
const _ctx = RichEditorContext.useStyledContext();
|
|
111
|
+
const placeholder = placeholderProp ?? t("Start writing...");
|
|
266
112
|
const internalRef = useRef<RichEditorRef>(null);
|
|
267
113
|
const stateRafRef = useRef<number>(0);
|
|
268
114
|
const changeRafRef = useRef<number>(0);
|
|
@@ -270,81 +116,56 @@ export const TiptapEditor = memo(
|
|
|
270
116
|
const onChangeRef = useRef(onChange);
|
|
271
117
|
const [markdownSource, setMarkdownSource] = useState("");
|
|
272
118
|
const prevModeRef = useRef(editorMode);
|
|
119
|
+
const theme = useTheme();
|
|
120
|
+
const themeName = useThemeName();
|
|
121
|
+
const { knobProps } = useResolvedKnobs();
|
|
122
|
+
const motionMs = knobProps.transition !== undefined ? MOTION_MS : 0;
|
|
123
|
+
const scopeClass = `rt-scope-${useId().replace(/[^a-zA-Z0-9-]/g, "")}`;
|
|
124
|
+
|
|
125
|
+
// Mention wiring is captured at mount (the extension list is fixed);
|
|
126
|
+
// the items function stays live through this ref.
|
|
127
|
+
const mentionsRef = useRef(mentions);
|
|
128
|
+
mentionsRef.current = mentions;
|
|
129
|
+
const [mentionExtension] = useState(() =>
|
|
130
|
+
mentions
|
|
131
|
+
? createMentionExtension({
|
|
132
|
+
trigger: mentions.trigger,
|
|
133
|
+
items: (query) => mentionsRef.current?.items(query) ?? [],
|
|
134
|
+
})
|
|
135
|
+
: null,
|
|
136
|
+
);
|
|
273
137
|
|
|
274
138
|
useEffect(() => {
|
|
275
139
|
onStateChangeRef.current = onStateChange;
|
|
276
140
|
onChangeRef.current = onChange;
|
|
277
141
|
});
|
|
278
142
|
|
|
143
|
+
// Capability surface is fixed at mount (extension lists cannot swap
|
|
144
|
+
// live); the canonical list comes from the one factory the capability
|
|
145
|
+
// specs also verify (LC-52).
|
|
146
|
+
const [extensions] = useState(() =>
|
|
147
|
+
buildEditorExtensions({ capabilities, placeholder, mentionExtension }),
|
|
148
|
+
);
|
|
149
|
+
|
|
279
150
|
const editor = useEditor({
|
|
280
|
-
extensions
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
},
|
|
286
|
-
paragraph: {
|
|
287
|
-
HTMLAttributes: { dir: "auto" },
|
|
288
|
-
},
|
|
289
|
-
link: {
|
|
290
|
-
openOnClick: false,
|
|
291
|
-
HTMLAttributes: {
|
|
292
|
-
rel: "noopener noreferrer",
|
|
293
|
-
target: "_blank",
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
bulletList: {
|
|
297
|
-
keepMarks: true,
|
|
298
|
-
},
|
|
299
|
-
orderedList: {
|
|
300
|
-
keepMarks: true,
|
|
301
|
-
},
|
|
302
|
-
codeBlock: false,
|
|
303
|
-
hardBreak: false,
|
|
304
|
-
}),
|
|
305
|
-
CodeBlockLowlight.configure({
|
|
306
|
-
lowlight,
|
|
307
|
-
exitOnTripleEnter: true,
|
|
308
|
-
exitOnArrowDown: false,
|
|
309
|
-
}),
|
|
310
|
-
ParagraphEnterKeys,
|
|
311
|
-
CodeBlockTabIndent,
|
|
312
|
-
ListItemKeys,
|
|
313
|
-
Typography,
|
|
314
|
-
CharacterCount,
|
|
315
|
-
SlashCommands,
|
|
316
|
-
MarkdownPaste,
|
|
317
|
-
BlockDragHandle,
|
|
318
|
-
Table.configure({ resizable: true }),
|
|
319
|
-
TableRow,
|
|
320
|
-
TableHeader,
|
|
321
|
-
TableCell,
|
|
322
|
-
Placeholder.configure({
|
|
323
|
-
placeholder,
|
|
324
|
-
}),
|
|
325
|
-
TextAlign.configure({
|
|
326
|
-
types: ["heading", "paragraph"],
|
|
327
|
-
defaultAlignment: "left",
|
|
328
|
-
}),
|
|
329
|
-
TextStyle,
|
|
330
|
-
Color,
|
|
331
|
-
Highlight.configure({
|
|
332
|
-
multicolor: true,
|
|
333
|
-
}),
|
|
334
|
-
Subscript,
|
|
335
|
-
Superscript,
|
|
336
|
-
TaskList,
|
|
337
|
-
TaskItem.configure({
|
|
338
|
-
nested: true,
|
|
339
|
-
}),
|
|
340
|
-
Image.configure({
|
|
341
|
-
inline: true,
|
|
342
|
-
allowBase64: true,
|
|
343
|
-
}),
|
|
344
|
-
],
|
|
345
|
-
content: initialJSON || initialContent,
|
|
151
|
+
extensions,
|
|
152
|
+
// In markdown capabilities the incoming string IS markdown
|
|
153
|
+
content:
|
|
154
|
+
initialJSON ||
|
|
155
|
+
(capabilities === "markdown" ? markdownToHtml(initialContent) : initialContent),
|
|
346
156
|
editable,
|
|
347
157
|
autofocus: autoFocus,
|
|
158
|
+
// No htmlFor target exists for the contenteditable — name it directly
|
|
159
|
+
// (axe aria-input-field-name); placeholder doubles as the name.
|
|
160
|
+
editorProps: {
|
|
161
|
+
attributes: {
|
|
162
|
+
role: "textbox",
|
|
163
|
+
"aria-multiline": "true",
|
|
164
|
+
"aria-label": placeholder || t("Rich text editor"),
|
|
165
|
+
},
|
|
166
|
+
// Strip Google Docs / Word clipboard junk before ProseMirror parses
|
|
167
|
+
transformPastedHTML: cleanPastedHtml,
|
|
168
|
+
},
|
|
348
169
|
injectCSS: false,
|
|
349
170
|
immediatelyRender: false,
|
|
350
171
|
shouldRerenderOnTransaction: false,
|
|
@@ -353,7 +174,12 @@ export const TiptapEditor = memo(
|
|
|
353
174
|
changeRafRef.current = requestAnimationFrame(() => {
|
|
354
175
|
const html = editor.getHTML();
|
|
355
176
|
const json = editor.getJSON();
|
|
356
|
-
|
|
177
|
+
// Markdown capabilities serialize the content OUT as markdown —
|
|
178
|
+
// the host's value stays a markdown string end to end.
|
|
179
|
+
onChangeRef.current?.(
|
|
180
|
+
capabilities === "markdown" ? htmlToMarkdown(html) : html,
|
|
181
|
+
json,
|
|
182
|
+
);
|
|
357
183
|
});
|
|
358
184
|
},
|
|
359
185
|
onTransaction: ({ editor }) => {
|
|
@@ -366,29 +192,89 @@ export const TiptapEditor = memo(
|
|
|
366
192
|
onBlur: () => onBlur?.(),
|
|
367
193
|
});
|
|
368
194
|
|
|
195
|
+
// Keep upload handlers live in editor storage (paste/drop + slash image)
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (!editor) return;
|
|
198
|
+
editor.storage.mediaUpload.handlers = { onImageUpload, onFileUpload };
|
|
199
|
+
}, [editor, onImageUpload, onFileUpload]);
|
|
200
|
+
|
|
201
|
+
// Push resolved theme + knob chrome for the DOM-portaled suggestion
|
|
202
|
+
// popups (slash / mention): every color and structural role arrives
|
|
203
|
+
// resolved -- the popups never invent their own values.
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
if (!editor) return;
|
|
206
|
+
const radiusToken = clampRadiusForLargeComponent(knobProps.borderRadius.borderRadius, 4);
|
|
207
|
+
const radiusValue =
|
|
208
|
+
typeof radiusToken === "number"
|
|
209
|
+
? radiusToken
|
|
210
|
+
: ((getTokens().radius as any)?.[radiusToken]?.val ?? fallbackSuggestionChrome.radius);
|
|
211
|
+
// LC-16: the DOM popup rows share menuRowFrame geometry — resolve
|
|
212
|
+
// its paddingHorizontal token to px here (theme scope) and push it.
|
|
213
|
+
const rowPadToken = menuRowFrame.paddingHorizontal as string;
|
|
214
|
+
const rowPaddingX =
|
|
215
|
+
(getTokens().space as any)?.[rowPadToken]?.val ?? fallbackSuggestionChrome.rowPaddingX;
|
|
216
|
+
// Elevation rides the theme's scheme-aware shadow tokens (Axiom 5) —
|
|
217
|
+
// the same channel the popover family resolves, never a raw rgba.
|
|
218
|
+
const shadowMain = theme.shadow2?.val;
|
|
219
|
+
const shadowSoft = theme.shadow1?.val;
|
|
220
|
+
const chrome: SuggestionChrome = {
|
|
221
|
+
background: theme.background?.val ?? fallbackSuggestionChrome.background,
|
|
222
|
+
borderColor: theme.borderColor?.val ?? fallbackSuggestionChrome.borderColor,
|
|
223
|
+
activeBackground: theme.color4?.val ?? fallbackSuggestionChrome.activeBackground,
|
|
224
|
+
iconTileBackground: theme.color3?.val ?? fallbackSuggestionChrome.iconTileBackground,
|
|
225
|
+
titleColor: theme.color12?.val ?? fallbackSuggestionChrome.titleColor,
|
|
226
|
+
descriptionColor: theme.color11?.val ?? fallbackSuggestionChrome.descriptionColor,
|
|
227
|
+
radius: typeof radiusValue === "number" ? radiusValue : fallbackSuggestionChrome.radius,
|
|
228
|
+
shadow:
|
|
229
|
+
shadowMain && shadowSoft
|
|
230
|
+
? `0px 8px 28px ${shadowMain}, 0px 2px 6px ${shadowSoft}`
|
|
231
|
+
: fallbackSuggestionChrome.shadow,
|
|
232
|
+
motionMs,
|
|
233
|
+
rowPaddingX:
|
|
234
|
+
typeof rowPaddingX === "number" ? rowPaddingX : fallbackSuggestionChrome.rowPaddingX,
|
|
235
|
+
};
|
|
236
|
+
editor.storage.suggestionChrome.value = chrome;
|
|
237
|
+
}, [editor, theme, knobProps.borderRadius.borderRadius, motionMs]);
|
|
238
|
+
|
|
239
|
+
// Push the resolved color scheme for block previews (mermaid/math):
|
|
240
|
+
// the node views subscribe and re-render diagrams on a theme flip.
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
if (!editor) return;
|
|
243
|
+
setPreviewChrome(editor, {
|
|
244
|
+
scheme: String(themeName).startsWith("dark") ? "dark" : "light",
|
|
245
|
+
fontFamily: bodyFontFamily,
|
|
246
|
+
});
|
|
247
|
+
}, [editor, themeName, bodyFontFamily]);
|
|
248
|
+
|
|
369
249
|
useEffect(() => {
|
|
370
250
|
if (!editor) return;
|
|
371
251
|
if (prevModeRef.current === editorMode) return;
|
|
372
252
|
prevModeRef.current = editorMode;
|
|
373
253
|
|
|
374
254
|
if (editorMode === "markdown") {
|
|
375
|
-
setMarkdownSource(
|
|
255
|
+
setMarkdownSource(htmlToMarkdown(editor.getHTML()));
|
|
376
256
|
} else {
|
|
377
|
-
|
|
378
|
-
editor.commands.setContent(html);
|
|
257
|
+
editor.commands.setContent(markdownToHtml(markdownSource));
|
|
379
258
|
}
|
|
380
259
|
}, [editorMode, editor, markdownSource]);
|
|
381
260
|
|
|
382
|
-
const handleMarkdownChange = useCallback(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
261
|
+
const handleMarkdownChange = useCallback(
|
|
262
|
+
(e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
263
|
+
const md = e.target.value;
|
|
264
|
+
setMarkdownSource(md);
|
|
265
|
+
// Markdown capabilities emit the markdown source itself; the full
|
|
266
|
+
// surface keeps its HTML onChange contract.
|
|
267
|
+
onChangeRef.current?.(capabilities === "markdown" ? md : markdownToHtml(md), null);
|
|
268
|
+
},
|
|
269
|
+
[capabilities],
|
|
270
|
+
);
|
|
388
271
|
|
|
389
272
|
const executeCommand = useCallback(
|
|
390
273
|
(command: EditorCommand, payload?: any) => {
|
|
391
274
|
if (!editor) return;
|
|
275
|
+
// Capability guard: outside the surface the command's extension is
|
|
276
|
+
// not registered, so the chained method would not even exist.
|
|
277
|
+
if (!isCommandInCapabilities(command, capabilities)) return;
|
|
392
278
|
|
|
393
279
|
const chain = editor.chain().focus();
|
|
394
280
|
|
|
@@ -457,9 +343,22 @@ export const TiptapEditor = memo(
|
|
|
457
343
|
break;
|
|
458
344
|
case "link":
|
|
459
345
|
if (payload?.href) {
|
|
460
|
-
|
|
346
|
+
if (editor.state.selection.empty && !editor.isActive("link")) {
|
|
347
|
+
// GitLab parity: with nothing selected, insert the URL
|
|
348
|
+
// itself as linked text instead of silently no-oping
|
|
349
|
+
chain
|
|
350
|
+
.insertContent({
|
|
351
|
+
type: "text",
|
|
352
|
+
text: payload.text ?? payload.href,
|
|
353
|
+
marks: [{ type: "link", attrs: { href: payload.href } }],
|
|
354
|
+
})
|
|
355
|
+
.run();
|
|
356
|
+
} else {
|
|
357
|
+
// Cursor inside an existing link updates the whole link
|
|
358
|
+
chain.extendMarkRange("link").setLink({ href: payload.href }).run();
|
|
359
|
+
}
|
|
461
360
|
} else {
|
|
462
|
-
chain.unsetLink().run();
|
|
361
|
+
chain.extendMarkRange("link").unsetLink().run();
|
|
463
362
|
}
|
|
464
363
|
break;
|
|
465
364
|
case "undo":
|
|
@@ -550,8 +449,13 @@ export const TiptapEditor = memo(
|
|
|
550
449
|
getState: () => getEditorStateFromTiptap(editor),
|
|
551
450
|
getHTML: () => editor?.getHTML() || "",
|
|
552
451
|
getJSON: () => editor?.getJSON() || null,
|
|
452
|
+
getMarkdown: () => htmlToMarkdown(editor?.getHTML() || ""),
|
|
553
453
|
setHTML: (html: string) => editor?.commands.setContent(html),
|
|
554
454
|
setJSON: (json: any) => editor?.commands.setContent(json),
|
|
455
|
+
// External value sync (not a user edit): emitUpdate false so the
|
|
456
|
+
// host's own set does not echo back through onChange.
|
|
457
|
+
setMarkdown: (markdown: string) =>
|
|
458
|
+
editor?.commands.setContent(markdownToHtml(markdown), { emitUpdate: false }),
|
|
555
459
|
focus: () => editor?.commands.focus(),
|
|
556
460
|
blur: () => editor?.commands.blur(),
|
|
557
461
|
}),
|
|
@@ -562,20 +466,35 @@ export const TiptapEditor = memo(
|
|
|
562
466
|
(internalRef as any).current = refMethods;
|
|
563
467
|
|
|
564
468
|
const editorCSS = useMemo(
|
|
565
|
-
() =>
|
|
566
|
-
|
|
469
|
+
() =>
|
|
470
|
+
getEditorCSS({
|
|
471
|
+
minHeight,
|
|
472
|
+
maxHeight,
|
|
473
|
+
bodyFontFamily,
|
|
474
|
+
headingFontFamily,
|
|
475
|
+
fullscreen,
|
|
476
|
+
motionMs,
|
|
477
|
+
scopeClass,
|
|
478
|
+
}),
|
|
479
|
+
[minHeight, maxHeight, bodyFontFamily, headingFontFamily, fullscreen, motionMs, scopeClass],
|
|
567
480
|
);
|
|
568
481
|
|
|
569
482
|
if (editorMode === "markdown") {
|
|
570
483
|
return (
|
|
571
|
-
<EditorContainer
|
|
484
|
+
<EditorContainer
|
|
485
|
+
minHeight={fullscreen ? 0 : minHeight}
|
|
486
|
+
maxHeight={fullscreen ? undefined : maxHeight}
|
|
487
|
+
overflow="hidden"
|
|
488
|
+
>
|
|
572
489
|
<textarea
|
|
573
490
|
value={markdownSource}
|
|
574
491
|
onChange={handleMarkdownChange}
|
|
492
|
+
aria-label={t("Markdown source")}
|
|
575
493
|
style={{
|
|
576
494
|
width: "100%",
|
|
577
|
-
minHeight: minHeight,
|
|
578
|
-
maxHeight: maxHeight || undefined,
|
|
495
|
+
minHeight: fullscreen ? 0 : minHeight,
|
|
496
|
+
maxHeight: fullscreen ? undefined : maxHeight || undefined,
|
|
497
|
+
flex: fullscreen ? "1 1 0%" : undefined,
|
|
579
498
|
padding: "12px 12px 12px 16px",
|
|
580
499
|
border: "none",
|
|
581
500
|
outline: "none",
|
|
@@ -595,18 +514,36 @@ export const TiptapEditor = memo(
|
|
|
595
514
|
}
|
|
596
515
|
|
|
597
516
|
return (
|
|
598
|
-
<EditorContainer
|
|
517
|
+
<EditorContainer
|
|
518
|
+
className={scopeClass}
|
|
519
|
+
minHeight={fullscreen ? 0 : minHeight}
|
|
520
|
+
maxHeight={fullscreen ? undefined : maxHeight}
|
|
521
|
+
overflow="hidden"
|
|
522
|
+
>
|
|
599
523
|
{isWeb && <style>{editorCSS}</style>}
|
|
600
524
|
{showBubbleToolbar && (
|
|
601
525
|
<>
|
|
602
|
-
<BubbleToolbar
|
|
526
|
+
<BubbleToolbar
|
|
527
|
+
editor={editor}
|
|
528
|
+
editorRef={internalRef}
|
|
529
|
+
state={defaultEditorState}
|
|
530
|
+
capabilities={capabilities}
|
|
531
|
+
/>
|
|
603
532
|
<LinkBubble editor={editor} />
|
|
604
533
|
<CodeBlockBubble editor={editor} />
|
|
605
534
|
<ImageBubble editor={editor} />
|
|
606
|
-
<TableBubble editor={editor} />
|
|
535
|
+
<TableBubble editor={editor} capabilities={capabilities} />
|
|
607
536
|
</>
|
|
608
537
|
)}
|
|
609
|
-
|
|
538
|
+
{/* Always mounted (unlike the optional bubbles): it is the ONLY
|
|
539
|
+
edit path for inline math atoms — without it a typed `$x$`
|
|
540
|
+
node would be a dead end. Markdown capabilities have no inline
|
|
541
|
+
math node, so the bubble has nothing to edit and stays out. */}
|
|
542
|
+
{editable && capabilities !== "markdown" && <MathBubble editor={editor} />}
|
|
543
|
+
<EditorContent
|
|
544
|
+
editor={editor}
|
|
545
|
+
style={fullscreen ? { flex: "1 1 0%", minHeight: 0, overflowY: "auto" } : undefined}
|
|
546
|
+
/>
|
|
610
547
|
</EditorContainer>
|
|
611
548
|
);
|
|
612
549
|
},
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block-rect bubble anchoring against a headless Tiptap editor.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { Editor } from "@tiptap/core";
|
|
7
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
8
|
+
import { Table } from "@tiptap/extension-table";
|
|
9
|
+
import { TableRow } from "@tiptap/extension-table-row";
|
|
10
|
+
import { TableHeader } from "@tiptap/extension-table-header";
|
|
11
|
+
import { TableCell } from "@tiptap/extension-table-cell";
|
|
12
|
+
import { TextSelection } from "@tiptap/pm/state";
|
|
13
|
+
import { getBlockVirtualElement } from "./blockAnchor";
|
|
14
|
+
|
|
15
|
+
function createEditor(content: string) {
|
|
16
|
+
return new Editor({
|
|
17
|
+
element: document.createElement("div"),
|
|
18
|
+
extensions: [StarterKit, Table, TableRow, TableHeader, TableCell],
|
|
19
|
+
content,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Places the text cursor inside the first node of the given type */
|
|
24
|
+
function placeCursorIn(editor: Editor, nodeTypeName: string) {
|
|
25
|
+
let target = -1;
|
|
26
|
+
editor.state.doc.descendants((node, pos) => {
|
|
27
|
+
if (target === -1 && node.type.name === nodeTypeName) target = pos + 1;
|
|
28
|
+
return target === -1;
|
|
29
|
+
});
|
|
30
|
+
if (target === -1) throw new Error(`no ${nodeTypeName} in doc`);
|
|
31
|
+
const selection = TextSelection.near(editor.state.doc.resolve(target + 1));
|
|
32
|
+
editor.view.dispatch(editor.state.tr.setSelection(selection));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe("getBlockVirtualElement", () => {
|
|
36
|
+
it("returns the table DOM element when the cursor is inside a table", () => {
|
|
37
|
+
const editor = createEditor(
|
|
38
|
+
"<p>before</p><table><tr><th>h</th></tr><tr><td>cell</td></tr></table>",
|
|
39
|
+
);
|
|
40
|
+
placeCursorIn(editor, "table");
|
|
41
|
+
|
|
42
|
+
const ref = getBlockVirtualElement(editor, "table");
|
|
43
|
+
expect(ref).not.toBeNull();
|
|
44
|
+
expect((ref!.contextElement as HTMLElement).tagName).toBe("TABLE");
|
|
45
|
+
// The anchor rect delegates to the block's live rect
|
|
46
|
+
expect(typeof ref!.getBoundingClientRect().width).toBe("number");
|
|
47
|
+
editor.destroy();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("returns the pre element when the cursor is inside a code block", () => {
|
|
51
|
+
const editor = createEditor("<p>before</p><pre><code>const a = 1;</code></pre>");
|
|
52
|
+
placeCursorIn(editor, "codeBlock");
|
|
53
|
+
|
|
54
|
+
const ref = getBlockVirtualElement(editor, "codeBlock");
|
|
55
|
+
expect(ref).not.toBeNull();
|
|
56
|
+
expect((ref!.contextElement as HTMLElement).tagName).toBe("PRE");
|
|
57
|
+
editor.destroy();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("returns null when the selection is outside the block type", () => {
|
|
61
|
+
const editor = createEditor("<p>plain paragraph</p><table><tr><td>cell</td></tr></table>");
|
|
62
|
+
// Cursor starts in the first paragraph by default
|
|
63
|
+
const selection = TextSelection.near(editor.state.doc.resolve(1));
|
|
64
|
+
editor.view.dispatch(editor.state.tr.setSelection(selection));
|
|
65
|
+
|
|
66
|
+
expect(getBlockVirtualElement(editor, "table")).toBeNull();
|
|
67
|
+
expect(getBlockVirtualElement(editor, "codeBlock")).toBeNull();
|
|
68
|
+
editor.destroy();
|
|
69
|
+
});
|
|
70
|
+
});
|