@datalayer/lexical-loro 0.2.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/lib/App.d.ts +0 -2
- package/lib/App.js +0 -141
- package/lib/Editor.d.ts +0 -2
- package/lib/Editor.js +0 -115
- package/lib/Settings.d.ts +0 -2
- package/lib/Settings.js +0 -57
- package/lib/appSettings.d.ts +0 -36
- package/lib/appSettings.js +0 -48
- package/lib/collab/loro/Bindings.d.ts +0 -41
- package/lib/collab/loro/Bindings.js +0 -99
- package/lib/collab/loro/Debug.d.ts +0 -33
- package/lib/collab/loro/Debug.js +0 -452
- package/lib/collab/loro/LexicalCollaborationContext.d.ts +0 -19
- package/lib/collab/loro/LexicalCollaborationContext.js +0 -52
- package/lib/collab/loro/LexicalCollaborationPlugin.d.ts +0 -24
- package/lib/collab/loro/LexicalCollaborationPlugin.js +0 -83
- package/lib/collab/loro/State.d.ts +0 -53
- package/lib/collab/loro/State.js +0 -94
- package/lib/collab/loro/components/LoroCollaborationUI.d.ts +0 -13
- package/lib/collab/loro/components/LoroCollaborationUI.js +0 -9
- package/lib/collab/loro/components/LoroCollaborators.d.ts +0 -8
- package/lib/collab/loro/components/LoroCollaborators.js +0 -102
- package/lib/collab/loro/components/index.d.ts +0 -2
- package/lib/collab/loro/components/index.js +0 -6
- package/lib/collab/loro/index.d.ts +0 -6
- package/lib/collab/loro/index.js +0 -10
- package/lib/collab/loro/integrators/BaseIntegrator.d.ts +0 -14
- package/lib/collab/loro/integrators/BaseIntegrator.js +0 -5
- package/lib/collab/loro/integrators/CounterIntegrator.d.ts +0 -23
- package/lib/collab/loro/integrators/CounterIntegrator.js +0 -44
- package/lib/collab/loro/integrators/ListIntegrator.d.ts +0 -23
- package/lib/collab/loro/integrators/ListIntegrator.js +0 -53
- package/lib/collab/loro/integrators/MapIntegrator.d.ts +0 -24
- package/lib/collab/loro/integrators/MapIntegrator.js +0 -235
- package/lib/collab/loro/integrators/TextIntegrator.d.ts +0 -25
- package/lib/collab/loro/integrators/TextIntegrator.js +0 -55
- package/lib/collab/loro/integrators/TreeIntegrator.d.ts +0 -36
- package/lib/collab/loro/integrators/TreeIntegrator.js +0 -251
- package/lib/collab/loro/nodes/NodeFactory.d.ts +0 -15
- package/lib/collab/loro/nodes/NodeFactory.js +0 -101
- package/lib/collab/loro/nodes/NodesMapper.d.ts +0 -120
- package/lib/collab/loro/nodes/NodesMapper.js +0 -277
- package/lib/collab/loro/propagators/DecoratorNodePropagator.d.ts +0 -60
- package/lib/collab/loro/propagators/DecoratorNodePropagator.js +0 -306
- package/lib/collab/loro/propagators/ElementNodePropagator.d.ts +0 -62
- package/lib/collab/loro/propagators/ElementNodePropagator.js +0 -326
- package/lib/collab/loro/propagators/LineBreakNodePropagator.d.ts +0 -57
- package/lib/collab/loro/propagators/LineBreakNodePropagator.js +0 -200
- package/lib/collab/loro/propagators/RootNodePropagator.d.ts +0 -55
- package/lib/collab/loro/propagators/RootNodePropagator.js +0 -174
- package/lib/collab/loro/propagators/TextNodePropagator.d.ts +0 -60
- package/lib/collab/loro/propagators/TextNodePropagator.js +0 -440
- package/lib/collab/loro/propagators/index.d.ts +0 -49
- package/lib/collab/loro/propagators/index.js +0 -30
- package/lib/collab/loro/provider/websocket.d.ts +0 -116
- package/lib/collab/loro/provider/websocket.js +0 -911
- package/lib/collab/loro/servers/index.d.ts +0 -0
- package/lib/collab/loro/servers/index.js +0 -4
- package/lib/collab/loro/servers/ws/callback.d.ts +0 -5
- package/lib/collab/loro/servers/ws/callback.js +0 -89
- package/lib/collab/loro/servers/ws/server.d.ts +0 -2
- package/lib/collab/loro/servers/ws/server.js +0 -29
- package/lib/collab/loro/servers/ws/utils.d.ts +0 -40
- package/lib/collab/loro/servers/ws/utils.js +0 -517
- package/lib/collab/loro/sync/SyncCursors.d.ts +0 -32
- package/lib/collab/loro/sync/SyncCursors.js +0 -475
- package/lib/collab/loro/sync/SyncLexicalToLoro.d.ts +0 -4
- package/lib/collab/loro/sync/SyncLexicalToLoro.js +0 -113
- package/lib/collab/loro/sync/SyncLoroToLexical.d.ts +0 -5
- package/lib/collab/loro/sync/SyncLoroToLexical.js +0 -100
- package/lib/collab/loro/types/LexicalNodeData.d.ts +0 -32
- package/lib/collab/loro/types/LexicalNodeData.js +0 -75
- package/lib/collab/loro/useCollaboration.d.ts +0 -12
- package/lib/collab/loro/useCollaboration.js +0 -260
- package/lib/collab/loro/utils/InitialContent.d.ts +0 -64
- package/lib/collab/loro/utils/InitialContent.js +0 -113
- package/lib/collab/loro/utils/LexicalToLoro.d.ts +0 -18
- package/lib/collab/loro/utils/LexicalToLoro.js +0 -100
- package/lib/collab/loro/utils/Utils.d.ts +0 -44
- package/lib/collab/loro/utils/Utils.js +0 -157
- package/lib/collab/loro/wsProvider.d.ts +0 -8
- package/lib/collab/loro/wsProvider.js +0 -35
- package/lib/collab/utils/invariant.d.ts +0 -1
- package/lib/collab/utils/invariant.js +0 -15
- package/lib/collab/utils/simpleDiffWithCursor.d.ts +0 -5
- package/lib/collab/utils/simpleDiffWithCursor.js +0 -35
- package/lib/collab/yjs/Bindings.d.ts +0 -23
- package/lib/collab/yjs/Bindings.js +0 -26
- package/lib/collab/yjs/Debug.d.ts +0 -23
- package/lib/collab/yjs/Debug.js +0 -213
- package/lib/collab/yjs/LexicalCollaborationContext.d.ts +0 -10
- package/lib/collab/yjs/LexicalCollaborationContext.js +0 -37
- package/lib/collab/yjs/LexicalCollaborationPlugin.d.ts +0 -21
- package/lib/collab/yjs/LexicalCollaborationPlugin.js +0 -63
- package/lib/collab/yjs/State.d.ts +0 -51
- package/lib/collab/yjs/State.js +0 -35
- package/lib/collab/yjs/nodes/AnyCollabNode.d.ts +0 -5
- package/lib/collab/yjs/nodes/AnyCollabNode.js +0 -1
- package/lib/collab/yjs/nodes/CollabDecoratorNode.d.ts +0 -22
- package/lib/collab/yjs/nodes/CollabDecoratorNode.js +0 -64
- package/lib/collab/yjs/nodes/CollabElementNode.d.ts +0 -40
- package/lib/collab/yjs/nodes/CollabElementNode.js +0 -462
- package/lib/collab/yjs/nodes/CollabLineBreakNode.d.ts +0 -19
- package/lib/collab/yjs/nodes/CollabLineBreakNode.js +0 -44
- package/lib/collab/yjs/nodes/CollabTextNode.d.ts +0 -25
- package/lib/collab/yjs/nodes/CollabTextNode.js +0 -103
- package/lib/collab/yjs/provider/websocket.d.ts +0 -88
- package/lib/collab/yjs/provider/websocket.js +0 -415
- 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 +0 -5
- package/lib/collab/yjs/servers/ws/callback.js +0 -72
- package/lib/collab/yjs/servers/ws/server.d.ts +0 -2
- package/lib/collab/yjs/servers/ws/server.js +0 -25
- package/lib/collab/yjs/servers/ws/utils.d.ts +0 -49
- package/lib/collab/yjs/servers/ws/utils.js +0 -284
- package/lib/collab/yjs/sync/SyncCursors.d.ts +0 -39
- package/lib/collab/yjs/sync/SyncCursors.js +0 -351
- package/lib/collab/yjs/sync/SyncEditorStates.d.ts +0 -10
- package/lib/collab/yjs/sync/SyncEditorStates.js +0 -200
- package/lib/collab/yjs/useCollaboration.d.ts +0 -12
- package/lib/collab/yjs/useCollaboration.js +0 -255
- package/lib/collab/yjs/utils/Utils.d.ts +0 -25
- package/lib/collab/yjs/utils/Utils.js +0 -402
- package/lib/collab/yjs/wsProvider.d.ts +0 -3
- package/lib/collab/yjs/wsProvider.js +0 -21
- package/lib/commenting/index.d.ts +0 -41
- package/lib/commenting/index.js +0 -328
- package/lib/context/FlashMessageContext.d.ts +0 -7
- package/lib/context/FlashMessageContext.js +0 -24
- package/lib/context/SettingsContext.d.ts +0 -12
- package/lib/context/SettingsContext.js +0 -38
- package/lib/context/SharedHistoryContext.d.ts +0 -11
- package/lib/context/SharedHistoryContext.js +0 -11
- package/lib/context/ToolbarContext.d.ts +0 -65
- package/lib/context/ToolbarContext.js +0 -84
- package/lib/demo.d.ts +0 -12
- package/lib/demo.js +0 -45
- package/lib/hooks/useFlashMessage.d.ts +0 -2
- package/lib/hooks/useFlashMessage.js +0 -8
- package/lib/hooks/useModal.d.ts +0 -5
- package/lib/hooks/useModal.js +0 -26
- package/lib/hooks/useReport.d.ts +0 -1
- package/lib/hooks/useReport.js +0 -50
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
- package/lib/nodes/AutocompleteNode.d.ts +0 -27
- package/lib/nodes/AutocompleteNode.js +0 -60
- package/lib/nodes/CounterComponent.d.ts +0 -6
- package/lib/nodes/CounterComponent.js +0 -137
- package/lib/nodes/CounterNode.d.ts +0 -23
- package/lib/nodes/CounterNode.js +0 -47
- package/lib/nodes/DateTimeNode/DateTimeComponent.d.ts +0 -8
- package/lib/nodes/DateTimeNode/DateTimeComponent.js +0 -119
- package/lib/nodes/DateTimeNode/DateTimeNode.d.ts +0 -27
- package/lib/nodes/DateTimeNode/DateTimeNode.js +0 -82
- package/lib/nodes/EmojiNode.d.ts +0 -18
- package/lib/nodes/EmojiNode.js +0 -54
- package/lib/nodes/EquationComponent.d.ts +0 -9
- package/lib/nodes/EquationComponent.js +0 -75
- package/lib/nodes/EquationNode.d.ts +0 -26
- package/lib/nodes/EquationNode.js +0 -109
- package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.d.ts +0 -8
- package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.js +0 -110
- package/lib/nodes/ExcalidrawNode/ExcalidrawImage.d.ts +0 -50
- package/lib/nodes/ExcalidrawNode/ExcalidrawImage.js +0 -55
- package/lib/nodes/ExcalidrawNode/index.d.ts +0 -32
- package/lib/nodes/ExcalidrawNode/index.js +0 -117
- package/lib/nodes/FigmaNode.d.ts +0 -20
- package/lib/nodes/FigmaNode.js +0 -52
- package/lib/nodes/ImageComponent.d.ts +0 -16
- package/lib/nodes/ImageComponent.js +0 -272
- package/lib/nodes/ImageNode.d.ts +0 -50
- package/lib/nodes/ImageNode.js +0 -151
- package/lib/nodes/InlineImageNode/InlineImageComponent.d.ts +0 -26
- package/lib/nodes/InlineImageNode/InlineImageComponent.js +0 -161
- package/lib/nodes/InlineImageNode/InlineImageNode.d.ts +0 -59
- package/lib/nodes/InlineImageNode/InlineImageNode.js +0 -162
- package/lib/nodes/KeywordNode.d.ts +0 -14
- package/lib/nodes/KeywordNode.js +0 -37
- package/lib/nodes/LayoutContainerNode.d.ts +0 -24
- package/lib/nodes/LayoutContainerNode.js +0 -95
- package/lib/nodes/LayoutItemNode.d.ts +0 -16
- package/lib/nodes/LayoutItemNode.js +0 -69
- package/lib/nodes/MentionNode.d.ts +0 -20
- package/lib/nodes/MentionNode.js +0 -85
- package/lib/nodes/PageBreakNode/index.d.ts +0 -17
- package/lib/nodes/PageBreakNode/index.js +0 -83
- package/lib/nodes/PlaygroundNodes.d.ts +0 -3
- package/lib/nodes/PlaygroundNodes.js +0 -75
- package/lib/nodes/PollComponent.d.ts +0 -9
- package/lib/nodes/PollComponent.js +0 -85
- package/lib/nodes/PollNode.d.ts +0 -43
- package/lib/nodes/PollNode.js +0 -153
- package/lib/nodes/SpecialTextNode.d.ts +0 -24
- package/lib/nodes/SpecialTextNode.js +0 -54
- package/lib/nodes/StickyComponent.d.ts +0 -10
- package/lib/nodes/StickyComponent.js +0 -162
- package/lib/nodes/StickyNode.d.ts +0 -31
- package/lib/nodes/StickyNode.js +0 -76
- package/lib/nodes/TweetNode.d.ts +0 -21
- package/lib/nodes/TweetNode.js +0 -119
- package/lib/nodes/YouTubeNode.d.ts +0 -22
- package/lib/nodes/YouTubeNode.js +0 -84
- package/lib/plugins/ActionsPlugin/index.d.ts +0 -5
- package/lib/plugins/ActionsPlugin/index.js +0 -168
- package/lib/plugins/AutoEmbedPlugin/index.d.ts +0 -19
- package/lib/plugins/AutoEmbedPlugin/index.js +0 -158
- package/lib/plugins/AutoLinkPlugin/index.d.ts +0 -2
- package/lib/plugins/AutoLinkPlugin/index.js +0 -15
- package/lib/plugins/AutocompletePlugin/index.d.ts +0 -10
- package/lib/plugins/AutocompletePlugin/index.js +0 -2477
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +0 -7
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +0 -46
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +0 -17
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +0 -115
- package/lib/plugins/CodeActionMenuPlugin/index.d.ts +0 -5
- package/lib/plugins/CodeActionMenuPlugin/index.js +0 -104
- package/lib/plugins/CodeActionMenuPlugin/utils.d.ts +0 -1
- package/lib/plugins/CodeActionMenuPlugin/utils.js +0 -22
- package/lib/plugins/CodeHighlightPrismPlugin/index.d.ts +0 -2
- package/lib/plugins/CodeHighlightPrismPlugin/index.js +0 -14
- package/lib/plugins/CodeHighlightShikiPlugin/index.d.ts +0 -2
- package/lib/plugins/CodeHighlightShikiPlugin/index.js +0 -14
- package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +0 -25
- package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.js +0 -135
- package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +0 -16
- package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.js +0 -83
- package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +0 -16
- package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.js +0 -85
- package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.d.ts +0 -2
- package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.js +0 -12
- package/lib/plugins/CollapsiblePlugin/index.d.ts +0 -3
- package/lib/plugins/CollapsiblePlugin/index.js +0 -132
- package/lib/plugins/CommentPlugin/index.d.ts +0 -9
- package/lib/plugins/CommentPlugin/index.js +0 -460
- package/lib/plugins/ComponentPickerPlugin/index.d.ts +0 -2
- package/lib/plugins/ComponentPickerPlugin/index.js +0 -276
- package/lib/plugins/ContextMenuPlugin/index.d.ts +0 -2
- package/lib/plugins/ContextMenuPlugin/index.js +0 -112
- package/lib/plugins/CounterPlugin/index.d.ts +0 -3
- package/lib/plugins/CounterPlugin/index.js +0 -24
- package/lib/plugins/DateTimePlugin/index.d.ts +0 -8
- package/lib/plugins/DateTimePlugin/index.js +0 -28
- package/lib/plugins/DebugPlugin/index.d.ts +0 -3
- package/lib/plugins/DebugPlugin/index.js +0 -219
- package/lib/plugins/DocsPlugin/index.d.ts +0 -2
- package/lib/plugins/DocsPlugin/index.js +0 -4
- package/lib/plugins/DragDropPastePlugin/index.d.ts +0 -1
- package/lib/plugins/DragDropPastePlugin/index.js +0 -37
- package/lib/plugins/DraggableBlockPlugin/index.d.ts +0 -12
- package/lib/plugins/DraggableBlockPlugin/index.js +0 -36
- package/lib/plugins/EmojiPickerPlugin/index.d.ts +0 -1
- package/lib/plugins/EmojiPickerPlugin/index.js +0 -84
- package/lib/plugins/EmojisPlugin/index.d.ts +0 -2
- package/lib/plugins/EmojisPlugin/index.js +0 -56
- package/lib/plugins/EquationsPlugin/index.d.ts +0 -14
- package/lib/plugins/EquationsPlugin/index.js +0 -34
- package/lib/plugins/ExcalidrawPlugin/index.d.ts +0 -5
- package/lib/plugins/ExcalidrawPlugin/index.js +0 -44
- package/lib/plugins/FigmaPlugin/index.d.ts +0 -4
- package/lib/plugins/FigmaPlugin/index.js +0 -24
- package/lib/plugins/FloatingLinkEditorPlugin/index.d.ts +0 -15
- package/lib/plugins/FloatingLinkEditorPlugin/index.js +0 -280
- package/lib/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +0 -7
- package/lib/plugins/FloatingTextFormatToolbarPlugin/index.js +0 -219
- package/lib/plugins/ImagesPlugin/index.d.ts +0 -24
- package/lib/plugins/ImagesPlugin/index.js +0 -195
- package/lib/plugins/InlineImagePlugin/index.d.ts +0 -17
- package/lib/plugins/InlineImagePlugin/index.js +0 -180
- package/lib/plugins/KeywordsPlugin/index.d.ts +0 -2
- package/lib/plugins/KeywordsPlugin/index.js +0 -35
- package/lib/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +0 -6
- package/lib/plugins/LayoutPlugin/InsertLayoutDialog.js +0 -21
- package/lib/plugins/LayoutPlugin/LayoutPlugin.d.ts +0 -7
- package/lib/plugins/LayoutPlugin/LayoutPlugin.js +0 -135
- package/lib/plugins/LinkPlugin/index.d.ts +0 -6
- package/lib/plugins/LinkPlugin/index.js +0 -11
- package/lib/plugins/MarkdownShortcutPlugin/index.d.ts +0 -2
- package/lib/plugins/MarkdownShortcutPlugin/index.js +0 -6
- package/lib/plugins/MarkdownTransformers/index.d.ts +0 -8
- package/lib/plugins/MarkdownTransformers/index.js +0 -238
- package/lib/plugins/MaxLengthPlugin/index.d.ts +0 -3
- package/lib/plugins/MaxLengthPlugin/index.js +0 -41
- package/lib/plugins/MentionsPlugin/index.d.ts +0 -2
- package/lib/plugins/MentionsPlugin/index.js +0 -564
- package/lib/plugins/PageBreakPlugin/index.d.ts +0 -4
- package/lib/plugins/PageBreakPlugin/index.js +0 -31
- package/lib/plugins/PasteLogPlugin/index.d.ts +0 -2
- package/lib/plugins/PasteLogPlugin/index.js +0 -27
- package/lib/plugins/PollPlugin/index.d.ts +0 -8
- package/lib/plugins/PollPlugin/index.js +0 -38
- package/lib/plugins/ShortcutsPlugin/index.d.ts +0 -6
- package/lib/plugins/ShortcutsPlugin/index.js +0 -116
- package/lib/plugins/ShortcutsPlugin/shortcuts.d.ts +0 -59
- package/lib/plugins/ShortcutsPlugin/shortcuts.js +0 -173
- package/lib/plugins/SpecialTextPlugin/index.d.ts +0 -2
- package/lib/plugins/SpecialTextPlugin/index.js +0 -50
- package/lib/plugins/SpeechToTextPlugin/index.d.ts +0 -5
- package/lib/plugins/SpeechToTextPlugin/index.js +0 -86
- package/lib/plugins/StickyPlugin/index.d.ts +0 -2
- package/lib/plugins/StickyPlugin/index.js +0 -16
- package/lib/plugins/TabFocusPlugin/index.d.ts +0 -1
- package/lib/plugins/TabFocusPlugin/index.js +0 -38
- package/lib/plugins/TableActionMenuPlugin/index.d.ts +0 -5
- package/lib/plugins/TableActionMenuPlugin/index.js +0 -492
- package/lib/plugins/TableCellResizer/index.d.ts +0 -3
- package/lib/plugins/TableCellResizer/index.js +0 -297
- package/lib/plugins/TableHoverActionsPlugin/index.d.ts +0 -4
- package/lib/plugins/TableHoverActionsPlugin/index.js +0 -188
- package/lib/plugins/TableOfContentsPlugin/index.d.ts +0 -2
- package/lib/plugins/TableOfContentsPlugin/index.js +0 -116
- package/lib/plugins/TablePlugin.d.ts +0 -31
- package/lib/plugins/TablePlugin.js +0 -63
- package/lib/plugins/TestRecorderPlugin/index.d.ts +0 -3
- package/lib/plugins/TestRecorderPlugin/index.js +0 -346
- package/lib/plugins/ToolbarPlugin/fontSize.d.ts +0 -9
- package/lib/plugins/ToolbarPlugin/fontSize.js +0 -84
- package/lib/plugins/ToolbarPlugin/index.d.ts +0 -9
- package/lib/plugins/ToolbarPlugin/index.js +0 -500
- package/lib/plugins/ToolbarPlugin/utils.d.ts +0 -26
- package/lib/plugins/ToolbarPlugin/utils.js +0 -247
- package/lib/plugins/TreeViewPlugin/index.d.ts +0 -2
- package/lib/plugins/TreeViewPlugin/index.js +0 -7
- package/lib/plugins/TwitterPlugin/index.d.ts +0 -4
- package/lib/plugins/TwitterPlugin/index.js +0 -24
- package/lib/plugins/TypingPerfPlugin/index.d.ts +0 -2
- package/lib/plugins/TypingPerfPlugin/index.js +0 -97
- package/lib/plugins/YouTubePlugin/index.d.ts +0 -4
- package/lib/plugins/YouTubePlugin/index.js +0 -24
- package/lib/server/validation.d.ts +0 -1
- package/lib/server/validation.js +0 -115
- package/lib/setupEnv.d.ts +0 -2
- package/lib/setupEnv.js +0 -29
- package/lib/themes/CommentEditorTheme.d.ts +0 -4
- package/lib/themes/CommentEditorTheme.js +0 -11
- package/lib/themes/PlaygroundEditorTheme.d.ts +0 -4
- package/lib/themes/PlaygroundEditorTheme.js +0 -124
- package/lib/themes/StickyEditorTheme.d.ts +0 -4
- package/lib/themes/StickyEditorTheme.js +0 -11
- package/lib/tyes.dt.d.ts +0 -12
- package/lib/tyes.dt.js +0 -4
- package/lib/ui/Button.d.ts +0 -12
- package/lib/ui/Button.js +0 -6
- package/lib/ui/ColorPicker.d.ts +0 -14
- package/lib/ui/ColorPicker.js +0 -219
- package/lib/ui/ContentEditable.d.ts +0 -9
- package/lib/ui/ContentEditable.js +0 -6
- package/lib/ui/Dialog.d.ts +0 -10
- package/lib/ui/Dialog.js +0 -8
- package/lib/ui/DropDown.d.ts +0 -18
- package/lib/ui/DropDown.js +0 -133
- package/lib/ui/DropdownColorPicker.d.ts +0 -13
- package/lib/ui/DropdownColorPicker.js +0 -6
- package/lib/ui/EquationEditor.d.ts +0 -8
- package/lib/ui/EquationEditor.js +0 -11
- package/lib/ui/ExcalidrawModal.d.ts +0 -42
- package/lib/ui/ExcalidrawModal.js +0 -103
- package/lib/ui/FileInput.d.ts +0 -10
- package/lib/ui/FileInput.js +0 -5
- package/lib/ui/FlashMessage.d.ts +0 -7
- package/lib/ui/FlashMessage.js +0 -6
- package/lib/ui/ImageResizer.d.ts +0 -17
- package/lib/ui/ImageResizer.js +0 -171
- package/lib/ui/KatexEquationAlterer.d.ts +0 -8
- package/lib/ui/KatexEquationAlterer.js +0 -23
- package/lib/ui/KatexRenderer.d.ts +0 -6
- package/lib/ui/KatexRenderer.js +0 -24
- package/lib/ui/Modal.d.ts +0 -9
- package/lib/ui/Modal.js +0 -48
- package/lib/ui/Select.d.ts +0 -8
- package/lib/ui/Select.js +0 -5
- package/lib/ui/Switch.d.ts +0 -8
- package/lib/ui/Switch.js +0 -6
- package/lib/ui/TextInput.d.ts +0 -13
- package/lib/ui/TextInput.js +0 -7
- package/lib/utils/docSerialization.d.ts +0 -3
- package/lib/utils/docSerialization.js +0 -60
- package/lib/utils/emoji-list.d.ts +0 -20
- package/lib/utils/emoji-list.js +0 -16609
- package/lib/utils/getDOMRangeRect.d.ts +0 -8
- package/lib/utils/getDOMRangeRect.js +0 -26
- package/lib/utils/getSelectedNode.d.ts +0 -2
- package/lib/utils/getSelectedNode.js +0 -28
- package/lib/utils/getThemeSelector.d.ts +0 -2
- package/lib/utils/getThemeSelector.js +0 -14
- package/lib/utils/isMobileWidth.d.ts +0 -7
- package/lib/utils/isMobileWidth.js +0 -11
- package/lib/utils/joinClasses.d.ts +0 -1
- package/lib/utils/joinClasses.js +0 -7
- package/lib/utils/setFloatingElemPosition.d.ts +0 -1
- package/lib/utils/setFloatingElemPosition.js +0 -59
- package/lib/utils/setFloatingElemPositionForLinkEditor.d.ts +0 -1
- package/lib/utils/setFloatingElemPositionForLinkEditor.js +0 -36
- package/lib/utils/swipe.d.ts +0 -4
- package/lib/utils/swipe.js +0 -94
- package/lib/utils/url.d.ts +0 -2
- package/lib/utils/url.js +0 -31
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Resolve lexical data from Loro, handling Loro container objects.
|
|
7
|
-
* When a JS object is stored in a LoroMap, Loro may return a LoroMap
|
|
8
|
-
* container internally. This helper ensures we always get a plain JS object.
|
|
9
|
-
*/
|
|
10
|
-
function resolveLexicalData(raw) {
|
|
11
|
-
if (raw && typeof raw === 'object' && typeof raw.toJSON === 'function') {
|
|
12
|
-
return raw.toJSON();
|
|
13
|
-
}
|
|
14
|
-
return raw;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Factory function to create Lexical nodes from Loro TreeID.
|
|
18
|
-
*
|
|
19
|
-
* Uses the registered node's static `importJSON()` method, which is the
|
|
20
|
-
* canonical Lexical API for restoring nodes from serialized data. This works
|
|
21
|
-
* generically for ALL node types — built-in (paragraph, heading, table,
|
|
22
|
-
* list, quote, code…), decorator (excalidraw, image, counter…), and any
|
|
23
|
-
* externally-defined custom nodes (e.g. JupyterCellNode) as long as they
|
|
24
|
-
* are registered with the editor and implement the standard `importJSON`
|
|
25
|
-
* static method required by Lexical's serialization contract.
|
|
26
|
-
*/
|
|
27
|
-
export function createLexicalNodeFromLoro(treeId, loroTree, binding, parentKey, nodeDataFromDiff) {
|
|
28
|
-
// Get node data from Loro tree
|
|
29
|
-
if (!loroTree.has(treeId)) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const treeNode = loroTree.getNodeByID(treeId);
|
|
33
|
-
// First try nodeData passed from TreeDiff integrator (has immediate lexical data)
|
|
34
|
-
let lexicalData = resolveLexicalData(nodeDataFromDiff?.lexical);
|
|
35
|
-
// Fallback to tree node data
|
|
36
|
-
if (!lexicalData) {
|
|
37
|
-
lexicalData = resolveLexicalData(treeNode?.data.get('lexical'));
|
|
38
|
-
}
|
|
39
|
-
if (!lexicalData || typeof lexicalData !== 'object') {
|
|
40
|
-
// Last resort: construct a minimal serialization from elementType metadata
|
|
41
|
-
const fallbackType = nodeDataFromDiff?.elementType ||
|
|
42
|
-
treeNode?.data.get('elementType') ||
|
|
43
|
-
treeNode?.data.get('nodeType');
|
|
44
|
-
if (!fallbackType || typeof fallbackType !== 'string') {
|
|
45
|
-
console.warn('🏭 NodeFactory: No lexical data or elementType for TreeID:', treeId);
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
lexicalData = { type: fallbackType, version: 1 };
|
|
49
|
-
}
|
|
50
|
-
const nodeType = lexicalData.type || lexicalData.__type;
|
|
51
|
-
if (!nodeType) {
|
|
52
|
-
console.warn('🏭 NodeFactory: No type field in lexical data for TreeID:', treeId);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
// Get the registered node class from the editor
|
|
56
|
-
const registeredNodes = binding.editor._nodes;
|
|
57
|
-
const nodeInfo = registeredNodes.get(nodeType);
|
|
58
|
-
if (!nodeInfo) {
|
|
59
|
-
console.warn(`🏭 NodeFactory: Node type '${nodeType}' is not registered in the editor`);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
// ---------- Generic creation via importJSON ----------
|
|
63
|
-
// Every Lexical node class must implement the static `importJSON` method.
|
|
64
|
-
// Using it guarantees that:
|
|
65
|
-
// • Constructor parameters are handled correctly (heading tag, excalidraw
|
|
66
|
-
// data, JupyterCellNode code/outputs, …)
|
|
67
|
-
// • Node state (Lexical 0.35+ `createState` / `$config`) is restored
|
|
68
|
-
// • Base properties (format, indent, direction, style, mode, detail, …)
|
|
69
|
-
// are applied via the chained `updateFromJSON` call
|
|
70
|
-
// This removes the need for any node-type-specific branching.
|
|
71
|
-
try {
|
|
72
|
-
const serializedData = { ...lexicalData };
|
|
73
|
-
// Ensure required serialization fields
|
|
74
|
-
if (!serializedData.type) {
|
|
75
|
-
serializedData.type = nodeType;
|
|
76
|
-
}
|
|
77
|
-
if (serializedData.version === undefined) {
|
|
78
|
-
serializedData.version = 1;
|
|
79
|
-
}
|
|
80
|
-
// Provide an empty children array for element-type nodes whose children
|
|
81
|
-
// are managed as separate Loro tree nodes (importJSON itself does not
|
|
82
|
-
// recurse into children — that is handled by TreeIntegrator).
|
|
83
|
-
if (!('children' in serializedData)) {
|
|
84
|
-
serializedData.children = [];
|
|
85
|
-
}
|
|
86
|
-
const lexicalNode = nodeInfo.klass.importJSON(serializedData);
|
|
87
|
-
return lexicalNode;
|
|
88
|
-
}
|
|
89
|
-
catch (importError) {
|
|
90
|
-
console.warn(`🏭 NodeFactory: importJSON failed for '${nodeType}', trying constructor fallback:`, importError);
|
|
91
|
-
// Fallback: try no-arg constructor (works for simple nodes)
|
|
92
|
-
try {
|
|
93
|
-
const lexicalNode = new nodeInfo.klass();
|
|
94
|
-
return lexicalNode;
|
|
95
|
-
}
|
|
96
|
-
catch (ctorError) {
|
|
97
|
-
console.warn(`🏭 NodeFactory: Constructor also failed for '${nodeType}':`, ctorError);
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { LoroTree, LoroTreeNode, TreeID } from 'loro-crdt';
|
|
2
|
-
import { LexicalNode, NodeKey, EditorState } from 'lexical';
|
|
3
|
-
import { Binding } from '../Bindings';
|
|
4
|
-
/**
|
|
5
|
-
* Bidirectional mapping between Lexical NodeKeys and Loro TreeIDs
|
|
6
|
-
*/
|
|
7
|
-
export declare class NodeMapper {
|
|
8
|
-
private lexicalToLoro;
|
|
9
|
-
private loroToLexical;
|
|
10
|
-
private tree;
|
|
11
|
-
constructor(binding: Binding);
|
|
12
|
-
/**
|
|
13
|
-
* Create a bidirectional mapping between Lexical NodeKey and Loro TreeID
|
|
14
|
-
*/
|
|
15
|
-
private createMapping;
|
|
16
|
-
/**
|
|
17
|
-
* Remove bidirectional mapping
|
|
18
|
-
*/
|
|
19
|
-
private removeMapping;
|
|
20
|
-
/**
|
|
21
|
-
* Get Loro TreeNode based on Lexical NodeKey
|
|
22
|
-
* If the node doesn't exist, create it with proper parent-child relationship
|
|
23
|
-
*/
|
|
24
|
-
getLoroNodeByLexicalKey(nodeKey: NodeKey, lexicalNode?: LexicalNode, parentTreeID?: TreeID, index?: number): LoroTreeNode;
|
|
25
|
-
/**
|
|
26
|
-
* Get Lexical NodeKey based on Loro TreeID
|
|
27
|
-
* If the node doesn't exist in Lexical, it needs to be created externally
|
|
28
|
-
*/
|
|
29
|
-
getLexicalKeyByLoroId(treeId: TreeID): NodeKey | null;
|
|
30
|
-
/**
|
|
31
|
-
* Get Lexical Node from EditorState based on Loro TreeID
|
|
32
|
-
*/
|
|
33
|
-
getLexicalNodeByLoroId(treeId: TreeID, editorState: EditorState): LexicalNode | null;
|
|
34
|
-
/**
|
|
35
|
-
* Get Lexical parent node key for a Loro TreeID
|
|
36
|
-
* Returns null if no parent or if parent not found in Lexical
|
|
37
|
-
* Note: This method needs the LoroTree API to be clarified for parent relationships
|
|
38
|
-
*/
|
|
39
|
-
getLexicalParentByLoroId(treeId: TreeID, loroTree: LoroTree): NodeKey | null;
|
|
40
|
-
/**
|
|
41
|
-
* Manually set bidirectional mapping between Lexical NodeKey and Loro TreeID
|
|
42
|
-
*/
|
|
43
|
-
setMapping(nodeKey: NodeKey, treeId: TreeID): void;
|
|
44
|
-
/**
|
|
45
|
-
* Create a new Loro TreeNode and establish mapping
|
|
46
|
-
*/
|
|
47
|
-
private createLoroNode;
|
|
48
|
-
/**
|
|
49
|
-
* Update the mapping when a node is moved or modified
|
|
50
|
-
*/
|
|
51
|
-
updateMapping(oldNodeKey: NodeKey, newNodeKey: NodeKey): void;
|
|
52
|
-
/**
|
|
53
|
-
* Remove mapping when a node is deleted (also deletes from Loro tree).
|
|
54
|
-
* Use this on the ORIGINATING side (propagation) where the local peer
|
|
55
|
-
* is actively deleting a node.
|
|
56
|
-
*/
|
|
57
|
-
deleteMapping(nodeKey: NodeKey): void;
|
|
58
|
-
/**
|
|
59
|
-
* Remove bidirectional mapping WITHOUT deleting from the Loro tree.
|
|
60
|
-
* Use this on the INTEGRATION side (receiving remote events) where the
|
|
61
|
-
* Loro tree has already been updated by the remote peer — we only need
|
|
62
|
-
* to clean up the local key↔TreeID association.
|
|
63
|
-
*/
|
|
64
|
-
removeMappingForKey(nodeKey: NodeKey): void;
|
|
65
|
-
/**
|
|
66
|
-
* Get TreeID by Lexical NodeKey (without creating if not found)
|
|
67
|
-
*/
|
|
68
|
-
getTreeIDByLexicalKey(nodeKey: NodeKey): TreeID | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* Check if a mapping exists for a Lexical NodeKey
|
|
71
|
-
*/
|
|
72
|
-
hasLexicalMapping(nodeKey: NodeKey): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Check if a mapping exists for a Loro TreeID
|
|
75
|
-
*/
|
|
76
|
-
hasLoroMapping(treeId: TreeID): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Get all current mappings (for debugging)
|
|
79
|
-
*/
|
|
80
|
-
getAllMappings(): {
|
|
81
|
-
lexicalToLoro: Map<NodeKey, TreeID>;
|
|
82
|
-
loroToLexical: Map<TreeID, NodeKey>;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Clear all mappings (useful for testing or reset)
|
|
86
|
-
*/
|
|
87
|
-
clearMappings(): void;
|
|
88
|
-
/**
|
|
89
|
-
* Synchronize existing tree nodes with Lexical editor state
|
|
90
|
-
* This should be called during initialization to establish mappings
|
|
91
|
-
*
|
|
92
|
-
* Note: Since lexicalKey is no longer persisted in tree node data,
|
|
93
|
-
* this method now relies on the TreeIntegrator to create mappings
|
|
94
|
-
* as nodes are integrated from Loro tree operations.
|
|
95
|
-
*/
|
|
96
|
-
syncExistingNodes(editorState: EditorState): void;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Initialize the global node mapper
|
|
100
|
-
*/
|
|
101
|
-
export declare function initializeNodeMapper(binding: Binding): NodeMapper;
|
|
102
|
-
/**
|
|
103
|
-
* Get the global node mapper instance
|
|
104
|
-
*/
|
|
105
|
-
export declare function getNodeMapper(): NodeMapper;
|
|
106
|
-
/**
|
|
107
|
-
* Utility functions for common operations
|
|
108
|
-
*/
|
|
109
|
-
/**
|
|
110
|
-
* Get Loro TreeNode by Lexical NodeKey (using global mapper)
|
|
111
|
-
*/
|
|
112
|
-
export declare function getLoroNodeByLexicalKey(nodeKey: NodeKey, lexicalNode?: LexicalNode, parentTreeID?: TreeID, index?: number): LoroTreeNode;
|
|
113
|
-
/**
|
|
114
|
-
* Get Lexical NodeKey by Loro TreeID (using global mapper)
|
|
115
|
-
*/
|
|
116
|
-
export declare function getLexicalKeyByLoroId(treeId: TreeID): NodeKey | null;
|
|
117
|
-
/**
|
|
118
|
-
* Get Lexical Node by Loro TreeID (using global mapper)
|
|
119
|
-
*/
|
|
120
|
-
export declare function getLexicalNodeByLoroId(treeId: TreeID, editorState: EditorState): LexicalNode | null;
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Bidirectional mapping between Lexical NodeKeys and Loro TreeIDs
|
|
7
|
-
*/
|
|
8
|
-
export class NodeMapper {
|
|
9
|
-
// Maps Lexical NodeKey to Loro TreeID
|
|
10
|
-
lexicalToLoro = new Map();
|
|
11
|
-
// Maps Loro TreeID to Lexical NodeKey
|
|
12
|
-
loroToLexical = new Map();
|
|
13
|
-
tree;
|
|
14
|
-
constructor(binding) {
|
|
15
|
-
this.tree = binding.tree;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create a bidirectional mapping between Lexical NodeKey and Loro TreeID
|
|
19
|
-
*/
|
|
20
|
-
createMapping(nodeKey, treeId) {
|
|
21
|
-
this.lexicalToLoro.set(nodeKey, treeId);
|
|
22
|
-
this.loroToLexical.set(treeId, nodeKey);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Remove bidirectional mapping
|
|
26
|
-
*/
|
|
27
|
-
removeMapping(nodeKey, treeId) {
|
|
28
|
-
this.lexicalToLoro.delete(nodeKey);
|
|
29
|
-
this.loroToLexical.delete(treeId);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Get Loro TreeNode based on Lexical NodeKey
|
|
33
|
-
* If the node doesn't exist, create it with proper parent-child relationship
|
|
34
|
-
*/
|
|
35
|
-
getLoroNodeByLexicalKey(nodeKey, lexicalNode, parentTreeID, index) {
|
|
36
|
-
// Check if mapping already exists
|
|
37
|
-
const existingTreeID = this.lexicalToLoro.get(nodeKey);
|
|
38
|
-
if (existingTreeID && this.tree.has(existingTreeID)) {
|
|
39
|
-
return this.tree.getNodeByID(existingTreeID);
|
|
40
|
-
}
|
|
41
|
-
// Get parent TreeID from Lexical node if not provided
|
|
42
|
-
if (!parentTreeID && lexicalNode) {
|
|
43
|
-
const lexicalParent = lexicalNode.getParent();
|
|
44
|
-
if (lexicalParent) {
|
|
45
|
-
const parentKey = lexicalParent.getKey();
|
|
46
|
-
parentTreeID = this.lexicalToLoro.get(parentKey);
|
|
47
|
-
// If parent doesn't exist in Loro, create it first
|
|
48
|
-
if (!parentTreeID) {
|
|
49
|
-
const parentLoroNode = this.getLoroNodeByLexicalKey(parentKey, lexicalParent, undefined, undefined);
|
|
50
|
-
parentTreeID = parentLoroNode.id;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// Get index from Lexical node if not provided
|
|
55
|
-
if (index === undefined && lexicalNode) {
|
|
56
|
-
index = lexicalNode.getIndexWithinParent();
|
|
57
|
-
}
|
|
58
|
-
// Create new tree node if it doesn't exist
|
|
59
|
-
const newTreeID = this.createLoroNode(nodeKey, lexicalNode, parentTreeID, index);
|
|
60
|
-
return this.tree.getNodeByID(newTreeID);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get Lexical NodeKey based on Loro TreeID
|
|
64
|
-
* If the node doesn't exist in Lexical, it needs to be created externally
|
|
65
|
-
*/
|
|
66
|
-
getLexicalKeyByLoroId(treeId) {
|
|
67
|
-
// Check if mapping exists
|
|
68
|
-
const existingNodeKey = this.loroToLexical.get(treeId);
|
|
69
|
-
if (existingNodeKey) {
|
|
70
|
-
return existingNodeKey;
|
|
71
|
-
}
|
|
72
|
-
// If no mapping exists, we can't create a Lexical node here
|
|
73
|
-
// The caller should integrate Lexical node creation
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Get Lexical Node from EditorState based on Loro TreeID
|
|
78
|
-
*/
|
|
79
|
-
getLexicalNodeByLoroId(treeId, editorState) {
|
|
80
|
-
const nodeKey = this.getLexicalKeyByLoroId(treeId);
|
|
81
|
-
if (!nodeKey) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
return editorState._nodeMap.get(nodeKey) || null;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Get Lexical parent node key for a Loro TreeID
|
|
88
|
-
* Returns null if no parent or if parent not found in Lexical
|
|
89
|
-
* Note: This method needs the LoroTree API to be clarified for parent relationships
|
|
90
|
-
*/
|
|
91
|
-
getLexicalParentByLoroId(treeId, loroTree) {
|
|
92
|
-
// TODO: Implement once LoroTree parent API is confirmed
|
|
93
|
-
// For now, we'll rely on the bidirectional mapping without tree traversal
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Manually set bidirectional mapping between Lexical NodeKey and Loro TreeID
|
|
98
|
-
*/
|
|
99
|
-
setMapping(nodeKey, treeId) {
|
|
100
|
-
this.lexicalToLoro.set(nodeKey, treeId);
|
|
101
|
-
this.loroToLexical.set(treeId, nodeKey);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Create a new Loro TreeNode and establish mapping
|
|
105
|
-
*/
|
|
106
|
-
createLoroNode(nodeKey, lexicalNode, parentTreeID, index) {
|
|
107
|
-
// Create the tree node first
|
|
108
|
-
const treeNode = this.tree.createNode(parentTreeID, index);
|
|
109
|
-
// Get the TreeID from the created node
|
|
110
|
-
const treeId = treeNode.id;
|
|
111
|
-
// Debug logging for parent relationship issues
|
|
112
|
-
if (parentTreeID) {
|
|
113
|
-
const actualParent = treeNode.parent();
|
|
114
|
-
if (!actualParent || actualParent.id !== parentTreeID) {
|
|
115
|
-
console.warn(`⚠️ Parent relationship not set correctly for ${nodeKey}: expected ${parentTreeID}, got ${actualParent?.id || 'None'}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Store basic metadata
|
|
119
|
-
treeNode.data.set('createdAt', Date.now());
|
|
120
|
-
// Store complete lexical node data if lexical node is provided
|
|
121
|
-
if (lexicalNode) {
|
|
122
|
-
try {
|
|
123
|
-
const lexicalNodeJSON = lexicalNode.exportJSON();
|
|
124
|
-
// Remove all key-related fields to avoid duplication (TreeID serves as the key)
|
|
125
|
-
if ('key' in lexicalNodeJSON || '__key' in lexicalNodeJSON || 'lexicalKey' in lexicalNodeJSON) {
|
|
126
|
-
const { key, __key, lexicalKey, children, ...cleanedData } = lexicalNodeJSON;
|
|
127
|
-
treeNode.data.set('lexical', cleanedData);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
const { children, ...cleanedData } = lexicalNodeJSON;
|
|
131
|
-
treeNode.data.set('lexical', cleanedData);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
console.warn('Failed to export lexical node JSON in NodesMapper:', error);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// Create bidirectional mapping
|
|
139
|
-
this.createMapping(nodeKey, treeId);
|
|
140
|
-
return treeId;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Update the mapping when a node is moved or modified
|
|
144
|
-
*/
|
|
145
|
-
updateMapping(oldNodeKey, newNodeKey) {
|
|
146
|
-
const treeId = this.lexicalToLoro.get(oldNodeKey);
|
|
147
|
-
if (treeId) {
|
|
148
|
-
this.removeMapping(oldNodeKey, treeId);
|
|
149
|
-
this.createMapping(newNodeKey, treeId);
|
|
150
|
-
// Update timestamp in tree node data
|
|
151
|
-
const treeNode = this.tree.getNodeByID(treeId);
|
|
152
|
-
if (treeNode) {
|
|
153
|
-
treeNode.data.set('updatedAt', Date.now());
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Remove mapping when a node is deleted (also deletes from Loro tree).
|
|
159
|
-
* Use this on the ORIGINATING side (propagation) where the local peer
|
|
160
|
-
* is actively deleting a node.
|
|
161
|
-
*/
|
|
162
|
-
deleteMapping(nodeKey) {
|
|
163
|
-
const treeId = this.lexicalToLoro.get(nodeKey);
|
|
164
|
-
if (treeId) {
|
|
165
|
-
this.removeMapping(nodeKey, treeId);
|
|
166
|
-
// Delete the tree node
|
|
167
|
-
if (this.tree.has(treeId)) {
|
|
168
|
-
this.tree.delete(treeId);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Remove bidirectional mapping WITHOUT deleting from the Loro tree.
|
|
174
|
-
* Use this on the INTEGRATION side (receiving remote events) where the
|
|
175
|
-
* Loro tree has already been updated by the remote peer — we only need
|
|
176
|
-
* to clean up the local key↔TreeID association.
|
|
177
|
-
*/
|
|
178
|
-
removeMappingForKey(nodeKey) {
|
|
179
|
-
const treeId = this.lexicalToLoro.get(nodeKey);
|
|
180
|
-
if (treeId) {
|
|
181
|
-
this.removeMapping(nodeKey, treeId);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Get TreeID by Lexical NodeKey (without creating if not found)
|
|
186
|
-
*/
|
|
187
|
-
getTreeIDByLexicalKey(nodeKey) {
|
|
188
|
-
return this.lexicalToLoro.get(nodeKey);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Check if a mapping exists for a Lexical NodeKey
|
|
192
|
-
*/
|
|
193
|
-
hasLexicalMapping(nodeKey) {
|
|
194
|
-
return this.lexicalToLoro.has(nodeKey);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Check if a mapping exists for a Loro TreeID
|
|
198
|
-
*/
|
|
199
|
-
hasLoroMapping(treeId) {
|
|
200
|
-
return this.loroToLexical.has(treeId);
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Get all current mappings (for debugging)
|
|
204
|
-
*/
|
|
205
|
-
getAllMappings() {
|
|
206
|
-
return {
|
|
207
|
-
lexicalToLoro: new Map(this.lexicalToLoro),
|
|
208
|
-
loroToLexical: new Map(this.loroToLexical)
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Clear all mappings (useful for testing or reset)
|
|
213
|
-
*/
|
|
214
|
-
clearMappings() {
|
|
215
|
-
this.lexicalToLoro.clear();
|
|
216
|
-
this.loroToLexical.clear();
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Synchronize existing tree nodes with Lexical editor state
|
|
220
|
-
* This should be called during initialization to establish mappings
|
|
221
|
-
*
|
|
222
|
-
* Note: Since lexicalKey is no longer persisted in tree node data,
|
|
223
|
-
* this method now relies on the TreeIntegrator to create mappings
|
|
224
|
-
* as nodes are integrated from Loro tree operations.
|
|
225
|
-
*/
|
|
226
|
-
syncExistingNodes(editorState) {
|
|
227
|
-
// Since we no longer persist lexicalKey in tree node data,
|
|
228
|
-
// we cannot automatically establish mappings from existing tree nodes.
|
|
229
|
-
//
|
|
230
|
-
// Instead, mappings will be established through:
|
|
231
|
-
// 1. TreeIntegrator processing tree diffs during initialization
|
|
232
|
-
// 2. Normal collaboration flow as nodes are created/updated
|
|
233
|
-
//
|
|
234
|
-
// This method is kept for compatibility but is now a no-op.
|
|
235
|
-
console.log('📍 syncExistingNodes: Skipping sync - mappings established through TreeIntegrator');
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
// Global instance to be shared across the application
|
|
239
|
-
let globalNodeMapper = null;
|
|
240
|
-
/**
|
|
241
|
-
* Initialize the global node mapper
|
|
242
|
-
*/
|
|
243
|
-
export function initializeNodeMapper(binding) {
|
|
244
|
-
globalNodeMapper = new NodeMapper(binding);
|
|
245
|
-
return globalNodeMapper;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Get the global node mapper instance
|
|
249
|
-
*/
|
|
250
|
-
export function getNodeMapper() {
|
|
251
|
-
if (!globalNodeMapper) {
|
|
252
|
-
throw new Error('NodeMapper not initialized. Call initializeNodeMapper() first.');
|
|
253
|
-
}
|
|
254
|
-
return globalNodeMapper;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Utility functions for common operations
|
|
258
|
-
*/
|
|
259
|
-
/**
|
|
260
|
-
* Get Loro TreeNode by Lexical NodeKey (using global mapper)
|
|
261
|
-
*/
|
|
262
|
-
export function getLoroNodeByLexicalKey(nodeKey, lexicalNode, parentTreeID, index) {
|
|
263
|
-
return getNodeMapper().getLoroNodeByLexicalKey(nodeKey, lexicalNode, parentTreeID, index);
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Get Lexical NodeKey by Loro TreeID (using global mapper)
|
|
267
|
-
*/
|
|
268
|
-
export function getLexicalKeyByLoroId(treeId) {
|
|
269
|
-
return getNodeMapper().getLexicalKeyByLoroId(treeId);
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Get Lexical Node by Loro TreeID (using global mapper)
|
|
273
|
-
*/
|
|
274
|
-
export function getLexicalNodeByLoroId(treeId, editorState) {
|
|
275
|
-
return getNodeMapper().getLexicalNodeByLoroId(treeId, editorState);
|
|
276
|
-
}
|
|
277
|
-
// createLexicalNodeFromLoro function is now imported from NodeFactory
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { TreeID, LoroTree } from 'loro-crdt';
|
|
2
|
-
import { DecoratorNode, UpdateListenerPayload, NodeKey, ElementNode } from 'lexical';
|
|
3
|
-
import { Binding } from '../Bindings';
|
|
4
|
-
/**
|
|
5
|
-
* DecoratorNode Propagator for Loro Tree Collaboration
|
|
6
|
-
*
|
|
7
|
-
* DecoratorNode characteristics:
|
|
8
|
-
* - Wraps arbitrary view (React components, DOM nodes, etc.)
|
|
9
|
-
* - Acts as opaque wrapper around external components
|
|
10
|
-
* - Cannot have children in the traditional sense
|
|
11
|
-
* - Renders through decorate() method which returns the view
|
|
12
|
-
* - Examples: Images, Videos, Tweets, Charts, Custom Widgets
|
|
13
|
-
*/
|
|
14
|
-
export interface DecoratorNodeMutatorOptions {
|
|
15
|
-
binding: Binding;
|
|
16
|
-
tree: LoroTree;
|
|
17
|
-
peerId: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create DecoratorNode in Loro tree
|
|
21
|
-
*/
|
|
22
|
-
export declare function createDecoratorNodeInLoro(nodeKey: NodeKey, decoratorType: string, // 'image', 'video', 'tweet', 'chart', etc.
|
|
23
|
-
decoratorData: any, // The data needed to render the decorator
|
|
24
|
-
parentId?: TreeID, index?: number, metadata?: Record<string, any>, lexicalNodeJSON?: any, // JSON object from exportJSON()
|
|
25
|
-
options?: DecoratorNodeMutatorOptions): TreeID;
|
|
26
|
-
/**
|
|
27
|
-
* Update DecoratorNode in Loro tree
|
|
28
|
-
*/
|
|
29
|
-
export declare function updateDecoratorNodeInLoro(nodeKey: NodeKey, decoratorType?: string, decoratorData?: any, parentId?: TreeID, index?: number, metadata?: Record<string, any>, lexicalNodeJSON?: any, // JSON object from exportJSON()
|
|
30
|
-
options?: DecoratorNodeMutatorOptions): void;
|
|
31
|
-
/**
|
|
32
|
-
* Delete DecoratorNode from Loro tree
|
|
33
|
-
*/
|
|
34
|
-
export declare function deleteDecoratorNodeInLoro(nodeKey: NodeKey, options: DecoratorNodeMutatorOptions): void;
|
|
35
|
-
/**
|
|
36
|
-
* Create DecoratorNode in Lexical from Loro tree data
|
|
37
|
-
* Note: This is a generic implementation. In practice, you'd need
|
|
38
|
-
* specific decorator node classes for each type (ImageNode, VideoNode, etc.)
|
|
39
|
-
*/
|
|
40
|
-
export declare function createDecoratorNodeFromLoro(treeId: TreeID, parentNode: ElementNode, index?: number, options?: DecoratorNodeMutatorOptions): DecoratorNode<any> | null;
|
|
41
|
-
/**
|
|
42
|
-
* Update DecoratorNode in Lexical from Loro tree data
|
|
43
|
-
*/
|
|
44
|
-
export declare function updateDecoratorNodeFromLoro(treeId: TreeID, lexicalNode: DecoratorNode<any>, newParentNode?: ElementNode, newIndex?: number, options?: DecoratorNodeMutatorOptions): void;
|
|
45
|
-
/**
|
|
46
|
-
* Delete DecoratorNode from Lexical
|
|
47
|
-
*/
|
|
48
|
-
export declare function deleteDecoratorNodeFromLoro(treeId: TreeID, lexicalNode: DecoratorNode<any>, options?: DecoratorNodeMutatorOptions): void;
|
|
49
|
-
/**
|
|
50
|
-
* Utility to check if a tree node represents a DecoratorNode
|
|
51
|
-
*/
|
|
52
|
-
export declare function isDecoratorNodeInTree(treeId: TreeID, tree: LoroTree): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Get DecoratorNode data from Loro tree
|
|
55
|
-
*/
|
|
56
|
-
export declare function getDecoratorNodeDataFromTree(treeId: TreeID, tree: LoroTree): any;
|
|
57
|
-
/**
|
|
58
|
-
* Main propagate method for DecoratorNode - propagates all mutation types
|
|
59
|
-
*/
|
|
60
|
-
export declare function propagateDecoratorNode(update: UpdateListenerPayload, mutation: 'created' | 'updated' | 'destroyed', nodeKey: NodeKey, options: DecoratorNodeMutatorOptions): void;
|