@datalayer/lexical-loro 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -137
- package/lib/App.d.ts +2 -0
- package/lib/App.js +141 -0
- package/lib/Editor.d.ts +2 -0
- package/lib/Editor.js +111 -0
- package/lib/Settings.d.ts +2 -0
- package/lib/Settings.js +57 -0
- package/lib/appSettings.d.ts +36 -0
- package/lib/appSettings.js +44 -0
- package/lib/collab/loro/Bindings.d.ts +41 -0
- package/lib/collab/loro/Bindings.js +95 -0
- package/lib/collab/loro/Debug.d.ts +33 -0
- package/lib/collab/loro/Debug.js +448 -0
- package/lib/collab/loro/LexicalCollaborationContext.d.ts +19 -0
- package/lib/collab/loro/LexicalCollaborationContext.js +48 -0
- package/lib/collab/loro/LexicalCollaborationPlugin.d.ts +24 -0
- package/lib/collab/loro/LexicalCollaborationPlugin.js +83 -0
- package/lib/collab/loro/State.d.ts +53 -0
- package/lib/collab/loro/State.js +90 -0
- package/lib/collab/loro/components/LoroCollaborationUI.d.ts +13 -0
- package/lib/collab/loro/components/LoroCollaborationUI.js +9 -0
- package/lib/collab/loro/components/LoroCollaborators.d.ts +8 -0
- package/lib/collab/loro/components/LoroCollaborators.js +97 -0
- package/lib/collab/loro/components/index.d.ts +2 -0
- package/lib/collab/loro/components/index.js +2 -0
- package/lib/collab/loro/index.d.ts +6 -0
- package/lib/collab/loro/index.js +6 -0
- package/lib/collab/loro/integrators/BaseIntegrator.d.ts +14 -0
- package/lib/collab/loro/integrators/BaseIntegrator.js +1 -0
- package/lib/collab/loro/integrators/CounterIntegrator.d.ts +23 -0
- package/lib/collab/loro/integrators/CounterIntegrator.js +40 -0
- package/lib/collab/loro/integrators/ListIntegrator.d.ts +23 -0
- package/lib/collab/loro/integrators/ListIntegrator.js +49 -0
- package/lib/collab/loro/integrators/MapIntegrator.d.ts +24 -0
- package/lib/collab/loro/integrators/MapIntegrator.js +177 -0
- package/lib/collab/loro/integrators/TextIntegrator.d.ts +25 -0
- package/lib/collab/loro/integrators/TextIntegrator.js +51 -0
- package/lib/collab/loro/integrators/TreeIntegrator.d.ts +25 -0
- package/lib/collab/loro/integrators/TreeIntegrator.js +201 -0
- package/lib/collab/loro/nodes/NodeFactory.d.ts +8 -0
- package/lib/collab/loro/nodes/NodeFactory.js +105 -0
- package/lib/collab/loro/nodes/NodesMapper.d.ts +111 -0
- package/lib/collab/loro/nodes/NodesMapper.js +258 -0
- package/lib/collab/loro/propagators/DecoratorNodePropagator.d.ts +60 -0
- package/lib/collab/loro/propagators/DecoratorNodePropagator.js +302 -0
- package/lib/collab/loro/propagators/ElementNodePropagator.d.ts +62 -0
- package/lib/collab/loro/propagators/ElementNodePropagator.js +335 -0
- package/lib/collab/loro/propagators/LineBreakNodePropagator.d.ts +57 -0
- package/lib/collab/loro/propagators/LineBreakNodePropagator.js +196 -0
- package/lib/collab/loro/propagators/RootNodePropagator.d.ts +55 -0
- package/lib/collab/loro/propagators/RootNodePropagator.js +168 -0
- package/lib/collab/loro/propagators/TextNodePropagator.d.ts +60 -0
- package/lib/collab/loro/propagators/TextNodePropagator.js +434 -0
- package/lib/collab/loro/propagators/index.d.ts +49 -0
- package/lib/collab/loro/propagators/index.js +32 -0
- package/lib/collab/loro/provider/websocket.d.ts +116 -0
- package/lib/collab/loro/provider/websocket.js +907 -0
- package/lib/collab/loro/servers/index.d.ts +0 -0
- package/lib/collab/loro/servers/index.js +0 -0
- package/lib/collab/loro/servers/ws/callback.d.ts +5 -0
- package/lib/collab/loro/servers/ws/callback.js +85 -0
- package/lib/collab/loro/servers/ws/server.d.ts +2 -0
- package/lib/collab/loro/servers/ws/server.js +25 -0
- package/lib/collab/loro/servers/ws/utils.d.ts +40 -0
- package/lib/collab/loro/servers/ws/utils.js +513 -0
- package/lib/collab/loro/sync/SyncCursors.d.ts +32 -0
- package/lib/collab/loro/sync/SyncCursors.js +435 -0
- package/lib/collab/loro/sync/SyncLexicalToLoro.d.ts +4 -0
- package/lib/collab/loro/sync/SyncLexicalToLoro.js +80 -0
- package/lib/collab/loro/sync/SyncLoroToLexical.d.ts +5 -0
- package/lib/collab/loro/sync/SyncLoroToLexical.js +96 -0
- package/lib/collab/loro/types/LexicalNodeData.d.ts +32 -0
- package/lib/collab/loro/types/LexicalNodeData.js +71 -0
- package/lib/collab/loro/useCollaboration.d.ts +12 -0
- package/lib/collab/loro/useCollaboration.js +248 -0
- package/lib/collab/loro/utils/InitialContent.d.ts +64 -0
- package/lib/collab/loro/utils/InitialContent.js +109 -0
- package/lib/collab/loro/utils/LexicalToLoro.d.ts +18 -0
- package/lib/collab/loro/utils/LexicalToLoro.js +96 -0
- package/lib/collab/loro/utils/Utils.d.ts +44 -0
- package/lib/collab/loro/utils/Utils.js +153 -0
- package/lib/collab/loro/wsProvider.d.ts +8 -0
- package/lib/collab/loro/wsProvider.js +31 -0
- package/lib/collab/utils/invariant.d.ts +1 -0
- package/lib/collab/utils/invariant.js +11 -0
- package/lib/collab/utils/simpleDiffWithCursor.d.ts +5 -0
- package/lib/collab/utils/simpleDiffWithCursor.js +31 -0
- package/lib/collab/yjs/Bindings.d.ts +23 -0
- package/lib/collab/yjs/Bindings.js +26 -0
- package/lib/collab/yjs/Debug.d.ts +23 -0
- package/lib/collab/yjs/Debug.js +213 -0
- package/lib/collab/yjs/LexicalCollaborationContext.d.ts +10 -0
- package/lib/collab/yjs/LexicalCollaborationContext.js +37 -0
- package/lib/collab/yjs/LexicalCollaborationPlugin.d.ts +21 -0
- package/lib/collab/yjs/LexicalCollaborationPlugin.js +63 -0
- package/lib/collab/yjs/State.d.ts +51 -0
- package/lib/collab/yjs/State.js +35 -0
- package/lib/collab/yjs/nodes/AnyCollabNode.d.ts +5 -0
- package/lib/collab/yjs/nodes/AnyCollabNode.js +1 -0
- package/lib/collab/yjs/nodes/CollabDecoratorNode.d.ts +22 -0
- package/lib/collab/yjs/nodes/CollabDecoratorNode.js +64 -0
- package/lib/collab/yjs/nodes/CollabElementNode.d.ts +40 -0
- package/lib/collab/yjs/nodes/CollabElementNode.js +462 -0
- package/lib/collab/yjs/nodes/CollabLineBreakNode.d.ts +19 -0
- package/lib/collab/yjs/nodes/CollabLineBreakNode.js +44 -0
- package/lib/collab/yjs/nodes/CollabTextNode.d.ts +25 -0
- package/lib/collab/yjs/nodes/CollabTextNode.js +103 -0
- package/lib/collab/yjs/provider/websocket.d.ts +88 -0
- package/lib/collab/yjs/provider/websocket.js +415 -0
- package/lib/collab/yjs/servers/index.d.ts +0 -0
- package/lib/collab/yjs/servers/index.js +0 -0
- package/lib/collab/yjs/servers/ws/callback.d.ts +5 -0
- package/lib/collab/yjs/servers/ws/callback.js +72 -0
- package/lib/collab/yjs/servers/ws/server.d.ts +2 -0
- package/lib/collab/yjs/servers/ws/server.js +25 -0
- package/lib/collab/yjs/servers/ws/utils.d.ts +49 -0
- package/lib/collab/yjs/servers/ws/utils.js +284 -0
- package/lib/collab/yjs/sync/SyncCursors.d.ts +39 -0
- package/lib/collab/yjs/sync/SyncCursors.js +351 -0
- package/lib/collab/yjs/sync/SyncEditorStates.d.ts +10 -0
- package/lib/collab/yjs/sync/SyncEditorStates.js +200 -0
- package/lib/collab/yjs/useCollaboration.d.ts +12 -0
- package/lib/collab/yjs/useCollaboration.js +255 -0
- package/lib/collab/yjs/utils/Utils.d.ts +25 -0
- package/lib/collab/yjs/utils/Utils.js +402 -0
- package/lib/collab/yjs/wsProvider.d.ts +3 -0
- package/lib/collab/yjs/wsProvider.js +21 -0
- package/lib/commenting/index.d.ts +41 -0
- package/lib/commenting/index.js +324 -0
- package/lib/context/FlashMessageContext.d.ts +7 -0
- package/lib/context/FlashMessageContext.js +24 -0
- package/lib/context/SettingsContext.d.ts +12 -0
- package/lib/context/SettingsContext.js +38 -0
- package/lib/context/SharedHistoryContext.d.ts +11 -0
- package/lib/context/SharedHistoryContext.js +11 -0
- package/lib/context/ToolbarContext.d.ts +65 -0
- package/lib/context/ToolbarContext.js +84 -0
- package/lib/demo.d.ts +12 -0
- package/lib/demo.js +41 -0
- package/lib/hooks/useFlashMessage.d.ts +2 -0
- package/lib/hooks/useFlashMessage.js +4 -0
- package/lib/hooks/useModal.d.ts +5 -0
- package/lib/hooks/useModal.js +26 -0
- package/lib/hooks/useReport.d.ts +1 -0
- package/lib/hooks/useReport.js +46 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -5
- package/lib/nodes/AutocompleteNode.d.ts +27 -0
- package/lib/nodes/AutocompleteNode.js +56 -0
- package/lib/nodes/CounterComponent.d.ts +6 -0
- package/lib/nodes/CounterComponent.js +137 -0
- package/lib/nodes/CounterNode.d.ts +23 -0
- package/lib/nodes/CounterNode.js +47 -0
- package/lib/nodes/DateTimeNode/DateTimeComponent.d.ts +8 -0
- package/lib/nodes/DateTimeNode/DateTimeComponent.js +119 -0
- package/lib/nodes/DateTimeNode/DateTimeNode.d.ts +27 -0
- package/lib/nodes/DateTimeNode/DateTimeNode.js +82 -0
- package/lib/nodes/EmojiNode.d.ts +18 -0
- package/lib/nodes/EmojiNode.js +50 -0
- package/lib/nodes/EquationComponent.d.ts +9 -0
- package/lib/nodes/EquationComponent.js +75 -0
- package/lib/nodes/EquationNode.d.ts +26 -0
- package/lib/nodes/EquationNode.js +109 -0
- package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.d.ts +8 -0
- package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.js +110 -0
- package/lib/nodes/ExcalidrawNode/ExcalidrawImage.d.ts +50 -0
- package/lib/nodes/ExcalidrawNode/ExcalidrawImage.js +55 -0
- package/lib/nodes/ExcalidrawNode/index.d.ts +32 -0
- package/lib/nodes/ExcalidrawNode/index.js +117 -0
- package/lib/nodes/FigmaNode.d.ts +20 -0
- package/lib/nodes/FigmaNode.js +52 -0
- package/lib/nodes/ImageComponent.d.ts +16 -0
- package/lib/nodes/ImageComponent.js +272 -0
- package/lib/nodes/ImageNode.d.ts +50 -0
- package/lib/nodes/ImageNode.js +151 -0
- package/lib/nodes/InlineImageNode/InlineImageComponent.d.ts +26 -0
- package/lib/nodes/InlineImageNode/InlineImageComponent.js +161 -0
- package/lib/nodes/InlineImageNode/InlineImageNode.d.ts +59 -0
- package/lib/nodes/InlineImageNode/InlineImageNode.js +162 -0
- package/lib/nodes/KeywordNode.d.ts +14 -0
- package/lib/nodes/KeywordNode.js +33 -0
- package/lib/nodes/LayoutContainerNode.d.ts +24 -0
- package/lib/nodes/LayoutContainerNode.js +91 -0
- package/lib/nodes/LayoutItemNode.d.ts +16 -0
- package/lib/nodes/LayoutItemNode.js +65 -0
- package/lib/nodes/MentionNode.d.ts +20 -0
- package/lib/nodes/MentionNode.js +81 -0
- package/lib/nodes/PageBreakNode/index.d.ts +17 -0
- package/lib/nodes/PageBreakNode/index.js +83 -0
- package/lib/nodes/PlaygroundNodes.d.ts +3 -0
- package/lib/nodes/PlaygroundNodes.js +71 -0
- package/lib/nodes/PollComponent.d.ts +9 -0
- package/lib/nodes/PollComponent.js +85 -0
- package/lib/nodes/PollNode.d.ts +43 -0
- package/lib/nodes/PollNode.js +153 -0
- package/lib/nodes/SpecialTextNode.d.ts +24 -0
- package/lib/nodes/SpecialTextNode.js +50 -0
- package/lib/nodes/StickyComponent.d.ts +10 -0
- package/lib/nodes/StickyComponent.js +162 -0
- package/lib/nodes/StickyNode.d.ts +31 -0
- package/lib/nodes/StickyNode.js +76 -0
- package/lib/nodes/TweetNode.d.ts +21 -0
- package/lib/nodes/TweetNode.js +119 -0
- package/lib/nodes/YouTubeNode.d.ts +22 -0
- package/lib/nodes/YouTubeNode.js +84 -0
- package/lib/plugins/ActionsPlugin/index.d.ts +5 -0
- package/lib/plugins/ActionsPlugin/index.js +168 -0
- package/lib/plugins/AutoEmbedPlugin/index.d.ts +19 -0
- package/lib/plugins/AutoEmbedPlugin/index.js +158 -0
- package/lib/plugins/AutoLinkPlugin/index.d.ts +2 -0
- package/lib/plugins/AutoLinkPlugin/index.js +15 -0
- package/lib/plugins/AutocompletePlugin/index.d.ts +10 -0
- package/lib/plugins/AutocompletePlugin/index.js +2473 -0
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +7 -0
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +42 -0
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +17 -0
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +111 -0
- package/lib/plugins/CodeActionMenuPlugin/index.d.ts +5 -0
- package/lib/plugins/CodeActionMenuPlugin/index.js +104 -0
- package/lib/plugins/CodeActionMenuPlugin/utils.d.ts +1 -0
- package/lib/plugins/CodeActionMenuPlugin/utils.js +18 -0
- package/lib/plugins/CodeHighlightPrismPlugin/index.d.ts +2 -0
- package/lib/plugins/CodeHighlightPrismPlugin/index.js +10 -0
- package/lib/plugins/CodeHighlightShikiPlugin/index.d.ts +2 -0
- package/lib/plugins/CodeHighlightShikiPlugin/index.js +10 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +25 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.js +131 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +16 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.js +79 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +16 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.js +81 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.d.ts +2 -0
- package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.js +8 -0
- package/lib/plugins/CollapsiblePlugin/index.d.ts +3 -0
- package/lib/plugins/CollapsiblePlugin/index.js +128 -0
- package/lib/plugins/CommentPlugin/index.d.ts +9 -0
- package/lib/plugins/CommentPlugin/index.js +460 -0
- package/lib/plugins/ComponentPickerPlugin/index.d.ts +2 -0
- package/lib/plugins/ComponentPickerPlugin/index.js +276 -0
- package/lib/plugins/ContextMenuPlugin/index.d.ts +2 -0
- package/lib/plugins/ContextMenuPlugin/index.js +112 -0
- package/lib/plugins/CounterPlugin/index.d.ts +3 -0
- package/lib/plugins/CounterPlugin/index.js +20 -0
- package/lib/plugins/DatalayerPlugin/index.d.ts +2 -0
- package/lib/plugins/DatalayerPlugin/index.js +218 -0
- package/lib/plugins/DateTimePlugin/index.d.ts +8 -0
- package/lib/plugins/DateTimePlugin/index.js +24 -0
- package/lib/plugins/DocsPlugin/index.d.ts +2 -0
- package/lib/plugins/DocsPlugin/index.js +4 -0
- package/lib/plugins/DragDropPastePlugin/index.d.ts +1 -0
- package/lib/plugins/DragDropPastePlugin/index.js +33 -0
- package/lib/plugins/DraggableBlockPlugin/index.d.ts +12 -0
- package/lib/plugins/DraggableBlockPlugin/index.js +36 -0
- package/lib/plugins/EmojiPickerPlugin/index.d.ts +1 -0
- package/lib/plugins/EmojiPickerPlugin/index.js +80 -0
- package/lib/plugins/EmojisPlugin/index.d.ts +2 -0
- package/lib/plugins/EmojisPlugin/index.js +52 -0
- package/lib/plugins/EquationsPlugin/index.d.ts +14 -0
- package/lib/plugins/EquationsPlugin/index.js +34 -0
- package/lib/plugins/ExcalidrawPlugin/index.d.ts +5 -0
- package/lib/plugins/ExcalidrawPlugin/index.js +44 -0
- package/lib/plugins/FigmaPlugin/index.d.ts +4 -0
- package/lib/plugins/FigmaPlugin/index.js +20 -0
- package/lib/plugins/FloatingLinkEditorPlugin/index.d.ts +15 -0
- package/lib/plugins/FloatingLinkEditorPlugin/index.js +280 -0
- package/lib/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +7 -0
- package/lib/plugins/FloatingTextFormatToolbarPlugin/index.js +219 -0
- package/lib/plugins/ImagesPlugin/index.d.ts +24 -0
- package/lib/plugins/ImagesPlugin/index.js +195 -0
- package/lib/plugins/InlineImagePlugin/index.d.ts +17 -0
- package/lib/plugins/InlineImagePlugin/index.js +180 -0
- package/lib/plugins/KeywordsPlugin/index.d.ts +2 -0
- package/lib/plugins/KeywordsPlugin/index.js +31 -0
- package/lib/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +6 -0
- package/lib/plugins/LayoutPlugin/InsertLayoutDialog.js +21 -0
- package/lib/plugins/LayoutPlugin/LayoutPlugin.d.ts +7 -0
- package/lib/plugins/LayoutPlugin/LayoutPlugin.js +131 -0
- package/lib/plugins/LinkPlugin/index.d.ts +6 -0
- package/lib/plugins/LinkPlugin/index.js +11 -0
- package/lib/plugins/MarkdownShortcutPlugin/index.d.ts +2 -0
- package/lib/plugins/MarkdownShortcutPlugin/index.js +6 -0
- package/lib/plugins/MarkdownTransformers/index.d.ts +8 -0
- package/lib/plugins/MarkdownTransformers/index.js +234 -0
- package/lib/plugins/MaxLengthPlugin/index.d.ts +3 -0
- package/lib/plugins/MaxLengthPlugin/index.js +37 -0
- package/lib/plugins/MentionsPlugin/index.d.ts +2 -0
- package/lib/plugins/MentionsPlugin/index.js +564 -0
- package/lib/plugins/PageBreakPlugin/index.d.ts +4 -0
- package/lib/plugins/PageBreakPlugin/index.js +27 -0
- package/lib/plugins/PasteLogPlugin/index.d.ts +2 -0
- package/lib/plugins/PasteLogPlugin/index.js +27 -0
- package/lib/plugins/PollPlugin/index.d.ts +8 -0
- package/lib/plugins/PollPlugin/index.js +38 -0
- package/lib/plugins/ShortcutsPlugin/index.d.ts +6 -0
- package/lib/plugins/ShortcutsPlugin/index.js +112 -0
- package/lib/plugins/ShortcutsPlugin/shortcuts.d.ts +59 -0
- package/lib/plugins/ShortcutsPlugin/shortcuts.js +169 -0
- package/lib/plugins/SpecialTextPlugin/index.d.ts +2 -0
- package/lib/plugins/SpecialTextPlugin/index.js +46 -0
- package/lib/plugins/SpeechToTextPlugin/index.d.ts +5 -0
- package/lib/plugins/SpeechToTextPlugin/index.js +82 -0
- package/lib/plugins/StickyPlugin/index.d.ts +2 -0
- package/lib/plugins/StickyPlugin/index.js +12 -0
- package/lib/plugins/TabFocusPlugin/index.d.ts +1 -0
- package/lib/plugins/TabFocusPlugin/index.js +34 -0
- package/lib/plugins/TableActionMenuPlugin/index.d.ts +5 -0
- package/lib/plugins/TableActionMenuPlugin/index.js +492 -0
- package/lib/plugins/TableCellResizer/index.d.ts +3 -0
- package/lib/plugins/TableCellResizer/index.js +297 -0
- package/lib/plugins/TableHoverActionsPlugin/index.d.ts +4 -0
- package/lib/plugins/TableHoverActionsPlugin/index.js +188 -0
- package/lib/plugins/TableOfContentsPlugin/index.d.ts +2 -0
- package/lib/plugins/TableOfContentsPlugin/index.js +116 -0
- package/lib/plugins/TablePlugin.d.ts +31 -0
- package/lib/plugins/TablePlugin.js +63 -0
- package/lib/plugins/TestRecorderPlugin/index.d.ts +3 -0
- package/lib/plugins/TestRecorderPlugin/index.js +346 -0
- package/lib/plugins/ToolbarPlugin/fontSize.d.ts +9 -0
- package/lib/plugins/ToolbarPlugin/fontSize.js +80 -0
- package/lib/plugins/ToolbarPlugin/index.d.ts +9 -0
- package/lib/plugins/ToolbarPlugin/index.js +500 -0
- package/lib/plugins/ToolbarPlugin/utils.d.ts +26 -0
- package/lib/plugins/ToolbarPlugin/utils.js +243 -0
- package/lib/plugins/TreeViewPlugin/index.d.ts +2 -0
- package/lib/plugins/TreeViewPlugin/index.js +7 -0
- package/lib/plugins/TwitterPlugin/index.d.ts +4 -0
- package/lib/plugins/TwitterPlugin/index.js +20 -0
- package/lib/plugins/TypingPerfPlugin/index.d.ts +2 -0
- package/lib/plugins/TypingPerfPlugin/index.js +93 -0
- package/lib/plugins/YouTubePlugin/index.d.ts +4 -0
- package/lib/plugins/YouTubePlugin/index.js +20 -0
- package/lib/server/validation.d.ts +1 -0
- package/lib/server/validation.js +111 -0
- package/lib/setupEnv.d.ts +2 -0
- package/lib/setupEnv.js +25 -0
- package/lib/themes/CommentEditorTheme.d.ts +4 -0
- package/lib/themes/CommentEditorTheme.js +7 -0
- package/lib/themes/PlaygroundEditorTheme.d.ts +4 -0
- package/lib/themes/PlaygroundEditorTheme.js +120 -0
- package/lib/themes/StickyEditorTheme.d.ts +4 -0
- package/lib/themes/StickyEditorTheme.js +7 -0
- package/lib/tyes.dt.d.ts +12 -0
- package/lib/tyes.dt.js +0 -0
- package/lib/ui/Button.d.ts +12 -0
- package/lib/ui/Button.js +6 -0
- package/lib/ui/ColorPicker.d.ts +14 -0
- package/lib/ui/ColorPicker.js +219 -0
- package/lib/ui/ContentEditable.d.ts +9 -0
- package/lib/ui/ContentEditable.js +6 -0
- package/lib/ui/Dialog.d.ts +10 -0
- package/lib/ui/Dialog.js +8 -0
- package/lib/ui/DropDown.d.ts +18 -0
- package/lib/ui/DropDown.js +133 -0
- package/lib/ui/DropdownColorPicker.d.ts +13 -0
- package/lib/ui/DropdownColorPicker.js +6 -0
- package/lib/ui/EquationEditor.d.ts +8 -0
- package/lib/ui/EquationEditor.js +11 -0
- package/lib/ui/ExcalidrawModal.d.ts +42 -0
- package/lib/ui/ExcalidrawModal.js +103 -0
- package/lib/ui/FileInput.d.ts +10 -0
- package/lib/ui/FileInput.js +5 -0
- package/lib/ui/FlashMessage.d.ts +7 -0
- package/lib/ui/FlashMessage.js +6 -0
- package/lib/ui/ImageResizer.d.ts +17 -0
- package/lib/ui/ImageResizer.js +171 -0
- package/lib/ui/KatexEquationAlterer.d.ts +8 -0
- package/lib/ui/KatexEquationAlterer.js +23 -0
- package/lib/ui/KatexRenderer.d.ts +6 -0
- package/lib/ui/KatexRenderer.js +24 -0
- package/lib/ui/Modal.d.ts +9 -0
- package/lib/ui/Modal.js +48 -0
- package/lib/ui/Select.d.ts +8 -0
- package/lib/ui/Select.js +5 -0
- package/lib/ui/Switch.d.ts +8 -0
- package/lib/ui/Switch.js +6 -0
- package/lib/ui/TextInput.d.ts +13 -0
- package/lib/ui/TextInput.js +7 -0
- package/lib/utils/docSerialization.d.ts +3 -0
- package/lib/utils/docSerialization.js +56 -0
- package/lib/utils/emoji-list.d.ts +20 -0
- package/lib/utils/emoji-list.js +16605 -0
- package/lib/utils/getDOMRangeRect.d.ts +8 -0
- package/lib/utils/getDOMRangeRect.js +22 -0
- package/lib/utils/getSelectedNode.d.ts +2 -0
- package/lib/utils/getSelectedNode.js +24 -0
- package/lib/utils/getThemeSelector.d.ts +2 -0
- package/lib/utils/getThemeSelector.js +10 -0
- package/lib/utils/isMobileWidth.d.ts +7 -0
- package/lib/utils/isMobileWidth.js +7 -0
- package/lib/utils/joinClasses.d.ts +1 -0
- package/lib/utils/joinClasses.js +3 -0
- package/lib/utils/setFloatingElemPosition.d.ts +1 -0
- package/lib/utils/setFloatingElemPosition.js +55 -0
- package/lib/utils/setFloatingElemPositionForLinkEditor.d.ts +1 -0
- package/lib/utils/setFloatingElemPositionForLinkEditor.js +32 -0
- package/lib/utils/swipe.d.ts +4 -0
- package/lib/utils/swipe.js +90 -0
- package/lib/utils/url.d.ts +2 -0
- package/lib/utils/url.js +27 -0
- package/package.json +84 -50
- package/lib/LoroCollaborativePlugin.d.ts +0 -16
- package/lib/LoroCollaborativePlugin.js +0 -2503
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, LexicalUpdateJSON, NodeKey, SerializedEditor, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
import type { JSX } from 'react';
|
|
3
|
+
import { DecoratorNode } from 'lexical';
|
|
4
|
+
export type Position = 'left' | 'right' | 'full' | undefined;
|
|
5
|
+
export interface InlineImagePayload {
|
|
6
|
+
altText: string;
|
|
7
|
+
caption?: LexicalEditor;
|
|
8
|
+
height?: number;
|
|
9
|
+
key?: NodeKey;
|
|
10
|
+
showCaption?: boolean;
|
|
11
|
+
src: string;
|
|
12
|
+
width?: number;
|
|
13
|
+
position?: Position;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateInlineImagePayload {
|
|
16
|
+
altText?: string;
|
|
17
|
+
showCaption?: boolean;
|
|
18
|
+
position?: Position;
|
|
19
|
+
}
|
|
20
|
+
export type SerializedInlineImageNode = Spread<{
|
|
21
|
+
altText: string;
|
|
22
|
+
caption: SerializedEditor;
|
|
23
|
+
height?: number;
|
|
24
|
+
showCaption: boolean;
|
|
25
|
+
src: string;
|
|
26
|
+
width?: number;
|
|
27
|
+
position?: Position;
|
|
28
|
+
}, SerializedLexicalNode>;
|
|
29
|
+
export declare class InlineImageNode extends DecoratorNode<JSX.Element> {
|
|
30
|
+
__src: string;
|
|
31
|
+
__altText: string;
|
|
32
|
+
__width: 'inherit' | number;
|
|
33
|
+
__height: 'inherit' | number;
|
|
34
|
+
__showCaption: boolean;
|
|
35
|
+
__caption: LexicalEditor;
|
|
36
|
+
__position: Position;
|
|
37
|
+
static getType(): string;
|
|
38
|
+
static clone(node: InlineImageNode): InlineImageNode;
|
|
39
|
+
static importJSON(serializedNode: SerializedInlineImageNode): InlineImageNode;
|
|
40
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedInlineImageNode>): this;
|
|
41
|
+
static importDOM(): DOMConversionMap | null;
|
|
42
|
+
constructor(src: string, altText: string, position: Position, width?: 'inherit' | number, height?: 'inherit' | number, showCaption?: boolean, caption?: LexicalEditor, key?: NodeKey);
|
|
43
|
+
exportDOM(): DOMExportOutput;
|
|
44
|
+
exportJSON(): SerializedInlineImageNode;
|
|
45
|
+
getSrc(): string;
|
|
46
|
+
getAltText(): string;
|
|
47
|
+
setAltText(altText: string): void;
|
|
48
|
+
setWidthAndHeight(width: 'inherit' | number, height: 'inherit' | number): void;
|
|
49
|
+
getShowCaption(): boolean;
|
|
50
|
+
setShowCaption(showCaption: boolean): void;
|
|
51
|
+
getPosition(): Position;
|
|
52
|
+
setPosition(position: Position): void;
|
|
53
|
+
update(payload: UpdateInlineImagePayload): void;
|
|
54
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
55
|
+
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): false;
|
|
56
|
+
decorate(): JSX.Element;
|
|
57
|
+
}
|
|
58
|
+
export declare function $createInlineImageNode({ altText, position, height, src, width, showCaption, caption, key, }: InlineImagePayload): InlineImageNode;
|
|
59
|
+
export declare function $isInlineImageNode(node: LexicalNode | null | undefined): node is InlineImageNode;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { addClassNamesToElement, removeClassNamesFromElement, } from '@lexical/utils';
|
|
3
|
+
import { $applyNodeReplacement, createEditor, DecoratorNode, isHTMLElement, } from 'lexical';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
const InlineImageComponent = React.lazy(() => import('./InlineImageComponent'));
|
|
6
|
+
function $convertInlineImageElement(domNode) {
|
|
7
|
+
if (isHTMLElement(domNode) && domNode.nodeName === 'IMG') {
|
|
8
|
+
const { alt: altText, src, width, height } = domNode;
|
|
9
|
+
const node = $createInlineImageNode({ altText, height, src, width });
|
|
10
|
+
return { node };
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
function getPositionClass(position) {
|
|
15
|
+
return typeof position === 'string' ? `position-${position}` : undefined;
|
|
16
|
+
}
|
|
17
|
+
export class InlineImageNode extends DecoratorNode {
|
|
18
|
+
__src;
|
|
19
|
+
__altText;
|
|
20
|
+
__width;
|
|
21
|
+
__height;
|
|
22
|
+
__showCaption;
|
|
23
|
+
__caption;
|
|
24
|
+
__position;
|
|
25
|
+
static getType() {
|
|
26
|
+
return 'inline-image';
|
|
27
|
+
}
|
|
28
|
+
static clone(node) {
|
|
29
|
+
return new InlineImageNode(node.__src, node.__altText, node.__position, node.__width, node.__height, node.__showCaption, node.__caption, node.__key);
|
|
30
|
+
}
|
|
31
|
+
static importJSON(serializedNode) {
|
|
32
|
+
const { altText, height, width, src, showCaption, position } = serializedNode;
|
|
33
|
+
return $createInlineImageNode({
|
|
34
|
+
altText,
|
|
35
|
+
height,
|
|
36
|
+
position,
|
|
37
|
+
showCaption,
|
|
38
|
+
src,
|
|
39
|
+
width,
|
|
40
|
+
}).updateFromJSON(serializedNode);
|
|
41
|
+
}
|
|
42
|
+
updateFromJSON(serializedNode) {
|
|
43
|
+
const { caption } = serializedNode;
|
|
44
|
+
const node = super.updateFromJSON(serializedNode);
|
|
45
|
+
const nestedEditor = node.__caption;
|
|
46
|
+
const editorState = nestedEditor.parseEditorState(caption.editorState);
|
|
47
|
+
if (!editorState.isEmpty()) {
|
|
48
|
+
nestedEditor.setEditorState(editorState);
|
|
49
|
+
}
|
|
50
|
+
return node;
|
|
51
|
+
}
|
|
52
|
+
static importDOM() {
|
|
53
|
+
return {
|
|
54
|
+
img: (node) => ({
|
|
55
|
+
conversion: $convertInlineImageElement,
|
|
56
|
+
priority: 0,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
constructor(src, altText, position, width, height, showCaption, caption, key) {
|
|
61
|
+
super(key);
|
|
62
|
+
this.__src = src;
|
|
63
|
+
this.__altText = altText;
|
|
64
|
+
this.__width = width || 'inherit';
|
|
65
|
+
this.__height = height || 'inherit';
|
|
66
|
+
this.__showCaption = showCaption || false;
|
|
67
|
+
this.__caption = caption || createEditor();
|
|
68
|
+
this.__position = position;
|
|
69
|
+
}
|
|
70
|
+
exportDOM() {
|
|
71
|
+
const element = document.createElement('img');
|
|
72
|
+
element.setAttribute('src', this.__src);
|
|
73
|
+
element.setAttribute('alt', this.__altText);
|
|
74
|
+
element.setAttribute('width', this.__width.toString());
|
|
75
|
+
element.setAttribute('height', this.__height.toString());
|
|
76
|
+
return { element };
|
|
77
|
+
}
|
|
78
|
+
exportJSON() {
|
|
79
|
+
return {
|
|
80
|
+
...super.exportJSON(),
|
|
81
|
+
altText: this.getAltText(),
|
|
82
|
+
caption: this.__caption.toJSON(),
|
|
83
|
+
height: this.__height === 'inherit' ? 0 : this.__height,
|
|
84
|
+
position: this.__position,
|
|
85
|
+
showCaption: this.__showCaption,
|
|
86
|
+
src: this.getSrc(),
|
|
87
|
+
width: this.__width === 'inherit' ? 0 : this.__width,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
getSrc() {
|
|
91
|
+
return this.__src;
|
|
92
|
+
}
|
|
93
|
+
getAltText() {
|
|
94
|
+
return this.__altText;
|
|
95
|
+
}
|
|
96
|
+
setAltText(altText) {
|
|
97
|
+
const writable = this.getWritable();
|
|
98
|
+
writable.__altText = altText;
|
|
99
|
+
}
|
|
100
|
+
setWidthAndHeight(width, height) {
|
|
101
|
+
const writable = this.getWritable();
|
|
102
|
+
writable.__width = width;
|
|
103
|
+
writable.__height = height;
|
|
104
|
+
}
|
|
105
|
+
getShowCaption() {
|
|
106
|
+
return this.__showCaption;
|
|
107
|
+
}
|
|
108
|
+
setShowCaption(showCaption) {
|
|
109
|
+
const writable = this.getWritable();
|
|
110
|
+
writable.__showCaption = showCaption;
|
|
111
|
+
}
|
|
112
|
+
getPosition() {
|
|
113
|
+
return this.__position;
|
|
114
|
+
}
|
|
115
|
+
setPosition(position) {
|
|
116
|
+
const writable = this.getWritable();
|
|
117
|
+
writable.__position = position;
|
|
118
|
+
}
|
|
119
|
+
update(payload) {
|
|
120
|
+
const writable = this.getWritable();
|
|
121
|
+
const { altText, showCaption, position } = payload;
|
|
122
|
+
if (altText !== undefined) {
|
|
123
|
+
writable.__altText = altText;
|
|
124
|
+
}
|
|
125
|
+
if (showCaption !== undefined) {
|
|
126
|
+
writable.__showCaption = showCaption;
|
|
127
|
+
}
|
|
128
|
+
if (position !== undefined) {
|
|
129
|
+
writable.__position = position;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// View
|
|
133
|
+
createDOM(config) {
|
|
134
|
+
const span = document.createElement('span');
|
|
135
|
+
for (const cls of [
|
|
136
|
+
config.theme.inlineImage,
|
|
137
|
+
getPositionClass(this.__position),
|
|
138
|
+
]) {
|
|
139
|
+
if (cls) {
|
|
140
|
+
addClassNamesToElement(span, cls);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return span;
|
|
144
|
+
}
|
|
145
|
+
updateDOM(prevNode, dom, config) {
|
|
146
|
+
const position = this.__position;
|
|
147
|
+
if (position !== prevNode.__position) {
|
|
148
|
+
removeClassNamesFromElement(dom, getPositionClass(prevNode.__position));
|
|
149
|
+
addClassNamesToElement(dom, getPositionClass(position));
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
decorate() {
|
|
154
|
+
return (_jsx(InlineImageComponent, { src: this.__src, altText: this.__altText, width: this.__width, height: this.__height, nodeKey: this.getKey(), showCaption: this.__showCaption, caption: this.__caption, position: this.__position }));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export function $createInlineImageNode({ altText, position, height, src, width, showCaption, caption, key, }) {
|
|
158
|
+
return $applyNodeReplacement(new InlineImageNode(src, altText, position, width, height, showCaption, caption, key));
|
|
159
|
+
}
|
|
160
|
+
export function $isInlineImageNode(node) {
|
|
161
|
+
return node instanceof InlineImageNode;
|
|
162
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorConfig, LexicalNode, SerializedTextNode } from 'lexical';
|
|
2
|
+
import { TextNode } from 'lexical';
|
|
3
|
+
export type SerializedKeywordNode = SerializedTextNode;
|
|
4
|
+
export declare class KeywordNode extends TextNode {
|
|
5
|
+
static getType(): string;
|
|
6
|
+
static clone(node: KeywordNode): KeywordNode;
|
|
7
|
+
static importJSON(serializedNode: SerializedKeywordNode): KeywordNode;
|
|
8
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
9
|
+
canInsertTextBefore(): boolean;
|
|
10
|
+
canInsertTextAfter(): boolean;
|
|
11
|
+
isTextEntity(): true;
|
|
12
|
+
}
|
|
13
|
+
export declare function $createKeywordNode(keyword?: string): KeywordNode;
|
|
14
|
+
export declare function $isKeywordNode(node: LexicalNode | null | undefined): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { $applyNodeReplacement, TextNode } from 'lexical';
|
|
2
|
+
export class KeywordNode extends TextNode {
|
|
3
|
+
static getType() {
|
|
4
|
+
return 'keyword';
|
|
5
|
+
}
|
|
6
|
+
static clone(node) {
|
|
7
|
+
return new KeywordNode(node.__text, node.__key);
|
|
8
|
+
}
|
|
9
|
+
static importJSON(serializedNode) {
|
|
10
|
+
return $createKeywordNode().updateFromJSON(serializedNode);
|
|
11
|
+
}
|
|
12
|
+
createDOM(config) {
|
|
13
|
+
const dom = super.createDOM(config);
|
|
14
|
+
dom.style.cursor = 'default';
|
|
15
|
+
dom.className = 'keyword';
|
|
16
|
+
return dom;
|
|
17
|
+
}
|
|
18
|
+
canInsertTextBefore() {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
canInsertTextAfter() {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
isTextEntity() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function $createKeywordNode(keyword = '') {
|
|
29
|
+
return $applyNodeReplacement(new KeywordNode(keyword));
|
|
30
|
+
}
|
|
31
|
+
export function $isKeywordNode(node) {
|
|
32
|
+
return node instanceof KeywordNode;
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, LexicalUpdateJSON, NodeKey, SerializedElementNode, Spread } from 'lexical';
|
|
2
|
+
import { ElementNode } from 'lexical';
|
|
3
|
+
export type SerializedLayoutContainerNode = Spread<{
|
|
4
|
+
templateColumns: string;
|
|
5
|
+
}, SerializedElementNode>;
|
|
6
|
+
export declare class LayoutContainerNode extends ElementNode {
|
|
7
|
+
__templateColumns: string;
|
|
8
|
+
constructor(templateColumns: string, key?: NodeKey);
|
|
9
|
+
static getType(): string;
|
|
10
|
+
static clone(node: LayoutContainerNode): LayoutContainerNode;
|
|
11
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
12
|
+
exportDOM(): DOMExportOutput;
|
|
13
|
+
updateDOM(prevNode: this, dom: HTMLElement): boolean;
|
|
14
|
+
static importDOM(): DOMConversionMap | null;
|
|
15
|
+
static importJSON(json: SerializedLayoutContainerNode): LayoutContainerNode;
|
|
16
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedLayoutContainerNode>): this;
|
|
17
|
+
isShadowRoot(): boolean;
|
|
18
|
+
canBeEmpty(): boolean;
|
|
19
|
+
exportJSON(): SerializedLayoutContainerNode;
|
|
20
|
+
getTemplateColumns(): string;
|
|
21
|
+
setTemplateColumns(templateColumns: string): this;
|
|
22
|
+
}
|
|
23
|
+
export declare function $createLayoutContainerNode(templateColumns?: string): LayoutContainerNode;
|
|
24
|
+
export declare function $isLayoutContainerNode(node: LexicalNode | null | undefined): node is LayoutContainerNode;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { addClassNamesToElement } from '@lexical/utils';
|
|
2
|
+
import { ElementNode } from 'lexical';
|
|
3
|
+
function $convertLayoutContainerElement(domNode) {
|
|
4
|
+
const styleAttributes = window.getComputedStyle(domNode);
|
|
5
|
+
const templateColumns = styleAttributes.getPropertyValue('grid-template-columns');
|
|
6
|
+
if (templateColumns) {
|
|
7
|
+
const node = $createLayoutContainerNode(templateColumns);
|
|
8
|
+
return { node };
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
export class LayoutContainerNode extends ElementNode {
|
|
13
|
+
__templateColumns;
|
|
14
|
+
constructor(templateColumns, key) {
|
|
15
|
+
super(key);
|
|
16
|
+
this.__templateColumns = templateColumns;
|
|
17
|
+
}
|
|
18
|
+
static getType() {
|
|
19
|
+
return 'layout-container';
|
|
20
|
+
}
|
|
21
|
+
static clone(node) {
|
|
22
|
+
return new LayoutContainerNode(node.__templateColumns, node.__key);
|
|
23
|
+
}
|
|
24
|
+
createDOM(config) {
|
|
25
|
+
const dom = document.createElement('div');
|
|
26
|
+
dom.style.gridTemplateColumns = this.__templateColumns;
|
|
27
|
+
if (typeof config.theme.layoutContainer === 'string') {
|
|
28
|
+
addClassNamesToElement(dom, config.theme.layoutContainer);
|
|
29
|
+
}
|
|
30
|
+
return dom;
|
|
31
|
+
}
|
|
32
|
+
exportDOM() {
|
|
33
|
+
const element = document.createElement('div');
|
|
34
|
+
element.style.gridTemplateColumns = this.__templateColumns;
|
|
35
|
+
element.setAttribute('data-lexical-layout-container', 'true');
|
|
36
|
+
return { element };
|
|
37
|
+
}
|
|
38
|
+
updateDOM(prevNode, dom) {
|
|
39
|
+
if (prevNode.__templateColumns !== this.__templateColumns) {
|
|
40
|
+
dom.style.gridTemplateColumns = this.__templateColumns;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
static importDOM() {
|
|
45
|
+
return {
|
|
46
|
+
div: (domNode) => {
|
|
47
|
+
if (!domNode.hasAttribute('data-lexical-layout-container')) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
conversion: $convertLayoutContainerElement,
|
|
52
|
+
priority: 2,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
static importJSON(json) {
|
|
58
|
+
return $createLayoutContainerNode().updateFromJSON(json);
|
|
59
|
+
}
|
|
60
|
+
updateFromJSON(serializedNode) {
|
|
61
|
+
return super
|
|
62
|
+
.updateFromJSON(serializedNode)
|
|
63
|
+
.setTemplateColumns(serializedNode.templateColumns);
|
|
64
|
+
}
|
|
65
|
+
isShadowRoot() {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
canBeEmpty() {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
exportJSON() {
|
|
72
|
+
return {
|
|
73
|
+
...super.exportJSON(),
|
|
74
|
+
templateColumns: this.__templateColumns,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
getTemplateColumns() {
|
|
78
|
+
return this.getLatest().__templateColumns;
|
|
79
|
+
}
|
|
80
|
+
setTemplateColumns(templateColumns) {
|
|
81
|
+
const self = this.getWritable();
|
|
82
|
+
self.__templateColumns = templateColumns;
|
|
83
|
+
return self;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function $createLayoutContainerNode(templateColumns = '') {
|
|
87
|
+
return new LayoutContainerNode(templateColumns);
|
|
88
|
+
}
|
|
89
|
+
export function $isLayoutContainerNode(node) {
|
|
90
|
+
return node instanceof LayoutContainerNode;
|
|
91
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DOMConversionMap, EditorConfig, LexicalNode, SerializedElementNode } from 'lexical';
|
|
2
|
+
import { ElementNode } from 'lexical';
|
|
3
|
+
export type SerializedLayoutItemNode = SerializedElementNode;
|
|
4
|
+
export declare function $isEmptyLayoutItemNode(node: LexicalNode): boolean;
|
|
5
|
+
export declare class LayoutItemNode extends ElementNode {
|
|
6
|
+
static getType(): string;
|
|
7
|
+
static clone(node: LayoutItemNode): LayoutItemNode;
|
|
8
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
9
|
+
updateDOM(): boolean;
|
|
10
|
+
collapseAtStart(): boolean;
|
|
11
|
+
static importDOM(): DOMConversionMap | null;
|
|
12
|
+
static importJSON(serializedNode: SerializedLayoutItemNode): LayoutItemNode;
|
|
13
|
+
isShadowRoot(): boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function $createLayoutItemNode(): LayoutItemNode;
|
|
16
|
+
export declare function $isLayoutItemNode(node: LexicalNode | null | undefined): node is LayoutItemNode;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { addClassNamesToElement } from '@lexical/utils';
|
|
2
|
+
import { $isParagraphNode, ElementNode } from 'lexical';
|
|
3
|
+
function $convertLayoutItemElement() {
|
|
4
|
+
return { node: $createLayoutItemNode() };
|
|
5
|
+
}
|
|
6
|
+
export function $isEmptyLayoutItemNode(node) {
|
|
7
|
+
if (!$isLayoutItemNode(node) || node.getChildrenSize() !== 1) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const firstChild = node.getFirstChild();
|
|
11
|
+
return $isParagraphNode(firstChild) && firstChild.isEmpty();
|
|
12
|
+
}
|
|
13
|
+
export class LayoutItemNode extends ElementNode {
|
|
14
|
+
static getType() {
|
|
15
|
+
return 'layout-item';
|
|
16
|
+
}
|
|
17
|
+
static clone(node) {
|
|
18
|
+
return new LayoutItemNode(node.__key);
|
|
19
|
+
}
|
|
20
|
+
createDOM(config) {
|
|
21
|
+
const dom = document.createElement('div');
|
|
22
|
+
dom.setAttribute('data-lexical-layout-item', 'true');
|
|
23
|
+
if (typeof config.theme.layoutItem === 'string') {
|
|
24
|
+
addClassNamesToElement(dom, config.theme.layoutItem);
|
|
25
|
+
}
|
|
26
|
+
return dom;
|
|
27
|
+
}
|
|
28
|
+
updateDOM() {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
collapseAtStart() {
|
|
32
|
+
const parent = this.getParentOrThrow();
|
|
33
|
+
if (this.is(parent.getFirstChild()) &&
|
|
34
|
+
parent.getChildren().every($isEmptyLayoutItemNode)) {
|
|
35
|
+
parent.remove();
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
static importDOM() {
|
|
41
|
+
return {
|
|
42
|
+
div: (domNode) => {
|
|
43
|
+
if (!domNode.hasAttribute('data-lexical-layout-item')) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
conversion: $convertLayoutItemElement,
|
|
48
|
+
priority: 2,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static importJSON(serializedNode) {
|
|
54
|
+
return $createLayoutItemNode().updateFromJSON(serializedNode);
|
|
55
|
+
}
|
|
56
|
+
isShadowRoot() {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function $createLayoutItemNode() {
|
|
61
|
+
return new LayoutItemNode();
|
|
62
|
+
}
|
|
63
|
+
export function $isLayoutItemNode(node) {
|
|
64
|
+
return node instanceof LayoutItemNode;
|
|
65
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalNode, type NodeKey, type SerializedTextNode, type Spread, TextNode } from 'lexical';
|
|
2
|
+
export type SerializedMentionNode = Spread<{
|
|
3
|
+
mentionName: string;
|
|
4
|
+
}, SerializedTextNode>;
|
|
5
|
+
export declare class MentionNode extends TextNode {
|
|
6
|
+
__mention: string;
|
|
7
|
+
static getType(): string;
|
|
8
|
+
static clone(node: MentionNode): MentionNode;
|
|
9
|
+
static importJSON(serializedNode: SerializedMentionNode): MentionNode;
|
|
10
|
+
constructor(mentionName: string, text?: string, key?: NodeKey);
|
|
11
|
+
exportJSON(): SerializedMentionNode;
|
|
12
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
13
|
+
exportDOM(): DOMExportOutput;
|
|
14
|
+
static importDOM(): DOMConversionMap | null;
|
|
15
|
+
isTextEntity(): true;
|
|
16
|
+
canInsertTextBefore(): boolean;
|
|
17
|
+
canInsertTextAfter(): boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function $createMentionNode(mentionName: string, textContent?: string): MentionNode;
|
|
20
|
+
export declare function $isMentionNode(node: LexicalNode | null | undefined): node is MentionNode;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { $applyNodeReplacement, TextNode, } from 'lexical';
|
|
2
|
+
function $convertMentionElement(domNode) {
|
|
3
|
+
const textContent = domNode.textContent;
|
|
4
|
+
const mentionName = domNode.getAttribute('data-lexical-mention-name');
|
|
5
|
+
if (textContent !== null) {
|
|
6
|
+
const node = $createMentionNode(typeof mentionName === 'string' ? mentionName : textContent, textContent);
|
|
7
|
+
return {
|
|
8
|
+
node,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const mentionStyle = 'background-color: rgba(24, 119, 232, 0.2)';
|
|
14
|
+
export class MentionNode extends TextNode {
|
|
15
|
+
__mention;
|
|
16
|
+
static getType() {
|
|
17
|
+
return 'mention';
|
|
18
|
+
}
|
|
19
|
+
static clone(node) {
|
|
20
|
+
return new MentionNode(node.__mention, node.__text, node.__key);
|
|
21
|
+
}
|
|
22
|
+
static importJSON(serializedNode) {
|
|
23
|
+
return $createMentionNode(serializedNode.mentionName).updateFromJSON(serializedNode);
|
|
24
|
+
}
|
|
25
|
+
constructor(mentionName, text, key) {
|
|
26
|
+
super(text ?? mentionName, key);
|
|
27
|
+
this.__mention = mentionName;
|
|
28
|
+
}
|
|
29
|
+
exportJSON() {
|
|
30
|
+
return {
|
|
31
|
+
...super.exportJSON(),
|
|
32
|
+
mentionName: this.__mention,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
createDOM(config) {
|
|
36
|
+
const dom = super.createDOM(config);
|
|
37
|
+
dom.style.cssText = mentionStyle;
|
|
38
|
+
dom.className = 'mention';
|
|
39
|
+
dom.spellcheck = false;
|
|
40
|
+
return dom;
|
|
41
|
+
}
|
|
42
|
+
exportDOM() {
|
|
43
|
+
const element = document.createElement('span');
|
|
44
|
+
element.setAttribute('data-lexical-mention', 'true');
|
|
45
|
+
if (this.__text !== this.__mention) {
|
|
46
|
+
element.setAttribute('data-lexical-mention-name', this.__mention);
|
|
47
|
+
}
|
|
48
|
+
element.textContent = this.__text;
|
|
49
|
+
return { element };
|
|
50
|
+
}
|
|
51
|
+
static importDOM() {
|
|
52
|
+
return {
|
|
53
|
+
span: (domNode) => {
|
|
54
|
+
if (!domNode.hasAttribute('data-lexical-mention')) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
conversion: $convertMentionElement,
|
|
59
|
+
priority: 1,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
isTextEntity() {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
canInsertTextBefore() {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
canInsertTextAfter() {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function $createMentionNode(mentionName, textContent) {
|
|
75
|
+
const mentionNode = new MentionNode(mentionName, (textContent = mentionName));
|
|
76
|
+
mentionNode.setMode('segmented').toggleDirectionless();
|
|
77
|
+
return $applyNodeReplacement(mentionNode);
|
|
78
|
+
}
|
|
79
|
+
export function $isMentionNode(node) {
|
|
80
|
+
return node instanceof MentionNode;
|
|
81
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import './index.css';
|
|
3
|
+
import { DecoratorNode, DOMConversionMap, LexicalNode, SerializedLexicalNode } from 'lexical';
|
|
4
|
+
export type SerializedPageBreakNode = SerializedLexicalNode;
|
|
5
|
+
export declare class PageBreakNode extends DecoratorNode<JSX.Element> {
|
|
6
|
+
static getType(): string;
|
|
7
|
+
static clone(node: PageBreakNode): PageBreakNode;
|
|
8
|
+
static importJSON(serializedNode: SerializedPageBreakNode): PageBreakNode;
|
|
9
|
+
static importDOM(): DOMConversionMap | null;
|
|
10
|
+
createDOM(): HTMLElement;
|
|
11
|
+
getTextContent(): string;
|
|
12
|
+
isInline(): false;
|
|
13
|
+
updateDOM(): boolean;
|
|
14
|
+
decorate(): JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export declare function $createPageBreakNode(): PageBreakNode;
|
|
17
|
+
export declare function $isPageBreakNode(node: LexicalNode | null | undefined): node is PageBreakNode;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import './index.css';
|
|
3
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
+
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
5
|
+
import { mergeRegister } from '@lexical/utils';
|
|
6
|
+
import { CLICK_COMMAND, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, DecoratorNode, } from 'lexical';
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
|
+
function PageBreakComponent({ nodeKey }) {
|
|
9
|
+
const [editor] = useLexicalComposerContext();
|
|
10
|
+
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
return mergeRegister(editor.registerCommand(CLICK_COMMAND, (event) => {
|
|
13
|
+
const pbElem = editor.getElementByKey(nodeKey);
|
|
14
|
+
if (event.target === pbElem) {
|
|
15
|
+
if (!event.shiftKey) {
|
|
16
|
+
clearSelection();
|
|
17
|
+
}
|
|
18
|
+
setSelected(!isSelected);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}, COMMAND_PRIORITY_LOW));
|
|
23
|
+
}, [clearSelection, editor, isSelected, nodeKey, setSelected]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const pbElem = editor.getElementByKey(nodeKey);
|
|
26
|
+
if (pbElem !== null) {
|
|
27
|
+
pbElem.className = isSelected ? 'selected' : '';
|
|
28
|
+
}
|
|
29
|
+
}, [editor, isSelected, nodeKey]);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
export class PageBreakNode extends DecoratorNode {
|
|
33
|
+
static getType() {
|
|
34
|
+
return 'page-break';
|
|
35
|
+
}
|
|
36
|
+
static clone(node) {
|
|
37
|
+
return new PageBreakNode(node.__key);
|
|
38
|
+
}
|
|
39
|
+
static importJSON(serializedNode) {
|
|
40
|
+
return $createPageBreakNode().updateFromJSON(serializedNode);
|
|
41
|
+
}
|
|
42
|
+
static importDOM() {
|
|
43
|
+
return {
|
|
44
|
+
figure: (domNode) => {
|
|
45
|
+
const tp = domNode.getAttribute('type');
|
|
46
|
+
if (tp !== this.getType()) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
conversion: $convertPageBreakElement,
|
|
51
|
+
priority: COMMAND_PRIORITY_HIGH,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
createDOM() {
|
|
57
|
+
const el = document.createElement('figure');
|
|
58
|
+
el.style.pageBreakAfter = 'always';
|
|
59
|
+
el.setAttribute('type', this.getType());
|
|
60
|
+
return el;
|
|
61
|
+
}
|
|
62
|
+
getTextContent() {
|
|
63
|
+
return '\n';
|
|
64
|
+
}
|
|
65
|
+
isInline() {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
updateDOM() {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
decorate() {
|
|
72
|
+
return _jsx(PageBreakComponent, { nodeKey: this.__key });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function $convertPageBreakElement() {
|
|
76
|
+
return { node: $createPageBreakNode() };
|
|
77
|
+
}
|
|
78
|
+
export function $createPageBreakNode() {
|
|
79
|
+
return new PageBreakNode();
|
|
80
|
+
}
|
|
81
|
+
export function $isPageBreakNode(node) {
|
|
82
|
+
return node instanceof PageBreakNode;
|
|
83
|
+
}
|