@dxos/react-ui-editor 0.8.4-main.67995b8 → 0.8.4-main.72ec0f3
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/dist/lib/browser/{chunk-22UMM3QJ.mjs → chunk-HL3YF6WC.mjs} +2 -2
- package/dist/lib/browser/chunk-HL3YF6WC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8336 -6712
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-YXYQPV6R.mjs → chunk-YJZGD3LY.mjs} +2 -2
- package/dist/lib/node-esm/chunk-YJZGD3LY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +8336 -6712
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Editor/Editor.d.ts +37 -15
- package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/components/Editor/Editor.stories.d.ts +20 -0
- package/dist/types/src/components/Editor/Editor.stories.d.ts.map +1 -0
- package/dist/types/src/components/EditorContent/EditorContent.d.ts +29 -0
- package/dist/types/src/components/EditorContent/EditorContent.d.ts.map +1 -0
- package/dist/types/src/components/EditorContent/EditorContent.stories.d.ts +26 -0
- package/dist/types/src/components/EditorContent/EditorContent.stories.d.ts.map +1 -0
- package/dist/types/src/components/EditorContent/controller.d.ts +10 -0
- package/dist/types/src/components/EditorContent/controller.d.ts.map +1 -0
- package/dist/types/src/components/EditorContent/index.d.ts +3 -0
- package/dist/types/src/components/EditorContent/index.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/EditorMenuProvider.d.ts +36 -0
- package/dist/types/src/components/EditorMenuProvider/EditorMenuProvider.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/index.d.ts +7 -0
- package/dist/types/src/components/EditorMenuProvider/index.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/menu-presets.d.ts +4 -0
- package/dist/types/src/components/EditorMenuProvider/menu-presets.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/menu.d.ts +28 -0
- package/dist/types/src/components/EditorMenuProvider/menu.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/popover.d.ts +47 -0
- package/dist/types/src/components/EditorMenuProvider/popover.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/useEditorMenu.d.ts +34 -0
- package/dist/types/src/components/EditorMenuProvider/useEditorMenu.d.ts.map +1 -0
- package/dist/types/src/components/EditorMenuProvider/util.d.ts +8 -0
- package/dist/types/src/components/EditorMenuProvider/util.d.ts.map +1 -0
- package/dist/types/src/components/EditorPreviewProvider/EditorPreviewProvider.d.ts +16 -0
- package/dist/types/src/components/EditorPreviewProvider/EditorPreviewProvider.d.ts.map +1 -0
- package/dist/types/src/components/EditorPreviewProvider/index.d.ts +2 -0
- package/dist/types/src/components/EditorPreviewProvider/index.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts +26 -2
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/actions.d.ts +39 -0
- package/dist/types/src/components/EditorToolbar/actions.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/blocks.d.ts +3 -3
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts +3 -3
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts +3 -3
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/index.d.ts +2 -1
- package/dist/types/src/components/EditorToolbar/index.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/useEditorToolbar.d.ts +11 -0
- package/dist/types/src/components/EditorToolbar/useEditorToolbar.d.ts.map +1 -0
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +3 -3
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete/autocomplete.d.ts +17 -0
- package/dist/types/src/extensions/autocomplete/autocomplete.d.ts.map +1 -0
- package/dist/types/src/extensions/autocomplete/index.d.ts +5 -0
- package/dist/types/src/extensions/autocomplete/index.d.ts.map +1 -0
- package/dist/types/src/extensions/autocomplete/match.d.ts +13 -0
- package/dist/types/src/extensions/autocomplete/match.d.ts.map +1 -0
- package/dist/types/src/extensions/autocomplete/placeholder.d.ts +20 -0
- package/dist/types/src/extensions/autocomplete/placeholder.d.ts.map +1 -0
- package/dist/types/src/extensions/autocomplete/typeahead.d.ts +10 -0
- package/dist/types/src/extensions/autocomplete/typeahead.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/automerge.d.ts +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts +10 -19
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts +3 -3
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/autoscroll.d.ts +20 -0
- package/dist/types/src/extensions/autoscroll.d.ts.map +1 -0
- package/dist/types/src/extensions/awareness/awareness-provider.d.ts +1 -1
- package/dist/types/src/extensions/awareness/awareness-provider.d.ts.map +1 -1
- package/dist/types/src/extensions/blocks.d.ts +2 -0
- package/dist/types/src/extensions/blocks.d.ts.map +1 -0
- package/dist/types/src/extensions/bookmarks.d.ts +12 -0
- package/dist/types/src/extensions/bookmarks.d.ts.map +1 -0
- package/dist/types/src/extensions/comments.d.ts +1 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/dnd.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts +11 -11
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/focus.d.ts.map +1 -1
- package/dist/types/src/extensions/folding.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +10 -1
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/json.d.ts +1 -1
- package/dist/types/src/extensions/json.d.ts.map +1 -1
- package/dist/types/src/extensions/listener.d.ts +8 -6
- package/dist/types/src/extensions/listener.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts +8 -2
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts +9 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts +2 -4
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/image.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/link.d.ts.map +1 -1
- package/dist/types/src/extensions/modal.d.ts +7 -0
- package/dist/types/src/extensions/modal.d.ts.map +1 -0
- package/dist/types/src/extensions/modes.d.ts +1 -1
- package/dist/types/src/extensions/modes.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/menu.d.ts +8 -0
- package/dist/types/src/extensions/outliner/menu.d.ts.map +1 -0
- package/dist/types/src/extensions/outliner/outliner.d.ts +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts +2 -2
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
- package/dist/types/src/extensions/preview/preview.d.ts +8 -8
- package/dist/types/src/extensions/preview/preview.d.ts.map +1 -1
- package/dist/types/src/extensions/replacer.d.ts +21 -0
- package/dist/types/src/extensions/replacer.d.ts.map +1 -0
- package/dist/types/src/extensions/replacer.test.d.ts +2 -0
- package/dist/types/src/extensions/replacer.test.d.ts.map +1 -0
- package/dist/types/src/extensions/scrolling.d.ts +78 -0
- package/dist/types/src/extensions/scrolling.d.ts.map +1 -0
- package/dist/types/src/extensions/state.d.ts +2 -0
- package/dist/types/src/extensions/state.d.ts.map +1 -0
- package/dist/types/src/extensions/submit.d.ts +10 -0
- package/dist/types/src/extensions/submit.d.ts.map +1 -0
- package/dist/types/src/extensions/tab.d.ts +4 -0
- package/dist/types/src/extensions/tab.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/extended-markdown.d.ts +10 -0
- package/dist/types/src/extensions/tags/extended-markdown.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/extended-markdown.test.d.ts +2 -0
- package/dist/types/src/extensions/tags/extended-markdown.test.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/index.d.ts +4 -0
- package/dist/types/src/extensions/tags/index.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/streamer.d.ts +12 -0
- package/dist/types/src/extensions/tags/streamer.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-tags.d.ts +97 -0
- package/dist/types/src/extensions/tags/xml-tags.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-util.d.ts +10 -0
- package/dist/types/src/extensions/tags/xml-util.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextEditor.d.ts +5 -9
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/stories/CommandDialog.stories.d.ts +14 -0
- package/dist/types/src/stories/CommandDialog.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Comments.stories.d.ts +21 -10
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/EditorToolbar.stories.d.ts +39 -3
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +22 -13
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +32 -43
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts +15 -21
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Popover.stories.d.ts +20 -0
- package/dist/types/src/stories/Popover.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Preview.stories.d.ts +22 -7
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Tags.stories.d.ts +16 -0
- package/dist/types/src/stories/Tags.stories.d.ts.map +1 -0
- package/dist/types/src/stories/TextEditor.stories.d.ts +37 -52
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +8 -9
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
- package/dist/types/src/stories/components/util.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/src/util/debug.d.ts +5 -1
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/decorations.d.ts +4 -0
- package/dist/types/src/util/decorations.d.ts.map +1 -0
- package/dist/types/src/util/dom.d.ts +2 -12
- package/dist/types/src/util/dom.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/react.d.ts +1 -1
- package/dist/types/src/util/react.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +74 -72
- package/src/components/Editor/Editor.stories.tsx +89 -0
- package/src/components/Editor/Editor.tsx +160 -25
- package/src/components/EditorContent/EditorContent.stories.tsx +70 -0
- package/src/components/EditorContent/EditorContent.tsx +70 -0
- package/src/components/EditorContent/controller.ts +50 -0
- package/src/components/EditorContent/index.ts +6 -0
- package/src/components/EditorMenuProvider/EditorMenuProvider.tsx +233 -0
- package/src/components/EditorMenuProvider/index.ts +11 -0
- package/src/components/EditorMenuProvider/menu-presets.ts +123 -0
- package/src/components/EditorMenuProvider/menu.ts +71 -0
- package/src/components/EditorMenuProvider/popover.ts +287 -0
- package/src/components/EditorMenuProvider/useEditorMenu.ts +175 -0
- package/src/components/EditorMenuProvider/util.ts +31 -0
- package/src/components/EditorPreviewProvider/EditorPreviewProvider.tsx +82 -0
- package/src/components/EditorPreviewProvider/index.ts +5 -0
- package/src/components/EditorToolbar/EditorToolbar.tsx +116 -96
- package/src/components/EditorToolbar/actions.ts +86 -0
- package/src/components/EditorToolbar/blocks.ts +22 -24
- package/src/components/EditorToolbar/formatting.ts +23 -25
- package/src/components/EditorToolbar/headings.ts +17 -9
- package/src/components/EditorToolbar/image.ts +9 -5
- package/src/components/EditorToolbar/index.ts +3 -7
- package/src/components/EditorToolbar/search.ts +9 -5
- package/src/components/EditorToolbar/useEditorToolbar.ts +20 -0
- package/src/components/EditorToolbar/view-mode.ts +12 -6
- package/src/components/index.ts +8 -2
- package/src/defaults.ts +5 -2
- package/src/extensions/autocomplete/autocomplete.ts +151 -0
- package/src/extensions/autocomplete/index.ts +8 -0
- package/src/extensions/autocomplete/match.ts +46 -0
- package/src/extensions/{command → autocomplete}/placeholder.ts +22 -18
- package/src/extensions/{command → autocomplete}/typeahead.ts +8 -50
- package/src/extensions/automerge/automerge.stories.tsx +32 -25
- package/src/extensions/automerge/automerge.ts +31 -11
- package/src/extensions/automerge/cursor.ts +1 -1
- package/src/extensions/automerge/defs.ts +1 -1
- package/src/extensions/automerge/sync.ts +9 -5
- package/src/extensions/automerge/update-automerge.ts +2 -2
- package/src/extensions/autoscroll.ts +163 -0
- package/src/extensions/awareness/awareness-provider.ts +2 -2
- package/src/extensions/awareness/awareness.ts +2 -2
- package/src/extensions/blocks.ts +131 -0
- package/src/extensions/bookmarks.ts +75 -0
- package/src/extensions/comments.ts +20 -14
- package/src/extensions/dnd.ts +1 -1
- package/src/extensions/factories.ts +54 -35
- package/src/extensions/focus.ts +5 -4
- package/src/extensions/folding.tsx +3 -6
- package/src/extensions/hashtag.tsx +2 -2
- package/src/extensions/index.ts +10 -1
- package/src/extensions/json.ts +1 -1
- package/src/extensions/listener.ts +14 -20
- package/src/extensions/markdown/action.ts +2 -1
- package/src/extensions/markdown/bundle.ts +40 -6
- package/src/extensions/markdown/changes.ts +1 -1
- package/src/extensions/markdown/decorate.ts +32 -22
- package/src/extensions/markdown/formatting.test.ts +6 -6
- package/src/extensions/markdown/formatting.ts +11 -13
- package/src/extensions/markdown/highlight.ts +2 -2
- package/src/extensions/markdown/image.ts +5 -6
- package/src/extensions/markdown/link.ts +3 -0
- package/src/extensions/markdown/table.ts +13 -7
- package/src/extensions/mention.ts +1 -1
- package/src/extensions/modal.ts +24 -0
- package/src/extensions/modes.ts +2 -2
- package/src/extensions/{command/floating-menu.ts → outliner/menu.ts} +16 -21
- package/src/extensions/outliner/outliner.test.ts +3 -2
- package/src/extensions/outliner/outliner.ts +8 -7
- package/src/extensions/outliner/selection.ts +1 -1
- package/src/extensions/outliner/tree.test.ts +3 -2
- package/src/extensions/outliner/tree.ts +2 -2
- package/src/extensions/preview/index.ts +1 -1
- package/src/extensions/preview/preview.ts +69 -69
- package/src/extensions/replacer.test.ts +75 -0
- package/src/extensions/replacer.ts +93 -0
- package/src/extensions/scrolling.ts +189 -0
- package/src/extensions/selection.ts +3 -3
- package/src/extensions/state.ts +7 -0
- package/src/extensions/submit.ts +62 -0
- package/src/extensions/tab.ts +29 -0
- package/src/extensions/tags/extended-markdown.test.ts +262 -0
- package/src/extensions/tags/extended-markdown.ts +78 -0
- package/src/extensions/tags/index.ts +7 -0
- package/src/extensions/tags/streamer.ts +243 -0
- package/src/extensions/tags/xml-tags.ts +500 -0
- package/src/extensions/tags/xml-util.ts +94 -0
- package/src/extensions/typewriter.ts +1 -1
- package/src/hooks/useTextEditor.ts +31 -43
- package/src/stories/CommandDialog.stories.tsx +83 -0
- package/src/stories/Comments.stories.tsx +17 -14
- package/src/stories/EditorToolbar.stories.tsx +21 -20
- package/src/stories/Experimental.stories.tsx +17 -13
- package/src/stories/Markdown.stories.tsx +26 -22
- package/src/stories/Outliner.stories.tsx +51 -39
- package/src/stories/Popover.stories.tsx +162 -0
- package/src/stories/Preview.stories.tsx +56 -51
- package/src/stories/Tags.stories.tsx +95 -0
- package/src/stories/TextEditor.stories.tsx +42 -61
- package/src/stories/components/EditorStory.tsx +36 -24
- package/src/stories/components/util.tsx +40 -8
- package/src/styles/markdown.ts +1 -1
- package/src/styles/theme.ts +16 -12
- package/src/translations.ts +1 -1
- package/src/types/types.ts +1 -1
- package/src/util/cursor.ts +2 -1
- package/src/util/debug.ts +7 -2
- package/src/util/decorations.ts +21 -0
- package/src/util/dom.ts +5 -27
- package/src/util/index.ts +1 -0
- package/src/util/react.tsx +1 -1
- package/dist/lib/browser/chunk-22UMM3QJ.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -6
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YXYQPV6R.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -8
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/components/EditorToolbar/lists.d.ts +0 -19
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +0 -1
- package/dist/types/src/components/EditorToolbar/util.d.ts +0 -51
- package/dist/types/src/components/EditorToolbar/util.d.ts.map +0 -1
- package/dist/types/src/components/Popover/CommandMenu.d.ts +0 -34
- package/dist/types/src/components/Popover/CommandMenu.d.ts.map +0 -1
- package/dist/types/src/components/Popover/RefDropdownMenu.d.ts +0 -21
- package/dist/types/src/components/Popover/RefDropdownMenu.d.ts.map +0 -1
- package/dist/types/src/components/Popover/RefPopover.d.ts +0 -34
- package/dist/types/src/components/Popover/RefPopover.d.ts.map +0 -1
- package/dist/types/src/components/Popover/index.d.ts +0 -4
- package/dist/types/src/components/Popover/index.d.ts.map +0 -1
- package/dist/types/src/extensions/autocomplete.d.ts +0 -13
- package/dist/types/src/extensions/autocomplete.d.ts.map +0 -1
- package/dist/types/src/extensions/command/action.d.ts +0 -17
- package/dist/types/src/extensions/command/action.d.ts.map +0 -1
- package/dist/types/src/extensions/command/command-menu.d.ts +0 -20
- package/dist/types/src/extensions/command/command-menu.d.ts.map +0 -1
- package/dist/types/src/extensions/command/command.d.ts +0 -6
- package/dist/types/src/extensions/command/command.d.ts.map +0 -1
- package/dist/types/src/extensions/command/floating-menu.d.ts +0 -7
- package/dist/types/src/extensions/command/floating-menu.d.ts.map +0 -1
- package/dist/types/src/extensions/command/hint.d.ts +0 -24
- package/dist/types/src/extensions/command/hint.d.ts.map +0 -1
- package/dist/types/src/extensions/command/index.d.ts +0 -7
- package/dist/types/src/extensions/command/index.d.ts.map +0 -1
- package/dist/types/src/extensions/command/placeholder.d.ts +0 -10
- package/dist/types/src/extensions/command/placeholder.d.ts.map +0 -1
- package/dist/types/src/extensions/command/state.d.ts +0 -16
- package/dist/types/src/extensions/command/state.d.ts.map +0 -1
- package/dist/types/src/extensions/command/typeahead.d.ts +0 -22
- package/dist/types/src/extensions/command/typeahead.d.ts.map +0 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts +0 -26
- package/dist/types/src/extensions/command/useCommandMenu.d.ts.map +0 -1
- package/dist/types/src/stories/Command.stories.d.ts +0 -7
- package/dist/types/src/stories/Command.stories.d.ts.map +0 -1
- package/dist/types/src/stories/CommandMenu.stories.d.ts +0 -13
- package/dist/types/src/stories/CommandMenu.stories.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/util.d.ts +0 -2
- package/dist/types/src/testing/util.d.ts.map +0 -1
- package/src/components/EditorToolbar/lists.ts +0 -59
- package/src/components/EditorToolbar/util.ts +0 -65
- package/src/components/Popover/CommandMenu.tsx +0 -279
- package/src/components/Popover/RefDropdownMenu.tsx +0 -85
- package/src/components/Popover/RefPopover.tsx +0 -99
- package/src/components/Popover/index.ts +0 -7
- package/src/extensions/autocomplete.ts +0 -69
- package/src/extensions/command/action.ts +0 -56
- package/src/extensions/command/command-menu.ts +0 -210
- package/src/extensions/command/command.ts +0 -34
- package/src/extensions/command/hint.ts +0 -102
- package/src/extensions/command/index.ts +0 -10
- package/src/extensions/command/state.ts +0 -89
- package/src/extensions/command/useCommandMenu.ts +0 -118
- package/src/stories/Command.stories.tsx +0 -97
- package/src/stories/CommandMenu.stories.tsx +0 -159
- package/src/testing/index.ts +0 -5
- package/src/testing/util.ts +0 -5
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { closeBrackets, closeBracketsKeymap } from '@codemirror/autocomplete';
|
|
6
6
|
import { defaultKeymap, history, historyKeymap, indentWithTab, standardKeymap } from '@codemirror/commands';
|
|
7
|
-
import {
|
|
7
|
+
import { HighlightStyle, bracketMatching, syntaxHighlighting } from '@codemirror/language';
|
|
8
8
|
import { searchKeymap } from '@codemirror/search';
|
|
9
|
-
import { EditorState, type Extension } from '@codemirror/state';
|
|
10
|
-
import { oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
|
|
9
|
+
import { type ChangeSpec, EditorState, type Extension, type TransactionSpec } from '@codemirror/state';
|
|
11
10
|
import {
|
|
12
11
|
EditorView,
|
|
13
12
|
type KeyBinding,
|
|
@@ -20,33 +19,58 @@ import {
|
|
|
20
19
|
placeholder,
|
|
21
20
|
scrollPastEnd,
|
|
22
21
|
} from '@codemirror/view';
|
|
22
|
+
import { vscodeDarkStyle, vscodeLightStyle } from '@uiw/codemirror-theme-vscode';
|
|
23
23
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
24
24
|
import merge from 'lodash.merge';
|
|
25
25
|
|
|
26
|
+
import { type DocAccessor, type Space } from '@dxos/client/echo';
|
|
27
|
+
import { type Identity } from '@dxos/client/halo';
|
|
26
28
|
import { generateName } from '@dxos/display-name';
|
|
27
29
|
import { log } from '@dxos/log';
|
|
28
|
-
import { type DocAccessor, type Space } from '@dxos/react-client/echo';
|
|
29
|
-
import { type Identity } from '@dxos/react-client/halo';
|
|
30
30
|
import { type ThemeMode } from '@dxos/react-ui';
|
|
31
31
|
import { type HuePalette } from '@dxos/react-ui-theme';
|
|
32
|
-
import { hexToHue,
|
|
32
|
+
import { hexToHue, isTruthy } from '@dxos/util';
|
|
33
|
+
|
|
34
|
+
import { editorGutter, editorMonospace } from '../defaults';
|
|
35
|
+
import { type ThemeStyles, defaultTheme } from '../styles';
|
|
33
36
|
|
|
34
37
|
import { automerge } from './automerge';
|
|
35
38
|
import { SpaceAwarenessProvider, awareness } from './awareness';
|
|
36
39
|
import { focus } from './focus';
|
|
37
|
-
import { editorGutter, editorMonospace } from '../defaults';
|
|
38
|
-
import { type ThemeStyles, defaultTheme } from '../styles';
|
|
39
40
|
|
|
40
41
|
//
|
|
41
42
|
// Basic
|
|
42
43
|
//
|
|
43
44
|
|
|
44
|
-
export const
|
|
45
|
+
export const filterChars = (chars: RegExp) => {
|
|
46
|
+
return EditorState.transactionFilter.of((transaction) => {
|
|
47
|
+
if (!transaction.docChanged) return transaction;
|
|
48
|
+
|
|
49
|
+
const changes: ChangeSpec[] = [];
|
|
50
|
+
transaction.changes.iterChanges((fromA, toA, fromB, toB, text) => {
|
|
51
|
+
const inserted = text.toString();
|
|
52
|
+
const filtered = inserted.replace(chars, '');
|
|
53
|
+
if (inserted !== filtered) {
|
|
54
|
+
changes.push({
|
|
55
|
+
from: fromB,
|
|
56
|
+
to: toB,
|
|
57
|
+
insert: filtered,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (changes.length) {
|
|
63
|
+
return [transaction, { changes, sequential: true } as TransactionSpec];
|
|
64
|
+
}
|
|
65
|
+
return transaction;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
45
68
|
|
|
46
69
|
/**
|
|
47
70
|
* https://codemirror.net/docs/extensions
|
|
48
71
|
* https://github.com/codemirror/basic-setup
|
|
49
72
|
* https://github.com/codemirror/basic-setup/blob/main/src/codemirror.ts
|
|
73
|
+
* https://github.com/codemirror/theme-one-dark
|
|
50
74
|
*/
|
|
51
75
|
export type BasicExtensionsOptions = {
|
|
52
76
|
allowMultipleSelections?: boolean;
|
|
@@ -63,11 +87,11 @@ export type BasicExtensionsOptions = {
|
|
|
63
87
|
lineNumbers?: boolean;
|
|
64
88
|
/** If false then do not set a max-width or side margin on the editor. */
|
|
65
89
|
lineWrapping?: boolean;
|
|
66
|
-
monospace?: boolean;
|
|
67
90
|
placeholder?: string;
|
|
68
91
|
/** If true user cannot edit the text, but they can still select and copy it. */
|
|
69
92
|
readOnly?: boolean;
|
|
70
93
|
search?: boolean;
|
|
94
|
+
/** NOTE: Do not use with stack sections. */
|
|
71
95
|
scrollPastEnd?: boolean;
|
|
72
96
|
standardKeymap?: boolean;
|
|
73
97
|
tabSize?: number;
|
|
@@ -82,7 +106,7 @@ const defaultBasicOptions: BasicExtensionsOptions = {
|
|
|
82
106
|
history: true,
|
|
83
107
|
keymap: 'standard',
|
|
84
108
|
lineWrapping: true,
|
|
85
|
-
search:
|
|
109
|
+
search: false,
|
|
86
110
|
} as const;
|
|
87
111
|
|
|
88
112
|
const keymaps: { [key: string]: readonly KeyBinding[] } = {
|
|
@@ -111,7 +135,6 @@ export const createBasicExtensions = (_props?: BasicExtensionsOptions): Extensio
|
|
|
111
135
|
props.history && history(),
|
|
112
136
|
props.lineNumbers && [lineNumbers(), editorGutter],
|
|
113
137
|
props.lineWrapping && EditorView.lineWrapping,
|
|
114
|
-
props.monospace && editorMonospace,
|
|
115
138
|
props.placeholder && placeholder(props.placeholder),
|
|
116
139
|
props.readOnly !== undefined && EditorState.readOnly.of(props.readOnly),
|
|
117
140
|
props.scrollPastEnd && scrollPastEnd(),
|
|
@@ -137,9 +160,9 @@ export const createBasicExtensions = (_props?: BasicExtensionsOptions): Extensio
|
|
|
137
160
|
preventDefault: true,
|
|
138
161
|
run: () => true,
|
|
139
162
|
},
|
|
140
|
-
].filter(
|
|
163
|
+
].filter(isTruthy),
|
|
141
164
|
),
|
|
142
|
-
].filter(
|
|
165
|
+
].filter(isTruthy);
|
|
143
166
|
};
|
|
144
167
|
|
|
145
168
|
//
|
|
@@ -148,6 +171,7 @@ export const createBasicExtensions = (_props?: BasicExtensionsOptions): Extensio
|
|
|
148
171
|
|
|
149
172
|
export type ThemeExtensionsOptions = {
|
|
150
173
|
themeMode?: ThemeMode;
|
|
174
|
+
monospace?: boolean;
|
|
151
175
|
styles?: ThemeStyles;
|
|
152
176
|
syntaxHighlighting?: boolean;
|
|
153
177
|
slots?: {
|
|
@@ -155,9 +179,7 @@ export type ThemeExtensionsOptions = {
|
|
|
155
179
|
className?: string;
|
|
156
180
|
};
|
|
157
181
|
scroll?: {
|
|
158
|
-
|
|
159
|
-
};
|
|
160
|
-
scroller?: {
|
|
182
|
+
// NOTE: Do not apply vertical padding to scroll container.
|
|
161
183
|
className?: string;
|
|
162
184
|
};
|
|
163
185
|
content?: {
|
|
@@ -180,41 +202,39 @@ export const fullWidth: ThemeExtensionsOptions['slots'] = {
|
|
|
180
202
|
|
|
181
203
|
export const defaultThemeSlots = grow;
|
|
182
204
|
|
|
205
|
+
export const defaultStyles = {
|
|
206
|
+
dark: vscodeDarkStyle,
|
|
207
|
+
light: vscodeLightStyle,
|
|
208
|
+
};
|
|
209
|
+
|
|
183
210
|
/**
|
|
184
211
|
* https://codemirror.net/examples/styling
|
|
185
212
|
*/
|
|
186
213
|
export const createThemeExtensions = ({
|
|
187
214
|
themeMode,
|
|
215
|
+
monospace,
|
|
188
216
|
styles,
|
|
189
|
-
syntaxHighlighting:
|
|
190
|
-
slots:
|
|
217
|
+
syntaxHighlighting: syntaxHighlightingProp,
|
|
218
|
+
slots: slotsParam,
|
|
191
219
|
}: ThemeExtensionsOptions = {}): Extension => {
|
|
192
|
-
const slots = defaultsDeep({},
|
|
220
|
+
const slots = defaultsDeep({}, slotsParam, defaultThemeSlots);
|
|
193
221
|
return [
|
|
194
222
|
EditorView.darkTheme.of(themeMode === 'dark'),
|
|
195
223
|
EditorView.baseTheme(styles ? merge({}, defaultTheme, styles) : defaultTheme),
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
(themeMode === 'dark' ?
|
|
224
|
+
monospace && editorMonospace,
|
|
225
|
+
syntaxHighlightingProp &&
|
|
226
|
+
syntaxHighlighting(HighlightStyle.define(themeMode === 'dark' ? defaultStyles.dark : defaultStyles.light)),
|
|
199
227
|
slots.editor?.className && EditorView.editorAttributes.of({ class: slots.editor.className }),
|
|
200
228
|
slots.content?.className && EditorView.contentAttributes.of({ class: slots.content.className }),
|
|
201
229
|
slots.scroll?.className &&
|
|
202
230
|
ViewPlugin.fromClass(
|
|
203
231
|
class {
|
|
204
232
|
constructor(view: EditorView) {
|
|
205
|
-
view.scrollDOM.classList.add(slots.scroll.className);
|
|
233
|
+
view.scrollDOM.classList.add(...slots.scroll.className.split(/\s+/));
|
|
206
234
|
}
|
|
207
235
|
},
|
|
208
236
|
),
|
|
209
|
-
|
|
210
|
-
ViewPlugin.fromClass(
|
|
211
|
-
class {
|
|
212
|
-
constructor(view: EditorView) {
|
|
213
|
-
view.dom.querySelector('.cm-scroller')?.classList.add(...slots.scroller.className.split(' '));
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
),
|
|
217
|
-
].filter(isNotFalsy);
|
|
237
|
+
].filter(isTruthy);
|
|
218
238
|
};
|
|
219
239
|
|
|
220
240
|
//
|
|
@@ -238,7 +258,6 @@ export const createDataExtensions = <T>({ id, text, space, identity }: DataExten
|
|
|
238
258
|
if (space && identity) {
|
|
239
259
|
const peerId = identity?.identityKey.toHex();
|
|
240
260
|
const hue = (identity?.profile?.data?.hue as HuePalette | undefined) ?? hexToHue(peerId ?? '0');
|
|
241
|
-
|
|
242
261
|
extensions.push(
|
|
243
262
|
awareness(
|
|
244
263
|
new SpaceAwarenessProvider({
|
|
@@ -246,9 +265,9 @@ export const createDataExtensions = <T>({ id, text, space, identity }: DataExten
|
|
|
246
265
|
channel: `awareness.${id}`,
|
|
247
266
|
peerId: identity.identityKey.toHex(),
|
|
248
267
|
info: {
|
|
249
|
-
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex()),
|
|
250
268
|
darkColor: `var(--dx-${hue}Cursor)`,
|
|
251
269
|
lightColor: `var(--dx-${hue}Cursor)`,
|
|
270
|
+
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex()),
|
|
252
271
|
},
|
|
253
272
|
}),
|
|
254
273
|
),
|
package/src/extensions/focus.ts
CHANGED
|
@@ -15,6 +15,7 @@ export const focusField = StateField.define<boolean>({
|
|
|
15
15
|
return effect.value;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
|
|
18
19
|
return value;
|
|
19
20
|
},
|
|
20
21
|
});
|
|
@@ -25,11 +26,11 @@ export const focusField = StateField.define<boolean>({
|
|
|
25
26
|
export const focus = [
|
|
26
27
|
focusField,
|
|
27
28
|
EditorView.domEventHandlers({
|
|
28
|
-
focus: (
|
|
29
|
-
|
|
29
|
+
focus: (_event, view) => {
|
|
30
|
+
requestAnimationFrame(() => view.dispatch({ effects: focusEffect.of(true) }));
|
|
30
31
|
},
|
|
31
|
-
blur: (
|
|
32
|
-
|
|
32
|
+
blur: (_event, view) => {
|
|
33
|
+
requestAnimationFrame(() => view.dispatch({ effects: focusEffect.of(false) }));
|
|
33
34
|
},
|
|
34
35
|
}),
|
|
35
36
|
];
|
|
@@ -7,16 +7,15 @@ import { type Extension } from '@codemirror/state';
|
|
|
7
7
|
import { EditorView } from '@codemirror/view';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
|
-
import { Icon } from '@dxos/react-ui';
|
|
10
|
+
import { Domino, Icon } from '@dxos/react-ui';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { renderRoot } from '../util';
|
|
13
13
|
|
|
14
14
|
export type FoldingOptions = {};
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* https://codemirror.net/examples/gutter
|
|
18
18
|
*/
|
|
19
|
-
// TODO(burdon): Remember folding state (to state).
|
|
20
19
|
export const folding = (_props: FoldingOptions = {}): Extension => [
|
|
21
20
|
codeFolding({
|
|
22
21
|
placeholderDOM: () => {
|
|
@@ -25,10 +24,8 @@ export const folding = (_props: FoldingOptions = {}): Extension => [
|
|
|
25
24
|
}),
|
|
26
25
|
foldGutter({
|
|
27
26
|
markerDOM: (open) => {
|
|
28
|
-
// TODO(burdon): Use sprite directly.
|
|
29
|
-
const el = createElement('div', { className: 'flex h-full items-center' });
|
|
30
27
|
return renderRoot(
|
|
31
|
-
|
|
28
|
+
Domino.of('div').classNames('flex bs-full items-center').build(),
|
|
32
29
|
<Icon icon='ph--caret-right--bold' size={3} classNames={['mx-3 cursor-pointer', open && 'rotate-90']} />,
|
|
33
30
|
);
|
|
34
31
|
},
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
WidgetType,
|
|
14
14
|
} from '@codemirror/view';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { getHashStyles, mx } from '@dxos/react-ui-theme';
|
|
17
17
|
|
|
18
18
|
class TagWidget extends WidgetType {
|
|
19
19
|
constructor(private _text: string) {
|
|
@@ -22,7 +22,7 @@ class TagWidget extends WidgetType {
|
|
|
22
22
|
|
|
23
23
|
toDOM(): HTMLSpanElement {
|
|
24
24
|
const span = document.createElement('span');
|
|
25
|
-
span.className = mx('cm-tag',
|
|
25
|
+
span.className = mx('cm-tag', getHashStyles(this._text).surface);
|
|
26
26
|
span.textContent = this._text;
|
|
27
27
|
return span;
|
|
28
28
|
}
|
package/src/extensions/index.ts
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
export * from './annotations';
|
|
6
6
|
export * from './autocomplete';
|
|
7
|
+
export * from './autoscroll';
|
|
7
8
|
export * from './automerge';
|
|
8
9
|
export * from './awareness';
|
|
9
10
|
export * from './blast';
|
|
10
|
-
export * from './
|
|
11
|
+
export * from './blocks';
|
|
12
|
+
export * from './bookmarks';
|
|
11
13
|
export * from './comments';
|
|
12
14
|
export * from './debug';
|
|
13
15
|
export * from './dnd';
|
|
@@ -19,8 +21,15 @@ export * from './json';
|
|
|
19
21
|
export * from './listener';
|
|
20
22
|
export * from './markdown';
|
|
21
23
|
export * from './mention';
|
|
24
|
+
export * from './modal';
|
|
22
25
|
export * from './modes';
|
|
23
26
|
export * from './outliner';
|
|
24
27
|
export * from './preview';
|
|
28
|
+
export * from './replacer';
|
|
25
29
|
export * from './selection';
|
|
30
|
+
export * from './scrolling';
|
|
31
|
+
export * from './state';
|
|
32
|
+
export * from './submit';
|
|
33
|
+
export * from './tab';
|
|
34
|
+
export * from './tags';
|
|
26
35
|
export * from './typewriter';
|
package/src/extensions/json.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type LintSource, linter } from '@codemirror/lint';
|
|
|
7
7
|
import { type Extension } from '@codemirror/state';
|
|
8
8
|
import Ajv, { type ValidateFunction } from 'ajv';
|
|
9
9
|
|
|
10
|
-
import { type JsonSchemaType } from '@dxos/echo
|
|
10
|
+
import { type JsonSchemaType } from '@dxos/echo/internal';
|
|
11
11
|
|
|
12
12
|
export type JsonExtensionsOptions = {
|
|
13
13
|
schema?: JsonSchemaType;
|
|
@@ -5,34 +5,28 @@
|
|
|
5
5
|
import { type Extension } from '@codemirror/state';
|
|
6
6
|
import { EditorView } from '@codemirror/view';
|
|
7
7
|
|
|
8
|
+
import { isNonNullable } from '@dxos/util';
|
|
9
|
+
|
|
8
10
|
import { documentId } from './selection';
|
|
9
11
|
|
|
10
12
|
export type ListenerOptions = {
|
|
11
|
-
onFocus?: (focusing: boolean) => void;
|
|
12
|
-
onChange?: (
|
|
13
|
+
onFocus?: (event: { id: string; focusing: boolean }) => void;
|
|
14
|
+
onChange?: (event: { id: string; text: string }) => void;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
|
-
/**
|
|
16
|
-
* Event listener.
|
|
17
|
-
* @deprecated Use EditorView.updateListener and listen for specific update events.
|
|
18
|
-
*/
|
|
19
17
|
export const listener = ({ onFocus, onChange }: ListenerOptions): Extension => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
EditorView.focusChangeEffect.of((_, focusing) => {
|
|
25
|
-
onFocus(focusing);
|
|
18
|
+
return [
|
|
19
|
+
onFocus &&
|
|
20
|
+
EditorView.focusChangeEffect.of((state, focusing) => {
|
|
21
|
+
onFocus({ id: state.facet(documentId), focusing });
|
|
26
22
|
return null;
|
|
27
23
|
}),
|
|
28
|
-
);
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
onChange &&
|
|
26
|
+
EditorView.updateListener.of(({ state, docChanged }) => {
|
|
27
|
+
if (docChanged) {
|
|
28
|
+
onChange({ id: state.facet(documentId), text: state.doc.toString() });
|
|
29
|
+
}
|
|
34
30
|
}),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return extensions;
|
|
31
|
+
].filter(isNonNullable);
|
|
38
32
|
};
|
|
@@ -7,6 +7,8 @@ import { type EditorView } from '@codemirror/view';
|
|
|
7
7
|
import { type Action } from '@dxos/app-graph';
|
|
8
8
|
import { type MenuActionProperties } from '@dxos/react-ui-menu';
|
|
9
9
|
|
|
10
|
+
import { createComment } from '../comments';
|
|
11
|
+
|
|
10
12
|
import {
|
|
11
13
|
Inline,
|
|
12
14
|
List,
|
|
@@ -25,7 +27,6 @@ import {
|
|
|
25
27
|
toggleList,
|
|
26
28
|
toggleStyle,
|
|
27
29
|
} from './formatting';
|
|
28
|
-
import { createComment } from '../comments';
|
|
29
30
|
|
|
30
31
|
export type PayloadType =
|
|
31
32
|
| 'view-mode'
|
|
@@ -4,20 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import { completionKeymap } from '@codemirror/autocomplete';
|
|
6
6
|
import { defaultKeymap, indentWithTab } from '@codemirror/commands';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { jsonLanguage } from '@codemirror/lang-json';
|
|
8
|
+
import { markdown, markdownLanguage } from '@codemirror/lang-markdown';
|
|
9
|
+
import { xml } from '@codemirror/lang-xml';
|
|
10
|
+
import { LanguageDescription, syntaxHighlighting } from '@codemirror/language';
|
|
9
11
|
import { languages } from '@codemirror/language-data';
|
|
10
12
|
import { type Extension } from '@codemirror/state';
|
|
11
13
|
import { keymap } from '@codemirror/view';
|
|
14
|
+
import { type MarkdownConfig } from '@lezer/markdown';
|
|
12
15
|
|
|
13
|
-
import {
|
|
14
|
-
import { isNotFalsy } from '@dxos/util';
|
|
16
|
+
import { isTruthy } from '@dxos/util';
|
|
15
17
|
|
|
16
18
|
import { markdownHighlightStyle, markdownTagsExtensions } from './highlight';
|
|
17
19
|
|
|
18
20
|
export type MarkdownBundleOptions = {
|
|
19
|
-
|
|
21
|
+
extensions?: MarkdownConfig[];
|
|
20
22
|
indentWithTab?: boolean;
|
|
23
|
+
setextHeading?: boolean;
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
/**
|
|
@@ -42,6 +45,7 @@ export const createMarkdownExtensions = (options: MarkdownBundleOptions = {}): E
|
|
|
42
45
|
base: markdownLanguage,
|
|
43
46
|
|
|
44
47
|
// Languages for syntax highlighting fenced code blocks.
|
|
48
|
+
defaultCodeLanguage: jsonLanguage,
|
|
45
49
|
codeLanguages: languages,
|
|
46
50
|
|
|
47
51
|
// Don't complete HTML tags.
|
|
@@ -51,6 +55,7 @@ export const createMarkdownExtensions = (options: MarkdownBundleOptions = {}): E
|
|
|
51
55
|
extensions: [
|
|
52
56
|
// GFM provided by default.
|
|
53
57
|
markdownTagsExtensions,
|
|
58
|
+
...(options.extensions ?? defaultExtensions()),
|
|
54
59
|
],
|
|
55
60
|
}),
|
|
56
61
|
|
|
@@ -64,8 +69,37 @@ export const createMarkdownExtensions = (options: MarkdownBundleOptions = {}): E
|
|
|
64
69
|
|
|
65
70
|
// https://codemirror.net/docs/ref/#commands.defaultKeymap
|
|
66
71
|
...defaultKeymap,
|
|
72
|
+
|
|
73
|
+
// TODO(burdon): Remove?
|
|
67
74
|
...completionKeymap,
|
|
68
|
-
].filter(
|
|
75
|
+
].filter(isTruthy),
|
|
69
76
|
),
|
|
70
77
|
];
|
|
71
78
|
};
|
|
79
|
+
|
|
80
|
+
const xmlLanguageDesc = LanguageDescription.of({
|
|
81
|
+
name: 'xml',
|
|
82
|
+
alias: ['html', 'xhtml'],
|
|
83
|
+
extensions: ['xml', 'xhtml'],
|
|
84
|
+
load: async () => xml(),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Default customizations.
|
|
89
|
+
* https://github.com/lezer-parser/markdown/blob/main/src/markdown.ts
|
|
90
|
+
*/
|
|
91
|
+
export const defaultExtensions = (): MarkdownConfig[] => [noSetExtHeading, noHtml];
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Remove SetextHeading (e.g., headings created from "---").
|
|
95
|
+
*/
|
|
96
|
+
const noSetExtHeading: MarkdownConfig = {
|
|
97
|
+
remove: ['SetextHeading'],
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Remove HTML and XML parsing.
|
|
102
|
+
*/
|
|
103
|
+
const noHtml: MarkdownConfig = {
|
|
104
|
+
// remove: ['HTMLBlock', 'HTMLTag'],
|
|
105
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { syntaxTree } from '@codemirror/language';
|
|
6
6
|
import { type ChangeSpec, Transaction } from '@codemirror/state';
|
|
7
|
-
import { ViewPlugin, type ViewUpdate
|
|
7
|
+
import { type PluginValue, ViewPlugin, type ViewUpdate } from '@codemirror/view';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Monitors and augments changes.
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { syntaxTree } from '@codemirror/language';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { type EditorState, Prec, RangeSetBuilder, StateEffect } from '@codemirror/state';
|
|
7
|
+
import { Decoration, type DecorationSet, EditorView, ViewPlugin, type ViewUpdate, WidgetType } from '@codemirror/view';
|
|
8
8
|
import { type SyntaxNodeRef } from '@lezer/common';
|
|
9
9
|
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
12
12
|
|
|
13
|
+
import { type HeadingLevel, theme } from '../../styles';
|
|
14
|
+
import { type RenderCallback } from '../../types';
|
|
15
|
+
import { wrapWithCatch } from '../../util';
|
|
16
|
+
|
|
13
17
|
import { adjustChanges } from './changes';
|
|
14
18
|
import { image } from './image';
|
|
15
|
-
import {
|
|
19
|
+
import { bulletListIndentationWidth, formattingStyles, orderedListIndentationWidth } from './styles';
|
|
16
20
|
import { table } from './table';
|
|
17
|
-
import { theme, type HeadingLevel } from '../../styles';
|
|
18
|
-
import { type RenderCallback } from '../../types';
|
|
19
|
-
import { wrapWithCatch } from '../../util';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Unicode characters.
|
|
@@ -51,12 +52,12 @@ class LinkButton extends WidgetType {
|
|
|
51
52
|
super();
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
override eq(other: this)
|
|
55
|
+
override eq(other: this) {
|
|
55
56
|
return this.url === other.url;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
// TODO(burdon): Create icon and link directly without react?
|
|
59
|
-
override toDOM(view: EditorView)
|
|
60
|
+
override toDOM(view: EditorView) {
|
|
60
61
|
const el = document.createElement('span');
|
|
61
62
|
this.render(el, { url: this.url }, view);
|
|
62
63
|
return el;
|
|
@@ -68,11 +69,15 @@ class CheckboxWidget extends WidgetType {
|
|
|
68
69
|
super();
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
override eq(other: this)
|
|
72
|
+
override eq(other: this) {
|
|
72
73
|
return this._checked === other._checked;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
override
|
|
76
|
+
override ignoreEvent() {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
override toDOM(view: EditorView) {
|
|
76
81
|
const input = document.createElement('input');
|
|
77
82
|
input.className = 'cm-task-checkbox dx-checkbox';
|
|
78
83
|
input.type = 'checkbox';
|
|
@@ -104,10 +109,6 @@ class CheckboxWidget extends WidgetType {
|
|
|
104
109
|
span.appendChild(input);
|
|
105
110
|
return span;
|
|
106
111
|
}
|
|
107
|
-
|
|
108
|
-
override ignoreEvent(): boolean {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
class TextWidget extends WidgetType {
|
|
@@ -233,7 +234,7 @@ const buildDecorations = (view: EditorView, options: DecorateOptions, focus: boo
|
|
|
233
234
|
const mark = node.node.firstChild!;
|
|
234
235
|
if (mark?.name === 'HeaderMark') {
|
|
235
236
|
const { from, to = 6 } = options.numberedHeadings ?? {};
|
|
236
|
-
const text =
|
|
237
|
+
const text = state.sliceDoc(node.from, node.to);
|
|
237
238
|
const len = text.match(/[#\s]+/)![0].length;
|
|
238
239
|
if (!from || level < from || level > to) {
|
|
239
240
|
atomicDeco.add(mark.from, mark.from + len, hide);
|
|
@@ -426,6 +427,9 @@ const buildDecorations = (view: EditorView, options: DecorateOptions, focus: boo
|
|
|
426
427
|
const editing = editingRange(state, node, focus);
|
|
427
428
|
if (urlNode && marks.length >= 2) {
|
|
428
429
|
const url = state.sliceDoc(urlNode.from, urlNode.to);
|
|
430
|
+
if (options.skip?.({ name: 'Link', url })) {
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
429
433
|
if (!editing) {
|
|
430
434
|
atomicDeco.add(node.from, marks[0].to, hide);
|
|
431
435
|
}
|
|
@@ -443,6 +447,7 @@ const buildDecorations = (view: EditorView, options: DecorateOptions, focus: boo
|
|
|
443
447
|
},
|
|
444
448
|
}),
|
|
445
449
|
);
|
|
450
|
+
|
|
446
451
|
if (!editing) {
|
|
447
452
|
atomicDeco.add(
|
|
448
453
|
marks[1].from,
|
|
@@ -493,15 +498,15 @@ const buildDecorations = (view: EditorView, options: DecorateOptions, focus: boo
|
|
|
493
498
|
tree.iterate({
|
|
494
499
|
from,
|
|
495
500
|
to,
|
|
496
|
-
enter: wrapWithCatch(enterNode),
|
|
497
|
-
leave: wrapWithCatch(leaveNode),
|
|
501
|
+
enter: wrapWithCatch(enterNode, 'decorate.enter'),
|
|
502
|
+
leave: wrapWithCatch(leaveNode, 'decorate.leave'),
|
|
498
503
|
});
|
|
499
504
|
}
|
|
500
505
|
} else {
|
|
501
506
|
// NOTE: If line numbering then we must iterate from the start of document.
|
|
502
507
|
tree.iterate({
|
|
503
|
-
enter: wrapWithCatch(enterNode),
|
|
504
|
-
leave: wrapWithCatch(leaveNode),
|
|
508
|
+
enter: wrapWithCatch(enterNode, 'decorate.enter'),
|
|
509
|
+
leave: wrapWithCatch(leaveNode, 'decorate.leave'),
|
|
505
510
|
});
|
|
506
511
|
}
|
|
507
512
|
|
|
@@ -513,15 +518,20 @@ const buildDecorations = (view: EditorView, options: DecorateOptions, focus: boo
|
|
|
513
518
|
|
|
514
519
|
const forceUpdate = StateEffect.define<null>();
|
|
515
520
|
|
|
521
|
+
export type NodeData = { name: 'Link'; url: string } | { name: 'Image'; url: string };
|
|
522
|
+
|
|
516
523
|
export interface DecorateOptions {
|
|
517
524
|
/**
|
|
518
525
|
* Prevents triggering decorations as the cursor moves through the document.
|
|
519
526
|
*/
|
|
520
527
|
selectionChangeDelay?: number;
|
|
521
528
|
numberedHeadings?: { from: number; to?: number };
|
|
522
|
-
renderLinkButton?: RenderCallback<{ url: string }>;
|
|
523
529
|
// TODO(burdon): Additional padding for each line.
|
|
524
530
|
listPaddingLeft?: number;
|
|
531
|
+
// TODO(burdon): Use consistently.
|
|
532
|
+
skip?: (node: NodeData) => boolean;
|
|
533
|
+
// TODO(burdon): Remove.
|
|
534
|
+
renderLinkButton?: RenderCallback<{ url: string }>;
|
|
525
535
|
}
|
|
526
536
|
|
|
527
537
|
export const decorateMarkdown = (options: DecorateOptions = {}) => {
|
|
@@ -577,9 +587,9 @@ export const decorateMarkdown = (options: DecorateOptions = {}) => {
|
|
|
577
587
|
},
|
|
578
588
|
{
|
|
579
589
|
provide: (plugin) => [
|
|
580
|
-
EditorView.
|
|
590
|
+
Prec.low(EditorView.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration.none)),
|
|
581
591
|
EditorView.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration.none),
|
|
582
|
-
EditorView.
|
|
592
|
+
EditorView.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration.none),
|
|
583
593
|
],
|
|
584
594
|
},
|
|
585
595
|
),
|
|
@@ -7,21 +7,21 @@ import { EditorState, type StateCommand } from '@codemirror/state';
|
|
|
7
7
|
import { describe, expect, test } from 'vitest';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
+
type Formatting,
|
|
11
|
+
Inline,
|
|
12
|
+
List,
|
|
10
13
|
addBlockquote,
|
|
11
14
|
addCodeblock,
|
|
12
15
|
addLink,
|
|
13
16
|
addList,
|
|
14
17
|
addStyle,
|
|
15
18
|
getFormatting,
|
|
16
|
-
removeStyle,
|
|
17
|
-
removeLink,
|
|
18
|
-
removeList,
|
|
19
19
|
removeBlockquote,
|
|
20
20
|
removeCodeblock,
|
|
21
|
+
removeLink,
|
|
22
|
+
removeList,
|
|
23
|
+
removeStyle,
|
|
21
24
|
setHeading,
|
|
22
|
-
Inline,
|
|
23
|
-
List,
|
|
24
|
-
type Formatting,
|
|
25
25
|
} from './formatting';
|
|
26
26
|
|
|
27
27
|
export const emptyFormatting: Formatting = {
|