@multiplatform.one/rich-text 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/cjs/RichEditor.cjs +132 -0
- package/dist/cjs/RichEditor.native.js +120 -0
- package/dist/cjs/RichEditor.native.js.map +1 -0
- package/dist/cjs/RichEditor.stories.cjs +327 -0
- package/dist/cjs/RichEditor.stories.native.js +342 -0
- package/dist/cjs/RichEditor.stories.native.js.map +1 -0
- package/dist/cjs/RichTextEditor/index.cjs +148 -0
- package/dist/cjs/RichTextEditor/index.native.js +160 -0
- package/dist/cjs/RichTextEditor/index.native.js.map +1 -0
- package/dist/cjs/constants.cjs +135 -0
- package/dist/cjs/constants.native.js +138 -0
- package/dist/cjs/constants.native.js.map +1 -0
- package/dist/cjs/context.cjs +33 -0
- package/dist/cjs/context.native.js +36 -0
- package/dist/cjs/context.native.js.map +1 -0
- package/dist/cjs/editor/BlockDragHandle.cjs +137 -0
- package/dist/cjs/editor/BlockDragHandle.native.js +142 -0
- package/dist/cjs/editor/BlockDragHandle.native.js.map +1 -0
- package/dist/cjs/editor/MarkdownPaste.cjs +65 -0
- package/dist/cjs/editor/MarkdownPaste.native.js +68 -0
- package/dist/cjs/editor/MarkdownPaste.native.js.map +1 -0
- package/dist/cjs/editor/SlashCommands.cjs +369 -0
- package/dist/cjs/editor/SlashCommands.native.js +424 -0
- package/dist/cjs/editor/SlashCommands.native.js.map +1 -0
- package/dist/cjs/editor/TentapEditor.native.js +242 -0
- package/dist/cjs/editor/TentapEditor.native.js.map +1 -0
- package/dist/cjs/editor/TiptapEditor.cjs +578 -0
- package/dist/cjs/editor/TiptapEditor.native.js +661 -0
- package/dist/cjs/editor/TiptapEditor.native.js.map +1 -0
- package/dist/cjs/editor/editorStyles.cjs +272 -0
- package/dist/cjs/editor/editorStyles.native.js +276 -0
- package/dist/cjs/editor/editorStyles.native.js.map +1 -0
- package/dist/cjs/editor/index.cjs +33 -0
- package/dist/cjs/editor/index.native.js +36 -0
- package/dist/cjs/editor/index.native.js.map +1 -0
- package/dist/cjs/editor/types.cjs +54 -0
- package/dist/cjs/editor/types.native.js +57 -0
- package/dist/cjs/editor/types.native.js.map +1 -0
- package/dist/cjs/editor/useEditorState.cjs +129 -0
- package/dist/cjs/editor/useEditorState.native.js +135 -0
- package/dist/cjs/editor/useEditorState.native.js.map +1 -0
- package/dist/cjs/index.cjs +30 -0
- package/dist/cjs/index.native.js +33 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/styled.cjs +173 -0
- package/dist/cjs/styled.native.js +185 -0
- package/dist/cjs/styled.native.js.map +1 -0
- package/dist/cjs/toolbar/BubbleToolbar.cjs +130 -0
- package/dist/cjs/toolbar/BubbleToolbar.native.js +159 -0
- package/dist/cjs/toolbar/BubbleToolbar.native.js.map +1 -0
- package/dist/cjs/toolbar/CodeBlockBubble.cjs +211 -0
- package/dist/cjs/toolbar/CodeBlockBubble.native.js +228 -0
- package/dist/cjs/toolbar/CodeBlockBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/ColorPicker.cjs +217 -0
- package/dist/cjs/toolbar/ColorPicker.native.js +234 -0
- package/dist/cjs/toolbar/ColorPicker.native.js.map +1 -0
- package/dist/cjs/toolbar/FixedToolbar.cjs +221 -0
- package/dist/cjs/toolbar/FixedToolbar.native.js +322 -0
- package/dist/cjs/toolbar/FixedToolbar.native.js.map +1 -0
- package/dist/cjs/toolbar/HeadingPicker.cjs +158 -0
- package/dist/cjs/toolbar/HeadingPicker.native.js +167 -0
- package/dist/cjs/toolbar/HeadingPicker.native.js.map +1 -0
- package/dist/cjs/toolbar/ImageBubble.cjs +156 -0
- package/dist/cjs/toolbar/ImageBubble.native.js +165 -0
- package/dist/cjs/toolbar/ImageBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/ImageDialog.cjs +115 -0
- package/dist/cjs/toolbar/ImageDialog.native.js +122 -0
- package/dist/cjs/toolbar/ImageDialog.native.js.map +1 -0
- package/dist/cjs/toolbar/LinkBubble.cjs +195 -0
- package/dist/cjs/toolbar/LinkBubble.native.js +204 -0
- package/dist/cjs/toolbar/LinkBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/LinkDialog.cjs +138 -0
- package/dist/cjs/toolbar/LinkDialog.native.js +146 -0
- package/dist/cjs/toolbar/LinkDialog.native.js.map +1 -0
- package/dist/cjs/toolbar/ListPicker.cjs +117 -0
- package/dist/cjs/toolbar/ListPicker.native.js +124 -0
- package/dist/cjs/toolbar/ListPicker.native.js.map +1 -0
- package/dist/cjs/toolbar/MoreDropdown.cjs +201 -0
- package/dist/cjs/toolbar/MoreDropdown.native.js +224 -0
- package/dist/cjs/toolbar/MoreDropdown.native.js.map +1 -0
- package/dist/cjs/toolbar/ResizeHandle.cjs +105 -0
- package/dist/cjs/toolbar/ResizeHandle.native.js +109 -0
- package/dist/cjs/toolbar/ResizeHandle.native.js.map +1 -0
- package/dist/cjs/toolbar/StatusBar.cjs +91 -0
- package/dist/cjs/toolbar/StatusBar.native.js +100 -0
- package/dist/cjs/toolbar/StatusBar.native.js.map +1 -0
- package/dist/cjs/toolbar/TableBubble.cjs +232 -0
- package/dist/cjs/toolbar/TableBubble.native.js +273 -0
- package/dist/cjs/toolbar/TableBubble.native.js.map +1 -0
- package/dist/cjs/toolbar/ToolbarButton.cjs +105 -0
- package/dist/cjs/toolbar/ToolbarButton.native.js +97 -0
- package/dist/cjs/toolbar/ToolbarButton.native.js.map +1 -0
- package/dist/cjs/toolbar/ToolbarGroup.cjs +41 -0
- package/dist/cjs/toolbar/ToolbarGroup.native.js +45 -0
- package/dist/cjs/toolbar/ToolbarGroup.native.js.map +1 -0
- package/dist/cjs/toolbar/icons.cjs +601 -0
- package/dist/cjs/toolbar/icons.native.js +165 -0
- package/dist/cjs/toolbar/icons.native.js.map +1 -0
- package/dist/cjs/toolbar/shortcuts.cjs +62 -0
- package/dist/cjs/toolbar/shortcuts.native.js +66 -0
- package/dist/cjs/toolbar/shortcuts.native.js.map +1 -0
- package/dist/cjs/toolbar/useHorizontalScroll.cjs +250 -0
- package/dist/cjs/toolbar/useHorizontalScroll.native.js +260 -0
- package/dist/cjs/toolbar/useHorizontalScroll.native.js.map +1 -0
- package/dist/cjs/types.cjs +56 -0
- package/dist/cjs/types.native.js +59 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/esm/RichEditor.mjs +107 -0
- package/dist/esm/RichEditor.mjs.map +1 -0
- package/dist/esm/RichEditor.native.js +92 -0
- package/dist/esm/RichEditor.native.js.map +1 -0
- package/dist/esm/RichEditor.stories.mjs +291 -0
- package/dist/esm/RichEditor.stories.mjs.map +1 -0
- package/dist/esm/RichEditor.stories.native.js +303 -0
- package/dist/esm/RichEditor.stories.native.js.map +1 -0
- package/dist/esm/RichTextEditor/index.mjs +123 -0
- package/dist/esm/RichTextEditor/index.mjs.map +1 -0
- package/dist/esm/RichTextEditor/index.native.js +132 -0
- package/dist/esm/RichTextEditor/index.native.js.map +1 -0
- package/dist/esm/constants.mjs +108 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/constants.native.js +108 -0
- package/dist/esm/constants.native.js.map +1 -0
- package/dist/esm/context.mjs +8 -0
- package/dist/esm/context.mjs.map +1 -0
- package/dist/esm/context.native.js +8 -0
- package/dist/esm/context.native.js.map +1 -0
- package/dist/esm/editor/BlockDragHandle.mjs +112 -0
- package/dist/esm/editor/BlockDragHandle.mjs.map +1 -0
- package/dist/esm/editor/BlockDragHandle.native.js +114 -0
- package/dist/esm/editor/BlockDragHandle.native.js.map +1 -0
- package/dist/esm/editor/MarkdownPaste.mjs +40 -0
- package/dist/esm/editor/MarkdownPaste.mjs.map +1 -0
- package/dist/esm/editor/MarkdownPaste.native.js +40 -0
- package/dist/esm/editor/MarkdownPaste.native.js.map +1 -0
- package/dist/esm/editor/SlashCommands.mjs +333 -0
- package/dist/esm/editor/SlashCommands.mjs.map +1 -0
- package/dist/esm/editor/SlashCommands.native.js +385 -0
- package/dist/esm/editor/SlashCommands.native.js.map +1 -0
- package/dist/esm/editor/TentapEditor.native.js +214 -0
- package/dist/esm/editor/TentapEditor.native.js.map +1 -0
- package/dist/esm/editor/TiptapEditor.mjs +542 -0
- package/dist/esm/editor/TiptapEditor.mjs.map +1 -0
- package/dist/esm/editor/TiptapEditor.native.js +622 -0
- package/dist/esm/editor/TiptapEditor.native.js.map +1 -0
- package/dist/esm/editor/editorStyles.mjs +247 -0
- package/dist/esm/editor/editorStyles.mjs.map +1 -0
- package/dist/esm/editor/editorStyles.native.js +248 -0
- package/dist/esm/editor/editorStyles.native.js.map +1 -0
- package/dist/esm/editor/index.mjs +5 -0
- package/dist/esm/editor/index.mjs.map +1 -0
- package/dist/esm/editor/index.native.js +5 -0
- package/dist/esm/editor/index.native.js.map +1 -0
- package/dist/esm/editor/types.mjs +29 -0
- package/dist/esm/editor/types.mjs.map +1 -0
- package/dist/esm/editor/types.native.js +29 -0
- package/dist/esm/editor/types.native.js.map +1 -0
- package/dist/esm/editor/useEditorState.mjs +102 -0
- package/dist/esm/editor/useEditorState.mjs.map +1 -0
- package/dist/esm/editor/useEditorState.native.js +105 -0
- package/dist/esm/editor/useEditorState.native.js.map +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +4 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/styled.mjs +144 -0
- package/dist/esm/styled.mjs.map +1 -0
- package/dist/esm/styled.native.js +153 -0
- package/dist/esm/styled.native.js.map +1 -0
- package/dist/esm/toolbar/BubbleToolbar.mjs +105 -0
- package/dist/esm/toolbar/BubbleToolbar.mjs.map +1 -0
- package/dist/esm/toolbar/BubbleToolbar.native.js +131 -0
- package/dist/esm/toolbar/BubbleToolbar.native.js.map +1 -0
- package/dist/esm/toolbar/CodeBlockBubble.mjs +186 -0
- package/dist/esm/toolbar/CodeBlockBubble.mjs.map +1 -0
- package/dist/esm/toolbar/CodeBlockBubble.native.js +200 -0
- package/dist/esm/toolbar/CodeBlockBubble.native.js.map +1 -0
- package/dist/esm/toolbar/ColorPicker.mjs +191 -0
- package/dist/esm/toolbar/ColorPicker.mjs.map +1 -0
- package/dist/esm/toolbar/ColorPicker.native.js +205 -0
- package/dist/esm/toolbar/ColorPicker.native.js.map +1 -0
- package/dist/esm/toolbar/FixedToolbar.mjs +196 -0
- package/dist/esm/toolbar/FixedToolbar.mjs.map +1 -0
- package/dist/esm/toolbar/FixedToolbar.native.js +294 -0
- package/dist/esm/toolbar/FixedToolbar.native.js.map +1 -0
- package/dist/esm/toolbar/HeadingPicker.mjs +133 -0
- package/dist/esm/toolbar/HeadingPicker.mjs.map +1 -0
- package/dist/esm/toolbar/HeadingPicker.native.js +139 -0
- package/dist/esm/toolbar/HeadingPicker.native.js.map +1 -0
- package/dist/esm/toolbar/ImageBubble.mjs +131 -0
- package/dist/esm/toolbar/ImageBubble.mjs.map +1 -0
- package/dist/esm/toolbar/ImageBubble.native.js +137 -0
- package/dist/esm/toolbar/ImageBubble.native.js.map +1 -0
- package/dist/esm/toolbar/ImageDialog.mjs +90 -0
- package/dist/esm/toolbar/ImageDialog.mjs.map +1 -0
- package/dist/esm/toolbar/ImageDialog.native.js +94 -0
- package/dist/esm/toolbar/ImageDialog.native.js.map +1 -0
- package/dist/esm/toolbar/LinkBubble.mjs +170 -0
- package/dist/esm/toolbar/LinkBubble.mjs.map +1 -0
- package/dist/esm/toolbar/LinkBubble.native.js +176 -0
- package/dist/esm/toolbar/LinkBubble.native.js.map +1 -0
- package/dist/esm/toolbar/LinkDialog.mjs +112 -0
- package/dist/esm/toolbar/LinkDialog.mjs.map +1 -0
- package/dist/esm/toolbar/LinkDialog.native.js +117 -0
- package/dist/esm/toolbar/LinkDialog.native.js.map +1 -0
- package/dist/esm/toolbar/ListPicker.mjs +92 -0
- package/dist/esm/toolbar/ListPicker.mjs.map +1 -0
- package/dist/esm/toolbar/ListPicker.native.js +96 -0
- package/dist/esm/toolbar/ListPicker.native.js.map +1 -0
- package/dist/esm/toolbar/MoreDropdown.mjs +176 -0
- package/dist/esm/toolbar/MoreDropdown.mjs.map +1 -0
- package/dist/esm/toolbar/MoreDropdown.native.js +196 -0
- package/dist/esm/toolbar/MoreDropdown.native.js.map +1 -0
- package/dist/esm/toolbar/ResizeHandle.mjs +80 -0
- package/dist/esm/toolbar/ResizeHandle.mjs.map +1 -0
- package/dist/esm/toolbar/ResizeHandle.native.js +81 -0
- package/dist/esm/toolbar/ResizeHandle.native.js.map +1 -0
- package/dist/esm/toolbar/StatusBar.mjs +66 -0
- package/dist/esm/toolbar/StatusBar.mjs.map +1 -0
- package/dist/esm/toolbar/StatusBar.native.js +72 -0
- package/dist/esm/toolbar/StatusBar.native.js.map +1 -0
- package/dist/esm/toolbar/TableBubble.mjs +207 -0
- package/dist/esm/toolbar/TableBubble.mjs.map +1 -0
- package/dist/esm/toolbar/TableBubble.native.js +245 -0
- package/dist/esm/toolbar/TableBubble.native.js.map +1 -0
- package/dist/esm/toolbar/ToolbarButton.mjs +79 -0
- package/dist/esm/toolbar/ToolbarButton.mjs.map +1 -0
- package/dist/esm/toolbar/ToolbarButton.native.js +68 -0
- package/dist/esm/toolbar/ToolbarButton.native.js.map +1 -0
- package/dist/esm/toolbar/ToolbarGroup.mjs +16 -0
- package/dist/esm/toolbar/ToolbarGroup.mjs.map +1 -0
- package/dist/esm/toolbar/ToolbarGroup.native.js +17 -0
- package/dist/esm/toolbar/ToolbarGroup.native.js.map +1 -0
- package/dist/esm/toolbar/icons.mjs +554 -0
- package/dist/esm/toolbar/icons.mjs.map +1 -0
- package/dist/esm/toolbar/icons.native.js +115 -0
- package/dist/esm/toolbar/icons.native.js.map +1 -0
- package/dist/esm/toolbar/shortcuts.mjs +36 -0
- package/dist/esm/toolbar/shortcuts.mjs.map +1 -0
- package/dist/esm/toolbar/shortcuts.native.js +37 -0
- package/dist/esm/toolbar/shortcuts.native.js.map +1 -0
- package/dist/esm/toolbar/useHorizontalScroll.mjs +223 -0
- package/dist/esm/toolbar/useHorizontalScroll.mjs.map +1 -0
- package/dist/esm/toolbar/useHorizontalScroll.native.js +230 -0
- package/dist/esm/toolbar/useHorizontalScroll.native.js.map +1 -0
- package/dist/esm/types.mjs +31 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +31 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/jsx/RichEditor.mjs +107 -0
- package/dist/jsx/RichEditor.mjs.map +1 -0
- package/dist/jsx/RichEditor.native.js +120 -0
- package/dist/jsx/RichEditor.native.js.map +1 -0
- package/dist/jsx/RichEditor.stories.mjs +291 -0
- package/dist/jsx/RichEditor.stories.mjs.map +1 -0
- package/dist/jsx/RichEditor.stories.native.js +342 -0
- package/dist/jsx/RichEditor.stories.native.js.map +1 -0
- package/dist/jsx/RichTextEditor/index.mjs +123 -0
- package/dist/jsx/RichTextEditor/index.mjs.map +1 -0
- package/dist/jsx/RichTextEditor/index.native.js +160 -0
- package/dist/jsx/RichTextEditor/index.native.js.map +1 -0
- package/dist/jsx/constants.mjs +108 -0
- package/dist/jsx/constants.mjs.map +1 -0
- package/dist/jsx/constants.native.js +138 -0
- package/dist/jsx/constants.native.js.map +1 -0
- package/dist/jsx/context.mjs +8 -0
- package/dist/jsx/context.mjs.map +1 -0
- package/dist/jsx/context.native.js +36 -0
- package/dist/jsx/context.native.js.map +1 -0
- package/dist/jsx/editor/BlockDragHandle.mjs +112 -0
- package/dist/jsx/editor/BlockDragHandle.mjs.map +1 -0
- package/dist/jsx/editor/BlockDragHandle.native.js +142 -0
- package/dist/jsx/editor/BlockDragHandle.native.js.map +1 -0
- package/dist/jsx/editor/MarkdownPaste.mjs +40 -0
- package/dist/jsx/editor/MarkdownPaste.mjs.map +1 -0
- package/dist/jsx/editor/MarkdownPaste.native.js +68 -0
- package/dist/jsx/editor/MarkdownPaste.native.js.map +1 -0
- package/dist/jsx/editor/SlashCommands.mjs +333 -0
- package/dist/jsx/editor/SlashCommands.mjs.map +1 -0
- package/dist/jsx/editor/SlashCommands.native.js +424 -0
- package/dist/jsx/editor/SlashCommands.native.js.map +1 -0
- package/dist/jsx/editor/TentapEditor.native.js +242 -0
- package/dist/jsx/editor/TentapEditor.native.js.map +1 -0
- package/dist/jsx/editor/TiptapEditor.mjs +542 -0
- package/dist/jsx/editor/TiptapEditor.mjs.map +1 -0
- package/dist/jsx/editor/TiptapEditor.native.js +661 -0
- package/dist/jsx/editor/TiptapEditor.native.js.map +1 -0
- package/dist/jsx/editor/editorStyles.mjs +247 -0
- package/dist/jsx/editor/editorStyles.mjs.map +1 -0
- package/dist/jsx/editor/editorStyles.native.js +276 -0
- package/dist/jsx/editor/editorStyles.native.js.map +1 -0
- package/dist/jsx/editor/index.mjs +5 -0
- package/dist/jsx/editor/index.mjs.map +1 -0
- package/dist/jsx/editor/index.native.js +36 -0
- package/dist/jsx/editor/index.native.js.map +1 -0
- package/dist/jsx/editor/types.mjs +29 -0
- package/dist/jsx/editor/types.mjs.map +1 -0
- package/dist/jsx/editor/types.native.js +57 -0
- package/dist/jsx/editor/types.native.js.map +1 -0
- package/dist/jsx/editor/useEditorState.mjs +102 -0
- package/dist/jsx/editor/useEditorState.mjs.map +1 -0
- package/dist/jsx/editor/useEditorState.native.js +135 -0
- package/dist/jsx/editor/useEditorState.native.js.map +1 -0
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +4 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +33 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/styled.mjs +144 -0
- package/dist/jsx/styled.mjs.map +1 -0
- package/dist/jsx/styled.native.js +185 -0
- package/dist/jsx/styled.native.js.map +1 -0
- package/dist/jsx/toolbar/BubbleToolbar.mjs +105 -0
- package/dist/jsx/toolbar/BubbleToolbar.mjs.map +1 -0
- package/dist/jsx/toolbar/BubbleToolbar.native.js +159 -0
- package/dist/jsx/toolbar/BubbleToolbar.native.js.map +1 -0
- package/dist/jsx/toolbar/CodeBlockBubble.mjs +186 -0
- package/dist/jsx/toolbar/CodeBlockBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/CodeBlockBubble.native.js +228 -0
- package/dist/jsx/toolbar/CodeBlockBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/ColorPicker.mjs +191 -0
- package/dist/jsx/toolbar/ColorPicker.mjs.map +1 -0
- package/dist/jsx/toolbar/ColorPicker.native.js +234 -0
- package/dist/jsx/toolbar/ColorPicker.native.js.map +1 -0
- package/dist/jsx/toolbar/FixedToolbar.mjs +196 -0
- package/dist/jsx/toolbar/FixedToolbar.mjs.map +1 -0
- package/dist/jsx/toolbar/FixedToolbar.native.js +322 -0
- package/dist/jsx/toolbar/FixedToolbar.native.js.map +1 -0
- package/dist/jsx/toolbar/HeadingPicker.mjs +133 -0
- package/dist/jsx/toolbar/HeadingPicker.mjs.map +1 -0
- package/dist/jsx/toolbar/HeadingPicker.native.js +167 -0
- package/dist/jsx/toolbar/HeadingPicker.native.js.map +1 -0
- package/dist/jsx/toolbar/ImageBubble.mjs +131 -0
- package/dist/jsx/toolbar/ImageBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/ImageBubble.native.js +165 -0
- package/dist/jsx/toolbar/ImageBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/ImageDialog.mjs +90 -0
- package/dist/jsx/toolbar/ImageDialog.mjs.map +1 -0
- package/dist/jsx/toolbar/ImageDialog.native.js +122 -0
- package/dist/jsx/toolbar/ImageDialog.native.js.map +1 -0
- package/dist/jsx/toolbar/LinkBubble.mjs +170 -0
- package/dist/jsx/toolbar/LinkBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/LinkBubble.native.js +204 -0
- package/dist/jsx/toolbar/LinkBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/LinkDialog.mjs +112 -0
- package/dist/jsx/toolbar/LinkDialog.mjs.map +1 -0
- package/dist/jsx/toolbar/LinkDialog.native.js +146 -0
- package/dist/jsx/toolbar/LinkDialog.native.js.map +1 -0
- package/dist/jsx/toolbar/ListPicker.mjs +92 -0
- package/dist/jsx/toolbar/ListPicker.mjs.map +1 -0
- package/dist/jsx/toolbar/ListPicker.native.js +124 -0
- package/dist/jsx/toolbar/ListPicker.native.js.map +1 -0
- package/dist/jsx/toolbar/MoreDropdown.mjs +176 -0
- package/dist/jsx/toolbar/MoreDropdown.mjs.map +1 -0
- package/dist/jsx/toolbar/MoreDropdown.native.js +224 -0
- package/dist/jsx/toolbar/MoreDropdown.native.js.map +1 -0
- package/dist/jsx/toolbar/ResizeHandle.mjs +80 -0
- package/dist/jsx/toolbar/ResizeHandle.mjs.map +1 -0
- package/dist/jsx/toolbar/ResizeHandle.native.js +109 -0
- package/dist/jsx/toolbar/ResizeHandle.native.js.map +1 -0
- package/dist/jsx/toolbar/StatusBar.mjs +66 -0
- package/dist/jsx/toolbar/StatusBar.mjs.map +1 -0
- package/dist/jsx/toolbar/StatusBar.native.js +100 -0
- package/dist/jsx/toolbar/StatusBar.native.js.map +1 -0
- package/dist/jsx/toolbar/TableBubble.mjs +207 -0
- package/dist/jsx/toolbar/TableBubble.mjs.map +1 -0
- package/dist/jsx/toolbar/TableBubble.native.js +273 -0
- package/dist/jsx/toolbar/TableBubble.native.js.map +1 -0
- package/dist/jsx/toolbar/ToolbarButton.mjs +79 -0
- package/dist/jsx/toolbar/ToolbarButton.mjs.map +1 -0
- package/dist/jsx/toolbar/ToolbarButton.native.js +97 -0
- package/dist/jsx/toolbar/ToolbarButton.native.js.map +1 -0
- package/dist/jsx/toolbar/ToolbarGroup.mjs +16 -0
- package/dist/jsx/toolbar/ToolbarGroup.mjs.map +1 -0
- package/dist/jsx/toolbar/ToolbarGroup.native.js +45 -0
- package/dist/jsx/toolbar/ToolbarGroup.native.js.map +1 -0
- package/dist/jsx/toolbar/icons.mjs +554 -0
- package/dist/jsx/toolbar/icons.mjs.map +1 -0
- package/dist/jsx/toolbar/icons.native.js +165 -0
- package/dist/jsx/toolbar/icons.native.js.map +1 -0
- package/dist/jsx/toolbar/shortcuts.mjs +36 -0
- package/dist/jsx/toolbar/shortcuts.mjs.map +1 -0
- package/dist/jsx/toolbar/shortcuts.native.js +66 -0
- package/dist/jsx/toolbar/shortcuts.native.js.map +1 -0
- package/dist/jsx/toolbar/useHorizontalScroll.mjs +223 -0
- package/dist/jsx/toolbar/useHorizontalScroll.mjs.map +1 -0
- package/dist/jsx/toolbar/useHorizontalScroll.native.js +260 -0
- package/dist/jsx/toolbar/useHorizontalScroll.native.js.map +1 -0
- package/dist/jsx/types.mjs +31 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/dist/jsx/types.native.js +59 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/package.json +117 -0
- package/src/RichEditor.native.tsx +161 -0
- package/src/RichEditor.stories.tsx +324 -0
- package/src/RichEditor.tsx +185 -0
- package/src/RichTextEditor/index.tsx +245 -0
- package/src/RichTextEditor/richTextEditor.spec.tsx +239 -0
- package/src/constants.ts +100 -0
- package/src/context.spec.ts +9 -0
- package/src/context.ts +16 -0
- package/src/editor/BlockDragHandle.ts +141 -0
- package/src/editor/MarkdownPaste.ts +50 -0
- package/src/editor/SlashCommands.tsx +357 -0
- package/src/editor/TentapEditor.native.tsx +269 -0
- package/src/editor/TiptapEditor.tsx +616 -0
- package/src/editor/editorStyles.spec.ts +24 -0
- package/src/editor/editorStyles.ts +260 -0
- package/src/editor/index.ts +10 -0
- package/src/editor/tentapEditor.spec.ts +125 -0
- package/src/editor/tiptapEditor.spec.tsx +169 -0
- package/src/editor/types.ts +142 -0
- package/src/editor/useEditorState.spec.ts +93 -0
- package/src/editor/useEditorState.ts +125 -0
- package/src/exports.spec.ts +128 -0
- package/src/index.ts +13 -0
- package/src/integration.spec.tsx +430 -0
- package/src/richEditor.spec.tsx +169 -0
- package/src/styled.spec.tsx +42 -0
- package/src/styled.ts +177 -0
- package/src/toolbar/BubbleToolbar.tsx +151 -0
- package/src/toolbar/CodeBlockBubble.tsx +141 -0
- package/src/toolbar/ColorPicker.tsx +211 -0
- package/src/toolbar/FixedToolbar.native.tsx +381 -0
- package/src/toolbar/FixedToolbar.tsx +252 -0
- package/src/toolbar/HeadingPicker.tsx +169 -0
- package/src/toolbar/ImageBubble.tsx +126 -0
- package/src/toolbar/ImageDialog.tsx +93 -0
- package/src/toolbar/LinkBubble.tsx +166 -0
- package/src/toolbar/LinkDialog.tsx +124 -0
- package/src/toolbar/ListPicker.tsx +121 -0
- package/src/toolbar/MoreDropdown.tsx +185 -0
- package/src/toolbar/ResizeHandle.tsx +80 -0
- package/src/toolbar/StatusBar.tsx +76 -0
- package/src/toolbar/TableBubble.tsx +197 -0
- package/src/toolbar/ToolbarButton.native.tsx +105 -0
- package/src/toolbar/ToolbarButton.tsx +114 -0
- package/src/toolbar/ToolbarGroup.tsx +38 -0
- package/src/toolbar/bubbleToolbar.spec.tsx +93 -0
- package/src/toolbar/fixedToolbar.spec.tsx +127 -0
- package/src/toolbar/icons.native.tsx +112 -0
- package/src/toolbar/icons.tsx +417 -0
- package/src/toolbar/shortcuts.ts +42 -0
- package/src/toolbar/toolbarPrimitives.spec.tsx +118 -0
- package/src/toolbar/toolbarSubComponents.spec.tsx +115 -0
- package/src/toolbar/useHorizontalScroll.tsx +270 -0
- package/src/types.spec.ts +102 -0
- package/src/types.ts +217 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heading picker dropdown for selecting heading levels
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
7
|
+
import { Popover, Text, YStack } from "tamagui";
|
|
8
|
+
import type { EditorCommand, EditorState, RichEditorRef } from "../types";
|
|
9
|
+
import { DropdownMenuItemFrame } from "../styled";
|
|
10
|
+
import { ToolbarDropdownButton } from "./ToolbarButton";
|
|
11
|
+
|
|
12
|
+
// ===========================================================================
|
|
13
|
+
// Types
|
|
14
|
+
// ===========================================================================
|
|
15
|
+
|
|
16
|
+
export interface HeadingPickerProps {
|
|
17
|
+
/** Reference to the editor */
|
|
18
|
+
editorRef: React.RefObject<RichEditorRef | null>;
|
|
19
|
+
/** Current editor state */
|
|
20
|
+
state: EditorState;
|
|
21
|
+
/** Whether the picker is disabled */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ===========================================================================
|
|
26
|
+
// Heading Options
|
|
27
|
+
// ===========================================================================
|
|
28
|
+
|
|
29
|
+
interface HeadingOption {
|
|
30
|
+
label: string;
|
|
31
|
+
description: string;
|
|
32
|
+
command: EditorCommand;
|
|
33
|
+
stateKey: keyof EditorState;
|
|
34
|
+
fontSize: string;
|
|
35
|
+
fontWeight: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const HEADING_OPTIONS: HeadingOption[] = [
|
|
39
|
+
{
|
|
40
|
+
label: "H1",
|
|
41
|
+
description: "Heading 1",
|
|
42
|
+
command: "heading1",
|
|
43
|
+
stateKey: "isHeading1",
|
|
44
|
+
fontSize: "$5",
|
|
45
|
+
fontWeight: "700",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: "H2",
|
|
49
|
+
description: "Heading 2",
|
|
50
|
+
command: "heading2",
|
|
51
|
+
stateKey: "isHeading2",
|
|
52
|
+
fontSize: "$4",
|
|
53
|
+
fontWeight: "600",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: "H3",
|
|
57
|
+
description: "Heading 3",
|
|
58
|
+
command: "heading3",
|
|
59
|
+
stateKey: "isHeading3",
|
|
60
|
+
fontSize: "$3",
|
|
61
|
+
fontWeight: "600",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: "H4",
|
|
65
|
+
description: "Heading 4",
|
|
66
|
+
command: "heading4",
|
|
67
|
+
stateKey: "isHeading4",
|
|
68
|
+
fontSize: "$2",
|
|
69
|
+
fontWeight: "600",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: "H5",
|
|
73
|
+
description: "Heading 5",
|
|
74
|
+
command: "heading5",
|
|
75
|
+
stateKey: "isHeading5",
|
|
76
|
+
fontSize: "$1",
|
|
77
|
+
fontWeight: "600",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: "H6",
|
|
81
|
+
description: "Heading 6",
|
|
82
|
+
command: "heading6",
|
|
83
|
+
stateKey: "isHeading6",
|
|
84
|
+
fontSize: "$1",
|
|
85
|
+
fontWeight: "600",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: "P",
|
|
89
|
+
description: "Paragraph",
|
|
90
|
+
command: "paragraph",
|
|
91
|
+
stateKey: "isParagraph",
|
|
92
|
+
fontSize: "$3",
|
|
93
|
+
fontWeight: "400",
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
// ===========================================================================
|
|
98
|
+
// HeadingPicker
|
|
99
|
+
// ===========================================================================
|
|
100
|
+
|
|
101
|
+
function getActiveHeadingLabel(state: EditorState): string {
|
|
102
|
+
if (state.isHeading1) return "H1";
|
|
103
|
+
if (state.isHeading2) return "H2";
|
|
104
|
+
if (state.isHeading3) return "H3";
|
|
105
|
+
if (state.isHeading4) return "H4";
|
|
106
|
+
if (state.isHeading5) return "H5";
|
|
107
|
+
if (state.isHeading6) return "H6";
|
|
108
|
+
return "H";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isAnyHeadingActive(state: EditorState): boolean {
|
|
112
|
+
return (
|
|
113
|
+
state.isHeading1 ||
|
|
114
|
+
state.isHeading2 ||
|
|
115
|
+
state.isHeading3 ||
|
|
116
|
+
state.isHeading4 ||
|
|
117
|
+
state.isHeading5 ||
|
|
118
|
+
state.isHeading6
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function HeadingPicker({ editorRef, state, disabled }: HeadingPickerProps) {
|
|
123
|
+
const { knobProps } = useResolvedKnobs();
|
|
124
|
+
const [open, setOpen] = useState(false);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<Popover open={open} onOpenChange={setOpen} placement="bottom-start">
|
|
128
|
+
<Popover.Trigger asChild>
|
|
129
|
+
<ToolbarDropdownButton
|
|
130
|
+
active={isAnyHeadingActive(state)}
|
|
131
|
+
disabled={disabled}
|
|
132
|
+
onPress={() => setOpen(true)}
|
|
133
|
+
aria-label="Heading"
|
|
134
|
+
>
|
|
135
|
+
<Text fontWeight="600">{getActiveHeadingLabel(state)}</Text>
|
|
136
|
+
</ToolbarDropdownButton>
|
|
137
|
+
</Popover.Trigger>
|
|
138
|
+
<Popover.Content
|
|
139
|
+
{...knobProps.panelPadding}
|
|
140
|
+
backgroundColor="$background"
|
|
141
|
+
borderWidth={1}
|
|
142
|
+
borderColor="$borderColor"
|
|
143
|
+
borderRadius={knobProps.borderRadius.borderRadius}
|
|
144
|
+
elevation={knobProps.elevation}
|
|
145
|
+
enterStyle={{ opacity: 0, y: -5 }}
|
|
146
|
+
exitStyle={{ opacity: 0, y: -5 }}
|
|
147
|
+
>
|
|
148
|
+
<YStack gap="$1" minWidth={140}>
|
|
149
|
+
{HEADING_OPTIONS.map((option) => (
|
|
150
|
+
<DropdownMenuItemFrame
|
|
151
|
+
key={option.command}
|
|
152
|
+
active={state[option.stateKey] as boolean}
|
|
153
|
+
onPress={() => {
|
|
154
|
+
editorRef.current?.executeCommand(option.command);
|
|
155
|
+
setOpen(false);
|
|
156
|
+
}}
|
|
157
|
+
aria-label={option.description}
|
|
158
|
+
>
|
|
159
|
+
<Text fontWeight={option.fontWeight as any} fontSize={option.fontSize as any}>
|
|
160
|
+
{option.label}
|
|
161
|
+
</Text>
|
|
162
|
+
<Text color="$color11">{option.description}</Text>
|
|
163
|
+
</DropdownMenuItemFrame>
|
|
164
|
+
))}
|
|
165
|
+
</YStack>
|
|
166
|
+
</Popover.Content>
|
|
167
|
+
</Popover>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bubble menu shown when an image node is selected.
|
|
3
|
+
* Provides options to update alt text or remove the image.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useCallback, useState } from "react";
|
|
7
|
+
import type { Editor } from "@tiptap/react";
|
|
8
|
+
import { BubbleMenu } from "@tiptap/react/menus";
|
|
9
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
10
|
+
import { Input, Text, XStack, YStack } from "tamagui";
|
|
11
|
+
import { Button } from "@multiplatform.one/forms";
|
|
12
|
+
import { ToolbarButton } from "./ToolbarButton";
|
|
13
|
+
|
|
14
|
+
function TrashIcon() {
|
|
15
|
+
return (
|
|
16
|
+
<svg
|
|
17
|
+
width="14"
|
|
18
|
+
height="14"
|
|
19
|
+
viewBox="0 0 24 24"
|
|
20
|
+
fill="none"
|
|
21
|
+
stroke="currentColor"
|
|
22
|
+
strokeWidth="2"
|
|
23
|
+
>
|
|
24
|
+
<polyline points="3 6 5 6 21 6" />
|
|
25
|
+
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function EditIcon() {
|
|
31
|
+
return (
|
|
32
|
+
<svg
|
|
33
|
+
width="14"
|
|
34
|
+
height="14"
|
|
35
|
+
viewBox="0 0 24 24"
|
|
36
|
+
fill="none"
|
|
37
|
+
stroke="currentColor"
|
|
38
|
+
strokeWidth="2"
|
|
39
|
+
>
|
|
40
|
+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
|
|
41
|
+
<path d="M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
|
|
42
|
+
</svg>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ImageBubbleProps {
|
|
47
|
+
editor: Editor | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function ImageBubble({ editor }: ImageBubbleProps) {
|
|
51
|
+
const { knobProps } = useResolvedKnobs();
|
|
52
|
+
const [editing, setEditing] = useState(false);
|
|
53
|
+
const [altText, setAltText] = useState("");
|
|
54
|
+
|
|
55
|
+
const handleEdit = useCallback(() => {
|
|
56
|
+
if (!editor) return;
|
|
57
|
+
const attrs = editor.getAttributes("image");
|
|
58
|
+
setAltText(attrs.alt || "");
|
|
59
|
+
setEditing(true);
|
|
60
|
+
}, [editor]);
|
|
61
|
+
|
|
62
|
+
const handleSave = useCallback(() => {
|
|
63
|
+
if (!editor) return;
|
|
64
|
+
editor.chain().focus().updateAttributes("image", { alt: altText }).run();
|
|
65
|
+
setEditing(false);
|
|
66
|
+
}, [editor, altText]);
|
|
67
|
+
|
|
68
|
+
const handleDelete = useCallback(() => {
|
|
69
|
+
if (!editor) return;
|
|
70
|
+
editor.chain().focus().deleteSelection().run();
|
|
71
|
+
}, [editor]);
|
|
72
|
+
|
|
73
|
+
if (!editor) return null;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<BubbleMenu editor={editor} shouldShow={({ editor: e }) => e.isActive("image")}>
|
|
77
|
+
<XStack
|
|
78
|
+
backgroundColor="$background"
|
|
79
|
+
borderWidth={1}
|
|
80
|
+
borderColor="$borderColor"
|
|
81
|
+
borderRadius={knobProps.borderRadius.borderRadius}
|
|
82
|
+
padding="$1.5"
|
|
83
|
+
gap="$1.5"
|
|
84
|
+
alignItems="center"
|
|
85
|
+
elevation={knobProps.elevation}
|
|
86
|
+
>
|
|
87
|
+
{editing ? (
|
|
88
|
+
<YStack gap="$1.5">
|
|
89
|
+
<Text fontSize={12} fontWeight="600">
|
|
90
|
+
Alt text
|
|
91
|
+
</Text>
|
|
92
|
+
<Input
|
|
93
|
+
size="$2"
|
|
94
|
+
placeholder="Describe this image..."
|
|
95
|
+
value={altText}
|
|
96
|
+
onChangeText={setAltText}
|
|
97
|
+
onSubmitEditing={handleSave}
|
|
98
|
+
autoFocus
|
|
99
|
+
minWidth={220}
|
|
100
|
+
/>
|
|
101
|
+
<XStack gap="$1" justifyContent="flex-end">
|
|
102
|
+
<Button size="$2" onPress={() => setEditing(false)} aria-label="Cancel">
|
|
103
|
+
Cancel
|
|
104
|
+
</Button>
|
|
105
|
+
<Button size="$2" theme="active" onPress={handleSave} aria-label="Save alt text">
|
|
106
|
+
Save
|
|
107
|
+
</Button>
|
|
108
|
+
</XStack>
|
|
109
|
+
</YStack>
|
|
110
|
+
) : (
|
|
111
|
+
<>
|
|
112
|
+
<Text fontSize={12} color="$color10" maxWidth={200} numberOfLines={1}>
|
|
113
|
+
{editor.getAttributes("image").alt || "No alt text"}
|
|
114
|
+
</Text>
|
|
115
|
+
<ToolbarButton onPress={handleEdit} aria-label="Edit alt text" tooltip="Edit alt text">
|
|
116
|
+
<EditIcon />
|
|
117
|
+
</ToolbarButton>
|
|
118
|
+
<ToolbarButton onPress={handleDelete} aria-label="Delete image" tooltip="Delete image">
|
|
119
|
+
<TrashIcon />
|
|
120
|
+
</ToolbarButton>
|
|
121
|
+
</>
|
|
122
|
+
)}
|
|
123
|
+
</XStack>
|
|
124
|
+
</BubbleMenu>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image dialog popover for inserting images via URL
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { useCallback, useState } from "react";
|
|
6
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
7
|
+
import { Input, Popover, Text, XStack, YStack } from "tamagui";
|
|
8
|
+
import { Button } from "@multiplatform.one/forms";
|
|
9
|
+
import type { RichEditorRef } from "../types";
|
|
10
|
+
import { ToolbarButton } from "./ToolbarButton";
|
|
11
|
+
import { ImageIcon } from "./icons";
|
|
12
|
+
import { SHORTCUTS } from "./shortcuts";
|
|
13
|
+
|
|
14
|
+
// ===========================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// ===========================================================================
|
|
17
|
+
|
|
18
|
+
export interface ImageDialogProps {
|
|
19
|
+
/** Reference to the editor */
|
|
20
|
+
editorRef: React.RefObject<RichEditorRef | null>;
|
|
21
|
+
/** Whether the dialog is disabled */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ===========================================================================
|
|
26
|
+
// ImageDialog
|
|
27
|
+
// ===========================================================================
|
|
28
|
+
|
|
29
|
+
export function ImageDialog({ editorRef, disabled }: ImageDialogProps) {
|
|
30
|
+
const { knobProps } = useResolvedKnobs();
|
|
31
|
+
const [open, setOpen] = useState(false);
|
|
32
|
+
const [imageUrl, setImageUrl] = useState("");
|
|
33
|
+
|
|
34
|
+
const handleInsert = useCallback(() => {
|
|
35
|
+
const trimmed = imageUrl.trim();
|
|
36
|
+
if (trimmed) {
|
|
37
|
+
editorRef.current?.executeCommand("image", { src: trimmed });
|
|
38
|
+
setImageUrl("");
|
|
39
|
+
setOpen(false);
|
|
40
|
+
}
|
|
41
|
+
}, [imageUrl, editorRef]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Popover open={open} onOpenChange={setOpen} placement="bottom">
|
|
45
|
+
<Popover.Trigger asChild>
|
|
46
|
+
<ToolbarButton
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
onPress={() => setOpen(true)}
|
|
49
|
+
aria-label="Insert Image"
|
|
50
|
+
tooltip={SHORTCUTS.image}
|
|
51
|
+
>
|
|
52
|
+
<ImageIcon />
|
|
53
|
+
</ToolbarButton>
|
|
54
|
+
</Popover.Trigger>
|
|
55
|
+
<Popover.Content
|
|
56
|
+
{...knobProps.panelPadding}
|
|
57
|
+
backgroundColor="$background"
|
|
58
|
+
borderWidth={1}
|
|
59
|
+
borderColor="$borderColor"
|
|
60
|
+
borderRadius={knobProps.borderRadius.borderRadius}
|
|
61
|
+
elevation={knobProps.elevation}
|
|
62
|
+
enterStyle={{ opacity: 0, y: -5 }}
|
|
63
|
+
exitStyle={{ opacity: 0, y: -5 }}
|
|
64
|
+
>
|
|
65
|
+
<Popover.Arrow borderColor="$borderColor" backgroundColor="$background" />
|
|
66
|
+
<YStack gap="$2" minWidth={250}>
|
|
67
|
+
<Text fontSize={knobProps.sizeToken} fontWeight="600">
|
|
68
|
+
Insert Image
|
|
69
|
+
</Text>
|
|
70
|
+
<Input
|
|
71
|
+
size="$3"
|
|
72
|
+
placeholder="https://example.com/image.jpg"
|
|
73
|
+
value={imageUrl}
|
|
74
|
+
onChangeText={setImageUrl}
|
|
75
|
+
onSubmitEditing={handleInsert}
|
|
76
|
+
autoFocus
|
|
77
|
+
/>
|
|
78
|
+
<XStack gap="$2" justifyContent="flex-end">
|
|
79
|
+
<Button
|
|
80
|
+
size="$2"
|
|
81
|
+
theme="active"
|
|
82
|
+
onPress={handleInsert}
|
|
83
|
+
disabled={!imageUrl.trim()}
|
|
84
|
+
aria-label="Insert image"
|
|
85
|
+
>
|
|
86
|
+
Insert
|
|
87
|
+
</Button>
|
|
88
|
+
</XStack>
|
|
89
|
+
</YStack>
|
|
90
|
+
</Popover.Content>
|
|
91
|
+
</Popover>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bubble menu shown when cursor is on a link.
|
|
3
|
+
* Displays the URL with options to visit, edit, or unlink.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useCallback, useState } from "react";
|
|
7
|
+
import type { Editor } from "@tiptap/react";
|
|
8
|
+
import { BubbleMenu } from "@tiptap/react/menus";
|
|
9
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
10
|
+
import { Input, Text, XStack, YStack } from "tamagui";
|
|
11
|
+
import { Button } from "@multiplatform.one/forms";
|
|
12
|
+
import { ToolbarButton } from "./ToolbarButton";
|
|
13
|
+
import { LinkIcon } from "./icons";
|
|
14
|
+
|
|
15
|
+
export interface LinkBubbleProps {
|
|
16
|
+
editor: Editor | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function ExternalLinkIcon() {
|
|
20
|
+
return (
|
|
21
|
+
<svg
|
|
22
|
+
width="14"
|
|
23
|
+
height="14"
|
|
24
|
+
viewBox="0 0 24 24"
|
|
25
|
+
fill="none"
|
|
26
|
+
stroke="currentColor"
|
|
27
|
+
strokeWidth="2"
|
|
28
|
+
>
|
|
29
|
+
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
|
|
30
|
+
<polyline points="15 3 21 3 21 9" />
|
|
31
|
+
<line x1="10" y1="14" x2="21" y2="3" />
|
|
32
|
+
</svg>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function UnlinkIcon() {
|
|
37
|
+
return (
|
|
38
|
+
<svg
|
|
39
|
+
width="14"
|
|
40
|
+
height="14"
|
|
41
|
+
viewBox="0 0 24 24"
|
|
42
|
+
fill="none"
|
|
43
|
+
stroke="currentColor"
|
|
44
|
+
strokeWidth="2"
|
|
45
|
+
>
|
|
46
|
+
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
|
|
47
|
+
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
|
|
48
|
+
<line x1="2" y1="2" x2="22" y2="22" strokeWidth="2" />
|
|
49
|
+
</svg>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function EditIcon() {
|
|
54
|
+
return (
|
|
55
|
+
<svg
|
|
56
|
+
width="14"
|
|
57
|
+
height="14"
|
|
58
|
+
viewBox="0 0 24 24"
|
|
59
|
+
fill="none"
|
|
60
|
+
stroke="currentColor"
|
|
61
|
+
strokeWidth="2"
|
|
62
|
+
>
|
|
63
|
+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
|
|
64
|
+
<path d="M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
|
|
65
|
+
</svg>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function LinkBubble({ editor }: LinkBubbleProps) {
|
|
70
|
+
const { knobProps } = useResolvedKnobs();
|
|
71
|
+
const [editing, setEditing] = useState(false);
|
|
72
|
+
const [editUrl, setEditUrl] = useState("");
|
|
73
|
+
|
|
74
|
+
const handleEdit = useCallback(() => {
|
|
75
|
+
if (!editor) return;
|
|
76
|
+
const attrs = editor.getAttributes("link");
|
|
77
|
+
setEditUrl(attrs.href || "");
|
|
78
|
+
setEditing(true);
|
|
79
|
+
}, [editor]);
|
|
80
|
+
|
|
81
|
+
const handleSave = useCallback(() => {
|
|
82
|
+
if (!editor) return;
|
|
83
|
+
const trimmed = editUrl.trim();
|
|
84
|
+
if (trimmed) {
|
|
85
|
+
editor.chain().focus().extendMarkRange("link").setLink({ href: trimmed }).run();
|
|
86
|
+
}
|
|
87
|
+
setEditing(false);
|
|
88
|
+
}, [editor, editUrl]);
|
|
89
|
+
|
|
90
|
+
const handleUnlink = useCallback(() => {
|
|
91
|
+
if (!editor) return;
|
|
92
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
93
|
+
setEditing(false);
|
|
94
|
+
}, [editor]);
|
|
95
|
+
|
|
96
|
+
if (!editor) return null;
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<BubbleMenu editor={editor} shouldShow={({ editor: e }) => e.isActive("link")}>
|
|
100
|
+
<XStack
|
|
101
|
+
backgroundColor="$background"
|
|
102
|
+
borderWidth={1}
|
|
103
|
+
borderColor="$borderColor"
|
|
104
|
+
borderRadius={knobProps.borderRadius.borderRadius}
|
|
105
|
+
padding="$1.5"
|
|
106
|
+
gap="$1.5"
|
|
107
|
+
alignItems="center"
|
|
108
|
+
elevation={knobProps.elevation}
|
|
109
|
+
>
|
|
110
|
+
{editing ? (
|
|
111
|
+
<YStack gap="$1.5">
|
|
112
|
+
<Input
|
|
113
|
+
size="$2"
|
|
114
|
+
placeholder="https://example.com"
|
|
115
|
+
value={editUrl}
|
|
116
|
+
onChangeText={setEditUrl}
|
|
117
|
+
onSubmitEditing={handleSave}
|
|
118
|
+
autoFocus
|
|
119
|
+
minWidth={220}
|
|
120
|
+
/>
|
|
121
|
+
<XStack gap="$1" justifyContent="flex-end">
|
|
122
|
+
<Button size="$2" onPress={() => setEditing(false)} aria-label="Cancel">
|
|
123
|
+
Cancel
|
|
124
|
+
</Button>
|
|
125
|
+
<Button size="$2" theme="active" onPress={handleSave} aria-label="Save link">
|
|
126
|
+
Save
|
|
127
|
+
</Button>
|
|
128
|
+
</XStack>
|
|
129
|
+
</YStack>
|
|
130
|
+
) : (
|
|
131
|
+
<>
|
|
132
|
+
<Text
|
|
133
|
+
fontSize={12}
|
|
134
|
+
color="$blue10"
|
|
135
|
+
maxWidth={200}
|
|
136
|
+
numberOfLines={1}
|
|
137
|
+
cursor="pointer"
|
|
138
|
+
onPress={() => {
|
|
139
|
+
const href = editor.getAttributes("link").href;
|
|
140
|
+
if (href) window.open(href, "_blank", "noopener,noreferrer");
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
{editor.getAttributes("link").href || "No URL"}
|
|
144
|
+
</Text>
|
|
145
|
+
<ToolbarButton
|
|
146
|
+
onPress={() => {
|
|
147
|
+
const href = editor.getAttributes("link").href;
|
|
148
|
+
if (href) window.open(href, "_blank", "noopener,noreferrer");
|
|
149
|
+
}}
|
|
150
|
+
aria-label="Open link"
|
|
151
|
+
tooltip="Open link"
|
|
152
|
+
>
|
|
153
|
+
<ExternalLinkIcon />
|
|
154
|
+
</ToolbarButton>
|
|
155
|
+
<ToolbarButton onPress={handleEdit} aria-label="Edit link" tooltip="Edit link">
|
|
156
|
+
<EditIcon />
|
|
157
|
+
</ToolbarButton>
|
|
158
|
+
<ToolbarButton onPress={handleUnlink} aria-label="Remove link" tooltip="Unlink">
|
|
159
|
+
<UnlinkIcon />
|
|
160
|
+
</ToolbarButton>
|
|
161
|
+
</>
|
|
162
|
+
)}
|
|
163
|
+
</XStack>
|
|
164
|
+
</BubbleMenu>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link dialog popover for inserting and editing links
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { useCallback, useState } from "react";
|
|
6
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
7
|
+
import { Input, Popover, Text, XStack, YStack } from "tamagui";
|
|
8
|
+
import { Button } from "@multiplatform.one/forms";
|
|
9
|
+
import type { EditorState, RichEditorRef } from "../types";
|
|
10
|
+
import { ToolbarButton } from "./ToolbarButton";
|
|
11
|
+
import { LinkIcon } from "./icons";
|
|
12
|
+
import { SHORTCUTS } from "./shortcuts";
|
|
13
|
+
|
|
14
|
+
// ===========================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// ===========================================================================
|
|
17
|
+
|
|
18
|
+
export interface LinkDialogProps {
|
|
19
|
+
/** Reference to the editor */
|
|
20
|
+
editorRef: React.RefObject<RichEditorRef | null>;
|
|
21
|
+
/** Current editor state */
|
|
22
|
+
state: EditorState;
|
|
23
|
+
/** Whether the dialog is disabled */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ===========================================================================
|
|
28
|
+
// Helpers
|
|
29
|
+
// ===========================================================================
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Ensures URL has a protocol prefix, auto-prepending https:// if missing.
|
|
33
|
+
*/
|
|
34
|
+
function normalizeUrl(url: string): string {
|
|
35
|
+
const trimmed = url.trim();
|
|
36
|
+
if (!trimmed) return trimmed;
|
|
37
|
+
if (/^https?:\/\//i.test(trimmed)) return trimmed;
|
|
38
|
+
if (/^mailto:/i.test(trimmed)) return trimmed;
|
|
39
|
+
if (/^tel:/i.test(trimmed)) return trimmed;
|
|
40
|
+
return `https://${trimmed}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ===========================================================================
|
|
44
|
+
// LinkDialog
|
|
45
|
+
// ===========================================================================
|
|
46
|
+
|
|
47
|
+
export function LinkDialog({ editorRef, state, disabled }: LinkDialogProps) {
|
|
48
|
+
const { knobProps } = useResolvedKnobs();
|
|
49
|
+
const [open, setOpen] = useState(false);
|
|
50
|
+
const [linkUrl, setLinkUrl] = useState("");
|
|
51
|
+
|
|
52
|
+
const handleSubmit = useCallback(() => {
|
|
53
|
+
const normalized = normalizeUrl(linkUrl);
|
|
54
|
+
if (normalized) {
|
|
55
|
+
editorRef.current?.executeCommand("link", { href: normalized });
|
|
56
|
+
}
|
|
57
|
+
setLinkUrl("");
|
|
58
|
+
setOpen(false);
|
|
59
|
+
}, [linkUrl, editorRef]);
|
|
60
|
+
|
|
61
|
+
const handleRemove = useCallback(() => {
|
|
62
|
+
editorRef.current?.executeCommand("link", { href: null });
|
|
63
|
+
setOpen(false);
|
|
64
|
+
}, [editorRef]);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Popover open={open} onOpenChange={setOpen} placement="bottom">
|
|
68
|
+
<Popover.Trigger asChild>
|
|
69
|
+
<ToolbarButton
|
|
70
|
+
active={state.isLink}
|
|
71
|
+
disabled={disabled}
|
|
72
|
+
onPress={() => setOpen(true)}
|
|
73
|
+
aria-label="Link"
|
|
74
|
+
tooltip={SHORTCUTS.link}
|
|
75
|
+
>
|
|
76
|
+
<LinkIcon />
|
|
77
|
+
</ToolbarButton>
|
|
78
|
+
</Popover.Trigger>
|
|
79
|
+
<Popover.Content
|
|
80
|
+
{...knobProps.panelPadding}
|
|
81
|
+
backgroundColor="$background"
|
|
82
|
+
borderWidth={1}
|
|
83
|
+
borderColor="$borderColor"
|
|
84
|
+
borderRadius={knobProps.borderRadius.borderRadius}
|
|
85
|
+
elevation={knobProps.elevation}
|
|
86
|
+
enterStyle={{ opacity: 0, y: -5 }}
|
|
87
|
+
exitStyle={{ opacity: 0, y: -5 }}
|
|
88
|
+
>
|
|
89
|
+
<Popover.Arrow borderColor="$borderColor" backgroundColor="$background" />
|
|
90
|
+
<YStack gap="$2" minWidth={250}>
|
|
91
|
+
<Text fontSize={knobProps.sizeToken} fontWeight="600">
|
|
92
|
+
{state.isLink ? "Edit Link" : "Add Link"}
|
|
93
|
+
</Text>
|
|
94
|
+
<Input
|
|
95
|
+
size="$3"
|
|
96
|
+
placeholder="https://example.com"
|
|
97
|
+
value={linkUrl}
|
|
98
|
+
onChangeText={setLinkUrl}
|
|
99
|
+
onSubmitEditing={handleSubmit}
|
|
100
|
+
autoFocus
|
|
101
|
+
/>
|
|
102
|
+
<XStack gap="$2" justifyContent="flex-end">
|
|
103
|
+
{state.isLink && (
|
|
104
|
+
<Button size="$2" theme="red" onPress={handleRemove} aria-label="Remove link">
|
|
105
|
+
Remove
|
|
106
|
+
</Button>
|
|
107
|
+
)}
|
|
108
|
+
<Button
|
|
109
|
+
size="$2"
|
|
110
|
+
theme="active"
|
|
111
|
+
onPress={handleSubmit}
|
|
112
|
+
disabled={!linkUrl.trim()}
|
|
113
|
+
aria-label={state.isLink ? "Update link" : "Add link"}
|
|
114
|
+
>
|
|
115
|
+
{state.isLink ? "Update" : "Add"}
|
|
116
|
+
</Button>
|
|
117
|
+
</XStack>
|
|
118
|
+
</YStack>
|
|
119
|
+
</Popover.Content>
|
|
120
|
+
</Popover>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export { normalizeUrl };
|