@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,170 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { useReactive } from 'ahooks';
|
|
4
|
+
import { ClickAwayListener, Box, MenuList, MenuItem, ListItemText, ListItemIcon, Typography } from '@mui/material';
|
|
5
|
+
import { mergeRegister } from '@lexical/utils';
|
|
6
|
+
import { $createParagraphNode, $insertNodes, $parseSerializedNode, COMMAND_PRIORITY_EDITOR, createCommand, $getSelection, $getNodeByKey, } from 'lexical';
|
|
7
|
+
import { useEffect, useRef } from 'react';
|
|
8
|
+
import { Card, MenuWrapper, NestedMenuItem } from './common';
|
|
9
|
+
import { SelectionPopper } from '../components/SelectionPopper';
|
|
10
|
+
import { safeParseJSON } from './utils';
|
|
11
|
+
import { TEMPLATE_CLASS_NAME } from './CustomOnChangePlugin';
|
|
12
|
+
import { useEditorConfig } from '../config';
|
|
13
|
+
function BlockletLogo(props) {
|
|
14
|
+
const { did, ...restProps } = props;
|
|
15
|
+
const src = `/.well-known/service/blocklet/logo-bundle/${did}`;
|
|
16
|
+
return _jsx("img", { width: 24, height: 24, src: src, alt: did, ...restProps });
|
|
17
|
+
}
|
|
18
|
+
export const INSERT_TEMPLATE_COMMAND = createCommand('INSERT_TEMPLATE_COMMAND');
|
|
19
|
+
export function TemplatePlugin() {
|
|
20
|
+
const [editor] = useLexicalComposerContext();
|
|
21
|
+
const { templatePlugin } = useEditorConfig();
|
|
22
|
+
const selectionRef = useRef(null);
|
|
23
|
+
const templateRef = useRef(null);
|
|
24
|
+
const boxRef = useRef(null);
|
|
25
|
+
const state = useReactive({
|
|
26
|
+
template: '',
|
|
27
|
+
open: false,
|
|
28
|
+
appendKey: '',
|
|
29
|
+
templateList: [],
|
|
30
|
+
});
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (templatePlugin?.fetchTemplateList) {
|
|
33
|
+
templatePlugin.fetchTemplateList().then((data) => {
|
|
34
|
+
state.templateList = data?.filter((item) => item.options?.length > 0) || [];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
return mergeRegister(editor.registerCommand(INSERT_TEMPLATE_COMMAND, (_payload) => {
|
|
40
|
+
onOpen();
|
|
41
|
+
editor.update(() => {
|
|
42
|
+
const selection = $getSelection();
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
const anchorNode = selection?.anchor?.getNode();
|
|
45
|
+
// must, clear anchor node to ensure selection not change
|
|
46
|
+
if (anchorNode?.clear) {
|
|
47
|
+
anchorNode.clear();
|
|
48
|
+
}
|
|
49
|
+
// must, insert a paragraph node to avoid index out of range
|
|
50
|
+
const p = $createParagraphNode();
|
|
51
|
+
$insertNodes([p]);
|
|
52
|
+
p.selectStart();
|
|
53
|
+
// @ts-ignore get new selection
|
|
54
|
+
selectionRef.current = $getSelection();
|
|
55
|
+
});
|
|
56
|
+
return true;
|
|
57
|
+
}, COMMAND_PRIORITY_EDITOR));
|
|
58
|
+
}, [editor]);
|
|
59
|
+
const onOpen = () => {
|
|
60
|
+
state.open = true;
|
|
61
|
+
window.addEventListener('keydown', onClickAway);
|
|
62
|
+
};
|
|
63
|
+
const onClose = () => {
|
|
64
|
+
state.open = false;
|
|
65
|
+
state.appendKey = '';
|
|
66
|
+
templateRef.current = null;
|
|
67
|
+
window.removeEventListener('keydown', onClickAway);
|
|
68
|
+
};
|
|
69
|
+
const removeTemplate = async () => {
|
|
70
|
+
editor.update(() => {
|
|
71
|
+
if (state.appendKey) {
|
|
72
|
+
const node = $getNodeByKey(state.appendKey);
|
|
73
|
+
// clear nodes
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
node?.clear();
|
|
76
|
+
state.appendKey = '';
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
selectionRef.current = $getSelection();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
await Promise.resolve().then();
|
|
82
|
+
};
|
|
83
|
+
const insertTemplate = async (item) => {
|
|
84
|
+
await removeTemplate();
|
|
85
|
+
editor.update(() => {
|
|
86
|
+
try {
|
|
87
|
+
const p = $createParagraphNode();
|
|
88
|
+
// @ts-ignore get all nodes in lexical state
|
|
89
|
+
const nodes = safeParseJSON(item.content, {})?.root?.children?.map?.((node) => {
|
|
90
|
+
return $parseSerializedNode(node);
|
|
91
|
+
});
|
|
92
|
+
p.append($createParagraphNode(),
|
|
93
|
+
// insert all nodes into paragraph
|
|
94
|
+
...nodes);
|
|
95
|
+
p.markDirty();
|
|
96
|
+
$insertNodes([p]);
|
|
97
|
+
// keep selection not change
|
|
98
|
+
p.selectStart();
|
|
99
|
+
state.appendKey = p.getKey();
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
console.error('insert nodes error: ', e);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
await Promise.resolve().then();
|
|
106
|
+
editor.getEditorState().read(() => {
|
|
107
|
+
const htmlElement = editor.getElementByKey(state.appendKey);
|
|
108
|
+
htmlElement?.classList.add(TEMPLATE_CLASS_NAME);
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
selectionRef.current = $getSelection();
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const onSelect = (item) => {
|
|
114
|
+
if (item.id === templateRef.current?.id) {
|
|
115
|
+
const htmlElement = editor.getElementByKey(state.appendKey);
|
|
116
|
+
if (htmlElement?.classList.contains(TEMPLATE_CLASS_NAME)) {
|
|
117
|
+
htmlElement?.classList.remove(TEMPLATE_CLASS_NAME);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
onClose();
|
|
121
|
+
if (templatePlugin?.importTemplate) {
|
|
122
|
+
templatePlugin.importTemplate(item);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const onHover = async (item) => {
|
|
126
|
+
if (item.id !== templateRef.current?.id) {
|
|
127
|
+
templateRef.current = item;
|
|
128
|
+
await insertTemplate(item);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const onClickAway = async (e) => {
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
await removeTemplate();
|
|
135
|
+
onClose();
|
|
136
|
+
};
|
|
137
|
+
const templateSelectProps = {
|
|
138
|
+
onSelect,
|
|
139
|
+
onHover,
|
|
140
|
+
templateList: state.templateList,
|
|
141
|
+
};
|
|
142
|
+
if (state.open) {
|
|
143
|
+
return (_jsx(ClickAwayListener, { onClickAway: onClickAway, children: _jsx(Box, { ref: boxRef, children: _jsx(SelectionPopper, { selection: selectionRef.current, sx: { display: 'flex', alignItems: 'center', zIndex: 9999 }, children: _jsx(TemplateSelect, { ...templateSelectProps }) }) }) }));
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
export function TemplateSelect({ onSelect, onHover, templateList = [], }) {
|
|
148
|
+
return (_jsx(Card, { component: MenuWrapper, sx: {
|
|
149
|
+
flex: '0 1 auto',
|
|
150
|
+
width: 280,
|
|
151
|
+
my: 0.5,
|
|
152
|
+
overflowY: 'auto',
|
|
153
|
+
maxHeight: 240,
|
|
154
|
+
}, children: templateList?.length > 0 ? (_jsx(MenuList, { children: templateList.map((template) => {
|
|
155
|
+
if (template.options) {
|
|
156
|
+
return (_jsxs(NestedMenuItem, { subMenu: _jsx(Card, { sx: { minWidth: 200, maxHeight: 240, overflowY: 'auto' }, children: _jsx(MenuList, { children: template.options.map((option) => {
|
|
157
|
+
return (_jsx(MenuItem, { onClick: () => onSelect?.(option), onMouseEnter: () => onHover?.(option), children: option.title }, option.title));
|
|
158
|
+
}) }) }), children: [_jsx(ListItemIcon, { sx: { mr: 0.75 }, children: _jsx(BlockletLogo, { did: template.did }) }), _jsx(ListItemText, { children: _jsx(Typography, { variant: "inherit", noWrap: true, sx: {
|
|
159
|
+
lineHeight: 1,
|
|
160
|
+
}, children: template.title }) })] }, template.title));
|
|
161
|
+
}
|
|
162
|
+
// not any options
|
|
163
|
+
return null;
|
|
164
|
+
}) })) : (_jsxs(MenuItem, { children: [_jsx(ListItemIcon, { sx: { mr: 0.75 }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": "material-symbols:info-outline", "data-height": "24px", "data-width": "24px" }) }), _jsx(ListItemText, { sx: {
|
|
165
|
+
whiteSpace: 'pre-wrap',
|
|
166
|
+
}, children: _jsx(Typography, { variant: "inherit", sx: {
|
|
167
|
+
lineHeight: 1.4,
|
|
168
|
+
whiteSpace: 'pre-wrap',
|
|
169
|
+
}, children: "There is no templates available, please contact the owner or admin to import it" }) })] })) }));
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function VideoPathFixerPlugin(): null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { joinURL } from 'ufo';
|
|
4
|
+
import { discussKitUploadsUrl } from './utils';
|
|
5
|
+
import { VideoNode } from './VideoPlugin/VideoNode';
|
|
6
|
+
const originalExportJSON = VideoNode.prototype.exportJSON;
|
|
7
|
+
const ensureLeadingSlash = (str) => (str.startsWith('/') ? str : `/${str}`);
|
|
8
|
+
VideoNode.prototype.exportJSON = function exportJSON() {
|
|
9
|
+
const json = originalExportJSON.call(this);
|
|
10
|
+
// 保存 editor content 时恢复 src (剥除 discussKitUploadsUrl)
|
|
11
|
+
if (json.src && json.src.startsWith(discussKitUploadsUrl)) {
|
|
12
|
+
json.src = json.src.replace(discussKitUploadsUrl, '');
|
|
13
|
+
json.src = ensureLeadingSlash(json.src);
|
|
14
|
+
}
|
|
15
|
+
return json;
|
|
16
|
+
};
|
|
17
|
+
function VideoNodeTransform(node) {
|
|
18
|
+
const targetNode = node;
|
|
19
|
+
const src = targetNode.getSrc();
|
|
20
|
+
// 仅处理以 "/" 为前缀的 image src, 并且避免重复处理
|
|
21
|
+
if (src?.startsWith('/') && !src.startsWith(discussKitUploadsUrl)) {
|
|
22
|
+
targetNode.setSrc(joinURL(discussKitUploadsUrl, src));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function VideoPathFixerPlugin() {
|
|
26
|
+
const [editor] = useLexicalComposerContext();
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
return editor.registerNodeTransform(VideoNode, VideoNodeTransform);
|
|
29
|
+
}, [editor]);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 VideoPayload {
|
|
5
|
+
key?: NodeKey;
|
|
6
|
+
src: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
maxWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
export type SerializedVideoNode = Spread<{
|
|
12
|
+
height?: number;
|
|
13
|
+
maxWidth: number;
|
|
14
|
+
src: string;
|
|
15
|
+
width?: number;
|
|
16
|
+
}, SerializedLexicalNode>;
|
|
17
|
+
export declare class VideoNode extends DecoratorNode<JSX.Element> {
|
|
18
|
+
__src: string;
|
|
19
|
+
__width: 'inherit' | number;
|
|
20
|
+
__height: 'inherit' | number;
|
|
21
|
+
__maxWidth: number;
|
|
22
|
+
static getType(): string;
|
|
23
|
+
static clone(node: VideoNode): VideoNode;
|
|
24
|
+
static importJSON(serializedNode: SerializedVideoNode): VideoNode;
|
|
25
|
+
exportDOM(): DOMExportOutput;
|
|
26
|
+
static importDOM(): DOMConversionMap | null;
|
|
27
|
+
constructor(src: string, maxWidth: number, width?: 'inherit' | number, height?: 'inherit' | number, key?: NodeKey);
|
|
28
|
+
exportJSON(): SerializedVideoNode;
|
|
29
|
+
setWidthAndHeight(width: 'inherit' | number, height: 'inherit' | number): void;
|
|
30
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
31
|
+
updateDOM(): false;
|
|
32
|
+
getSrc(): string;
|
|
33
|
+
setSrc(src: string): void;
|
|
34
|
+
decorate(): JSX.Element;
|
|
35
|
+
}
|
|
36
|
+
export declare function $createVideoNode({ height, maxWidth, src, width, key }: VideoPayload): VideoNode;
|
|
37
|
+
export declare function $isVideoNode(node: LexicalNode | null | undefined): node is VideoNode;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $applyNodeReplacement, DecoratorNode } from 'lexical';
|
|
3
|
+
import { lazyRetry as lazy } from '@arcblock/ux/lib/Util';
|
|
4
|
+
import { Suspense } from 'react';
|
|
5
|
+
const VideoComponent = lazy(
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
() => import('./VideoComponent'));
|
|
8
|
+
function convertVideoElement(domNode) {
|
|
9
|
+
if (domNode instanceof HTMLVideoElement) {
|
|
10
|
+
const { src, width, height } = domNode;
|
|
11
|
+
const node = $createVideoNode({ height, src, width });
|
|
12
|
+
return { node };
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
export class VideoNode extends DecoratorNode {
|
|
17
|
+
__src;
|
|
18
|
+
__width;
|
|
19
|
+
__height;
|
|
20
|
+
__maxWidth;
|
|
21
|
+
static getType() {
|
|
22
|
+
return 'video';
|
|
23
|
+
}
|
|
24
|
+
static clone(node) {
|
|
25
|
+
return new VideoNode(node.__src, node.__maxWidth, node.__width, node.__height, node.__key);
|
|
26
|
+
}
|
|
27
|
+
static importJSON(serializedNode) {
|
|
28
|
+
const { height, width, maxWidth, src } = serializedNode;
|
|
29
|
+
const node = $createVideoNode({
|
|
30
|
+
height,
|
|
31
|
+
maxWidth,
|
|
32
|
+
src,
|
|
33
|
+
width,
|
|
34
|
+
});
|
|
35
|
+
return node;
|
|
36
|
+
}
|
|
37
|
+
exportDOM() {
|
|
38
|
+
const element = document.createElement('img');
|
|
39
|
+
element.setAttribute('src', this.__src);
|
|
40
|
+
element.setAttribute('width', this.__width.toString());
|
|
41
|
+
element.setAttribute('height', this.__height.toString());
|
|
42
|
+
return { element };
|
|
43
|
+
}
|
|
44
|
+
static importDOM() {
|
|
45
|
+
return {
|
|
46
|
+
img: (node) => ({
|
|
47
|
+
conversion: convertVideoElement,
|
|
48
|
+
priority: 0,
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
constructor(src, maxWidth, width, height, key) {
|
|
53
|
+
super(key);
|
|
54
|
+
this.__src = src;
|
|
55
|
+
this.__maxWidth = maxWidth;
|
|
56
|
+
this.__width = width || 'inherit';
|
|
57
|
+
this.__height = height || 'inherit';
|
|
58
|
+
}
|
|
59
|
+
exportJSON() {
|
|
60
|
+
return {
|
|
61
|
+
height: this.__height === 'inherit' ? 0 : this.__height,
|
|
62
|
+
maxWidth: this.__maxWidth,
|
|
63
|
+
src: this.getSrc(),
|
|
64
|
+
type: 'video',
|
|
65
|
+
version: 1,
|
|
66
|
+
width: this.__width === 'inherit' ? 0 : this.__width,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
setWidthAndHeight(width, height) {
|
|
70
|
+
const writable = this.getWritable();
|
|
71
|
+
writable.__width = width;
|
|
72
|
+
writable.__height = height;
|
|
73
|
+
}
|
|
74
|
+
createDOM(config) {
|
|
75
|
+
const span = document.createElement('span');
|
|
76
|
+
return span;
|
|
77
|
+
}
|
|
78
|
+
updateDOM() {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
getSrc() {
|
|
82
|
+
return this.__src;
|
|
83
|
+
}
|
|
84
|
+
setSrc(src) {
|
|
85
|
+
const writable = this.getWritable();
|
|
86
|
+
writable.__src = src;
|
|
87
|
+
}
|
|
88
|
+
decorate() {
|
|
89
|
+
return (_jsx(Suspense, { fallback: null, children: _jsx(VideoComponent, { url: this.__src }) }));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function $createVideoNode({ height, maxWidth = 500, src, width, key }) {
|
|
93
|
+
return $applyNodeReplacement(new VideoNode(src, maxWidth, width, height, key));
|
|
94
|
+
}
|
|
95
|
+
export function $isVideoNode(node) {
|
|
96
|
+
return node instanceof VideoNode;
|
|
97
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LexicalCommand } from 'lexical';
|
|
2
|
+
import { type JSX } from 'react';
|
|
3
|
+
import { VideoPayload } from './VideoNode';
|
|
4
|
+
export type InsertVideoPayload = Readonly<VideoPayload>;
|
|
5
|
+
export declare const INSERT_VIDEO_COMMAND: LexicalCommand<InsertVideoPayload>;
|
|
6
|
+
export declare function VideoPlugin(): JSX.Element | null;
|
|
7
|
+
export declare const isVideo: (src: string) => boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { $wrapNodeInElement, mergeRegister } from '@lexical/utils';
|
|
3
|
+
import { $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, createCommand, } from 'lexical';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { $createVideoNode, VideoNode } from './VideoNode';
|
|
6
|
+
export const INSERT_VIDEO_COMMAND = createCommand('INSERT_VIDEO_COMMAND');
|
|
7
|
+
export function VideoPlugin() {
|
|
8
|
+
const [editor] = useLexicalComposerContext();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!editor.hasNodes([VideoNode])) {
|
|
11
|
+
throw new Error('VideoPlugin: VideoNode not registered on editor');
|
|
12
|
+
}
|
|
13
|
+
return mergeRegister(editor.registerCommand(INSERT_VIDEO_COMMAND, (payload) => {
|
|
14
|
+
const videoNode = $createVideoNode(payload);
|
|
15
|
+
$insertNodes([videoNode]);
|
|
16
|
+
if ($isRootOrShadowRoot(videoNode.getParentOrThrow())) {
|
|
17
|
+
$wrapNodeInElement(videoNode, $createParagraphNode).selectEnd();
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}, COMMAND_PRIORITY_EDITOR));
|
|
21
|
+
}, [editor]);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export const isVideo = (src) => {
|
|
25
|
+
return /\.(mp4|avi|mov|wmv|flv|mkv|mpeg|mpg|webm|ogg|ogv|3gp)$/i.test(src);
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SxProps, BoxProps, MenuItemProps, ButtonProps } from '@mui/material';
|
|
3
|
+
type Props = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
sx?: SxProps;
|
|
6
|
+
} & BoxProps;
|
|
7
|
+
export declare function Card({ ref, children, sx, ...rest }: Props & {
|
|
8
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const MenuWrapper: React.FC<BoxProps>;
|
|
11
|
+
export declare const GradientButton: React.FC<ButtonProps>;
|
|
12
|
+
export declare function NestedMenuItem({ children, subMenu, ...rest }: MenuItemProps & {
|
|
13
|
+
subMenu: React.ReactNode;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Button, MenuItem, styled } from '@mui/material';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { usePopper } from 'react-popper';
|
|
5
|
+
export function Card({ ref = undefined, children, sx, ...rest }) {
|
|
6
|
+
const mergedSx = [
|
|
7
|
+
{
|
|
8
|
+
maxWidth: '100%',
|
|
9
|
+
border: 1,
|
|
10
|
+
borderColor: 'divider',
|
|
11
|
+
borderRadius: 2,
|
|
12
|
+
bgcolor: 'background.paper',
|
|
13
|
+
boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
|
|
14
|
+
pointerEvents: 'initial',
|
|
15
|
+
},
|
|
16
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
17
|
+
];
|
|
18
|
+
return (_jsx(Box, { ref: ref, sx: mergedSx, ...rest, children: children }));
|
|
19
|
+
}
|
|
20
|
+
export const MenuWrapper = styled(Box) `
|
|
21
|
+
.MuiMenuItem-root {
|
|
22
|
+
min-height: 32px;
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
.MuiListItemIcon-root {
|
|
25
|
+
min-width: 28px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
export const GradientButton = styled(Button) `
|
|
30
|
+
background-image: linear-gradient(to right, #4776e6 0%, #8e54e9 51%, #4776e6 100%);
|
|
31
|
+
transition: 0.5s;
|
|
32
|
+
background-size: 200% auto;
|
|
33
|
+
color: white;
|
|
34
|
+
box-shadow: 0 0 20px #eee;
|
|
35
|
+
|
|
36
|
+
&:hover {
|
|
37
|
+
background-position: right center;
|
|
38
|
+
color: #fff;
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
export function NestedMenuItem({ children, subMenu, ...rest }) {
|
|
43
|
+
const [referenceElement, setReferenceElement] = useState(null);
|
|
44
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
45
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
46
|
+
placement: 'right',
|
|
47
|
+
strategy: 'fixed',
|
|
48
|
+
});
|
|
49
|
+
const mouseOverPopper = useRef(false);
|
|
50
|
+
const handleMouseMoveOut = () => {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
if (!mouseOverPopper.current) {
|
|
53
|
+
setReferenceElement(null);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs(MenuItem, { ...rest, onMouseOut: handleMouseMoveOut, children: [children, _jsx(Box, { component: "i", className: "iconify", "data-icon": "mdi:chevron-right", "data-height": "18px", sx: { color: 'text.secondary' } }), _jsx(Box, { sx: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }, onMouseOver: (e) => setReferenceElement(e.target) }), referenceElement && (_jsx(Box, { ref: setPopperElement, style: styles.popper, ...attributes.popper, onMouseOver: () => {
|
|
58
|
+
mouseOverPopper.current = true;
|
|
59
|
+
}, onMouseOut: () => {
|
|
60
|
+
mouseOverPopper.current = false;
|
|
61
|
+
}, children: subMenu }))] }));
|
|
62
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
function GithubComponent({ title, image, link }) {
|
|
5
|
+
const number = useMemo(() => {
|
|
6
|
+
if (!link) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const { pathname } = new URL(link || '');
|
|
11
|
+
const [, , , id] = pathname.split('/').filter(Boolean);
|
|
12
|
+
return id;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
}, [link]);
|
|
18
|
+
return (_jsxs(Box, { className: "github-container", sx: { color: 'text.primary' }, children: [_jsx("i", { className: "iconify github-icon", "data-icon": "mdi:github" }), !!number && _jsx(Box, { className: "github-number", sx: { color: 'text.secondary' }, children: `#${number}` }), _jsx(Box, { component: "a", className: "github-text", href: link, title: title, sx: { color: 'inherit', borderBottom: 1, borderColor: 'divider' }, children: title }), image && _jsx("img", { src: image, alt: "github-avatar", className: "github-avatar" })] }));
|
|
19
|
+
}
|
|
20
|
+
export default GithubComponent;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
import { DecoratorNode } from 'lexical';
|
|
3
|
+
import { type JSX } from 'react';
|
|
4
|
+
import { GithubInfoType } from './util';
|
|
5
|
+
export type SerializedGithubNode = Spread<{
|
|
6
|
+
title: string;
|
|
7
|
+
image: string;
|
|
8
|
+
link: string;
|
|
9
|
+
type: 'github';
|
|
10
|
+
version: 1;
|
|
11
|
+
}, SerializedLexicalNode>;
|
|
12
|
+
export declare class GithubNode extends DecoratorNode<JSX.Element> {
|
|
13
|
+
__title: string;
|
|
14
|
+
__image: string;
|
|
15
|
+
__link: string;
|
|
16
|
+
static getType(): string;
|
|
17
|
+
static clone(node: GithubNode): GithubNode;
|
|
18
|
+
static importJSON(serializedNode: SerializedGithubNode): GithubNode;
|
|
19
|
+
exportDOM(): DOMExportOutput;
|
|
20
|
+
static importDOM(): DOMConversionMap | null;
|
|
21
|
+
constructor(title: string, image: string, link: string, key?: NodeKey);
|
|
22
|
+
exportJSON(): SerializedGithubNode;
|
|
23
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
24
|
+
updateDOM(): false;
|
|
25
|
+
decorate(): JSX.Element;
|
|
26
|
+
}
|
|
27
|
+
export declare function $createGithubNode(github: GithubInfoType): GithubNode;
|
|
28
|
+
export declare function $isGithubNode(node: GithubNode | LexicalNode | null | undefined): node is GithubNode;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DecoratorNode } from 'lexical';
|
|
3
|
+
import { Suspense } from 'react';
|
|
4
|
+
import GithubComponent from './GithubComp';
|
|
5
|
+
function convertGithubElement(domNode) {
|
|
6
|
+
const githubStr = domNode.getAttribute('data-lexical-github');
|
|
7
|
+
if (!githubStr) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(githubStr);
|
|
12
|
+
if (parsed && typeof parsed === 'object') {
|
|
13
|
+
const node = $createGithubNode({ title: parsed.title, image: parsed.image, link: parsed.link });
|
|
14
|
+
return { node };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.warn(`Failed to parse: ${githubStr}`, e);
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export class GithubNode extends DecoratorNode {
|
|
23
|
+
__title;
|
|
24
|
+
__image;
|
|
25
|
+
__link;
|
|
26
|
+
static getType() {
|
|
27
|
+
return 'github';
|
|
28
|
+
}
|
|
29
|
+
static clone(node) {
|
|
30
|
+
return new GithubNode(node.__title, node.__image, node.__link, node.__key);
|
|
31
|
+
}
|
|
32
|
+
static importJSON(serializedNode) {
|
|
33
|
+
const { title, image, link } = serializedNode;
|
|
34
|
+
const node = $createGithubNode({
|
|
35
|
+
title,
|
|
36
|
+
image,
|
|
37
|
+
link,
|
|
38
|
+
});
|
|
39
|
+
return node;
|
|
40
|
+
}
|
|
41
|
+
exportDOM() {
|
|
42
|
+
const element = document.createElement('span');
|
|
43
|
+
element.className = 'github-node-container';
|
|
44
|
+
element.setAttribute('data-lexical-github', JSON.stringify({ title: this.__title, image: this.__image, link: this.__link }));
|
|
45
|
+
return { element };
|
|
46
|
+
}
|
|
47
|
+
static importDOM() {
|
|
48
|
+
return {
|
|
49
|
+
span: (domNode) => {
|
|
50
|
+
if (!domNode.hasAttribute('data-lexical-github')) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
conversion: convertGithubElement,
|
|
55
|
+
priority: 4,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
constructor(title, image, link, key) {
|
|
61
|
+
super(key);
|
|
62
|
+
this.__title = title;
|
|
63
|
+
this.__image = image;
|
|
64
|
+
this.__link = link;
|
|
65
|
+
}
|
|
66
|
+
exportJSON() {
|
|
67
|
+
return {
|
|
68
|
+
title: this.__title,
|
|
69
|
+
image: this.__image,
|
|
70
|
+
link: this.__link,
|
|
71
|
+
type: 'github',
|
|
72
|
+
version: 1,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// View
|
|
76
|
+
createDOM(config) {
|
|
77
|
+
const span = document.createElement('span');
|
|
78
|
+
span.className = 'github-node-container';
|
|
79
|
+
span.setAttribute('data-lexical-github', JSON.stringify({ title: this.__title, image: this.__image, link: this.__link }));
|
|
80
|
+
return span;
|
|
81
|
+
}
|
|
82
|
+
updateDOM() {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
decorate() {
|
|
86
|
+
return (_jsx(Suspense, { fallback: null, children: _jsx(GithubComponent, { title: this.__title, image: this.__image, link: this.__link }) }));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export function $createGithubNode(github) {
|
|
90
|
+
return new GithubNode(github?.title || '', github?.image || '', github?.link || '');
|
|
91
|
+
}
|
|
92
|
+
export function $isGithubNode(node) {
|
|
93
|
+
return node instanceof GithubNode;
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ElementNode, LexicalNode, LexicalEditor } from 'lexical';
|
|
2
|
+
export declare const $nodeToHtml: (editor: LexicalEditor, node: ElementNode) => string;
|
|
3
|
+
export declare const $htmlToNodes: (editor: LexicalEditor, text: string) => LexicalNode[] | import("lexical").TextNode[];
|
|
4
|
+
/**
|
|
5
|
+
* 判断 node 是否是有效的 TextNode
|
|
6
|
+
* - $isTextNode => true
|
|
7
|
+
* - format 不是 code
|
|
8
|
+
*/
|
|
9
|
+
export declare const $isValidTextNode: (node: LexicalNode) => boolean | "";
|
|
10
|
+
/**
|
|
11
|
+
* 判断一个 ElementNode 是否含有效的 TextNode 的 child
|
|
12
|
+
*/
|
|
13
|
+
export declare const $hasValidTextNode: (elementNode: ElementNode) => boolean;
|
|
14
|
+
export declare const $findTranslatableElementNodes: () => ElementNode[];
|
|
15
|
+
export declare const $createNodeKeyToSidMap: () => Map<string, string>;
|
|
16
|
+
export declare const $createSidToNodeKeyMap: () => Map<string, string>;
|