@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
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension factory for the web Tiptap editor.
|
|
3
|
+
*
|
|
4
|
+
* One canonical list (LC-16) consumed by TiptapEditor AND by the
|
|
5
|
+
* capability specs, so what ships is exactly what is verified. With
|
|
6
|
+
* `capabilities: "markdown"` the non-markdown extensions are NOT
|
|
7
|
+
* registered — their commands do not exist on the editor (LC-52
|
|
8
|
+
* MARKDOWN-EXPRESSIBLE-EDITING), and StarterKit's underline sub-extension
|
|
9
|
+
* is disabled.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Extension, type Extensions } from "@tiptap/core";
|
|
13
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
14
|
+
import Placeholder from "@tiptap/extension-placeholder";
|
|
15
|
+
import TextAlign from "@tiptap/extension-text-align";
|
|
16
|
+
import { Color } from "@tiptap/extension-color";
|
|
17
|
+
import { TextStyle } from "@tiptap/extension-text-style";
|
|
18
|
+
import { Highlight } from "@tiptap/extension-highlight";
|
|
19
|
+
import { Subscript } from "@tiptap/extension-subscript";
|
|
20
|
+
import { Superscript } from "@tiptap/extension-superscript";
|
|
21
|
+
import TaskList from "@tiptap/extension-task-list";
|
|
22
|
+
import TaskItem from "@tiptap/extension-task-item";
|
|
23
|
+
import Image from "@tiptap/extension-image";
|
|
24
|
+
import Typography from "@tiptap/extension-typography";
|
|
25
|
+
import CharacterCount from "@tiptap/extension-character-count";
|
|
26
|
+
import { Details, DetailsContent, DetailsSummary } from "@tiptap/extension-details";
|
|
27
|
+
import { Table } from "@tiptap/extension-table";
|
|
28
|
+
import { TableRow } from "@tiptap/extension-table-row";
|
|
29
|
+
import { TableHeader } from "@tiptap/extension-table-header";
|
|
30
|
+
import { TableCell } from "@tiptap/extension-table-cell";
|
|
31
|
+
import { common, createLowlight } from "lowlight";
|
|
32
|
+
import type { EditorCapabilities } from "../types";
|
|
33
|
+
import { MARKDOWN_EXCLUDED_SLASH_IDS } from "./capabilities";
|
|
34
|
+
import { SlashCommands } from "./SlashCommands";
|
|
35
|
+
import { MarkdownPaste } from "./MarkdownPaste";
|
|
36
|
+
import { BlockDragHandle } from "./BlockDragHandle";
|
|
37
|
+
import { MediaUpload } from "./media";
|
|
38
|
+
import { EmojiSuggestion } from "./emoji";
|
|
39
|
+
import { InlineMath } from "./mathematics";
|
|
40
|
+
import { CodeBlockWithPreview, PreviewChromeStore } from "./codeBlockPreview";
|
|
41
|
+
import { SuggestionChromeStore } from "./suggestionPopup";
|
|
42
|
+
import { t } from "../shared/t";
|
|
43
|
+
|
|
44
|
+
const lowlight = createLowlight(common);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Tab / Shift-Tab indentation inside code blocks.
|
|
48
|
+
* Inserts or removes 2 spaces at the cursor (or start of each selected line).
|
|
49
|
+
*/
|
|
50
|
+
export const CodeBlockTabIndent = Extension.create({
|
|
51
|
+
name: "codeBlockTabIndent",
|
|
52
|
+
addKeyboardShortcuts() {
|
|
53
|
+
return {
|
|
54
|
+
Tab: ({ editor }) => {
|
|
55
|
+
if (!editor.isActive("codeBlock")) return false;
|
|
56
|
+
const { state, dispatch } = editor.view;
|
|
57
|
+
const { from, to } = state.selection;
|
|
58
|
+
|
|
59
|
+
if (from === to) {
|
|
60
|
+
dispatch(state.tr.insertText(" ", from, to));
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const doc = state.doc;
|
|
65
|
+
const lines: { start: number }[] = [];
|
|
66
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
67
|
+
if (node.isTextblock) {
|
|
68
|
+
lines.push({ start: pos + 1 });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (lines.length === 0) {
|
|
72
|
+
dispatch(state.tr.insertText(" ", from, to));
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let tr = state.tr;
|
|
77
|
+
let offset = 0;
|
|
78
|
+
for (const line of lines) {
|
|
79
|
+
const lineStart = line.start + offset;
|
|
80
|
+
tr = tr.insertText(" ", lineStart);
|
|
81
|
+
offset += 2;
|
|
82
|
+
}
|
|
83
|
+
dispatch(tr);
|
|
84
|
+
return true;
|
|
85
|
+
},
|
|
86
|
+
"Shift-Tab": ({ editor }) => {
|
|
87
|
+
if (!editor.isActive("codeBlock")) return false;
|
|
88
|
+
const { state, dispatch } = editor.view;
|
|
89
|
+
const { from, to, $from } = state.selection;
|
|
90
|
+
|
|
91
|
+
if (from === to) {
|
|
92
|
+
const lineStart = from - $from.parentOffset;
|
|
93
|
+
const text = state.doc.textBetween(lineStart, from);
|
|
94
|
+
const leadingSpaces = text.match(/^ {1,2}/)?.[0];
|
|
95
|
+
if (leadingSpaces) {
|
|
96
|
+
dispatch(state.tr.delete(lineStart, lineStart + leadingSpaces.length));
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const doc = state.doc;
|
|
102
|
+
let tr = state.tr;
|
|
103
|
+
let offset = 0;
|
|
104
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
105
|
+
if (node.isTextblock) {
|
|
106
|
+
const lineStart = pos + 1 + offset;
|
|
107
|
+
const text = tr.doc.textBetween(
|
|
108
|
+
lineStart,
|
|
109
|
+
Math.min(lineStart + node.content.size, tr.doc.content.size),
|
|
110
|
+
);
|
|
111
|
+
const leadingSpaces = text.match(/^ {1,2}/)?.[0];
|
|
112
|
+
if (leadingSpaces) {
|
|
113
|
+
tr = tr.delete(lineStart, lineStart + leadingSpaces.length);
|
|
114
|
+
offset -= leadingSpaces.length;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
dispatch(tr);
|
|
119
|
+
return true;
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Override Shift-Enter and Mod-Enter to create new paragraphs instead of
|
|
127
|
+
* hard breaks (<br>). Mirrors GitLab's approach: HardBreak node stays
|
|
128
|
+
* registered (so <br> in pasted HTML is preserved) but its keyboard
|
|
129
|
+
* shortcuts are replaced with the default enter (split paragraph) behavior.
|
|
130
|
+
*/
|
|
131
|
+
export const ParagraphEnterKeys = Extension.create({
|
|
132
|
+
name: "paragraphEnterKeys",
|
|
133
|
+
priority: 1000,
|
|
134
|
+
addKeyboardShortcuts() {
|
|
135
|
+
return {
|
|
136
|
+
"Shift-Enter": ({ editor }) =>
|
|
137
|
+
editor.commands.first([
|
|
138
|
+
() => editor.commands.newlineInCode(),
|
|
139
|
+
() => editor.commands.splitListItem("listItem"),
|
|
140
|
+
() => editor.commands.createParagraphNear(),
|
|
141
|
+
() => editor.commands.liftEmptyBlock(),
|
|
142
|
+
() => editor.commands.splitBlock(),
|
|
143
|
+
]),
|
|
144
|
+
"Mod-Enter": ({ editor }) =>
|
|
145
|
+
editor.commands.first([
|
|
146
|
+
() => editor.commands.newlineInCode(),
|
|
147
|
+
() => editor.commands.createParagraphNear(),
|
|
148
|
+
() => editor.commands.liftEmptyBlock(),
|
|
149
|
+
() => editor.commands.splitBlock(),
|
|
150
|
+
]),
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Tab/Shift-Tab indent/dedent and Alt+Arrow move for list items.
|
|
157
|
+
* Tab sinks (indents), Shift-Tab lifts (dedents).
|
|
158
|
+
* Alt+Up/Down moves the list item up or down among siblings.
|
|
159
|
+
*/
|
|
160
|
+
export const ListItemKeys = Extension.create({
|
|
161
|
+
name: "listItemKeys",
|
|
162
|
+
addKeyboardShortcuts() {
|
|
163
|
+
return {
|
|
164
|
+
Tab: ({ editor }) => {
|
|
165
|
+
if (editor.isActive("codeBlock")) return false;
|
|
166
|
+
if (
|
|
167
|
+
editor.isActive("bulletList") ||
|
|
168
|
+
editor.isActive("orderedList") ||
|
|
169
|
+
editor.isActive("taskList")
|
|
170
|
+
) {
|
|
171
|
+
return (
|
|
172
|
+
editor.commands.sinkListItem("listItem") || editor.commands.sinkListItem("taskItem")
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
},
|
|
177
|
+
"Shift-Tab": ({ editor }) => {
|
|
178
|
+
if (editor.isActive("codeBlock")) return false;
|
|
179
|
+
if (
|
|
180
|
+
editor.isActive("bulletList") ||
|
|
181
|
+
editor.isActive("orderedList") ||
|
|
182
|
+
editor.isActive("taskList")
|
|
183
|
+
) {
|
|
184
|
+
return (
|
|
185
|
+
editor.commands.liftListItem("listItem") || editor.commands.liftListItem("taskItem")
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// ===========================================================================
|
|
195
|
+
// Factory
|
|
196
|
+
// ===========================================================================
|
|
197
|
+
|
|
198
|
+
export interface BuildEditorExtensionsOptions {
|
|
199
|
+
/** Capability preset (default "full") */
|
|
200
|
+
capabilities?: EditorCapabilities;
|
|
201
|
+
/** Placeholder text (defaults to the translated "Start writing...") */
|
|
202
|
+
placeholder?: string;
|
|
203
|
+
/** Pre-built mention extension (ignored in markdown capabilities) */
|
|
204
|
+
mentionExtension?: Extensions[number] | null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Build the production extension list for the given capability surface */
|
|
208
|
+
export function buildEditorExtensions({
|
|
209
|
+
capabilities = "full",
|
|
210
|
+
placeholder,
|
|
211
|
+
mentionExtension = null,
|
|
212
|
+
}: BuildEditorExtensionsOptions = {}): Extensions {
|
|
213
|
+
const markdown = capabilities === "markdown";
|
|
214
|
+
|
|
215
|
+
return [
|
|
216
|
+
StarterKit.configure({
|
|
217
|
+
heading: {
|
|
218
|
+
levels: [1, 2, 3, 4, 5, 6],
|
|
219
|
+
HTMLAttributes: { dir: "auto" },
|
|
220
|
+
},
|
|
221
|
+
paragraph: {
|
|
222
|
+
HTMLAttributes: { dir: "auto" },
|
|
223
|
+
},
|
|
224
|
+
link: {
|
|
225
|
+
openOnClick: false,
|
|
226
|
+
HTMLAttributes: {
|
|
227
|
+
rel: "noopener noreferrer",
|
|
228
|
+
target: "_blank",
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
bulletList: {
|
|
232
|
+
keepMarks: true,
|
|
233
|
+
},
|
|
234
|
+
orderedList: {
|
|
235
|
+
keepMarks: true,
|
|
236
|
+
},
|
|
237
|
+
codeBlock: false,
|
|
238
|
+
hardBreak: false,
|
|
239
|
+
// Markdown has no underline syntax — the mark must not exist
|
|
240
|
+
...(markdown && { underline: false }),
|
|
241
|
+
}),
|
|
242
|
+
CodeBlockWithPreview.configure({
|
|
243
|
+
lowlight,
|
|
244
|
+
exitOnTripleEnter: true,
|
|
245
|
+
exitOnArrowDown: false,
|
|
246
|
+
}),
|
|
247
|
+
ParagraphEnterKeys,
|
|
248
|
+
CodeBlockTabIndent,
|
|
249
|
+
ListItemKeys,
|
|
250
|
+
// superscriptTwo/Three would mangle typed TeX (`$E=mc^2$` became
|
|
251
|
+
// `E=mc²` before the math input rule ran) — off, rest stays.
|
|
252
|
+
Typography.configure({
|
|
253
|
+
superscriptTwo: false,
|
|
254
|
+
superscriptThree: false,
|
|
255
|
+
}),
|
|
256
|
+
CharacterCount,
|
|
257
|
+
SlashCommands.configure({
|
|
258
|
+
excludeIds: markdown ? [...MARKDOWN_EXCLUDED_SLASH_IDS] : [],
|
|
259
|
+
}),
|
|
260
|
+
MarkdownPaste,
|
|
261
|
+
MediaUpload,
|
|
262
|
+
SuggestionChromeStore,
|
|
263
|
+
PreviewChromeStore,
|
|
264
|
+
// Emoji suggestions insert plain unicode characters (just text), so
|
|
265
|
+
// they stay available in markdown capabilities.
|
|
266
|
+
EmojiSuggestion,
|
|
267
|
+
...(markdown
|
|
268
|
+
? []
|
|
269
|
+
: [
|
|
270
|
+
InlineMath,
|
|
271
|
+
// Collapsible sections (GitLab <details> parity). persist: true
|
|
272
|
+
// is the extension's supported mode: its node view re-syncs the
|
|
273
|
+
// open state from node.attrs on every update, so ephemeral
|
|
274
|
+
// (persist: false) toggles get reverted by the next transaction.
|
|
275
|
+
// The open state therefore lives in the doc and serializes as
|
|
276
|
+
// `<details open>` — valid GitLab markdown.
|
|
277
|
+
Details.configure({ persist: true }),
|
|
278
|
+
DetailsSummary,
|
|
279
|
+
DetailsContent,
|
|
280
|
+
]),
|
|
281
|
+
// Mention chips have no markdown representation — full surface only
|
|
282
|
+
...(mentionExtension && !markdown ? [mentionExtension] : []),
|
|
283
|
+
BlockDragHandle,
|
|
284
|
+
Table.configure({ resizable: true }),
|
|
285
|
+
TableRow,
|
|
286
|
+
TableHeader,
|
|
287
|
+
TableCell,
|
|
288
|
+
Placeholder.configure({
|
|
289
|
+
placeholder: placeholder ?? t("Start writing..."),
|
|
290
|
+
}),
|
|
291
|
+
...(markdown
|
|
292
|
+
? []
|
|
293
|
+
: [
|
|
294
|
+
TextAlign.configure({
|
|
295
|
+
types: ["heading", "paragraph"],
|
|
296
|
+
defaultAlignment: "left",
|
|
297
|
+
}),
|
|
298
|
+
TextStyle,
|
|
299
|
+
Color,
|
|
300
|
+
Highlight.configure({
|
|
301
|
+
multicolor: true,
|
|
302
|
+
}),
|
|
303
|
+
Subscript,
|
|
304
|
+
Superscript,
|
|
305
|
+
]),
|
|
306
|
+
TaskList,
|
|
307
|
+
TaskItem.configure({
|
|
308
|
+
nested: true,
|
|
309
|
+
}),
|
|
310
|
+
Image.configure({
|
|
311
|
+
inline: true,
|
|
312
|
+
allowBase64: true,
|
|
313
|
+
}),
|
|
314
|
+
];
|
|
315
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { mountKatexHtml, renderKatexHtml } from "./lazyKatex";
|
|
3
|
+
|
|
4
|
+
describe("renderKatexHtml", () => {
|
|
5
|
+
it("renders valid TeX to KaTeX markup", async () => {
|
|
6
|
+
const result = await renderKatexHtml("x^2");
|
|
7
|
+
expect(result.ok).toBe(true);
|
|
8
|
+
if (result.ok) expect(result.html).toContain("katex");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("renders display mode for block math", async () => {
|
|
12
|
+
const result = await renderKatexHtml("\\sum_{i=0}^n i", { displayMode: true });
|
|
13
|
+
expect(result.ok).toBe(true);
|
|
14
|
+
if (result.ok) expect(result.html).toContain("katex-display");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("returns the parse error for invalid TeX (Axiom 6: never blank)", async () => {
|
|
18
|
+
const result = await renderKatexHtml("\\undefinedmacro{");
|
|
19
|
+
expect(result.ok).toBe(false);
|
|
20
|
+
if (!result.ok) expect(result.error).toMatch(/parse error/i);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("mountKatexHtml", () => {
|
|
25
|
+
it("mounts markup as real nodes", async () => {
|
|
26
|
+
const result = await renderKatexHtml("x^2");
|
|
27
|
+
const container = document.createElement("span");
|
|
28
|
+
if (result.ok) mountKatexHtml(container, result.html);
|
|
29
|
+
expect(container.querySelector(".katex")).not.toBeNull();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("strips executable elements (defense in depth)", () => {
|
|
33
|
+
const container = document.createElement("span");
|
|
34
|
+
mountKatexHtml(container, '<span class="katex">ok</span><script>alert(1)</script>');
|
|
35
|
+
expect(container.querySelector("script")).toBeNull();
|
|
36
|
+
expect(container.querySelector(".katex")?.textContent).toBe("ok");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy KaTeX renderer for `$...$` inline and `$$...$$` block math.
|
|
3
|
+
*
|
|
4
|
+
* Bundle discipline: KaTeX (~70 KB gz JS + CSS + fonts) never rides the
|
|
5
|
+
* editor chunk. Both the library and its stylesheet load through dynamic
|
|
6
|
+
* import on the first math render and are cached for the session. The
|
|
7
|
+
* stylesheet colors inherit `currentColor`, so dark schemes work without
|
|
8
|
+
* a separate dark CSS pass.
|
|
9
|
+
*
|
|
10
|
+
* The result contract is Axiom 6 friendly — invalid TeX returns
|
|
11
|
+
* `{ ok: false, error }` with KaTeX's parse message so callers can show
|
|
12
|
+
* the error instead of a blank node.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export type KatexRenderResult = { ok: true; html: string } | { ok: false; error: string };
|
|
16
|
+
|
|
17
|
+
type KatexModule = typeof import("katex").default;
|
|
18
|
+
|
|
19
|
+
let katexPromise: Promise<KatexModule> | null = null;
|
|
20
|
+
|
|
21
|
+
function loadKatex(): Promise<KatexModule> {
|
|
22
|
+
if (!katexPromise) {
|
|
23
|
+
katexPromise = Promise.all([
|
|
24
|
+
import("katex"),
|
|
25
|
+
// the stylesheet (fonts included) code-splits with this async chunk
|
|
26
|
+
import("katex/dist/katex.min.css"),
|
|
27
|
+
]).then(([mod]) => (mod as any).default ?? mod);
|
|
28
|
+
}
|
|
29
|
+
return katexPromise;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Renders TeX to KaTeX HTML markup (display mode for `$$` blocks) */
|
|
33
|
+
export async function renderKatexHtml(
|
|
34
|
+
latex: string,
|
|
35
|
+
options: { displayMode?: boolean } = {},
|
|
36
|
+
): Promise<KatexRenderResult> {
|
|
37
|
+
try {
|
|
38
|
+
const katex = await loadKatex();
|
|
39
|
+
const html = katex.renderToString(latex, {
|
|
40
|
+
displayMode: options.displayMode ?? false,
|
|
41
|
+
throwOnError: true,
|
|
42
|
+
strict: false,
|
|
43
|
+
});
|
|
44
|
+
return { ok: true, html };
|
|
45
|
+
} catch (err) {
|
|
46
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Mounts KaTeX markup as real DOM nodes. KaTeX output is spans + MathML by
|
|
52
|
+
* construction; parsing inert and stripping executables is defense in
|
|
53
|
+
* depth, mirroring the mermaid mount helper.
|
|
54
|
+
*/
|
|
55
|
+
export function mountKatexHtml(container: HTMLElement, html: string): void {
|
|
56
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
57
|
+
for (const el of Array.from(doc.body.querySelectorAll("script, iframe, object, embed"))) {
|
|
58
|
+
el.remove();
|
|
59
|
+
}
|
|
60
|
+
container.replaceChildren(
|
|
61
|
+
...Array.from(doc.body.childNodes).map((node) => document.importNode(node, true)),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Test seam: reset the cached library promise */
|
|
66
|
+
export function resetKatexForTesting(): void {
|
|
67
|
+
katexPromise = null;
|
|
68
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { htmlToMarkdown, markdownToHtml } from "./markdown";
|
|
3
|
+
|
|
4
|
+
describe("htmlToMarkdown", () => {
|
|
5
|
+
it("converts headings, emphasis, and inline code to GFM", () => {
|
|
6
|
+
const md = htmlToMarkdown(
|
|
7
|
+
"<h1>Title</h1><p><strong>bold</strong> and <em>italic</em> and <code>code</code></p>",
|
|
8
|
+
);
|
|
9
|
+
expect(md).toContain("# Title");
|
|
10
|
+
expect(md).toContain("**bold**");
|
|
11
|
+
expect(md).toContain("_italic_");
|
|
12
|
+
expect(md).toContain("`code`");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("converts strikethrough to ~~", () => {
|
|
16
|
+
expect(htmlToMarkdown("<p><s>gone</s></p>")).toContain("~~gone~~");
|
|
17
|
+
expect(htmlToMarkdown("<p><del>gone</del></p>")).toContain("~~gone~~");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("converts fenced code blocks", () => {
|
|
21
|
+
const md = htmlToMarkdown('<pre><code class="language-js">const a = 1;</code></pre>');
|
|
22
|
+
expect(md).toContain("```");
|
|
23
|
+
expect(md).toContain("const a = 1;");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("converts Tiptap task items to GFM checkboxes", () => {
|
|
27
|
+
const html =
|
|
28
|
+
'<ul data-type="taskList">' +
|
|
29
|
+
'<li data-type="taskItem" data-checked="true"><label><input type="checkbox" checked><span></span></label><div><p>done</p></div></li>' +
|
|
30
|
+
'<li data-type="taskItem" data-checked="false"><label><input type="checkbox"><span></span></label><div><p>todo</p></div></li>' +
|
|
31
|
+
"</ul>";
|
|
32
|
+
const md = htmlToMarkdown(html);
|
|
33
|
+
expect(md).toContain("- [x] done");
|
|
34
|
+
expect(md).toContain("- [ ] todo");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("converts tables to GFM pipe tables", () => {
|
|
38
|
+
const html =
|
|
39
|
+
"<table><tr><th>Name</th><th>Role</th></tr><tr><td>Ada</td><td>Analyst</td></tr></table>";
|
|
40
|
+
const md = htmlToMarkdown(html);
|
|
41
|
+
expect(md).toContain("| Name | Role |");
|
|
42
|
+
expect(md).toContain("| --- | --- |");
|
|
43
|
+
expect(md).toContain("| Ada | Analyst |");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("escapes pipes inside table cells", () => {
|
|
47
|
+
const md = htmlToMarkdown("<table><tr><th>A</th></tr><tr><td>x | y</td></tr></table>");
|
|
48
|
+
expect(md).toContain("x \\| y");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("keeps marks markdown cannot express as inline HTML (lossless)", () => {
|
|
52
|
+
const md = htmlToMarkdown(
|
|
53
|
+
'<p><u>under</u> <sub>sub</sub> <sup>sup</sup> <mark>hi</mark> <span style="color: rgb(255, 0, 0)">red</span></p>',
|
|
54
|
+
);
|
|
55
|
+
expect(md).toContain("<u>under</u>");
|
|
56
|
+
expect(md).toContain("<sub>sub</sub>");
|
|
57
|
+
expect(md).toContain("<sup>sup</sup>");
|
|
58
|
+
expect(md).toContain("<mark>hi</mark>");
|
|
59
|
+
expect(md).toMatch(/<span style="color:\s*rgb\(255,\s*0,\s*0\)/);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("markdownToHtml", () => {
|
|
64
|
+
it("converts GFM to HTML", () => {
|
|
65
|
+
const html = markdownToHtml("# Title\n\n**bold** and ~~strike~~");
|
|
66
|
+
expect(html).toContain("<h1>Title</h1>");
|
|
67
|
+
expect(html).toContain("<strong>bold</strong>");
|
|
68
|
+
expect(html).toContain("<del>strike</del>");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("upgrades GFM task lists to the Tiptap taskList schema", () => {
|
|
72
|
+
const html = markdownToHtml("- [x] done\n- [ ] todo");
|
|
73
|
+
expect(html).toContain('data-type="taskList"');
|
|
74
|
+
expect(html).toContain('data-type="taskItem"');
|
|
75
|
+
expect(html).toContain('data-checked="true"');
|
|
76
|
+
expect(html).toContain('data-checked="false"');
|
|
77
|
+
// marked's raw checkbox inputs are removed after the upgrade
|
|
78
|
+
expect(html).not.toContain("<input");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("parses pipe tables", () => {
|
|
82
|
+
const html = markdownToHtml("| A | B |\n| --- | --- |\n| 1 | 2 |");
|
|
83
|
+
expect(html).toContain("<table>");
|
|
84
|
+
expect(html).toContain("<th>A</th>");
|
|
85
|
+
expect(html).toContain("<td>1</td>");
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("math markdown (GitLab-flavored dollar math)", () => {
|
|
90
|
+
it("converts inline math spans to $...$", () => {
|
|
91
|
+
const md = htmlToMarkdown(
|
|
92
|
+
'<p>energy <span data-type="inline-math" data-latex="E=mc^2">E=mc^2</span> here</p>',
|
|
93
|
+
);
|
|
94
|
+
expect(md).toContain("$E=mc^2$");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("converts math code blocks to $$ fences", () => {
|
|
98
|
+
const md = htmlToMarkdown('<pre><code class="language-math">\\frac{a}{b}</code></pre>');
|
|
99
|
+
expect(md).toContain("$$\n\\frac{a}{b}\n$$");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("parses $...$ into inline math spans", () => {
|
|
103
|
+
const html = markdownToHtml("the mass $E=mc^2$ equation");
|
|
104
|
+
expect(html).toContain('data-type="inline-math"');
|
|
105
|
+
expect(html).toContain('data-latex="E=mc^2"');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("parses $$ blocks (own-line and single-line) into math code blocks", () => {
|
|
109
|
+
expect(markdownToHtml("$$\n\\sqrt{x}\n$$")).toContain('<code class="language-math">');
|
|
110
|
+
expect(markdownToHtml("$$\\sqrt{x}$$")).toContain('<code class="language-math">');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("parses ```math fences into the same math code block", () => {
|
|
114
|
+
expect(markdownToHtml("```math\n\\sqrt{x}\n```")).toContain('class="language-math"');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("does not treat prices as math", () => {
|
|
118
|
+
const html = markdownToHtml("costs $5 and $10 total");
|
|
119
|
+
expect(html).not.toContain("inline-math");
|
|
120
|
+
expect(html).toContain("costs $5 and $10 total");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("escapes HTML inside latex both directions", () => {
|
|
124
|
+
const html = markdownToHtml("$a<b$");
|
|
125
|
+
expect(html).toContain("a<b");
|
|
126
|
+
expect(html).not.toContain("<b$");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("round-trips inline and block math losslessly", () => {
|
|
130
|
+
const source =
|
|
131
|
+
'<p>inline <span data-type="inline-math" data-latex="x^2">x^2</span></p>' +
|
|
132
|
+
'<pre><code class="language-math">\\sum_{i=0}^n i</code></pre>';
|
|
133
|
+
const roundTripped = markdownToHtml(htmlToMarkdown(source));
|
|
134
|
+
expect(roundTripped).toContain('data-latex="x^2"');
|
|
135
|
+
expect(roundTripped).toContain('<code class="language-math">');
|
|
136
|
+
expect(roundTripped).toContain("\\sum_{i=0}^n i");
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe("mermaid markdown", () => {
|
|
141
|
+
it("round-trips mermaid fences losslessly", () => {
|
|
142
|
+
const source = '<pre><code class="language-mermaid">graph TD\n A-->B</code></pre>';
|
|
143
|
+
const md = htmlToMarkdown(source);
|
|
144
|
+
expect(md).toContain("```mermaid");
|
|
145
|
+
expect(md).toContain("graph TD");
|
|
146
|
+
const roundTripped = markdownToHtml(md);
|
|
147
|
+
expect(roundTripped).toContain('class="language-mermaid"');
|
|
148
|
+
expect(roundTripped).toContain("A-->B");
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe("details markdown (collapsible sections)", () => {
|
|
153
|
+
it("keeps <details> as raw HTML (GitLab behavior) and round-trips it", () => {
|
|
154
|
+
const source =
|
|
155
|
+
"<details><summary>Click me</summary>" +
|
|
156
|
+
'<div data-type="detailsContent"><p>hidden <strong>content</strong></p></div></details>';
|
|
157
|
+
const md = htmlToMarkdown(source);
|
|
158
|
+
expect(md).toContain("<details>");
|
|
159
|
+
expect(md).toContain("<summary>Click me</summary>");
|
|
160
|
+
const roundTripped = markdownToHtml(md);
|
|
161
|
+
expect(roundTripped).toContain("<details>");
|
|
162
|
+
expect(roundTripped).toContain("<summary>Click me</summary>");
|
|
163
|
+
expect(roundTripped).toContain("<strong>content</strong>");
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe("round-trip (rich -> markdown -> rich)", () => {
|
|
168
|
+
it("preserves headings, lists, tasks, quotes, and inline marks", () => {
|
|
169
|
+
const source =
|
|
170
|
+
"<h2>Notes</h2>" +
|
|
171
|
+
"<p><strong>bold</strong> <em>em</em> <s>strike</s> <code>code</code> <u>under</u></p>" +
|
|
172
|
+
"<ul><li><p>one</p></li><li><p>two</p></li></ul>" +
|
|
173
|
+
'<ul data-type="taskList"><li data-type="taskItem" data-checked="true"><label><input type="checkbox" checked><span></span></label><div><p>task</p></div></li></ul>' +
|
|
174
|
+
"<blockquote><p>quote</p></blockquote>";
|
|
175
|
+
const roundTripped = markdownToHtml(htmlToMarkdown(source));
|
|
176
|
+
expect(roundTripped).toContain("<h2>Notes</h2>");
|
|
177
|
+
expect(roundTripped).toContain("<strong>bold</strong>");
|
|
178
|
+
expect(roundTripped).toContain("<em>em</em>");
|
|
179
|
+
expect(roundTripped).toContain("<del>strike</del>");
|
|
180
|
+
expect(roundTripped).toContain("<code>code</code>");
|
|
181
|
+
expect(roundTripped).toContain("<u>under</u>");
|
|
182
|
+
// Tiptap emits loose lists (<li><p>…</p></li>); either form is fine
|
|
183
|
+
expect(roundTripped).toMatch(/<li>(<p>)?one(<\/p>)?\s*<\/li>/);
|
|
184
|
+
expect(roundTripped).toContain('data-type="taskItem"');
|
|
185
|
+
expect(roundTripped).toContain('data-checked="true"');
|
|
186
|
+
expect(roundTripped).toContain("<blockquote>");
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("preserves tables through the round trip", () => {
|
|
190
|
+
const source = "<table><tr><th>H</th></tr><tr><td>cell</td></tr></table>";
|
|
191
|
+
const roundTripped = markdownToHtml(htmlToMarkdown(source));
|
|
192
|
+
expect(roundTripped).toContain("<table>");
|
|
193
|
+
expect(roundTripped).toContain("<th>H</th>");
|
|
194
|
+
expect(roundTripped).toContain("<td>cell</td>");
|
|
195
|
+
});
|
|
196
|
+
});
|