@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,232 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { Box, ClickAwayListener, Stack } from '@mui/material';
|
|
5
|
+
import { useInViewport, usePrevious } from 'ahooks';
|
|
6
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
7
|
+
import { usePopper } from 'react-popper';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
9
|
+
import { css, Global } from '@emotion/react';
|
|
10
|
+
import { blue } from '@mui/material/colors';
|
|
11
|
+
import { useInlineTranslationStore, useStatus, useTargetLanguage } from './store';
|
|
12
|
+
import { useEditorTranslator } from './EditorTranslator';
|
|
13
|
+
import { NODE_TYPE } from './TranslationNode';
|
|
14
|
+
const translations = {
|
|
15
|
+
translatedContent: {
|
|
16
|
+
en: 'AI-Translated Content',
|
|
17
|
+
zh: 'AI 翻译内容',
|
|
18
|
+
},
|
|
19
|
+
original: {
|
|
20
|
+
en: 'Original',
|
|
21
|
+
zh: '原文',
|
|
22
|
+
},
|
|
23
|
+
translation: {
|
|
24
|
+
en: 'Translation',
|
|
25
|
+
zh: '翻译',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
function InternalInlineTranslationPlugin({ translateService, detectLanguage, onTranslate, onRestore, showTranslationBadge = true, }) {
|
|
29
|
+
const [editor] = useLexicalComposerContext();
|
|
30
|
+
const [inViewport] = useInViewport(editor.getRootElement());
|
|
31
|
+
const setStatus = useInlineTranslationStore((s) => s.setStatus);
|
|
32
|
+
const registerEditor = useInlineTranslationStore((s) => s.registerEditor);
|
|
33
|
+
const displayMode = useInlineTranslationStore((s) => s.displayMode);
|
|
34
|
+
const useCache = useInlineTranslationStore((s) => s.editorTranslateStates.get(editor)?.useCache);
|
|
35
|
+
const targetLanguage = useTargetLanguage();
|
|
36
|
+
const status = useStatus(editor);
|
|
37
|
+
const previousStatus = usePrevious(status);
|
|
38
|
+
const editorTranslator = useEditorTranslator({ displayMode });
|
|
39
|
+
const { locale } = useLocaleContext();
|
|
40
|
+
const handleTranslate = async () => {
|
|
41
|
+
try {
|
|
42
|
+
setStatus(editor, 'processing');
|
|
43
|
+
onTranslate?.({ targetLanguage });
|
|
44
|
+
await editorTranslator.translate({
|
|
45
|
+
translateService,
|
|
46
|
+
targetLanguage,
|
|
47
|
+
detectLanguage,
|
|
48
|
+
useCache,
|
|
49
|
+
});
|
|
50
|
+
setStatus(editor, 'completed');
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.error(err);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const handleRestore = () => {
|
|
57
|
+
onRestore?.();
|
|
58
|
+
editorTranslator.restore();
|
|
59
|
+
setStatus(editor, 'idle');
|
|
60
|
+
};
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
return registerEditor(editor);
|
|
63
|
+
}, [editor]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (inViewport && status === 'pending') {
|
|
66
|
+
handleTranslate();
|
|
67
|
+
}
|
|
68
|
+
}, [editor, status, inViewport]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (previousStatus === 'completed' && status === 'idle') {
|
|
71
|
+
handleRestore();
|
|
72
|
+
}
|
|
73
|
+
}, [editor, status, previousStatus]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
editorTranslator.updateOptions({ displayMode });
|
|
76
|
+
}, [editorTranslator, displayMode]);
|
|
77
|
+
// 对于翻译后的内容,禁止 checkbox 点击交互
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const onClick = (event) => {
|
|
80
|
+
const target = event.target;
|
|
81
|
+
if ((editorTranslator.isTranslating || editorTranslator.isTranslated) && target.closest('li[role="checkbox"]')) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
event.stopPropagation();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return editor.registerRootListener((rootElement, prevRootElement) => {
|
|
87
|
+
if (prevRootElement) {
|
|
88
|
+
prevRootElement.removeEventListener('click', onClick, { capture: true });
|
|
89
|
+
}
|
|
90
|
+
if (rootElement) {
|
|
91
|
+
rootElement.addEventListener('click', onClick, { capture: true });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}, [editor, editorTranslator]);
|
|
95
|
+
if (editor.isEditable()) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return (_jsxs(_Fragment, { children: [_jsx(TranslationElementPopper, { editorTranslator: editorTranslator }), showTranslationBadge && status === 'completed' && editorTranslator.isTranslated ? (_jsx(Box, { sx: { mb: 0.5 }, children: _jsxs(Box, { className: "inline-translation-badge", sx: {
|
|
99
|
+
display: 'inline-block',
|
|
100
|
+
px: 1,
|
|
101
|
+
fontSize: 12,
|
|
102
|
+
fontWeight: 'medium',
|
|
103
|
+
color: 'text.secondary',
|
|
104
|
+
bgcolor: 'grey.50',
|
|
105
|
+
border: 1,
|
|
106
|
+
borderColor: 'divider',
|
|
107
|
+
borderRadius: 0.5,
|
|
108
|
+
}, children: ["\uD83E\uDD16", ' ', translations.translatedContent[locale] ||
|
|
109
|
+
translations.translatedContent.en] }) })) : (_jsx(Box, { sx: { position: 'absolute', top: 0, bottom: 0, left: 0, width: '1px' } }))] }));
|
|
110
|
+
}
|
|
111
|
+
export function InlineTranslationPlugin(props) {
|
|
112
|
+
const [editor] = useLexicalComposerContext();
|
|
113
|
+
if (editor.isEditable()) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return _jsx(InternalInlineTranslationPlugin, { ...props });
|
|
117
|
+
}
|
|
118
|
+
function TranslationElementPopper({ editorTranslator }) {
|
|
119
|
+
const [editor] = useLexicalComposerContext();
|
|
120
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
121
|
+
const popperElementRef = useRef(null);
|
|
122
|
+
const [hoveringTranslationElement, setHoveringTranslationElement] = useState(null);
|
|
123
|
+
const [originalText, setOriginalText] = useState(null);
|
|
124
|
+
const { locale } = useLocaleContext();
|
|
125
|
+
useLayoutEffect(() => {
|
|
126
|
+
popperElementRef.current = popperElement;
|
|
127
|
+
}, [popperElement]);
|
|
128
|
+
const reset = () => {
|
|
129
|
+
setHoveringTranslationElement(null);
|
|
130
|
+
setOriginalText(null);
|
|
131
|
+
};
|
|
132
|
+
const isInsidePopper = (element) => {
|
|
133
|
+
return (popperElementRef.current && (popperElementRef.current === element || popperElementRef.current.contains(element)));
|
|
134
|
+
};
|
|
135
|
+
const hoveringTranslationElementPopper = usePopper(hoveringTranslationElement, popperElement, {
|
|
136
|
+
strategy: 'fixed',
|
|
137
|
+
placement: 'left-start',
|
|
138
|
+
modifiers: [
|
|
139
|
+
{
|
|
140
|
+
name: 'flip',
|
|
141
|
+
options: {
|
|
142
|
+
fallbackPlacements: ['bottom-start'],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
const translationPreviewPopper = usePopper(hoveringTranslationElement, popperElement, {
|
|
148
|
+
strategy: 'fixed',
|
|
149
|
+
placement: 'bottom-start',
|
|
150
|
+
modifiers: [
|
|
151
|
+
{
|
|
152
|
+
name: 'flip',
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
});
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
return editor.registerRootListener((rootElement, prevRootElement) => {
|
|
158
|
+
const handleMouseOver = (event) => {
|
|
159
|
+
const target = event.target;
|
|
160
|
+
if (isInsidePopper(target)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const translationElement = target.closest(`.${NODE_TYPE}`);
|
|
164
|
+
if (translationElement) {
|
|
165
|
+
setHoveringTranslationElement(translationElement);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
reset();
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
let timer = null;
|
|
172
|
+
const handleMouseOut = (event) => {
|
|
173
|
+
const relatedTarget = event.relatedTarget;
|
|
174
|
+
if (timer) {
|
|
175
|
+
clearTimeout(timer);
|
|
176
|
+
}
|
|
177
|
+
timer = setTimeout(() => {
|
|
178
|
+
if (rootElement && !rootElement?.contains(relatedTarget) && !isInsidePopper(relatedTarget)) {
|
|
179
|
+
reset();
|
|
180
|
+
}
|
|
181
|
+
}, 100);
|
|
182
|
+
};
|
|
183
|
+
if (prevRootElement) {
|
|
184
|
+
prevRootElement.removeEventListener('mouseover', handleMouseOver);
|
|
185
|
+
prevRootElement.removeEventListener('mouseout', handleMouseOut);
|
|
186
|
+
}
|
|
187
|
+
if (rootElement) {
|
|
188
|
+
rootElement.addEventListener('mouseover', handleMouseOver);
|
|
189
|
+
rootElement.addEventListener('mouseout', handleMouseOut);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}, [editor]);
|
|
193
|
+
if (!hoveringTranslationElement) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const globalStyles = css `
|
|
197
|
+
.inline-translation-node[data-eid='${editor.getKey()}'][data-sid='${hoveringTranslationElement.dataset.sid}'] > * {
|
|
198
|
+
background-color: ${blue[50]};
|
|
199
|
+
border-radius: 4px;
|
|
200
|
+
}
|
|
201
|
+
`;
|
|
202
|
+
return createPortal(_jsxs(_Fragment, { children: [!!originalText && (_jsxs(_Fragment, { children: [_jsx(Global, { styles: globalStyles }), _jsx(ClickAwayListener, { onClickAway: reset, children: _jsxs(Box, { style: translationPreviewPopper.styles.popper, ...translationPreviewPopper.attributes.popper, sx: {
|
|
203
|
+
position: 'relative',
|
|
204
|
+
zIndex: 'modal',
|
|
205
|
+
maxWidth: 600,
|
|
206
|
+
maxHeight: 400,
|
|
207
|
+
p: 2,
|
|
208
|
+
border: 1,
|
|
209
|
+
borderColor: 'divider',
|
|
210
|
+
borderRadius: 1,
|
|
211
|
+
fontSize: 13,
|
|
212
|
+
bgcolor: '#fff',
|
|
213
|
+
boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)',
|
|
214
|
+
'h1,h2,h3,h4,h5,h6': {
|
|
215
|
+
margin: 0,
|
|
216
|
+
},
|
|
217
|
+
}, children: [_jsxs(Box, { children: [_jsx(Box, { sx: { color: 'text.secondary', fontWeight: 'medium' }, children: translations.original[locale] || translations.original.en }), _jsx(Box, { dangerouslySetInnerHTML: { __html: originalText } })] }), _jsxs(Box, { sx: { mt: 1.5 }, children: [_jsx(Box, { sx: { color: 'text.secondary', fontWeight: 'medium' }, children: translations.translation[locale] ||
|
|
218
|
+
translations.translation.en }), _jsx(Box, { dangerouslySetInnerHTML: {
|
|
219
|
+
__html: editorTranslator.getTranslationText(hoveringTranslationElement.dataset.sid) || '',
|
|
220
|
+
} })] })] }) })] })), _jsx(Box, { ref: setPopperElement, style: hoveringTranslationElementPopper.styles.popper, ...hoveringTranslationElementPopper.attributes.popper, sx: { zIndex: 'modal' }, onMouseLeave: reset, children: !originalText && (_jsx(Stack, { direction: "row", onClick: () => setOriginalText(originalText ? null : editorTranslator.getOriginalText(hoveringTranslationElement.dataset.sid) || ''), sx: {
|
|
221
|
+
alignItems: hoveringTranslationElement.clientHeight > 100 ? 'center' : 'flex-start',
|
|
222
|
+
pr: 1,
|
|
223
|
+
pt: 0.5,
|
|
224
|
+
color: 'text.secondary',
|
|
225
|
+
fontSize: 12,
|
|
226
|
+
cursor: 'pointer',
|
|
227
|
+
height: hoveringTranslationElement.clientHeight,
|
|
228
|
+
}, children: _jsxs(Stack, { direction: "row", sx: {
|
|
229
|
+
alignItems: 'center',
|
|
230
|
+
gap: 0.25,
|
|
231
|
+
}, children: [_jsx("i", { className: "iconify", "data-icon": "tabler:tooltip", "data-height": 16 }), translations.original[locale] || translations.original.en] }) })) })] }), document.body);
|
|
232
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EditorConfig, ElementNode, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
import { DisplayMode } from './types';
|
|
3
|
+
interface TranslationNodeProps {
|
|
4
|
+
sid: string;
|
|
5
|
+
displayMode: DisplayMode;
|
|
6
|
+
}
|
|
7
|
+
export type SerializedTranslationNode = Spread<TranslationNodeProps, SerializedLexicalNode>;
|
|
8
|
+
export declare const NODE_TYPE = "inline-translation-node";
|
|
9
|
+
export declare class TranslationNode extends ElementNode {
|
|
10
|
+
__data: TranslationNodeProps;
|
|
11
|
+
constructor(data: TranslationNodeProps, key?: NodeKey);
|
|
12
|
+
static getType(): string;
|
|
13
|
+
static clone(node: TranslationNode): TranslationNode;
|
|
14
|
+
static importJSON(serializedNode: SerializedTranslationNode): TranslationNode;
|
|
15
|
+
createDOM(config: EditorConfig, editor: LexicalEditor): HTMLElement;
|
|
16
|
+
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function $createTranslationNode({ translatedNodes, data, }: {
|
|
19
|
+
translatedNodes: LexicalNode[];
|
|
20
|
+
data: TranslationNodeProps;
|
|
21
|
+
}): TranslationNode;
|
|
22
|
+
export declare function $isTranslationNode(node: LexicalNode | null | undefined): node is TranslationNode;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { $isElementNode, ElementNode, } from 'lexical';
|
|
2
|
+
export const NODE_TYPE = 'inline-translation-node';
|
|
3
|
+
export class TranslationNode extends ElementNode {
|
|
4
|
+
__data;
|
|
5
|
+
constructor(data, key) {
|
|
6
|
+
super(key);
|
|
7
|
+
this.__data = data;
|
|
8
|
+
}
|
|
9
|
+
static getType() {
|
|
10
|
+
return NODE_TYPE;
|
|
11
|
+
}
|
|
12
|
+
static clone(node) {
|
|
13
|
+
return new TranslationNode(node.__data, node.__key);
|
|
14
|
+
}
|
|
15
|
+
static importJSON(serializedNode) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
createDOM(config, editor) {
|
|
19
|
+
const dom = document.createElement('div');
|
|
20
|
+
dom.classList.add(NODE_TYPE, `${NODE_TYPE}-${this.__data.displayMode}`);
|
|
21
|
+
dom.dataset.eid = editor.getKey();
|
|
22
|
+
dom.dataset.sid = this.__data.sid;
|
|
23
|
+
return dom;
|
|
24
|
+
}
|
|
25
|
+
updateDOM(prevNode, dom, config) {
|
|
26
|
+
// Returning false tells Lexical that this node does not need its
|
|
27
|
+
// DOM element replacing with a new copy from createDOM.
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function $createTranslationNode({ translatedNodes, data, }) {
|
|
32
|
+
const node = new TranslationNode(data);
|
|
33
|
+
if (translatedNodes.length === 1) {
|
|
34
|
+
const first = translatedNodes[0];
|
|
35
|
+
if ($isElementNode(first)) {
|
|
36
|
+
node.append(...first.getChildren());
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
node.append(first);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
node.append(...translatedNodes);
|
|
44
|
+
}
|
|
45
|
+
return node;
|
|
46
|
+
}
|
|
47
|
+
export function $isTranslationNode(node) {
|
|
48
|
+
return node instanceof TranslationNode;
|
|
49
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
import { DisplayMode } from './types';
|
|
3
|
+
type TranslateStatus = 'idle' | 'pending' | 'processing' | 'completed';
|
|
4
|
+
interface EditorTranslateState {
|
|
5
|
+
useCache: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface State {
|
|
8
|
+
targetLanguage: string | null;
|
|
9
|
+
autoTranslate: boolean;
|
|
10
|
+
displayMode: DisplayMode;
|
|
11
|
+
editors: Map<LexicalEditor, TranslateStatus>;
|
|
12
|
+
editorTranslateStates: Map<LexicalEditor, EditorTranslateState>;
|
|
13
|
+
}
|
|
14
|
+
interface Action {
|
|
15
|
+
translate: (editor?: LexicalEditor, options?: {
|
|
16
|
+
useCache?: boolean;
|
|
17
|
+
}) => void;
|
|
18
|
+
showOriginal: (editor?: LexicalEditor) => void;
|
|
19
|
+
setTargetLanguage: (targetLanguage: string) => void;
|
|
20
|
+
setAutoTranslate: (autoTranslate: boolean) => void;
|
|
21
|
+
setStatus: (editor: LexicalEditor, status: TranslateStatus) => void;
|
|
22
|
+
setDisplayMode: (displayMode: DisplayMode) => void;
|
|
23
|
+
registerEditor: (editor: LexicalEditor) => () => void;
|
|
24
|
+
unregisterEditor: (editor: LexicalEditor) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const useInlineTranslationStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<State & Action>, "persist"> & {
|
|
27
|
+
persist: {
|
|
28
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<State & Action, {
|
|
29
|
+
targetLanguage: string | null;
|
|
30
|
+
autoTranslate: boolean;
|
|
31
|
+
displayMode: DisplayMode;
|
|
32
|
+
}>>) => void;
|
|
33
|
+
clearStorage: () => void;
|
|
34
|
+
rehydrate: () => void | Promise<void>;
|
|
35
|
+
hasHydrated: () => boolean;
|
|
36
|
+
onHydrate: (fn: (state: State & Action) => void) => () => void;
|
|
37
|
+
onFinishHydration: (fn: (state: State & Action) => void) => () => void;
|
|
38
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<State & Action, {
|
|
39
|
+
targetLanguage: string | null;
|
|
40
|
+
autoTranslate: boolean;
|
|
41
|
+
displayMode: DisplayMode;
|
|
42
|
+
}>>;
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
45
|
+
export declare const useStatus: (editor: LexicalEditor) => TranslateStatus | undefined;
|
|
46
|
+
export declare const useIsIdle: () => boolean;
|
|
47
|
+
export declare const useIsTranslating: () => boolean;
|
|
48
|
+
export declare const useIsTranslated: () => boolean;
|
|
49
|
+
export declare const useTargetLanguage: () => string;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
+
import { create } from 'zustand';
|
|
3
|
+
import { persist } from 'zustand/middleware';
|
|
4
|
+
import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
|
|
5
|
+
import { useContext } from 'react';
|
|
6
|
+
export const useInlineTranslationStore = create()(persist((set, get) => ({
|
|
7
|
+
targetLanguage: null,
|
|
8
|
+
autoTranslate: false,
|
|
9
|
+
displayMode: 'translationOnly',
|
|
10
|
+
editors: new Map(),
|
|
11
|
+
editorTranslateStates: new Map(),
|
|
12
|
+
translate: (editor, options) => {
|
|
13
|
+
if (editor) {
|
|
14
|
+
set((state) => ({
|
|
15
|
+
editors: new Map(state.editors).set(editor, 'pending'),
|
|
16
|
+
...(options?.useCache !== undefined && {
|
|
17
|
+
editorTranslateStates: new Map(state.editorTranslateStates).set(editor, { useCache: options.useCache }),
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
set((state) => ({
|
|
23
|
+
editors: new Map(Array.from(state.editors.entries()).map(([k, v]) => [k, v === 'idle' ? 'pending' : v])),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
showOriginal: (editor) => {
|
|
28
|
+
if (editor) {
|
|
29
|
+
set((state) => ({
|
|
30
|
+
editors: new Map(state.editors).set(editor, 'idle'),
|
|
31
|
+
editorTranslateStates: new Map(Array.from(state.editorTranslateStates.entries()).filter(([k]) => k !== editor)),
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
set((state) => ({
|
|
36
|
+
editors: new Map(Array.from(state.editors.entries()).map(([k]) => [k, 'idle'])),
|
|
37
|
+
editorTranslateStates: new Map(),
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
setTargetLanguage: (targetLanguage) => set({ targetLanguage }),
|
|
42
|
+
setAutoTranslate: (autoTranslate) => {
|
|
43
|
+
set({ autoTranslate });
|
|
44
|
+
if (autoTranslate) {
|
|
45
|
+
get().translate();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
setStatus: (editor, status) => {
|
|
49
|
+
set((state) => ({ editors: new Map(state.editors).set(editor, status) }));
|
|
50
|
+
},
|
|
51
|
+
setDisplayMode: (displayMode) => set({ displayMode }),
|
|
52
|
+
registerEditor: (editor) => {
|
|
53
|
+
set((state) => ({
|
|
54
|
+
editors: new Map(state.editors).set(editor, state.autoTranslate ? 'pending' : 'idle'),
|
|
55
|
+
}));
|
|
56
|
+
return () => {
|
|
57
|
+
get().unregisterEditor(editor);
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
unregisterEditor: (editor) => {
|
|
61
|
+
set((state) => ({
|
|
62
|
+
editors: new Map(Array.from(state.editors.entries()).filter(([k]) => k !== editor)),
|
|
63
|
+
}));
|
|
64
|
+
},
|
|
65
|
+
}), {
|
|
66
|
+
name: 'inline-translation-settings',
|
|
67
|
+
partialize: (state) => ({
|
|
68
|
+
targetLanguage: state.targetLanguage,
|
|
69
|
+
autoTranslate: state.autoTranslate,
|
|
70
|
+
displayMode: state.displayMode,
|
|
71
|
+
}),
|
|
72
|
+
}));
|
|
73
|
+
export const useStatus = (editor) => {
|
|
74
|
+
return useInlineTranslationStore((state) => state.editors.get(editor));
|
|
75
|
+
};
|
|
76
|
+
export const useIsIdle = () => {
|
|
77
|
+
return useInlineTranslationStore((state) => Array.from(state.editors.values()).every((x) => x === 'idle'));
|
|
78
|
+
};
|
|
79
|
+
export const useIsTranslating = () => {
|
|
80
|
+
return useInlineTranslationStore((state) => Array.from(state.editors.values()).some((x) => x === 'processing'));
|
|
81
|
+
};
|
|
82
|
+
export const useIsTranslated = () => {
|
|
83
|
+
return useInlineTranslationStore((state) => {
|
|
84
|
+
const statusArr = Array.from(state.editors.values());
|
|
85
|
+
return statusArr.length > 0 && statusArr.every((x) => x === 'completed' || x === 'pending');
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
export const useTargetLanguage = () => {
|
|
89
|
+
const { locale, languages } = useLocaleContext();
|
|
90
|
+
const { session } = useContext(SessionContext);
|
|
91
|
+
// session.user.locale 可能是无效值, 安全起见从 languages 中查找, 参考: https://github.com/ArcBlock/blocklet-server/issues/10660
|
|
92
|
+
const preferredLanguage = languages.find((x) => x.code === session?.user?.locale);
|
|
93
|
+
return preferredLanguage?.code ?? locale;
|
|
94
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DisplayMode = 'inline' | 'translationOnly';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* TODO: 最新版 lexical 已经内置在 lexical-react package 中
|
|
6
|
+
*
|
|
7
|
+
* Use this plugin to access the editor instance outside of the
|
|
8
|
+
* LexicalComposer. This can help with things like buttons or other
|
|
9
|
+
* UI components that need to update or read EditorState but need to
|
|
10
|
+
* be positioned outside the LexicalComposer in the React tree.
|
|
11
|
+
*/
|
|
12
|
+
export declare function EditorRefPlugin({ editorRef, }: {
|
|
13
|
+
editorRef: React.RefCallback<LexicalEditor> | MutableRefObject<LexicalEditor | null>;
|
|
14
|
+
}): null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* TODO: 最新版 lexical 已经内置在 lexical-react package 中
|
|
5
|
+
*
|
|
6
|
+
* Use this plugin to access the editor instance outside of the
|
|
7
|
+
* LexicalComposer. This can help with things like buttons or other
|
|
8
|
+
* UI components that need to update or read EditorState but need to
|
|
9
|
+
* be positioned outside the LexicalComposer in the React tree.
|
|
10
|
+
*/
|
|
11
|
+
export function EditorRefPlugin({ editorRef, }) {
|
|
12
|
+
const [editor] = useLexicalComposerContext();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (typeof editorRef === 'function') {
|
|
15
|
+
editorRef(editor);
|
|
16
|
+
return () => editorRef(null);
|
|
17
|
+
}
|
|
18
|
+
if (typeof editorRef === 'object') {
|
|
19
|
+
editorRef.current = editor;
|
|
20
|
+
return () => {
|
|
21
|
+
editorRef.current = null;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}, [editor]);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorState, LexicalEditor } from 'lexical';
|
|
2
|
+
type OnChange = (editorState: EditorState, editor: LexicalEditor) => void;
|
|
3
|
+
/**
|
|
4
|
+
* 检听内容变化
|
|
5
|
+
* - 忽略 selection 事件
|
|
6
|
+
* - 默认忽略首次 onChange 事件 (autofocus 开启时 editor 初始化后会自动触发 onChange)
|
|
7
|
+
*
|
|
8
|
+
* 注意: Editor#autofocus 与 OnChangePlugin 行为有关系: https://github.com/facebook/lexical/issues/4493
|
|
9
|
+
*/
|
|
10
|
+
export declare function OnContentChangePlugin({ onChange, ignoreInitialChange, }: {
|
|
11
|
+
onChange: OnChange;
|
|
12
|
+
ignoreInitialChange?: boolean;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
3
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
4
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
+
/**
|
|
6
|
+
* 检听内容变化
|
|
7
|
+
* - 忽略 selection 事件
|
|
8
|
+
* - 默认忽略首次 onChange 事件 (autofocus 开启时 editor 初始化后会自动触发 onChange)
|
|
9
|
+
*
|
|
10
|
+
* 注意: Editor#autofocus 与 OnChangePlugin 行为有关系: https://github.com/facebook/lexical/issues/4493
|
|
11
|
+
*/
|
|
12
|
+
export function OnContentChangePlugin({ onChange, ignoreInitialChange = true, }) {
|
|
13
|
+
const [editor] = useLexicalComposerContext();
|
|
14
|
+
const initialContentRef = useRef(undefined);
|
|
15
|
+
const changedRef = useRef(false);
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
if (initialContentRef.current === undefined) {
|
|
18
|
+
const editorState = editor.getEditorState();
|
|
19
|
+
initialContentRef.current = editorState ? JSON.stringify(editorState) : '';
|
|
20
|
+
}
|
|
21
|
+
}, [editor]);
|
|
22
|
+
const handleOnChange = (editorState, lexicalEditor) => {
|
|
23
|
+
if (changedRef.current) {
|
|
24
|
+
onChange(editorState, lexicalEditor);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const content = editorState ? JSON.stringify(editorState) : '';
|
|
28
|
+
if (content !== initialContentRef.current || !ignoreInitialChange) {
|
|
29
|
+
onChange(editorState, lexicalEditor);
|
|
30
|
+
changedRef.current = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return _jsx(OnChangePlugin, { onChange: handleOnChange, ignoreSelectionChange: true });
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { COMMAND_PRIORITY_CRITICAL, PASTE_COMMAND } from 'lexical';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { DRAG_DROP_PASTE, eventFiles } from '@lexical/rich-text';
|
|
5
|
+
export default function PasteSlackImagePlugin() {
|
|
6
|
+
const [editor] = useLexicalComposerContext();
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const unregister = editor.registerCommand(PASTE_COMMAND, (e) => {
|
|
9
|
+
const [, files] = eventFiles(e);
|
|
10
|
+
if (files.length && files.every((file) => file.type.startsWith('image/'))) {
|
|
11
|
+
editor.dispatchCommand(DRAG_DROP_PASTE, files);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}, COMMAND_PRIORITY_CRITICAL // 使用最高优先级
|
|
16
|
+
);
|
|
17
|
+
return () => {
|
|
18
|
+
unregister();
|
|
19
|
+
};
|
|
20
|
+
}, [editor]);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
import { DecoratorNode } from 'lexical';
|
|
3
|
+
import { type JSX } from 'react';
|
|
4
|
+
export interface PostInfo {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
link: string;
|
|
8
|
+
type: 'post' | 'blog' | 'doc' | 'task';
|
|
9
|
+
boardId: string;
|
|
10
|
+
external?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type SerializedPostLinkNode = Spread<{
|
|
13
|
+
postInfo: string;
|
|
14
|
+
type: 'post-link';
|
|
15
|
+
version: 1;
|
|
16
|
+
}, SerializedLexicalNode>;
|
|
17
|
+
export declare class PostLinkNode extends DecoratorNode<JSX.Element> {
|
|
18
|
+
__postInfo: PostInfo;
|
|
19
|
+
static getType(): string;
|
|
20
|
+
static clone(node: PostLinkNode): PostLinkNode;
|
|
21
|
+
static importJSON(serializedNode: SerializedPostLinkNode): PostLinkNode;
|
|
22
|
+
exportDOM(): DOMExportOutput;
|
|
23
|
+
static importDOM(): DOMConversionMap | null;
|
|
24
|
+
constructor(postInfo: PostInfo, key?: NodeKey);
|
|
25
|
+
exportJSON(): SerializedPostLinkNode;
|
|
26
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
27
|
+
updateDOM(): false;
|
|
28
|
+
getPostInfo(): PostInfo;
|
|
29
|
+
decorate(): JSX.Element;
|
|
30
|
+
}
|
|
31
|
+
export declare function $createPostLinkNode(postInfo: PostInfo): PostLinkNode;
|
|
32
|
+
export declare function $isPostLinkNode(node: PostLinkNode | LexicalNode | null | undefined): node is PostLinkNode;
|