@datalayer/lexical-loro 0.0.7 → 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 +82 -51
- package/lib/DiffMerge.d.ts +0 -39
- package/lib/DiffMerge.js +0 -437
- package/lib/LoroCollaborativePlugin.d.ts +0 -62
- package/lib/LoroCollaborativePlugin.js +0 -2826
- package/lib/stableNodeState.d.ts +0 -8
- package/lib/stableNodeState.js +0 -15
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AppState, BinaryFiles, ExcalidrawInitialDataState } from '@excalidraw/excalidraw/types';
|
|
2
|
+
import './ExcalidrawModal.css';
|
|
3
|
+
import { ReactPortal } from 'react';
|
|
4
|
+
export type ExcalidrawInitialElements = ExcalidrawInitialDataState['elements'];
|
|
5
|
+
type Props = {
|
|
6
|
+
closeOnClickOutside?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The initial set of elements to draw into the scene
|
|
9
|
+
*/
|
|
10
|
+
initialElements: ExcalidrawInitialElements;
|
|
11
|
+
/**
|
|
12
|
+
* The initial set of elements to draw into the scene
|
|
13
|
+
*/
|
|
14
|
+
initialAppState: AppState;
|
|
15
|
+
/**
|
|
16
|
+
* The initial set of elements to draw into the scene
|
|
17
|
+
*/
|
|
18
|
+
initialFiles: BinaryFiles;
|
|
19
|
+
/**
|
|
20
|
+
* Controls the visibility of the modal
|
|
21
|
+
*/
|
|
22
|
+
isShown?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Callback when closing and discarding the new changes
|
|
25
|
+
*/
|
|
26
|
+
onClose: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Completely remove Excalidraw component
|
|
29
|
+
*/
|
|
30
|
+
onDelete: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Callback when the save button is clicked
|
|
33
|
+
*/
|
|
34
|
+
onSave: (elements: ExcalidrawInitialElements, appState: Partial<AppState>, files: BinaryFiles) => void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @explorer-desc
|
|
38
|
+
* A component which renders a modal with Excalidraw (a painting app)
|
|
39
|
+
* which can be used to export an editable image
|
|
40
|
+
*/
|
|
41
|
+
export default function ExcalidrawModal({ closeOnClickOutside, onSave, initialElements, initialAppState, initialFiles, isShown, onDelete, onClose, }: Props): ReactPortal | null;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './ExcalidrawModal.css';
|
|
3
|
+
import { Excalidraw } from '@excalidraw/excalidraw';
|
|
4
|
+
import { isDOMNode } from 'lexical';
|
|
5
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
6
|
+
import { createPortal } from 'react-dom';
|
|
7
|
+
import Button from './Button';
|
|
8
|
+
import Modal from './Modal';
|
|
9
|
+
/**
|
|
10
|
+
* @explorer-desc
|
|
11
|
+
* A component which renders a modal with Excalidraw (a painting app)
|
|
12
|
+
* which can be used to export an editable image
|
|
13
|
+
*/
|
|
14
|
+
export default function ExcalidrawModal({ closeOnClickOutside = false, onSave, initialElements, initialAppState, initialFiles, isShown = false, onDelete, onClose, }) {
|
|
15
|
+
const excaliDrawModelRef = useRef(null);
|
|
16
|
+
const [excalidrawAPI, setExcalidrawAPI] = useState(null);
|
|
17
|
+
const [discardModalOpen, setDiscardModalOpen] = useState(false);
|
|
18
|
+
const [elements, setElements] = useState(initialElements);
|
|
19
|
+
const [files, setFiles] = useState(initialFiles);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
excaliDrawModelRef.current?.focus();
|
|
22
|
+
}, []);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
let modalOverlayElement = null;
|
|
25
|
+
const clickOutsideHandler = (event) => {
|
|
26
|
+
const target = event.target;
|
|
27
|
+
if (excaliDrawModelRef.current !== null &&
|
|
28
|
+
isDOMNode(target) &&
|
|
29
|
+
!excaliDrawModelRef.current.contains(target) &&
|
|
30
|
+
closeOnClickOutside) {
|
|
31
|
+
onDelete();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
if (excaliDrawModelRef.current !== null) {
|
|
35
|
+
modalOverlayElement = excaliDrawModelRef.current?.parentElement;
|
|
36
|
+
modalOverlayElement?.addEventListener('click', clickOutsideHandler);
|
|
37
|
+
}
|
|
38
|
+
return () => {
|
|
39
|
+
modalOverlayElement?.removeEventListener('click', clickOutsideHandler);
|
|
40
|
+
};
|
|
41
|
+
}, [closeOnClickOutside, onDelete]);
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
const currentModalRef = excaliDrawModelRef.current;
|
|
44
|
+
const onKeyDown = (event) => {
|
|
45
|
+
if (event.key === 'Escape') {
|
|
46
|
+
onDelete();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
currentModalRef?.addEventListener('keydown', onKeyDown);
|
|
50
|
+
return () => {
|
|
51
|
+
currentModalRef?.removeEventListener('keydown', onKeyDown);
|
|
52
|
+
};
|
|
53
|
+
}, [elements, files, onDelete]);
|
|
54
|
+
const save = () => {
|
|
55
|
+
if (elements?.some((el) => !el.isDeleted)) {
|
|
56
|
+
const appState = excalidrawAPI?.getAppState();
|
|
57
|
+
// We only need a subset of the state
|
|
58
|
+
const partialState = {
|
|
59
|
+
exportBackground: appState?.exportBackground,
|
|
60
|
+
exportScale: appState?.exportScale,
|
|
61
|
+
exportWithDarkMode: appState?.theme === 'dark',
|
|
62
|
+
isBindingEnabled: appState?.isBindingEnabled,
|
|
63
|
+
isLoading: appState?.isLoading,
|
|
64
|
+
name: appState?.name,
|
|
65
|
+
theme: appState?.theme,
|
|
66
|
+
viewBackgroundColor: appState?.viewBackgroundColor,
|
|
67
|
+
viewModeEnabled: appState?.viewModeEnabled,
|
|
68
|
+
zenModeEnabled: appState?.zenModeEnabled,
|
|
69
|
+
zoom: appState?.zoom,
|
|
70
|
+
};
|
|
71
|
+
onSave(elements, partialState, files);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// delete node if the scene is clear
|
|
75
|
+
onDelete();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const discard = () => {
|
|
79
|
+
setDiscardModalOpen(true);
|
|
80
|
+
};
|
|
81
|
+
function ShowDiscardDialog() {
|
|
82
|
+
return (_jsxs(Modal, { title: "Discard", onClose: () => {
|
|
83
|
+
setDiscardModalOpen(false);
|
|
84
|
+
}, closeOnClickOutside: false, children: ["Are you sure you want to discard the changes?", _jsxs("div", { className: "ExcalidrawModal__discardModal", children: [_jsx(Button, { onClick: () => {
|
|
85
|
+
setDiscardModalOpen(false);
|
|
86
|
+
onClose();
|
|
87
|
+
}, children: "Discard" }), ' ', _jsx(Button, { onClick: () => {
|
|
88
|
+
setDiscardModalOpen(false);
|
|
89
|
+
}, children: "Cancel" })] })] }));
|
|
90
|
+
}
|
|
91
|
+
if (isShown === false) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const onChange = (els, _, fls) => {
|
|
95
|
+
setElements(els);
|
|
96
|
+
setFiles(fls);
|
|
97
|
+
};
|
|
98
|
+
return createPortal(_jsx("div", { className: "ExcalidrawModal__overlay", role: "dialog", children: _jsx("div", { className: "ExcalidrawModal__modal", ref: excaliDrawModelRef, tabIndex: -1, children: _jsxs("div", { className: "ExcalidrawModal__row", children: [discardModalOpen && _jsx(ShowDiscardDialog, {}), _jsx(Excalidraw, { onChange: onChange, excalidrawAPI: setExcalidrawAPI, initialData: {
|
|
99
|
+
appState: initialAppState || { isLoading: false },
|
|
100
|
+
elements: initialElements,
|
|
101
|
+
files: initialFiles,
|
|
102
|
+
} }), _jsxs("div", { className: "ExcalidrawModal__actions", children: [_jsx("button", { className: "action-button", onClick: discard, children: "Discard" }), _jsx("button", { className: "action-button", onClick: save, children: "Save" })] })] }) }) }), document.body);
|
|
103
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import './Input.css';
|
|
3
|
+
type Props = Readonly<{
|
|
4
|
+
'data-test-id'?: string;
|
|
5
|
+
accept?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
onChange: (files: FileList | null) => void;
|
|
8
|
+
}>;
|
|
9
|
+
export default function FileInput({ accept, label, onChange, 'data-test-id': dataTestId, }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './Input.css';
|
|
3
|
+
export default function FileInput({ accept, label, onChange, 'data-test-id': dataTestId, }) {
|
|
4
|
+
return (_jsxs("div", { className: "Input__wrapper", children: [_jsx("label", { className: "Input__label", children: label }), _jsx("input", { type: "file", accept: accept, className: "Input__input", onChange: (e) => onChange(e.target.files), "data-test-id": dataTestId })] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import './FlashMessage.css';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
export default function FlashMessage({ children, }) {
|
|
5
|
+
return createPortal(_jsx("div", { className: "FlashMessage__overlay", role: "dialog", children: _jsx("p", { className: "FlashMessage__alert", role: "alert", children: children }) }), document.body);
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LexicalEditor } from 'lexical';
|
|
2
|
+
import type { JSX } from 'react';
|
|
3
|
+
export default function ImageResizer({ onResizeStart, onResizeEnd, buttonRef, imageRef, maxWidth, editor, showCaption, setShowCaption, captionsEnabled, }: {
|
|
4
|
+
editor: LexicalEditor;
|
|
5
|
+
buttonRef: {
|
|
6
|
+
current: null | HTMLButtonElement;
|
|
7
|
+
};
|
|
8
|
+
imageRef: {
|
|
9
|
+
current: null | HTMLElement;
|
|
10
|
+
};
|
|
11
|
+
maxWidth?: number;
|
|
12
|
+
onResizeEnd: (width: 'inherit' | number, height: 'inherit' | number) => void;
|
|
13
|
+
onResizeStart: () => void;
|
|
14
|
+
setShowCaption: (show: boolean) => void;
|
|
15
|
+
showCaption: boolean;
|
|
16
|
+
captionsEnabled: boolean;
|
|
17
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { calculateZoomLevel } from '@lexical/utils';
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
function clamp(value, min, max) {
|
|
5
|
+
return Math.min(Math.max(value, min), max);
|
|
6
|
+
}
|
|
7
|
+
const Direction = {
|
|
8
|
+
east: 1 << 0,
|
|
9
|
+
north: 1 << 3,
|
|
10
|
+
south: 1 << 1,
|
|
11
|
+
west: 1 << 2,
|
|
12
|
+
};
|
|
13
|
+
export default function ImageResizer({ onResizeStart, onResizeEnd, buttonRef, imageRef, maxWidth, editor, showCaption, setShowCaption, captionsEnabled, }) {
|
|
14
|
+
const controlWrapperRef = useRef(null);
|
|
15
|
+
const userSelect = useRef({
|
|
16
|
+
priority: '',
|
|
17
|
+
value: 'default',
|
|
18
|
+
});
|
|
19
|
+
const positioningRef = useRef({
|
|
20
|
+
currentHeight: 0,
|
|
21
|
+
currentWidth: 0,
|
|
22
|
+
direction: 0,
|
|
23
|
+
isResizing: false,
|
|
24
|
+
ratio: 0,
|
|
25
|
+
startHeight: 0,
|
|
26
|
+
startWidth: 0,
|
|
27
|
+
startX: 0,
|
|
28
|
+
startY: 0,
|
|
29
|
+
});
|
|
30
|
+
const editorRootElement = editor.getRootElement();
|
|
31
|
+
// Find max width, accounting for editor padding.
|
|
32
|
+
const maxWidthContainer = maxWidth
|
|
33
|
+
? maxWidth
|
|
34
|
+
: editorRootElement !== null
|
|
35
|
+
? editorRootElement.getBoundingClientRect().width - 20
|
|
36
|
+
: 100;
|
|
37
|
+
const maxHeightContainer = editorRootElement !== null
|
|
38
|
+
? editorRootElement.getBoundingClientRect().height - 20
|
|
39
|
+
: 100;
|
|
40
|
+
const minWidth = 100;
|
|
41
|
+
const minHeight = 100;
|
|
42
|
+
const setStartCursor = (direction) => {
|
|
43
|
+
const ew = direction === Direction.east || direction === Direction.west;
|
|
44
|
+
const ns = direction === Direction.north || direction === Direction.south;
|
|
45
|
+
const nwse = (direction & Direction.north && direction & Direction.west) ||
|
|
46
|
+
(direction & Direction.south && direction & Direction.east);
|
|
47
|
+
const cursorDir = ew ? 'ew' : ns ? 'ns' : nwse ? 'nwse' : 'nesw';
|
|
48
|
+
if (editorRootElement !== null) {
|
|
49
|
+
editorRootElement.style.setProperty('cursor', `${cursorDir}-resize`, 'important');
|
|
50
|
+
}
|
|
51
|
+
if (document.body !== null) {
|
|
52
|
+
document.body.style.setProperty('cursor', `${cursorDir}-resize`, 'important');
|
|
53
|
+
userSelect.current.value = document.body.style.getPropertyValue('-webkit-user-select');
|
|
54
|
+
userSelect.current.priority = document.body.style.getPropertyPriority('-webkit-user-select');
|
|
55
|
+
document.body.style.setProperty('-webkit-user-select', `none`, 'important');
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const setEndCursor = () => {
|
|
59
|
+
if (editorRootElement !== null) {
|
|
60
|
+
editorRootElement.style.setProperty('cursor', 'text');
|
|
61
|
+
}
|
|
62
|
+
if (document.body !== null) {
|
|
63
|
+
document.body.style.setProperty('cursor', 'default');
|
|
64
|
+
document.body.style.setProperty('-webkit-user-select', userSelect.current.value, userSelect.current.priority);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handlePointerDown = (event, direction) => {
|
|
68
|
+
if (!editor.isEditable()) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const image = imageRef.current;
|
|
72
|
+
const controlWrapper = controlWrapperRef.current;
|
|
73
|
+
if (image !== null && controlWrapper !== null) {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
const { width, height } = image.getBoundingClientRect();
|
|
76
|
+
const zoom = calculateZoomLevel(image);
|
|
77
|
+
const positioning = positioningRef.current;
|
|
78
|
+
positioning.startWidth = width;
|
|
79
|
+
positioning.startHeight = height;
|
|
80
|
+
positioning.ratio = width / height;
|
|
81
|
+
positioning.currentWidth = width;
|
|
82
|
+
positioning.currentHeight = height;
|
|
83
|
+
positioning.startX = event.clientX / zoom;
|
|
84
|
+
positioning.startY = event.clientY / zoom;
|
|
85
|
+
positioning.isResizing = true;
|
|
86
|
+
positioning.direction = direction;
|
|
87
|
+
setStartCursor(direction);
|
|
88
|
+
onResizeStart();
|
|
89
|
+
controlWrapper.classList.add('image-control-wrapper--resizing');
|
|
90
|
+
image.style.height = `${height}px`;
|
|
91
|
+
image.style.width = `${width}px`;
|
|
92
|
+
document.addEventListener('pointermove', handlePointerMove);
|
|
93
|
+
document.addEventListener('pointerup', handlePointerUp);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const handlePointerMove = (event) => {
|
|
97
|
+
const image = imageRef.current;
|
|
98
|
+
const positioning = positioningRef.current;
|
|
99
|
+
const isHorizontal = positioning.direction & (Direction.east | Direction.west);
|
|
100
|
+
const isVertical = positioning.direction & (Direction.south | Direction.north);
|
|
101
|
+
if (image !== null && positioning.isResizing) {
|
|
102
|
+
const zoom = calculateZoomLevel(image);
|
|
103
|
+
// Corner cursor
|
|
104
|
+
if (isHorizontal && isVertical) {
|
|
105
|
+
let diff = Math.floor(positioning.startX - event.clientX / zoom);
|
|
106
|
+
diff = positioning.direction & Direction.east ? -diff : diff;
|
|
107
|
+
const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
|
|
108
|
+
const height = width / positioning.ratio;
|
|
109
|
+
image.style.width = `${width}px`;
|
|
110
|
+
image.style.height = `${height}px`;
|
|
111
|
+
positioning.currentHeight = height;
|
|
112
|
+
positioning.currentWidth = width;
|
|
113
|
+
}
|
|
114
|
+
else if (isVertical) {
|
|
115
|
+
let diff = Math.floor(positioning.startY - event.clientY / zoom);
|
|
116
|
+
diff = positioning.direction & Direction.south ? -diff : diff;
|
|
117
|
+
const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);
|
|
118
|
+
image.style.height = `${height}px`;
|
|
119
|
+
positioning.currentHeight = height;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
let diff = Math.floor(positioning.startX - event.clientX / zoom);
|
|
123
|
+
diff = positioning.direction & Direction.east ? -diff : diff;
|
|
124
|
+
const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
|
|
125
|
+
image.style.width = `${width}px`;
|
|
126
|
+
positioning.currentWidth = width;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const handlePointerUp = () => {
|
|
131
|
+
const image = imageRef.current;
|
|
132
|
+
const positioning = positioningRef.current;
|
|
133
|
+
const controlWrapper = controlWrapperRef.current;
|
|
134
|
+
if (image !== null && controlWrapper !== null && positioning.isResizing) {
|
|
135
|
+
const width = positioning.currentWidth;
|
|
136
|
+
const height = positioning.currentHeight;
|
|
137
|
+
positioning.startWidth = 0;
|
|
138
|
+
positioning.startHeight = 0;
|
|
139
|
+
positioning.ratio = 0;
|
|
140
|
+
positioning.startX = 0;
|
|
141
|
+
positioning.startY = 0;
|
|
142
|
+
positioning.currentWidth = 0;
|
|
143
|
+
positioning.currentHeight = 0;
|
|
144
|
+
positioning.isResizing = false;
|
|
145
|
+
controlWrapper.classList.remove('image-control-wrapper--resizing');
|
|
146
|
+
setEndCursor();
|
|
147
|
+
onResizeEnd(width, height);
|
|
148
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
149
|
+
document.removeEventListener('pointerup', handlePointerUp);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return (_jsxs("div", { ref: controlWrapperRef, children: [!showCaption && captionsEnabled && (_jsx("button", { className: "image-caption-button", ref: buttonRef, onClick: () => {
|
|
153
|
+
setShowCaption(!showCaption);
|
|
154
|
+
}, children: "Add Caption" })), _jsx("div", { className: "image-resizer image-resizer-n", onPointerDown: (event) => {
|
|
155
|
+
handlePointerDown(event, Direction.north);
|
|
156
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-ne", onPointerDown: (event) => {
|
|
157
|
+
handlePointerDown(event, Direction.north | Direction.east);
|
|
158
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-e", onPointerDown: (event) => {
|
|
159
|
+
handlePointerDown(event, Direction.east);
|
|
160
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-se", onPointerDown: (event) => {
|
|
161
|
+
handlePointerDown(event, Direction.south | Direction.east);
|
|
162
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-s", onPointerDown: (event) => {
|
|
163
|
+
handlePointerDown(event, Direction.south);
|
|
164
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-sw", onPointerDown: (event) => {
|
|
165
|
+
handlePointerDown(event, Direction.south | Direction.west);
|
|
166
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-w", onPointerDown: (event) => {
|
|
167
|
+
handlePointerDown(event, Direction.west);
|
|
168
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-nw", onPointerDown: (event) => {
|
|
169
|
+
handlePointerDown(event, Direction.north | Direction.west);
|
|
170
|
+
} })] }));
|
|
171
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import './KatexEquationAlterer.css';
|
|
3
|
+
type Props = {
|
|
4
|
+
initialEquation?: string;
|
|
5
|
+
onConfirm: (equation: string, inline: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
export default function KatexEquationAlterer({ onConfirm, initialEquation, }: Props): JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import './KatexEquationAlterer.css';
|
|
3
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
+
import { useCallback, useState } from 'react';
|
|
5
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
6
|
+
import Button from '../ui/Button';
|
|
7
|
+
import KatexRenderer from './KatexRenderer';
|
|
8
|
+
export default function KatexEquationAlterer({ onConfirm, initialEquation = '', }) {
|
|
9
|
+
const [editor] = useLexicalComposerContext();
|
|
10
|
+
const [equation, setEquation] = useState(initialEquation);
|
|
11
|
+
const [inline, setInline] = useState(true);
|
|
12
|
+
const onClick = useCallback(() => {
|
|
13
|
+
onConfirm(equation, inline);
|
|
14
|
+
}, [onConfirm, equation, inline]);
|
|
15
|
+
const onCheckboxChange = useCallback(() => {
|
|
16
|
+
setInline(!inline);
|
|
17
|
+
}, [setInline, inline]);
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "KatexEquationAlterer_defaultRow", children: ["Inline", _jsx("input", { type: "checkbox", checked: inline, onChange: onCheckboxChange })] }), _jsx("div", { className: "KatexEquationAlterer_defaultRow", children: "Equation " }), _jsx("div", { className: "KatexEquationAlterer_centerRow", children: inline ? (_jsx("input", { onChange: (event) => {
|
|
19
|
+
setEquation(event.target.value);
|
|
20
|
+
}, value: equation, className: "KatexEquationAlterer_textArea" })) : (_jsx("textarea", { onChange: (event) => {
|
|
21
|
+
setEquation(event.target.value);
|
|
22
|
+
}, value: equation, className: "KatexEquationAlterer_textArea" })) }), _jsx("div", { className: "KatexEquationAlterer_defaultRow", children: "Visualization " }), _jsx("div", { className: "KatexEquationAlterer_centerRow", children: _jsx(ErrorBoundary, { onError: (e) => editor._onError(e), fallback: null, children: _jsx(KatexRenderer, { equation: equation, inline: false, onDoubleClick: () => null }) }) }), _jsx("div", { className: "KatexEquationAlterer_dialogActions", children: _jsx(Button, { onClick: onClick, children: "Confirm" }) })] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import katex from 'katex';
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
export default function KatexRenderer({ equation, inline, onDoubleClick, }) {
|
|
5
|
+
const katexElementRef = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const katexElement = katexElementRef.current;
|
|
8
|
+
if (katexElement !== null) {
|
|
9
|
+
katex.render(equation, katexElement, {
|
|
10
|
+
displayMode: !inline, // true === block display //
|
|
11
|
+
errorColor: '#cc0000',
|
|
12
|
+
output: 'html',
|
|
13
|
+
strict: 'warn',
|
|
14
|
+
throwOnError: false,
|
|
15
|
+
trust: false,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}, [equation, inline]);
|
|
19
|
+
return (
|
|
20
|
+
// We use an empty image tag either side to ensure Android doesn't try and compose from the
|
|
21
|
+
// inner text from Katex. There didn't seem to be any other way of making this work,
|
|
22
|
+
// without having a physical space.
|
|
23
|
+
_jsxs(_Fragment, { children: [_jsx("img", { src: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", width: "0", height: "0", alt: "" }), _jsx("span", { role: "button", tabIndex: -1, onDoubleClick: onDoubleClick, ref: katexElementRef }), _jsx("img", { src: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", width: "0", height: "0", alt: "" })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import './Modal.css';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export default function Modal({ onClose, children, title, closeOnClickOutside, }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
closeOnClickOutside?: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
title: string;
|
|
9
|
+
}): JSX.Element;
|
package/lib/ui/Modal.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './Modal.css';
|
|
3
|
+
import { isDOMNode } from 'lexical';
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
function PortalImpl({ onClose, children, title, closeOnClickOutside, }) {
|
|
7
|
+
const modalRef = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (modalRef.current !== null) {
|
|
10
|
+
modalRef.current.focus();
|
|
11
|
+
}
|
|
12
|
+
}, []);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
let modalOverlayElement = null;
|
|
15
|
+
const handler = (event) => {
|
|
16
|
+
if (event.key === 'Escape') {
|
|
17
|
+
onClose();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const clickOutsideHandler = (event) => {
|
|
21
|
+
const target = event.target;
|
|
22
|
+
if (modalRef.current !== null &&
|
|
23
|
+
isDOMNode(target) &&
|
|
24
|
+
!modalRef.current.contains(target) &&
|
|
25
|
+
closeOnClickOutside) {
|
|
26
|
+
onClose();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const modelElement = modalRef.current;
|
|
30
|
+
if (modelElement !== null) {
|
|
31
|
+
modalOverlayElement = modelElement.parentElement;
|
|
32
|
+
if (modalOverlayElement !== null) {
|
|
33
|
+
modalOverlayElement.addEventListener('click', clickOutsideHandler);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
window.addEventListener('keydown', handler);
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener('keydown', handler);
|
|
39
|
+
if (modalOverlayElement !== null) {
|
|
40
|
+
modalOverlayElement?.removeEventListener('click', clickOutsideHandler);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}, [closeOnClickOutside, onClose]);
|
|
44
|
+
return (_jsx("div", { className: "Modal__overlay", role: "dialog", children: _jsxs("div", { className: "Modal__modal", tabIndex: -1, ref: modalRef, children: [_jsx("h2", { className: "Modal__title", children: title }), _jsx("button", { className: "Modal__closeButton", "aria-label": "Close modal", type: "button", onClick: onClose, children: "X" }), _jsx("div", { className: "Modal__content", children: children })] }) }));
|
|
45
|
+
}
|
|
46
|
+
export default function Modal({ onClose, children, title, closeOnClickOutside = false, }) {
|
|
47
|
+
return createPortal(_jsx(PortalImpl, { onClose: onClose, title: title, closeOnClickOutside: closeOnClickOutside, children: children }), document.body);
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import './Select.css';
|
|
3
|
+
type SelectIntrinsicProps = JSX.IntrinsicElements['select'];
|
|
4
|
+
interface SelectProps extends SelectIntrinsicProps {
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
export default function Select({ children, label, className, ...other }: SelectProps): JSX.Element;
|
|
8
|
+
export {};
|
package/lib/ui/Select.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './Select.css';
|
|
3
|
+
export default function Select({ children, label, className, ...other }) {
|
|
4
|
+
return (_jsxs("div", { className: "Input__wrapper", children: [_jsx("label", { style: { marginTop: '-1em' }, className: "Input__label", children: label }), _jsx("select", { ...other, className: className || 'select', children: children })] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export default function Switch({ checked, onClick, text, id, }: Readonly<{
|
|
4
|
+
checked: boolean;
|
|
5
|
+
id?: string;
|
|
6
|
+
onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
7
|
+
text: string;
|
|
8
|
+
}>): JSX.Element;
|
package/lib/ui/Switch.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
export default function Switch({ checked, onClick, text, id, }) {
|
|
4
|
+
const buttonId = useMemo(() => 'id_' + Math.floor(Math.random() * 10000), []);
|
|
5
|
+
return (_jsxs("div", { className: "switch", id: id, children: [_jsx("label", { htmlFor: buttonId, children: text }), _jsx("button", { role: "switch", "aria-checked": checked, id: buttonId, onClick: onClick, children: _jsx("span", {}) })] }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import './Input.css';
|
|
3
|
+
import { HTMLInputTypeAttribute } from 'react';
|
|
4
|
+
type Props = Readonly<{
|
|
5
|
+
'data-test-id'?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
onChange: (val: string) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
value: string;
|
|
10
|
+
type?: HTMLInputTypeAttribute;
|
|
11
|
+
}>;
|
|
12
|
+
export default function TextInput({ label, value, onChange, placeholder, 'data-test-id': dataTestId, type, }: Props): JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './Input.css';
|
|
3
|
+
export default function TextInput({ label, value, onChange, placeholder = '', 'data-test-id': dataTestId, type = 'text', }) {
|
|
4
|
+
return (_jsxs("div", { className: "Input__wrapper", children: [_jsx("label", { className: "Input__label", children: label }), _jsx("input", { type: type, className: "Input__input", placeholder: placeholder, value: value, onChange: (e) => {
|
|
5
|
+
onChange(e.target.value);
|
|
6
|
+
}, "data-test-id": dataTestId })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
async function* generateReader(reader) {
|
|
3
|
+
let done = false;
|
|
4
|
+
while (!done) {
|
|
5
|
+
const res = await reader.read();
|
|
6
|
+
const { value } = res;
|
|
7
|
+
if (value !== undefined) {
|
|
8
|
+
yield value;
|
|
9
|
+
}
|
|
10
|
+
done = res.done;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
async function readBytestoString(reader) {
|
|
14
|
+
const output = [];
|
|
15
|
+
const chunkSize = 0x8000;
|
|
16
|
+
for await (const value of generateReader(reader)) {
|
|
17
|
+
for (let i = 0; i < value.length; i += chunkSize) {
|
|
18
|
+
output.push(String.fromCharCode(...value.subarray(i, i + chunkSize)));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return output.join('');
|
|
22
|
+
}
|
|
23
|
+
export async function docToHash(doc) {
|
|
24
|
+
const cs = new CompressionStream('gzip');
|
|
25
|
+
const writer = cs.writable.getWriter();
|
|
26
|
+
const [, output] = await Promise.all([
|
|
27
|
+
writer
|
|
28
|
+
.write(new TextEncoder().encode(JSON.stringify(doc)))
|
|
29
|
+
.then(() => writer.close()),
|
|
30
|
+
readBytestoString(cs.readable.getReader()),
|
|
31
|
+
]);
|
|
32
|
+
return `#doc=${btoa(output)
|
|
33
|
+
.replace(/\//g, '_')
|
|
34
|
+
.replace(/\+/g, '-')
|
|
35
|
+
.replace(/=+$/, '')}`;
|
|
36
|
+
}
|
|
37
|
+
export async function docFromHash(hash) {
|
|
38
|
+
const m = /^#doc=(.*)$/.exec(hash);
|
|
39
|
+
if (!m) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const ds = new DecompressionStream('gzip');
|
|
43
|
+
const writer = ds.writable.getWriter();
|
|
44
|
+
const b64 = atob(m[1].replace(/_/g, '/').replace(/-/g, '+'));
|
|
45
|
+
const array = new Uint8Array(b64.length);
|
|
46
|
+
for (let i = 0; i < b64.length; i++) {
|
|
47
|
+
array[i] = b64.charCodeAt(i);
|
|
48
|
+
}
|
|
49
|
+
const closed = writer.write(array).then(() => writer.close());
|
|
50
|
+
const output = [];
|
|
51
|
+
for await (const chunk of generateReader(ds.readable.pipeThrough(new TextDecoderStream()).getReader())) {
|
|
52
|
+
output.push(chunk);
|
|
53
|
+
}
|
|
54
|
+
await closed;
|
|
55
|
+
return JSON.parse(output.join(''));
|
|
56
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: ({
|
|
2
|
+
description: string;
|
|
3
|
+
emoji: string;
|
|
4
|
+
category: string;
|
|
5
|
+
aliases: string[];
|
|
6
|
+
tags: string[];
|
|
7
|
+
unicode_version: string;
|
|
8
|
+
ios_version: string;
|
|
9
|
+
skin_tones?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
emoji: string;
|
|
12
|
+
description: string;
|
|
13
|
+
category: string;
|
|
14
|
+
aliases: string[];
|
|
15
|
+
tags: string[];
|
|
16
|
+
unicode_version: string;
|
|
17
|
+
ios_version: string;
|
|
18
|
+
skin_tones: boolean;
|
|
19
|
+
})[];
|
|
20
|
+
export default _default;
|