@blocklet/editor-lite 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +33 -0
- package/lib/blocklet-editor-viewer.d.ts +4 -0
- package/lib/blocklet-editor-viewer.js +12 -0
- package/lib/blocklet-editor.d.ts +2 -0
- package/lib/blocklet-editor.js +12 -0
- package/lib/components/Loading.d.ts +4 -0
- package/lib/components/Loading.js +13 -0
- package/lib/components/SelectionPopper.d.ts +14 -0
- package/lib/components/SelectionPopper.js +73 -0
- package/lib/components/animateText.d.ts +3 -0
- package/lib/components/animateText.js +29 -0
- package/lib/components/createPortal.d.ts +2 -0
- package/lib/components/createPortal.js +16 -0
- package/lib/config.d.ts +37 -0
- package/lib/config.js +12 -0
- package/lib/ext/AIPlugin/AIIcon.d.ts +5 -0
- package/lib/ext/AIPlugin/AIIcon.js +7 -0
- package/lib/ext/AIPlugin/Arrow.d.ts +1 -0
- package/lib/ext/AIPlugin/Arrow.js +5 -0
- package/lib/ext/AIPlugin/TextGeneration.d.ts +6 -0
- package/lib/ext/AIPlugin/TextGeneration.js +131 -0
- package/lib/ext/AIPlugin/Writing.d.ts +1 -0
- package/lib/ext/AIPlugin/Writing.js +7 -0
- package/lib/ext/AIPlugin/index.d.ts +9 -0
- package/lib/ext/AIPlugin/index.js +180 -0
- package/lib/ext/AIPlugin/utils.d.ts +6 -0
- package/lib/ext/AIPlugin/utils.js +44 -0
- package/lib/ext/AITranslationPlugin/index.d.ts +9 -0
- package/lib/ext/AITranslationPlugin/index.js +124 -0
- package/lib/ext/AITranslationPlugin/selection.d.ts +3 -0
- package/lib/ext/AITranslationPlugin/selection.js +45 -0
- package/lib/ext/AITranslationPlugin/translation.d.ts +3 -0
- package/lib/ext/AITranslationPlugin/translation.js +67 -0
- package/lib/ext/AITranslationPlugin/types.d.ts +49 -0
- package/lib/ext/AITranslationPlugin/types.js +1 -0
- package/lib/ext/AITranslationPlugin/utils.d.ts +46 -0
- package/lib/ext/AITranslationPlugin/utils.js +343 -0
- package/lib/ext/Aide/Aide.d.ts +4 -0
- package/lib/ext/Aide/Aide.js +30 -0
- package/lib/ext/Aide/Delayed.d.ts +7 -0
- package/lib/ext/Aide/Delayed.js +12 -0
- package/lib/ext/Aide/Input.d.ts +6 -0
- package/lib/ext/Aide/Input.js +49 -0
- package/lib/ext/Aide/Menu.d.ts +4 -0
- package/lib/ext/Aide/Menu.js +29 -0
- package/lib/ext/Aide/Output.d.ts +4 -0
- package/lib/ext/Aide/Output.js +14 -0
- package/lib/ext/Aide/Templates.d.ts +4 -0
- package/lib/ext/Aide/Templates.js +34 -0
- package/lib/ext/Aide/builtin-templates.d.ts +3 -0
- package/lib/ext/Aide/builtin-templates.js +48 -0
- package/lib/ext/Aide/context.d.ts +47 -0
- package/lib/ext/Aide/context.js +114 -0
- package/lib/ext/Aide/external-templates/Breadcrumb.d.ts +10 -0
- package/lib/ext/Aide/external-templates/Breadcrumb.js +11 -0
- package/lib/ext/Aide/external-templates/Output.d.ts +8 -0
- package/lib/ext/Aide/external-templates/Output.js +22 -0
- package/lib/ext/Aide/external-templates/Search.d.ts +6 -0
- package/lib/ext/Aide/external-templates/Search.js +14 -0
- package/lib/ext/Aide/external-templates/Tags.d.ts +4 -0
- package/lib/ext/Aide/external-templates/Tags.js +44 -0
- package/lib/ext/Aide/external-templates/Template.d.ts +7 -0
- package/lib/ext/Aide/external-templates/Template.js +110 -0
- package/lib/ext/Aide/external-templates/Templates.d.ts +6 -0
- package/lib/ext/Aide/external-templates/Templates.js +61 -0
- package/lib/ext/Aide/external-templates/index.d.ts +4 -0
- package/lib/ext/Aide/external-templates/index.js +83 -0
- package/lib/ext/Aide/external-templates/parameter-field.d.ts +6 -0
- package/lib/ext/Aide/external-templates/parameter-field.js +92 -0
- package/lib/ext/Aide/hooks.d.ts +7 -0
- package/lib/ext/Aide/hooks.js +14 -0
- package/lib/ext/Aide/index.d.ts +2 -0
- package/lib/ext/Aide/index.js +2 -0
- package/lib/ext/Aide/types.d.ts +84 -0
- package/lib/ext/Aide/types.js +25 -0
- package/lib/ext/Aide/withAiAvailable.d.ts +5 -0
- package/lib/ext/Aide/withAiAvailable.js +11 -0
- package/lib/ext/Alert/AlertComponent.d.ts +10 -0
- package/lib/ext/Alert/AlertComponent.js +38 -0
- package/lib/ext/Alert/AlertNode.d.ts +28 -0
- package/lib/ext/Alert/AlertNode.js +105 -0
- package/lib/ext/Alert/AlertPlugin.d.ts +11 -0
- package/lib/ext/Alert/AlertPlugin.js +41 -0
- package/lib/ext/BilibiliPlugin/BilibiliNode.d.ts +31 -0
- package/lib/ext/BilibiliPlugin/BilibiliNode.js +95 -0
- package/lib/ext/BilibiliPlugin/BilibiliVideo.d.ts +6 -0
- package/lib/ext/BilibiliPlugin/BilibiliVideo.js +24 -0
- package/lib/ext/BilibiliPlugin/config.d.ts +2 -0
- package/lib/ext/BilibiliPlugin/config.js +40 -0
- package/lib/ext/BilibiliPlugin/index.d.ts +5 -0
- package/lib/ext/BilibiliPlugin/index.js +20 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbed.d.ts +7 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbed.js +51 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbedNode.d.ts +30 -0
- package/lib/ext/BlockletEmbedPlugin/BlockletEmbedNode.js +96 -0
- package/lib/ext/BlockletEmbedPlugin/index.d.ts +12 -0
- package/lib/ext/BlockletEmbedPlugin/index.js +76 -0
- package/lib/ext/BlurTextPlugin.d.ts +1 -0
- package/lib/ext/BlurTextPlugin.js +40 -0
- package/lib/ext/BookmarkPlugin/Bookmark.d.ts +7 -0
- package/lib/ext/BookmarkPlugin/Bookmark.js +175 -0
- package/lib/ext/BookmarkPlugin/BookmarkNode.d.ts +35 -0
- package/lib/ext/BookmarkPlugin/BookmarkNode.js +110 -0
- package/lib/ext/BookmarkPlugin/index.d.ts +11 -0
- package/lib/ext/BookmarkPlugin/index.js +45 -0
- package/lib/ext/BusyPlugin.d.ts +9 -0
- package/lib/ext/BusyPlugin.js +17 -0
- package/lib/ext/CharacterCountPlugin/index.d.ts +10 -0
- package/lib/ext/CharacterCountPlugin/index.js +39 -0
- package/lib/ext/CharacterCountPlugin/useCharacterCount.d.ts +11 -0
- package/lib/ext/CharacterCountPlugin/useCharacterCount.js +49 -0
- package/lib/ext/CharacterLimitPlugin/index.d.ts +9 -0
- package/lib/ext/CharacterLimitPlugin/index.js +49 -0
- package/lib/ext/CheckboxPlugin.d.ts +3 -0
- package/lib/ext/CheckboxPlugin.js +75 -0
- package/lib/ext/CodeCopyPlugin/CodeCopyPlugin.d.ts +2 -0
- package/lib/ext/CodeCopyPlugin/CodeCopyPlugin.js +90 -0
- package/lib/ext/CodeCopyPlugin/copy.svg +1 -0
- package/lib/ext/CodeCopyPlugin/index.d.ts +1 -0
- package/lib/ext/CodeCopyPlugin/index.js +1 -0
- package/lib/ext/CodeCopyPlugin/style.css +12 -0
- package/lib/ext/ContentLocale.d.ts +7 -0
- package/lib/ext/ContentLocale.js +15 -0
- package/lib/ext/CustomOnChangePlugin/index.d.ts +5 -0
- package/lib/ext/CustomOnChangePlugin/index.js +17 -0
- package/lib/ext/CustomOnChangePlugin/styles.css +14 -0
- package/lib/ext/CustomOnChangePlugin/utils.d.ts +30 -0
- package/lib/ext/CustomOnChangePlugin/utils.js +148 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderContext.d.ts +13 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderContext.js +15 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderPlugin.d.ts +1 -0
- package/lib/ext/EditorHolderPlugin/EditorHolderPlugin.js +11 -0
- package/lib/ext/EditorHolderPlugin/index.d.ts +2 -0
- package/lib/ext/EditorHolderPlugin/index.js +2 -0
- package/lib/ext/EditorReadyPlugin.d.ts +3 -0
- package/lib/ext/EditorReadyPlugin.js +15 -0
- package/lib/ext/FilePlugin/FileNode.d.ts +44 -0
- package/lib/ext/FilePlugin/FileNode.js +195 -0
- package/lib/ext/FilePlugin/FilePlugin.d.ts +7 -0
- package/lib/ext/FilePlugin/FilePlugin.js +27 -0
- package/lib/ext/FilePlugin/index.d.ts +2 -0
- package/lib/ext/FilePlugin/index.js +2 -0
- package/lib/ext/HeadingsIdPlugin.d.ts +1 -0
- package/lib/ext/HeadingsIdPlugin.js +67 -0
- package/lib/ext/ImagePathFixerPlugin.d.ts +1 -0
- package/lib/ext/ImagePathFixerPlugin.js +31 -0
- package/lib/ext/InlineTranslationPlugin/EditorTranslator.d.ts +42 -0
- package/lib/ext/InlineTranslationPlugin/EditorTranslator.js +199 -0
- package/lib/ext/InlineTranslationPlugin/InlineTranslationPlugin.d.ts +12 -0
- package/lib/ext/InlineTranslationPlugin/InlineTranslationPlugin.js +232 -0
- package/lib/ext/InlineTranslationPlugin/TranslationNode.d.ts +23 -0
- package/lib/ext/InlineTranslationPlugin/TranslationNode.js +49 -0
- package/lib/ext/InlineTranslationPlugin/index.d.ts +4 -0
- package/lib/ext/InlineTranslationPlugin/index.js +4 -0
- package/lib/ext/InlineTranslationPlugin/store.d.ts +50 -0
- package/lib/ext/InlineTranslationPlugin/store.js +94 -0
- package/lib/ext/InlineTranslationPlugin/types.d.ts +1 -0
- package/lib/ext/InlineTranslationPlugin/types.js +1 -0
- package/lib/ext/LexicalEditorRefPlugin.d.ts +14 -0
- package/lib/ext/LexicalEditorRefPlugin.js +26 -0
- package/lib/ext/OnContentChangePlugin.d.ts +14 -0
- package/lib/ext/OnContentChangePlugin.js +35 -0
- package/lib/ext/PasteSlackImagePlugin/index.d.ts +2 -0
- package/lib/ext/PasteSlackImagePlugin/index.js +22 -0
- package/lib/ext/PostLinkEmbedPlugin/PostLinkNode.d.ts +32 -0
- package/lib/ext/PostLinkEmbedPlugin/PostLinkNode.js +140 -0
- package/lib/ext/PostLinkEmbedPlugin/fixInvalidPostLinkNodes.d.ts +1 -0
- package/lib/ext/PostLinkEmbedPlugin/fixInvalidPostLinkNodes.js +15 -0
- package/lib/ext/PostLinkEmbedPlugin/index.d.ts +21 -0
- package/lib/ext/PostLinkEmbedPlugin/index.js +148 -0
- package/lib/ext/RemoveListPlugin.d.ts +1 -0
- package/lib/ext/RemoveListPlugin.js +63 -0
- package/lib/ext/SafeAreaPlugin.d.ts +12 -0
- package/lib/ext/SafeAreaPlugin.js +56 -0
- package/lib/ext/SelectBlockPlugin.d.ts +1 -0
- package/lib/ext/SelectBlockPlugin.js +95 -0
- package/lib/ext/ShortcutPlugin/CtrlsShortcutPlugin.d.ts +6 -0
- package/lib/ext/ShortcutPlugin/CtrlsShortcutPlugin.js +17 -0
- package/lib/ext/ShortcutPlugin/index.d.ts +1 -0
- package/lib/ext/ShortcutPlugin/index.js +1 -0
- package/lib/ext/TemplatePlugin.d.ts +8 -0
- package/lib/ext/TemplatePlugin.js +170 -0
- package/lib/ext/VideoPathFixerPlugin.d.ts +1 -0
- package/lib/ext/VideoPathFixerPlugin.js +31 -0
- package/lib/ext/VideoPlugin/VideoComponent.d.ts +5 -0
- package/lib/ext/VideoPlugin/VideoComponent.js +5 -0
- package/lib/ext/VideoPlugin/VideoNode.d.ts +37 -0
- package/lib/ext/VideoPlugin/VideoNode.js +97 -0
- package/lib/ext/VideoPlugin/VideoPlugin.d.ts +7 -0
- package/lib/ext/VideoPlugin/VideoPlugin.js +26 -0
- package/lib/ext/VideoPlugin/index.d.ts +2 -0
- package/lib/ext/VideoPlugin/index.js +2 -0
- package/lib/ext/common.d.ts +15 -0
- package/lib/ext/common.js +62 -0
- package/lib/ext/nodes/GithubComp.d.ts +3 -0
- package/lib/ext/nodes/GithubComp.js +20 -0
- package/lib/ext/nodes/GithubNode.d.ts +28 -0
- package/lib/ext/nodes/GithubNode.js +94 -0
- package/lib/ext/nodes/util.d.ts +5 -0
- package/lib/ext/nodes/util.js +1 -0
- package/lib/ext/translation/translation-utils.d.ts +16 -0
- package/lib/ext/translation/translation-utils.js +63 -0
- package/lib/ext/utils.d.ts +21 -0
- package/lib/ext/utils.js +88 -0
- package/lib/global.d.ts +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/lexical-utils/index.d.ts +46 -0
- package/lib/lexical-utils/index.js +243 -0
- package/lib/libs/sort-array-by-key.d.ts +4 -0
- package/lib/libs/sort-array-by-key.js +68 -0
- package/lib/libs/utm.d.ts +9 -0
- package/lib/libs/utm.js +43 -0
- package/lib/main/appSettings.d.ts +11 -0
- package/lib/main/appSettings.js +20 -0
- package/lib/main/context/SharedAutocompleteContext.d.ts +16 -0
- package/lib/main/context/SharedAutocompleteContext.js +35 -0
- package/lib/main/context/SharedHistoryContext.d.ts +17 -0
- package/lib/main/context/SharedHistoryContext.js +11 -0
- package/lib/main/editor-root.d.ts +2 -0
- package/lib/main/editor-root.js +46 -0
- package/lib/main/editor.d.ts +21 -0
- package/lib/main/editor.js +99 -0
- package/lib/main/hooks/hooks.d.ts +15 -0
- package/lib/main/hooks/hooks.js +49 -0
- package/lib/main/hooks/medium-zoom.d.ts +9 -0
- package/lib/main/hooks/medium-zoom.js +34 -0
- package/lib/main/hooks/use-mobile.d.ts +4 -0
- package/lib/main/hooks/use-mobile.js +6 -0
- package/lib/main/hooks/useBeforeUnload.d.ts +1 -0
- package/lib/main/hooks/useBeforeUnload.js +15 -0
- package/lib/main/hooks/useHasNodes.d.ts +1 -0
- package/lib/main/hooks/useHasNodes.js +8 -0
- package/lib/main/hooks/useIsFocused.d.ts +1 -0
- package/lib/main/hooks/useIsFocused.js +20 -0
- package/lib/main/hooks/useModal.d.ts +12 -0
- package/lib/main/hooks/useModal.js +33 -0
- package/lib/main/hooks/useReport.d.ts +8 -0
- package/lib/main/hooks/useReport.js +48 -0
- package/lib/main/hooks/useResponsiveTable.d.ts +5 -0
- package/lib/main/hooks/useResponsiveTable.js +31 -0
- package/lib/main/hooks/useTranslationListener.d.ts +4 -0
- package/lib/main/hooks/useTranslationListener.js +94 -0
- package/lib/main/icons.d.ts +3 -0
- package/lib/main/icons.js +25 -0
- package/lib/main/images/emoji/1F600.png +0 -0
- package/lib/main/images/emoji/1F641.png +0 -0
- package/lib/main/images/emoji/1F642.png +0 -0
- package/lib/main/images/emoji/2764.png +0 -0
- package/lib/main/images/excalidraw.svg +3 -0
- package/lib/main/images/icons/arrow-clockwise.svg +1 -0
- package/lib/main/images/icons/arrow-counterclockwise.svg +1 -0
- package/lib/main/images/icons/bg-color.svg +1 -0
- package/lib/main/images/icons/camera.svg +1 -0
- package/lib/main/images/icons/caret-right-fill.svg +1 -0
- package/lib/main/images/icons/chat-left-text.svg +1 -0
- package/lib/main/images/icons/chat-right-dots.svg +1 -0
- package/lib/main/images/icons/chat-right-text.svg +1 -0
- package/lib/main/images/icons/chat-right.svg +1 -0
- package/lib/main/images/icons/chat-square-quote.svg +1 -0
- package/lib/main/images/icons/chevron-down.svg +1 -0
- package/lib/main/images/icons/clipboard.svg +1 -0
- package/lib/main/images/icons/close.svg +1 -0
- package/lib/main/images/icons/code.svg +1 -0
- package/lib/main/images/icons/comments.svg +1 -0
- package/lib/main/images/icons/copy.svg +1 -0
- package/lib/main/images/icons/diagram-2.svg +1 -0
- package/lib/main/images/icons/download.svg +1 -0
- package/lib/main/images/icons/draggable-block-menu.svg +1 -0
- package/lib/main/images/icons/dropdown-more.svg +1 -0
- package/lib/main/images/icons/figma.svg +1 -0
- package/lib/main/images/icons/file-image.svg +1 -0
- package/lib/main/images/icons/filetype-gif.svg +1 -0
- package/lib/main/images/icons/font-color.svg +1 -0
- package/lib/main/images/icons/font-family.svg +1 -0
- package/lib/main/images/icons/gear.svg +1 -0
- package/lib/main/images/icons/horizontal-rule.svg +1 -0
- package/lib/main/images/icons/indent.svg +1 -0
- package/lib/main/images/icons/journal-code.svg +1 -0
- package/lib/main/images/icons/journal-text.svg +1 -0
- package/lib/main/images/icons/justify.svg +1 -0
- package/lib/main/images/icons/link.svg +1 -0
- package/lib/main/images/icons/list-ol.svg +1 -0
- package/lib/main/images/icons/list-ul.svg +1 -0
- package/lib/main/images/icons/lock-fill.svg +1 -0
- package/lib/main/images/icons/lock.svg +1 -0
- package/lib/main/images/icons/markdown.svg +1 -0
- package/lib/main/images/icons/mic.svg +1 -0
- package/lib/main/images/icons/outdent.svg +1 -0
- package/lib/main/images/icons/paint-bucket.svg +1 -0
- package/lib/main/images/icons/palette.svg +1 -0
- package/lib/main/images/icons/pencil-fill.svg +1 -0
- package/lib/main/images/icons/plug-fill.svg +1 -0
- package/lib/main/images/icons/plug.svg +1 -0
- package/lib/main/images/icons/plus-slash-minus.svg +1 -0
- package/lib/main/images/icons/plus.svg +1 -0
- package/lib/main/images/icons/prettier-error.svg +1 -0
- package/lib/main/images/icons/prettier.svg +1 -0
- package/lib/main/images/icons/send.svg +1 -0
- package/lib/main/images/icons/square-check.svg +1 -0
- package/lib/main/images/icons/sticky.svg +1 -0
- package/lib/main/images/icons/success.svg +1 -0
- package/lib/main/images/icons/table.svg +1 -0
- package/lib/main/images/icons/text-center.svg +1 -0
- package/lib/main/images/icons/text-left.svg +1 -0
- package/lib/main/images/icons/text-paragraph.svg +1 -0
- package/lib/main/images/icons/text-right.svg +1 -0
- package/lib/main/images/icons/trash.svg +1 -0
- package/lib/main/images/icons/trash3.svg +1 -0
- package/lib/main/images/icons/tweet.svg +1 -0
- package/lib/main/images/icons/type-bold.svg +1 -0
- package/lib/main/images/icons/type-h1.svg +1 -0
- package/lib/main/images/icons/type-h2.svg +1 -0
- package/lib/main/images/icons/type-h3.svg +1 -0
- package/lib/main/images/icons/type-h4.svg +1 -0
- package/lib/main/images/icons/type-h5.svg +1 -0
- package/lib/main/images/icons/type-h6.svg +1 -0
- package/lib/main/images/icons/type-italic.svg +1 -0
- package/lib/main/images/icons/type-strikethrough.svg +1 -0
- package/lib/main/images/icons/type-subscript.svg +1 -0
- package/lib/main/images/icons/type-superscript.svg +1 -0
- package/lib/main/images/icons/type-underline.svg +1 -0
- package/lib/main/images/icons/upload.svg +1 -0
- package/lib/main/images/icons/user.svg +1 -0
- package/lib/main/images/icons/youtube.svg +1 -0
- package/lib/main/images/landscape.jpg +0 -0
- package/lib/main/index.css +257 -0
- package/lib/main/index.d.ts +28 -0
- package/lib/main/index.js +52 -0
- package/lib/main/nodes/EmojiNode.d.ts +25 -0
- package/lib/main/nodes/EmojiNode.js +57 -0
- package/lib/main/nodes/EquationNode.d.ts +31 -0
- package/lib/main/nodes/EquationNode.js +65 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawComponent.d.ts +13 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawComponent.js +155 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawImage.d.ts +58 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawImage.js +60 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.css +75 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.d.ts +49 -0
- package/lib/main/nodes/ExcalidrawNode/ExcalidrawModal.js +197 -0
- package/lib/main/nodes/ExcalidrawNode/index.d.ts +30 -0
- package/lib/main/nodes/ExcalidrawNode/index.js +95 -0
- package/lib/main/nodes/ExcalidrawNode/utils.d.ts +5 -0
- package/lib/main/nodes/ExcalidrawNode/utils.js +71 -0
- package/lib/main/nodes/FigmaNode.d.ts +30 -0
- package/lib/main/nodes/FigmaNode.js +59 -0
- package/lib/main/nodes/ImageComponent.d.ts +27 -0
- package/lib/main/nodes/ImageComponent.js +432 -0
- package/lib/main/nodes/ImageNode.css +51 -0
- package/lib/main/nodes/ImageNode.d.ts +74 -0
- package/lib/main/nodes/ImageNode.js +151 -0
- package/lib/main/nodes/KeywordNode.d.ts +25 -0
- package/lib/main/nodes/KeywordNode.js +52 -0
- package/lib/main/nodes/MentionNode.d.ts +27 -0
- package/lib/main/nodes/MentionNode.js +88 -0
- package/lib/main/nodes/PlaygroundNodes.d.ts +10 -0
- package/lib/main/nodes/PlaygroundNodes.js +70 -0
- package/lib/main/nodes/TweetNode.d.ts +31 -0
- package/lib/main/nodes/TweetNode.js +126 -0
- package/lib/main/nodes/YouTubeNode.d.ts +32 -0
- package/lib/main/nodes/YouTubeNode.js +94 -0
- package/lib/main/plugins/AutoEmbedPlugin/index.d.ts +27 -0
- package/lib/main/plugins/AutoEmbedPlugin/index.js +353 -0
- package/lib/main/plugins/AutoEmbedPlugin/urlParseCache.d.ts +2 -0
- package/lib/main/plugins/AutoEmbedPlugin/urlParseCache.js +14 -0
- package/lib/main/plugins/AutoLinkPlugin/index.d.ts +9 -0
- package/lib/main/plugins/AutoLinkPlugin/index.js +39 -0
- package/lib/main/plugins/ClickableLinkPlugin/index.d.ts +8 -0
- package/lib/main/plugins/ClickableLinkPlugin/index.js +141 -0
- package/lib/main/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +7 -0
- package/lib/main/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +44 -0
- package/lib/main/plugins/CodeActionMenuPlugin/index.css +46 -0
- package/lib/main/plugins/CodeActionMenuPlugin/index.d.ts +12 -0
- package/lib/main/plugins/CodeActionMenuPlugin/index.js +100 -0
- package/lib/main/plugins/CodeActionMenuPlugin/utils.d.ts +2 -0
- package/lib/main/plugins/CodeActionMenuPlugin/utils.js +18 -0
- package/lib/main/plugins/CodeHighlightPlugin/index.d.ts +9 -0
- package/lib/main/plugins/CodeHighlightPlugin/index.js +17 -0
- package/lib/main/plugins/CollapsiblePlugin/Collapsible.css +61 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +30 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContainerNode.js +120 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +24 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleContentNode.js +90 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +24 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleTitleNode.js +95 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleUtils.d.ts +9 -0
- package/lib/main/plugins/CollapsiblePlugin/CollapsibleUtils.js +15 -0
- package/lib/main/plugins/CollapsiblePlugin/index.d.ts +11 -0
- package/lib/main/plugins/CollapsiblePlugin/index.js +147 -0
- package/lib/main/plugins/ComponentPickerPlugin/index.d.ts +12 -0
- package/lib/main/plugins/ComponentPickerPlugin/index.js +438 -0
- package/lib/main/plugins/DragDropPastePlugin/index.d.ts +8 -0
- package/lib/main/plugins/DragDropPastePlugin/index.js +32 -0
- package/lib/main/plugins/DraggableBlockPlugin/index.css +36 -0
- package/lib/main/plugins/DraggableBlockPlugin/index.d.ts +12 -0
- package/lib/main/plugins/DraggableBlockPlugin/index.js +288 -0
- package/lib/main/plugins/EmojisPlugin/index.d.ts +9 -0
- package/lib/main/plugins/EmojisPlugin/index.js +63 -0
- package/lib/main/plugins/ExcalidrawPlugin/index.d.ts +3 -0
- package/lib/main/plugins/ExcalidrawPlugin/index.js +30 -0
- package/lib/main/plugins/FigmaPlugin/index.d.ts +11 -0
- package/lib/main/plugins/FigmaPlugin/index.js +27 -0
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.css +39 -0
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.d.ts +12 -0
- package/lib/main/plugins/FloatingLinkEditorPlugin/index.js +181 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/ColorPickerButton.d.ts +5 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/ColorPickerButton.js +24 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.css +128 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +12 -0
- package/lib/main/plugins/FloatingTextFormatToolbarPlugin/index.js +216 -0
- package/lib/main/plugins/HorizontalRulePlugin/index.d.ts +8 -0
- package/lib/main/plugins/HorizontalRulePlugin/index.js +30 -0
- package/lib/main/plugins/ImagesPlugin/index.d.ts +15 -0
- package/lib/main/plugins/ImagesPlugin/index.js +36 -0
- package/lib/main/plugins/LexicalTypeaheadMenuPlugin/index.d.ts +64 -0
- package/lib/main/plugins/LexicalTypeaheadMenuPlugin/index.js +493 -0
- package/lib/main/plugins/MarkdownShortcutPlugin/index.d.ts +9 -0
- package/lib/main/plugins/MarkdownShortcutPlugin/index.js +22 -0
- package/lib/main/plugins/MarkdownTransformers/index.d.ts +12 -0
- package/lib/main/plugins/MarkdownTransformers/index.js +185 -0
- package/lib/main/plugins/MaxLengthPlugin/index.d.ts +10 -0
- package/lib/main/plugins/MaxLengthPlugin/index.js +43 -0
- package/lib/main/plugins/MentionsPlugin/HighlightStyle.d.ts +2 -0
- package/lib/main/plugins/MentionsPlugin/HighlightStyle.js +13 -0
- package/lib/main/plugins/MentionsPlugin/index.d.ts +9 -0
- package/lib/main/plugins/MentionsPlugin/index.js +175 -0
- package/lib/main/plugins/TabFocusPlugin/index.d.ts +8 -0
- package/lib/main/plugins/TabFocusPlugin/index.js +41 -0
- package/lib/main/plugins/TableActionMenuPlugin/index.d.ts +12 -0
- package/lib/main/plugins/TableActionMenuPlugin/index.js +486 -0
- package/lib/main/plugins/TableCellResizer/index.css +20 -0
- package/lib/main/plugins/TableCellResizer/index.d.ts +3 -0
- package/lib/main/plugins/TableCellResizer/index.js +295 -0
- package/lib/main/plugins/TableOfContentsPlugin/index.css +87 -0
- package/lib/main/plugins/TableOfContentsPlugin/index.d.ts +2 -0
- package/lib/main/plugins/TableOfContentsPlugin/index.js +106 -0
- package/lib/main/plugins/TablePlugin.d.ts +38 -0
- package/lib/main/plugins/TablePlugin.js +63 -0
- package/lib/main/plugins/ToolbarPlugin/index.d.ts +8 -0
- package/lib/main/plugins/ToolbarPlugin/index.js +467 -0
- package/lib/main/plugins/TreeViewPlugin/index.d.ts +9 -0
- package/lib/main/plugins/TreeViewPlugin/index.js +14 -0
- package/lib/main/plugins/TwitterPlugin/index.d.ts +11 -0
- package/lib/main/plugins/TwitterPlugin/index.js +27 -0
- package/lib/main/plugins/TypingPerfPlugin/index.d.ts +9 -0
- package/lib/main/plugins/TypingPerfPlugin/index.js +100 -0
- package/lib/main/plugins/YouTubePlugin/index.d.ts +11 -0
- package/lib/main/plugins/YouTubePlugin/index.js +27 -0
- package/lib/main/server/validation.d.ts +8 -0
- package/lib/main/server/validation.js +119 -0
- package/lib/main/setupEnv.d.ts +8 -0
- package/lib/main/setupEnv.js +25 -0
- package/lib/main/style/editable.css +476 -0
- package/lib/main/styled-editor-content.d.ts +5 -0
- package/lib/main/styled-editor-content.js +206 -0
- package/lib/main/themes/code-highlight/index.d.ts +32 -0
- package/lib/main/themes/code-highlight/index.js +58 -0
- package/lib/main/themes/customTheme.d.ts +2 -0
- package/lib/main/themes/customTheme.js +324 -0
- package/lib/main/themes/defaultTheme.d.ts +10 -0
- package/lib/main/themes/defaultTheme.js +554 -0
- package/lib/main/themes/table/index.d.ts +3 -0
- package/lib/main/themes/table/index.js +20 -0
- package/lib/main/themes/table/table.css +214 -0
- package/lib/main/ui/Button.css +36 -0
- package/lib/main/ui/Button.d.ts +18 -0
- package/lib/main/ui/Button.js +13 -0
- package/lib/main/ui/ColorPicker.css +89 -0
- package/lib/main/ui/ColorPicker.d.ts +28 -0
- package/lib/main/ui/ColorPicker.js +206 -0
- package/lib/main/ui/ContentEditable.d.ts +2 -0
- package/lib/main/ui/ContentEditable.js +15 -0
- package/lib/main/ui/Dialog.css +17 -0
- package/lib/main/ui/Dialog.d.ts +16 -0
- package/lib/main/ui/Dialog.js +15 -0
- package/lib/main/ui/DropDown.d.ts +25 -0
- package/lib/main/ui/DropDown.js +146 -0
- package/lib/main/ui/FileInput.d.ts +17 -0
- package/lib/main/ui/FileInput.js +5 -0
- package/lib/main/ui/FrameMockup/browser.css +52 -0
- package/lib/main/ui/FrameMockup/browser.d.ts +13 -0
- package/lib/main/ui/FrameMockup/browser.js +22 -0
- package/lib/main/ui/FrameMockup/index.d.ts +113 -0
- package/lib/main/ui/FrameMockup/index.js +61 -0
- package/lib/main/ui/ImageEnhancer.d.ts +29 -0
- package/lib/main/ui/ImageEnhancer.js +113 -0
- package/lib/main/ui/ImageResizer.d.ts +24 -0
- package/lib/main/ui/ImageResizer.js +154 -0
- package/lib/main/ui/Input.css +30 -0
- package/lib/main/ui/Modal.css +62 -0
- package/lib/main/ui/Modal.d.ts +15 -0
- package/lib/main/ui/Modal.js +50 -0
- package/lib/main/ui/Placeholder.d.ts +6 -0
- package/lib/main/ui/Placeholder.js +20 -0
- package/lib/main/ui/TextInput.d.ts +20 -0
- package/lib/main/ui/TextInput.js +14 -0
- package/lib/main/utils/getDOMRangeRect.d.ts +8 -0
- package/lib/main/utils/getDOMRangeRect.js +22 -0
- package/lib/main/utils/getSelectedNode.d.ts +2 -0
- package/lib/main/utils/getSelectedNode.js +22 -0
- package/lib/main/utils/guard.d.ts +14 -0
- package/lib/main/utils/guard.js +36 -0
- package/lib/main/utils/images.d.ts +10 -0
- package/lib/main/utils/images.js +16 -0
- package/lib/main/utils/join-classes.d.ts +8 -0
- package/lib/main/utils/join-classes.js +10 -0
- package/lib/main/utils/point.d.ts +21 -0
- package/lib/main/utils/point.js +42 -0
- package/lib/main/utils/prevent-duplicate-upload.d.ts +2 -0
- package/lib/main/utils/prevent-duplicate-upload.js +25 -0
- package/lib/main/utils/rect.d.ts +45 -0
- package/lib/main/utils/rect.js +98 -0
- package/lib/main/utils/sanitizeUrl.d.ts +8 -0
- package/lib/main/utils/sanitizeUrl.js +17 -0
- package/lib/main/utils/setFloatingElemPosition.d.ts +1 -0
- package/lib/main/utils/setFloatingElemPosition.js +32 -0
- package/lib/main/utils/swipe.d.ts +11 -0
- package/lib/main/utils/swipe.js +98 -0
- package/lib/main/viewer/index.d.ts +5 -0
- package/lib/main/viewer/index.js +25 -0
- package/lib/main/viewer/types.d.ts +14 -0
- package/lib/main/viewer/types.js +1 -0
- package/lib/main/viewer/viewer.d.ts +3 -0
- package/lib/main/viewer/viewer.js +31 -0
- package/lib/shared/canUseDOM.d.ts +8 -0
- package/lib/shared/canUseDOM.js +10 -0
- package/lib/shared/environment.d.ts +24 -0
- package/lib/shared/environment.js +21 -0
- package/lib/shared/getDOMSelection.d.ts +9 -0
- package/lib/shared/getDOMSelection.js +10 -0
- package/lib/shared/invariant.d.ts +8 -0
- package/lib/shared/invariant.js +16 -0
- package/lib/shared/useLayoutEffect.d.ts +10 -0
- package/lib/shared/useLayoutEffect.js +11 -0
- package/lib/types.d.ts +19 -0
- package/lib/types.js +1 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/LexicalCharacterLimitPlugin.d.ts +15 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/LexicalCharacterLimitPlugin.js +45 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/index.d.ts +1 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/index.js +1 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/useCharacterLimit.d.ts +16 -0
- package/lib/vendor/LexicalCharacterLimitPlugin/useCharacterLimit.js +208 -0
- package/lib/vendor/history/LexicalHistoryPlugin.d.ts +14 -0
- package/lib/vendor/history/LexicalHistoryPlugin.js +15 -0
- package/lib/vendor/history/history/index.d.ts +63 -0
- package/lib/vendor/history/history/index.js +351 -0
- package/lib/vendor/history/useHistory.d.ts +10 -0
- package/lib/vendor/history/useHistory.js +15 -0
- package/package.json +109 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './index.css';
|
|
3
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
+
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
5
|
+
import { $computeTableMapSkipCellCheck, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $isTableCellNode, $isTableRowNode, getDOMCellFromTarget, getTableElement, TableNode, } from '@lexical/table';
|
|
6
|
+
import { calculateZoomLevel, mergeRegister } from '@lexical/utils';
|
|
7
|
+
import { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
9
|
+
import { createPortal } from 'react-dom';
|
|
10
|
+
const MIN_ROW_HEIGHT = 33;
|
|
11
|
+
const MIN_COLUMN_WIDTH = 92;
|
|
12
|
+
function TableCellResizer({ editor }) {
|
|
13
|
+
const targetRef = useRef(null);
|
|
14
|
+
const resizerRef = useRef(null);
|
|
15
|
+
const tableRectRef = useRef(null);
|
|
16
|
+
const [hasTable, setHasTable] = useState(false);
|
|
17
|
+
const pointerStartPosRef = useRef(null);
|
|
18
|
+
const [pointerCurrentPos, updatePointerCurrentPos] = useState(null);
|
|
19
|
+
const [activeCell, updateActiveCell] = useState(null);
|
|
20
|
+
const [draggingDirection, updateDraggingDirection] = useState(null);
|
|
21
|
+
const resetState = useCallback(() => {
|
|
22
|
+
updateActiveCell(null);
|
|
23
|
+
targetRef.current = null;
|
|
24
|
+
updateDraggingDirection(null);
|
|
25
|
+
pointerStartPosRef.current = null;
|
|
26
|
+
tableRectRef.current = null;
|
|
27
|
+
}, []);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const tableKeys = new Set();
|
|
30
|
+
return mergeRegister(editor.registerMutationListener(TableNode, (nodeMutations) => {
|
|
31
|
+
for (const [nodeKey, mutation] of nodeMutations) {
|
|
32
|
+
if (mutation === 'destroyed') {
|
|
33
|
+
tableKeys.delete(nodeKey);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
tableKeys.add(nodeKey);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
setHasTable(tableKeys.size > 0);
|
|
40
|
+
}), editor.registerNodeTransform(TableNode, (tableNode) => {
|
|
41
|
+
if (tableNode.getColWidths()) {
|
|
42
|
+
return tableNode;
|
|
43
|
+
}
|
|
44
|
+
const numColumns = tableNode.getColumnCount();
|
|
45
|
+
const columnWidth = MIN_COLUMN_WIDTH;
|
|
46
|
+
tableNode.setColWidths(Array(numColumns).fill(columnWidth));
|
|
47
|
+
return tableNode;
|
|
48
|
+
}));
|
|
49
|
+
}, [editor]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!hasTable) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const onPointerMove = (event) => {
|
|
55
|
+
const { target } = event;
|
|
56
|
+
if (!isHTMLElement(target)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (draggingDirection) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
updatePointerCurrentPos({
|
|
63
|
+
x: event.clientX,
|
|
64
|
+
y: event.clientY,
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (resizerRef.current && resizerRef.current.contains(target)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (targetRef.current !== target) {
|
|
72
|
+
targetRef.current = target;
|
|
73
|
+
const cell = getDOMCellFromTarget(target);
|
|
74
|
+
if (cell && activeCell !== cell) {
|
|
75
|
+
editor.getEditorState().read(() => {
|
|
76
|
+
const tableCellNode = $getNearestNodeFromDOMNode(cell.elem);
|
|
77
|
+
if (!tableCellNode) {
|
|
78
|
+
throw new Error('TableCellResizer: Table cell node not found.');
|
|
79
|
+
}
|
|
80
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
81
|
+
const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));
|
|
82
|
+
if (!tableElement) {
|
|
83
|
+
throw new Error('TableCellResizer: Table element not found.');
|
|
84
|
+
}
|
|
85
|
+
targetRef.current = target;
|
|
86
|
+
tableRectRef.current = tableElement.getBoundingClientRect();
|
|
87
|
+
updateActiveCell(cell);
|
|
88
|
+
}, { editor });
|
|
89
|
+
}
|
|
90
|
+
else if (cell == null) {
|
|
91
|
+
resetState();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const onPointerDown = (event) => {
|
|
96
|
+
const isTouchEvent = event.pointerType === 'touch';
|
|
97
|
+
if (isTouchEvent) {
|
|
98
|
+
onPointerMove(event);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const resizerContainer = resizerRef.current;
|
|
102
|
+
resizerContainer?.addEventListener('pointermove', onPointerMove, {
|
|
103
|
+
capture: true,
|
|
104
|
+
});
|
|
105
|
+
const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {
|
|
106
|
+
prevRootElement?.removeEventListener('pointermove', onPointerMove);
|
|
107
|
+
prevRootElement?.removeEventListener('pointerdown', onPointerDown);
|
|
108
|
+
rootElement?.addEventListener('pointermove', onPointerMove);
|
|
109
|
+
rootElement?.addEventListener('pointerdown', onPointerDown);
|
|
110
|
+
});
|
|
111
|
+
return () => {
|
|
112
|
+
removeRootListener();
|
|
113
|
+
resizerContainer?.removeEventListener('pointermove', onPointerMove);
|
|
114
|
+
};
|
|
115
|
+
}, [activeCell, draggingDirection, editor, resetState, hasTable]);
|
|
116
|
+
const isHeightChanging = (direction) => {
|
|
117
|
+
if (direction === 'bottom') {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
};
|
|
122
|
+
const updateRowHeight = useCallback((heightChange) => {
|
|
123
|
+
if (!activeCell) {
|
|
124
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
125
|
+
}
|
|
126
|
+
editor.update(() => {
|
|
127
|
+
const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
|
|
128
|
+
if (!$isTableCellNode(tableCellNode)) {
|
|
129
|
+
throw new Error('TableCellResizer: Table cell node not found.');
|
|
130
|
+
}
|
|
131
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
132
|
+
const baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
|
|
133
|
+
const tableRows = tableNode.getChildren();
|
|
134
|
+
// Determine if this is a full row merge by checking colspan
|
|
135
|
+
const isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount();
|
|
136
|
+
// For full row merges, apply to first row. For partial merges, apply to last row
|
|
137
|
+
const tableRowIndex = isFullRowMerge ? baseRowIndex : baseRowIndex + tableCellNode.getRowSpan() - 1;
|
|
138
|
+
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
139
|
+
throw new Error('Expected table cell to be inside of table row.');
|
|
140
|
+
}
|
|
141
|
+
const tableRow = tableRows[tableRowIndex];
|
|
142
|
+
if (!$isTableRowNode(tableRow)) {
|
|
143
|
+
throw new Error('Expected table row');
|
|
144
|
+
}
|
|
145
|
+
let height = tableRow.getHeight();
|
|
146
|
+
if (height === undefined) {
|
|
147
|
+
const rowCells = tableRow.getChildren();
|
|
148
|
+
height = Math.min(...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity));
|
|
149
|
+
}
|
|
150
|
+
const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);
|
|
151
|
+
tableRow.setHeight(newHeight);
|
|
152
|
+
}, { tag: 'skip-scroll-into-view' });
|
|
153
|
+
}, [activeCell, editor]);
|
|
154
|
+
const getCellNodeHeight = (cell, activeEditor) => {
|
|
155
|
+
const domCellNode = activeEditor.getElementByKey(cell.getKey());
|
|
156
|
+
return domCellNode?.clientHeight;
|
|
157
|
+
};
|
|
158
|
+
const getCellColumnIndex = (tableCellNode, tableMap) => {
|
|
159
|
+
for (let row = 0; row < tableMap.length; row++) {
|
|
160
|
+
for (let column = 0; column < tableMap[row].length; column++) {
|
|
161
|
+
if (tableMap[row][column].cell === tableCellNode) {
|
|
162
|
+
return column;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const updateColumnWidth = useCallback((widthChange) => {
|
|
168
|
+
if (!activeCell) {
|
|
169
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
170
|
+
}
|
|
171
|
+
editor.update(() => {
|
|
172
|
+
const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
|
|
173
|
+
if (!$isTableCellNode(tableCellNode)) {
|
|
174
|
+
throw new Error('TableCellResizer: Table cell node not found.');
|
|
175
|
+
}
|
|
176
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
177
|
+
const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null);
|
|
178
|
+
const columnIndex = getCellColumnIndex(tableCellNode, tableMap);
|
|
179
|
+
if (columnIndex === undefined) {
|
|
180
|
+
throw new Error('TableCellResizer: Table column not found.');
|
|
181
|
+
}
|
|
182
|
+
const colWidths = tableNode.getColWidths();
|
|
183
|
+
if (!colWidths) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const width = colWidths[columnIndex];
|
|
187
|
+
if (width === undefined) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const newColWidths = [...colWidths];
|
|
191
|
+
const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
|
|
192
|
+
newColWidths[columnIndex] = newWidth;
|
|
193
|
+
tableNode.setColWidths(newColWidths);
|
|
194
|
+
}, { tag: 'skip-scroll-into-view' });
|
|
195
|
+
}, [activeCell, editor]);
|
|
196
|
+
const pointerUpHandler = useCallback((direction) => {
|
|
197
|
+
const handler = (event) => {
|
|
198
|
+
event.preventDefault();
|
|
199
|
+
event.stopPropagation();
|
|
200
|
+
if (!activeCell) {
|
|
201
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
202
|
+
}
|
|
203
|
+
if (pointerStartPosRef.current) {
|
|
204
|
+
const { x, y } = pointerStartPosRef.current;
|
|
205
|
+
if (activeCell === null) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const zoom = calculateZoomLevel(event.target);
|
|
209
|
+
if (isHeightChanging(direction)) {
|
|
210
|
+
const heightChange = (event.clientY - y) / zoom;
|
|
211
|
+
updateRowHeight(heightChange);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const widthChange = (event.clientX - x) / zoom;
|
|
215
|
+
updateColumnWidth(widthChange);
|
|
216
|
+
}
|
|
217
|
+
resetState();
|
|
218
|
+
document.removeEventListener('pointerup', handler);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
return handler;
|
|
222
|
+
}, [activeCell, resetState, updateColumnWidth, updateRowHeight]);
|
|
223
|
+
const toggleResize = useCallback((direction) => (event) => {
|
|
224
|
+
event.preventDefault();
|
|
225
|
+
event.stopPropagation();
|
|
226
|
+
if (!activeCell) {
|
|
227
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
228
|
+
}
|
|
229
|
+
pointerStartPosRef.current = {
|
|
230
|
+
x: event.clientX,
|
|
231
|
+
y: event.clientY,
|
|
232
|
+
};
|
|
233
|
+
updatePointerCurrentPos(pointerStartPosRef.current);
|
|
234
|
+
updateDraggingDirection(direction);
|
|
235
|
+
document.addEventListener('pointerup', pointerUpHandler(direction));
|
|
236
|
+
}, [activeCell, pointerUpHandler]);
|
|
237
|
+
const getResizers = useCallback(() => {
|
|
238
|
+
if (activeCell) {
|
|
239
|
+
const { height, width, top, left } = activeCell.elem.getBoundingClientRect();
|
|
240
|
+
const zoom = calculateZoomLevel(activeCell.elem);
|
|
241
|
+
const zoneWidth = 16; // Pixel width of the zone where you can drag the edge
|
|
242
|
+
const styles = {
|
|
243
|
+
bottom: {
|
|
244
|
+
backgroundColor: 'none',
|
|
245
|
+
cursor: 'row-resize',
|
|
246
|
+
height: `${zoneWidth}px`,
|
|
247
|
+
left: `${window.scrollX + left}px`,
|
|
248
|
+
top: `${window.scrollY + top + height - zoneWidth / 2}px`,
|
|
249
|
+
zIndex: 1,
|
|
250
|
+
width: `${width}px`,
|
|
251
|
+
},
|
|
252
|
+
right: {
|
|
253
|
+
backgroundColor: 'none',
|
|
254
|
+
cursor: 'col-resize',
|
|
255
|
+
height: `${height}px`,
|
|
256
|
+
left: `${window.scrollX + left + width - zoneWidth / 2}px`,
|
|
257
|
+
top: `${window.scrollY + top}px`,
|
|
258
|
+
zIndex: 1,
|
|
259
|
+
width: `${zoneWidth}px`,
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
const tableRect = tableRectRef.current;
|
|
263
|
+
if (draggingDirection && pointerCurrentPos && tableRect) {
|
|
264
|
+
if (isHeightChanging(draggingDirection)) {
|
|
265
|
+
styles[draggingDirection].left = `${window.scrollX + tableRect.left}px`;
|
|
266
|
+
styles[draggingDirection].top = `${window.scrollY + pointerCurrentPos.y / zoom}px`;
|
|
267
|
+
styles[draggingDirection].height = '3px';
|
|
268
|
+
styles[draggingDirection].width = `${tableRect.width}px`;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
styles[draggingDirection].top = `${window.scrollY + tableRect.top}px`;
|
|
272
|
+
styles[draggingDirection].left = `${window.scrollX + pointerCurrentPos.x / zoom}px`;
|
|
273
|
+
styles[draggingDirection].width = '3px';
|
|
274
|
+
styles[draggingDirection].height = `${tableRect.height}px`;
|
|
275
|
+
}
|
|
276
|
+
styles[draggingDirection].backgroundColor = '#adf';
|
|
277
|
+
styles[draggingDirection].mixBlendMode = 'unset';
|
|
278
|
+
}
|
|
279
|
+
return styles;
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
bottom: null,
|
|
283
|
+
left: null,
|
|
284
|
+
right: null,
|
|
285
|
+
top: null,
|
|
286
|
+
};
|
|
287
|
+
}, [activeCell, draggingDirection, pointerCurrentPos]);
|
|
288
|
+
const resizerStyles = getResizers();
|
|
289
|
+
return (_jsx("div", { ref: resizerRef, children: activeCell != null && (_jsxs(_Fragment, { children: [_jsx("div", { className: "TableCellResizer__resizer TableCellResizer__ui", style: resizerStyles.right || undefined, onPointerDown: toggleResize('right') }), _jsx("div", { className: "TableCellResizer__resizer TableCellResizer__ui", style: resizerStyles.bottom || undefined, onPointerDown: toggleResize('bottom') })] })) }));
|
|
290
|
+
}
|
|
291
|
+
export default function TableCellResizerPlugin() {
|
|
292
|
+
const [editor] = useLexicalComposerContext();
|
|
293
|
+
const isEditable = useLexicalEditable();
|
|
294
|
+
return useMemo(() => (isEditable ? createPortal(_jsx(TableCellResizer, { editor: editor }), document.body) : null), [editor, isEditable]);
|
|
295
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.table-of-contents .heading2 {
|
|
2
|
+
margin-left: 10px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.table-of-contents .heading3 {
|
|
6
|
+
margin-left: 20px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.selected-heading {
|
|
10
|
+
color: #3578e5;
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.selected-heading-wrapper::before {
|
|
15
|
+
content: ' ';
|
|
16
|
+
position: absolute;
|
|
17
|
+
display: inline-block;
|
|
18
|
+
left: -30px;
|
|
19
|
+
top: 4px;
|
|
20
|
+
z-index: 10;
|
|
21
|
+
height: 4px;
|
|
22
|
+
width: 4px;
|
|
23
|
+
background-color: #3578e5;
|
|
24
|
+
border: solid 4px white;
|
|
25
|
+
border-radius: 50%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.normal-heading {
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
line-height: 20px;
|
|
31
|
+
font-size: 16px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.table-of-contents {
|
|
35
|
+
color: #65676b;
|
|
36
|
+
position: fixed;
|
|
37
|
+
top: 200px;
|
|
38
|
+
right: -35px;
|
|
39
|
+
padding: 10px;
|
|
40
|
+
width: 250px;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: row;
|
|
43
|
+
justify-content: flex-start;
|
|
44
|
+
z-index: 1;
|
|
45
|
+
height: 300px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.first-heading {
|
|
49
|
+
color: black;
|
|
50
|
+
font-weight: bold;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.headings {
|
|
55
|
+
list-style: none;
|
|
56
|
+
margin-top: 0;
|
|
57
|
+
margin-left: 10px;
|
|
58
|
+
padding: 0;
|
|
59
|
+
overflow: scroll;
|
|
60
|
+
width: 200px;
|
|
61
|
+
height: 220px;
|
|
62
|
+
overflow-x: hidden;
|
|
63
|
+
overflow-y: auto;
|
|
64
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
65
|
+
scrollbar-width: none; /* Firefox */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
69
|
+
.headings::-webkit-scrollbar {
|
|
70
|
+
display: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.headings::before {
|
|
74
|
+
content: ' ';
|
|
75
|
+
position: absolute;
|
|
76
|
+
height: 220px;
|
|
77
|
+
width: 4px;
|
|
78
|
+
right: 240px;
|
|
79
|
+
margin-top: 5px;
|
|
80
|
+
background-color: #ccd0d5;
|
|
81
|
+
border-radius: 2px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.normal-heading-wrapper {
|
|
85
|
+
margin-left: 32px;
|
|
86
|
+
position: relative;
|
|
87
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './index.css';
|
|
3
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
+
import { TableOfContentsPlugin as LexicalTableOfContentsPlugin } from '@lexical/react/LexicalTableOfContentsPlugin';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
const MARGIN_ABOVE_EDITOR = 624;
|
|
7
|
+
const HEADING_WIDTH = 9;
|
|
8
|
+
function indent(tagName) {
|
|
9
|
+
if (tagName === 'h2') {
|
|
10
|
+
return 'heading2';
|
|
11
|
+
}
|
|
12
|
+
if (tagName === 'h3') {
|
|
13
|
+
return 'heading3';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function isHeadingAtTheTopOfThePage(element) {
|
|
17
|
+
const elementYPosition = element?.getClientRects()[0].y;
|
|
18
|
+
return elementYPosition >= MARGIN_ABOVE_EDITOR && elementYPosition <= MARGIN_ABOVE_EDITOR + HEADING_WIDTH;
|
|
19
|
+
}
|
|
20
|
+
function isHeadingAboveViewport(element) {
|
|
21
|
+
const elementYPosition = element?.getClientRects()[0].y;
|
|
22
|
+
return elementYPosition < MARGIN_ABOVE_EDITOR;
|
|
23
|
+
}
|
|
24
|
+
function isHeadingBelowTheTopOfThePage(element) {
|
|
25
|
+
const elementYPosition = element?.getClientRects()[0].y;
|
|
26
|
+
return elementYPosition >= MARGIN_ABOVE_EDITOR + HEADING_WIDTH;
|
|
27
|
+
}
|
|
28
|
+
function TableOfContentsList({ tableOfContents }) {
|
|
29
|
+
const [selectedKey, setSelectedKey] = useState('');
|
|
30
|
+
const selectedIndex = useRef(0);
|
|
31
|
+
const [editor] = useLexicalComposerContext();
|
|
32
|
+
function scrollToNode(key, currIndex) {
|
|
33
|
+
editor.getEditorState().read(() => {
|
|
34
|
+
const domElement = editor.getElementByKey(key);
|
|
35
|
+
if (domElement !== null) {
|
|
36
|
+
domElement.scrollIntoView();
|
|
37
|
+
setSelectedKey(key);
|
|
38
|
+
selectedIndex.current = currIndex;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
function scrollCallback() {
|
|
44
|
+
if (tableOfContents.length !== 0 && selectedIndex.current < tableOfContents.length - 1) {
|
|
45
|
+
let currentHeading = editor.getElementByKey(tableOfContents[selectedIndex.current][0]);
|
|
46
|
+
if (currentHeading !== null) {
|
|
47
|
+
if (isHeadingBelowTheTopOfThePage(currentHeading)) {
|
|
48
|
+
// On natural scroll, user is scrolling up
|
|
49
|
+
while (currentHeading !== null &&
|
|
50
|
+
isHeadingBelowTheTopOfThePage(currentHeading) &&
|
|
51
|
+
selectedIndex.current > 0) {
|
|
52
|
+
const prevHeading = editor.getElementByKey(tableOfContents[selectedIndex.current - 1][0]);
|
|
53
|
+
if (prevHeading !== null &&
|
|
54
|
+
(isHeadingAboveViewport(prevHeading) || isHeadingBelowTheTopOfThePage(prevHeading))) {
|
|
55
|
+
selectedIndex.current--;
|
|
56
|
+
}
|
|
57
|
+
currentHeading = prevHeading;
|
|
58
|
+
}
|
|
59
|
+
const prevHeadingKey = tableOfContents[selectedIndex.current][0];
|
|
60
|
+
setSelectedKey(prevHeadingKey);
|
|
61
|
+
}
|
|
62
|
+
else if (isHeadingAboveViewport(currentHeading)) {
|
|
63
|
+
// On natural scroll, user is scrolling down
|
|
64
|
+
while (currentHeading !== null &&
|
|
65
|
+
isHeadingAboveViewport(currentHeading) &&
|
|
66
|
+
selectedIndex.current < tableOfContents.length - 1) {
|
|
67
|
+
const nextHeading = editor.getElementByKey(tableOfContents[selectedIndex.current + 1][0]);
|
|
68
|
+
if (nextHeading !== null &&
|
|
69
|
+
(isHeadingAtTheTopOfThePage(nextHeading) || isHeadingAboveViewport(nextHeading))) {
|
|
70
|
+
selectedIndex.current++;
|
|
71
|
+
}
|
|
72
|
+
currentHeading = nextHeading;
|
|
73
|
+
}
|
|
74
|
+
const nextHeadingKey = tableOfContents[selectedIndex.current][0];
|
|
75
|
+
setSelectedKey(nextHeadingKey);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
selectedIndex.current = 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let timerId;
|
|
84
|
+
function debounceFunction(func, delay) {
|
|
85
|
+
clearTimeout(timerId);
|
|
86
|
+
timerId = setTimeout(func, delay);
|
|
87
|
+
}
|
|
88
|
+
function onScroll() {
|
|
89
|
+
debounceFunction(scrollCallback, 10);
|
|
90
|
+
}
|
|
91
|
+
document.addEventListener('scroll', onScroll);
|
|
92
|
+
return () => document.removeEventListener('scroll', onScroll);
|
|
93
|
+
}, [tableOfContents, editor]);
|
|
94
|
+
return (_jsx("div", { className: "table-of-contents", children: _jsx("ul", { className: "headings", children: tableOfContents.map(([key, text, tag], index) => {
|
|
95
|
+
if (index === 0) {
|
|
96
|
+
return (_jsxs("div", { className: "normal-heading-wrapper", children: [_jsx("div", { className: "first-heading", onClick: () => scrollToNode(key, index), role: "button", tabIndex: 0, children: `${text}`.length > 20 ? `${text.substring(0, 20)}...` : text }), _jsx("br", {})] }, key));
|
|
97
|
+
}
|
|
98
|
+
return (_jsx("div", { className: `normal-heading-wrapper ${selectedKey === key ? 'selected-heading-wrapper' : ''}`, children: _jsx("div", { onClick: () => scrollToNode(key, index), role: "button", className: indent(tag), tabIndex: 0, children: _jsx("li", { className: `normal-heading ${selectedKey === key ? 'selected-heading' : ''}
|
|
99
|
+
`, children: `${text}`.length > 27 ? `${text.substring(0, 27)}...` : text }) }) }, key));
|
|
100
|
+
}) }) }));
|
|
101
|
+
}
|
|
102
|
+
export default function TableOfContentsPlugin() {
|
|
103
|
+
return (_jsx(LexicalTableOfContentsPlugin, { children: (tableOfContents) => {
|
|
104
|
+
return _jsx(TableOfContentsList, { tableOfContents: tableOfContents });
|
|
105
|
+
} }));
|
|
106
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { JSX } from 'react';
|
|
9
|
+
import { EditorThemeClasses, Klass, LexicalEditor, LexicalNode } from 'lexical';
|
|
10
|
+
export type InsertTableCommandPayload = Readonly<{
|
|
11
|
+
columns: string;
|
|
12
|
+
rows: string;
|
|
13
|
+
includeHeaders?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
export type CellContextShape = {
|
|
16
|
+
cellEditorConfig: null | CellEditorConfig;
|
|
17
|
+
cellEditorPlugins: null | JSX.Element | Array<JSX.Element>;
|
|
18
|
+
set: (cellEditorConfig: null | CellEditorConfig, cellEditorPlugins: null | JSX.Element | Array<JSX.Element>) => void;
|
|
19
|
+
};
|
|
20
|
+
export type CellEditorConfig = Readonly<{
|
|
21
|
+
namespace: string;
|
|
22
|
+
nodes?: ReadonlyArray<Klass<LexicalNode>>;
|
|
23
|
+
onError: (error: Error, editor: LexicalEditor) => void;
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
theme?: EditorThemeClasses;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const CellContext: import("react").Context<CellContextShape>;
|
|
28
|
+
export declare function TableContext({ children }: {
|
|
29
|
+
children: JSX.Element;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function InsertTableDialog({ activeEditor, onClose, }: {
|
|
32
|
+
activeEditor: LexicalEditor;
|
|
33
|
+
onClose: () => void;
|
|
34
|
+
}): JSX.Element;
|
|
35
|
+
export declare function TablePlugin({ cellEditorConfig, children, }: {
|
|
36
|
+
cellEditorConfig: CellEditorConfig;
|
|
37
|
+
children: JSX.Element | Array<JSX.Element>;
|
|
38
|
+
}): JSX.Element | null;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
4
|
+
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import Button from '../ui/Button';
|
|
6
|
+
import { DialogActions } from '../ui/Dialog';
|
|
7
|
+
import TextInput from '../ui/TextInput';
|
|
8
|
+
export const CellContext = createContext({
|
|
9
|
+
cellEditorConfig: null,
|
|
10
|
+
cellEditorPlugins: null,
|
|
11
|
+
set: () => {
|
|
12
|
+
// Empty
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
export function TableContext({ children }) {
|
|
16
|
+
const [contextValue, setContextValue] = useState({
|
|
17
|
+
cellEditorConfig: null,
|
|
18
|
+
cellEditorPlugins: null,
|
|
19
|
+
});
|
|
20
|
+
return (_jsx(CellContext.Provider, { value: useMemo(() => ({
|
|
21
|
+
cellEditorConfig: contextValue.cellEditorConfig,
|
|
22
|
+
cellEditorPlugins: contextValue.cellEditorPlugins,
|
|
23
|
+
set: (cellEditorConfig, cellEditorPlugins) => {
|
|
24
|
+
setContextValue({ cellEditorConfig, cellEditorPlugins });
|
|
25
|
+
},
|
|
26
|
+
}), [contextValue.cellEditorConfig, contextValue.cellEditorPlugins]), children: children }));
|
|
27
|
+
}
|
|
28
|
+
export function InsertTableDialog({ activeEditor, onClose, }) {
|
|
29
|
+
const [rows, setRows] = useState('5');
|
|
30
|
+
const [columns, setColumns] = useState('5');
|
|
31
|
+
const [isDisabled, setIsDisabled] = useState(true);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const row = Number(rows);
|
|
34
|
+
const column = Number(columns);
|
|
35
|
+
if (row && row > 0 && row <= 500 && column && column > 0 && column <= 50) {
|
|
36
|
+
setIsDisabled(false);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
setIsDisabled(true);
|
|
40
|
+
}
|
|
41
|
+
}, [rows, columns]);
|
|
42
|
+
const onClick = () => {
|
|
43
|
+
activeEditor.dispatchCommand(INSERT_TABLE_COMMAND, {
|
|
44
|
+
columns,
|
|
45
|
+
rows,
|
|
46
|
+
});
|
|
47
|
+
onClose();
|
|
48
|
+
};
|
|
49
|
+
return (_jsxs(_Fragment, { children: [_jsx(TextInput, { placeholder: "# of rows (1-500)", label: "Rows", onChange: setRows, value: rows, "data-test-id": "table-modal-rows", type: "number" }), _jsx(TextInput, { placeholder: "# of columns (1-50)", label: "Columns", onChange: setColumns, value: columns, "data-test-id": "table-modal-columns", type: "number" }), _jsx(DialogActions, { "data-test-id": "table-model-confirm-insert", children: _jsx(Button, { disabled: isDisabled, onClick: onClick, children: "Confirm" }) })] }));
|
|
50
|
+
}
|
|
51
|
+
export function TablePlugin({ cellEditorConfig, children, }) {
|
|
52
|
+
const [editor] = useLexicalComposerContext();
|
|
53
|
+
const cellContext = useContext(CellContext);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {
|
|
56
|
+
throw new Error('TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor');
|
|
57
|
+
}
|
|
58
|
+
}, [editor]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
cellContext.set(cellEditorConfig, children);
|
|
61
|
+
}, [cellContext, cellEditorConfig, children]);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default function ToolbarPlugin(): import("react/jsx-runtime").JSX.Element | null;
|