@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,257 @@
|
|
|
1
|
+
@keyframes slide-in {
|
|
2
|
+
0% {
|
|
3
|
+
opacity: 0;
|
|
4
|
+
transform: translateX(-200px);
|
|
5
|
+
}
|
|
6
|
+
100% {
|
|
7
|
+
opacity: 1;
|
|
8
|
+
transform: translateX(0);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@keyframes mic-pulsate-color {
|
|
13
|
+
0% {
|
|
14
|
+
background-color: #ffdcdc;
|
|
15
|
+
}
|
|
16
|
+
50% {
|
|
17
|
+
background-color: #ff8585;
|
|
18
|
+
}
|
|
19
|
+
100% {
|
|
20
|
+
background-color: #ffdcdc;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ltr {
|
|
25
|
+
text-align: left;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.rtl {
|
|
29
|
+
text-align: right;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.excalidraw-button {
|
|
33
|
+
border: 0;
|
|
34
|
+
padding: 0;
|
|
35
|
+
margin: 0;
|
|
36
|
+
background-color: transparent;
|
|
37
|
+
|
|
38
|
+
width: 100%;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.excalidraw-button.selected {
|
|
42
|
+
outline: 2px solid rgb(60, 132, 244);
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.tree-view-output {
|
|
47
|
+
display: block;
|
|
48
|
+
background: #222;
|
|
49
|
+
color: #fff;
|
|
50
|
+
padding: 0;
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
position: relative;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
border-bottom-left-radius: 10px;
|
|
55
|
+
border-bottom-right-radius: 10px;
|
|
56
|
+
min-height: 100px;
|
|
57
|
+
margin: 20px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.github-node-container,
|
|
61
|
+
.inline-embed-container {
|
|
62
|
+
display: inline-block;
|
|
63
|
+
max-width: 100%;
|
|
64
|
+
line-height: normal;
|
|
65
|
+
vertical-align: text-bottom;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.github-container {
|
|
69
|
+
position: relative;
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: flex-start;
|
|
73
|
+
width: max-content;
|
|
74
|
+
max-width: 100%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.github-container .github-icon {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
flex: 0 0 auto;
|
|
82
|
+
width: 18px;
|
|
83
|
+
height: 18px;
|
|
84
|
+
margin-right: 3px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.github-container .github-number {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
flex: 0 0 auto;
|
|
92
|
+
font-size: 15px;
|
|
93
|
+
margin-right: 3px;
|
|
94
|
+
height: 18px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.github-container .github-text {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
word-break: break-word;
|
|
103
|
+
font-size: 14px;
|
|
104
|
+
font-weight: bold;
|
|
105
|
+
height: 18px;
|
|
106
|
+
line-height: 18px;
|
|
107
|
+
text-decoration: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
table td .github-container .github-text {
|
|
111
|
+
max-width: 300px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.github-container .github-avatar {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
width: 16px;
|
|
119
|
+
height: 16px;
|
|
120
|
+
border-radius: 3px;
|
|
121
|
+
margin-left: 4px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.github-container:hover {
|
|
125
|
+
cursor: pointer !important;
|
|
126
|
+
background: rgba(148, 148, 148, 0.15);
|
|
127
|
+
box-shadow: 0 0 0 3px rgba(148, 148, 148, 0.15);
|
|
128
|
+
border-radius: 1px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.global-loading {
|
|
132
|
+
vertical-align: middle;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.global-loading span {
|
|
136
|
+
display: inline-block;
|
|
137
|
+
width: 16px;
|
|
138
|
+
height: 16px;
|
|
139
|
+
border-radius: 50%;
|
|
140
|
+
position: relative;
|
|
141
|
+
animation: be-rotate 1s linear infinite;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.global-loading span::before {
|
|
145
|
+
content: '';
|
|
146
|
+
box-sizing: border-box;
|
|
147
|
+
position: absolute;
|
|
148
|
+
inset: 0px;
|
|
149
|
+
border-radius: 50%;
|
|
150
|
+
border: 2px solid #b9c6d4;
|
|
151
|
+
animation: be-prixClipFix 2s linear infinite;
|
|
152
|
+
|
|
153
|
+
width: 16px;
|
|
154
|
+
height: 16px;
|
|
155
|
+
top: 50%;
|
|
156
|
+
left: 50%;
|
|
157
|
+
transform: translate(-50%, -50%);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@keyframes be-rotate {
|
|
161
|
+
100% {
|
|
162
|
+
transform: rotate(360deg);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@keyframes be-prixClipFix {
|
|
167
|
+
0% {
|
|
168
|
+
clip-path: polygon(50% 50%, 0 0, 0 0, 0 0, 0 0, 0 0);
|
|
169
|
+
}
|
|
170
|
+
25% {
|
|
171
|
+
clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 0, 100% 0, 100% 0);
|
|
172
|
+
}
|
|
173
|
+
50% {
|
|
174
|
+
clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 100% 100%, 100% 100%);
|
|
175
|
+
}
|
|
176
|
+
75% {
|
|
177
|
+
clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 100%);
|
|
178
|
+
}
|
|
179
|
+
100% {
|
|
180
|
+
clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 0);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
li.embed-option-disabled > span:after {
|
|
184
|
+
overflow: hidden;
|
|
185
|
+
display: inline-block;
|
|
186
|
+
vertical-align: bottom;
|
|
187
|
+
-webkit-animation: ellipsis steps(4, end) 900ms infinite;
|
|
188
|
+
animation: ellipsis steps(4, end) 900ms infinite;
|
|
189
|
+
content: '\2026'; /* ascii code for the ellipsis character */
|
|
190
|
+
width: 0px;
|
|
191
|
+
}
|
|
192
|
+
@keyframes loading-ellipsis {
|
|
193
|
+
to {
|
|
194
|
+
width: 1.25em;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
@-webkit-keyframes loading-ellipsis {
|
|
198
|
+
to {
|
|
199
|
+
width: 1.25em;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* HeadingsIdPlugin */
|
|
204
|
+
.be-editable h1[id] > a:last-child,
|
|
205
|
+
.be-editable h2[id] > a:last-child,
|
|
206
|
+
.be-editable h3[id] > a:last-child,
|
|
207
|
+
.be-editable h4[id] > a:last-child,
|
|
208
|
+
.be-editable h5[id] > a:last-child,
|
|
209
|
+
.be-editable h6[id] > a:last-child {
|
|
210
|
+
user-select: none;
|
|
211
|
+
-webkit-user-select: none; /* 兼容 Safari */
|
|
212
|
+
display: inline-block;
|
|
213
|
+
width: 24px;
|
|
214
|
+
height: 24px;
|
|
215
|
+
margin-left: 8px;
|
|
216
|
+
color: #999;
|
|
217
|
+
font-size: inherit;
|
|
218
|
+
opacity: 0;
|
|
219
|
+
text-decoration: none;
|
|
220
|
+
transition: opacity 0.3s ease;
|
|
221
|
+
border: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.be-editable h1[id]:hover a,
|
|
225
|
+
.be-editable h2[id]:hover a,
|
|
226
|
+
.be-editable h3[id]:hover a,
|
|
227
|
+
.be-editable h4[id]:hover a,
|
|
228
|
+
.be-editable h5[id]:hover a,
|
|
229
|
+
.be-editable h6[id]:hover a {
|
|
230
|
+
opacity: 1;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* https://github.com/francoischalifour/medium-zoom */
|
|
234
|
+
.medium-zoom-overlay,
|
|
235
|
+
.medium-zoom-image--opened {
|
|
236
|
+
z-index: 99999;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.inline-translation-node {
|
|
240
|
+
position: relative;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* 紧挨的 2 个 TranslationNode 容器结点,分别用于包裹翻译结果结点和原文结点, 第 2 个 TranslationNode 是隐藏状态, 通过调换顺序来实现单个结点的原文/翻译切换 */
|
|
244
|
+
.inline-translation-node + .inline-translation-node {
|
|
245
|
+
display: none;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.inline-translation-node-inline > * {
|
|
249
|
+
border-bottom: 2px dashed #3890f9;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.bg-excalidraw {
|
|
253
|
+
background-image: url(images/excalidraw.svg);
|
|
254
|
+
background-size: contain;
|
|
255
|
+
background-repeat: no-repeat;
|
|
256
|
+
background-position: center;
|
|
257
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import '@iconify/iconify';
|
|
9
|
+
import './index.css';
|
|
10
|
+
import './style/editable.css';
|
|
11
|
+
import { EditorState, Klass, LexicalEditor, LexicalNode } from 'lexical';
|
|
12
|
+
import React, { MutableRefObject, ReactNode, type JSX } from 'react';
|
|
13
|
+
export interface BlockletEditorProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'placeholder' | 'onChange'> {
|
|
14
|
+
placeholder?: ReactNode;
|
|
15
|
+
editable?: boolean;
|
|
16
|
+
editorState?: string;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
prepend?: ReactNode;
|
|
19
|
+
nodes?: ReadonlyArray<Klass<LexicalNode>>;
|
|
20
|
+
onChange?: (editorState: EditorState, editor: LexicalEditor) => void;
|
|
21
|
+
autoFocus?: boolean;
|
|
22
|
+
showToolbar?: boolean;
|
|
23
|
+
editorRef?: React.RefCallback<LexicalEditor> | MutableRefObject<LexicalEditor | null>;
|
|
24
|
+
onReady?: () => void;
|
|
25
|
+
enableHeadingsIdPlugin?: boolean;
|
|
26
|
+
markdown?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export default function BlockletEditor({ editorState, nodes, editable, markdown, ...props }: BlockletEditorProps): JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import '@iconify/iconify';
|
|
10
|
+
import './index.css';
|
|
11
|
+
import './style/editable.css';
|
|
12
|
+
import { cx } from '@emotion/css';
|
|
13
|
+
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
14
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
15
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
16
|
+
import { useTheme } from '@mui/material';
|
|
17
|
+
import { SharedAutocompleteContext } from './context/SharedAutocompleteContext';
|
|
18
|
+
import { SharedHistoryContext } from './context/SharedHistoryContext';
|
|
19
|
+
import Editor from './editor';
|
|
20
|
+
import { EditorRoot } from './editor-root';
|
|
21
|
+
import PlaygroundNodes from './nodes/PlaygroundNodes';
|
|
22
|
+
import { TableContext } from './plugins/TablePlugin';
|
|
23
|
+
import { useCustomTheme } from './themes/customTheme';
|
|
24
|
+
import { getInitialEditorState } from '../lexical-utils';
|
|
25
|
+
export default function BlockletEditor({ editorState, nodes = PlaygroundNodes, editable = true, markdown, ...props }) {
|
|
26
|
+
const theme = useCustomTheme();
|
|
27
|
+
const initialConfig = {
|
|
28
|
+
namespace: 'Playground',
|
|
29
|
+
editorState: getInitialEditorState(editorState ?? '', markdown),
|
|
30
|
+
nodes,
|
|
31
|
+
editable,
|
|
32
|
+
onError: (error) => {
|
|
33
|
+
throw error;
|
|
34
|
+
},
|
|
35
|
+
theme,
|
|
36
|
+
};
|
|
37
|
+
return (_jsx(SharedHistoryContext, { children: _jsx(SharedAutocompleteContext, { children: _jsx(TableContext, { children: _jsx(LexicalComposer, { initialConfig: initialConfig, children: _jsx(EditorShell, { ...props, editable: editable }) }) }) }) }));
|
|
38
|
+
}
|
|
39
|
+
function EditorShell({ placeholder, children, prepend, editable, onChange, autoFocus, showToolbar = true, editorRef, onReady, enableHeadingsIdPlugin, ...props }) {
|
|
40
|
+
const muiTheme = useTheme();
|
|
41
|
+
const [editor] = useLexicalComposerContext();
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
editor.setEditable(editable ?? true);
|
|
44
|
+
}, [editable]);
|
|
45
|
+
const shellRef = useRef(null);
|
|
46
|
+
const onShellClick = useCallback((e) => {
|
|
47
|
+
if (e.target === shellRef.current) {
|
|
48
|
+
editor.focus();
|
|
49
|
+
}
|
|
50
|
+
}, []);
|
|
51
|
+
return (_jsx(EditorRoot, { ...props, className: cx(props.className, 'be-shell'), ref: shellRef, "data-mode": muiTheme.palette.mode, onClick: onShellClick, children: _jsx(Editor, { onChange: onChange, placeholder: placeholder, autoFocus: autoFocus, showToolbar: showToolbar, editorRef: editorRef, onReady: onReady, enableHeadingsIdPlugin: enableHeadingsIdPlugin, prepend: prepend, children: children }) }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { EditorConfig, LexicalNode, NodeKey, SerializedTextNode, Spread } from 'lexical';
|
|
9
|
+
import { TextNode } from 'lexical';
|
|
10
|
+
export type SerializedEmojiNode = Spread<{
|
|
11
|
+
className: string;
|
|
12
|
+
}, SerializedTextNode>;
|
|
13
|
+
export declare class EmojiNode extends TextNode {
|
|
14
|
+
__className: string;
|
|
15
|
+
static getType(): string;
|
|
16
|
+
static clone(node: EmojiNode): EmojiNode;
|
|
17
|
+
constructor(className: string, text: string, key?: NodeKey);
|
|
18
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
19
|
+
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
|
|
20
|
+
static importJSON(serializedNode: SerializedEmojiNode): EmojiNode;
|
|
21
|
+
exportJSON(): SerializedEmojiNode;
|
|
22
|
+
getClassName(): string;
|
|
23
|
+
}
|
|
24
|
+
export declare function $isEmojiNode(node: LexicalNode | null | undefined): node is EmojiNode;
|
|
25
|
+
export declare function $createEmojiNode(className: string, emojiText: string): EmojiNode;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { $applyNodeReplacement, TextNode } from 'lexical';
|
|
9
|
+
export class EmojiNode extends TextNode {
|
|
10
|
+
__className;
|
|
11
|
+
static getType() {
|
|
12
|
+
return 'emoji';
|
|
13
|
+
}
|
|
14
|
+
static clone(node) {
|
|
15
|
+
return new EmojiNode(node.__className, node.__text, node.__key);
|
|
16
|
+
}
|
|
17
|
+
constructor(className, text, key) {
|
|
18
|
+
super(text, key);
|
|
19
|
+
this.__className = className;
|
|
20
|
+
}
|
|
21
|
+
createDOM(config) {
|
|
22
|
+
const dom = document.createElement('span');
|
|
23
|
+
const inner = super.createDOM(config);
|
|
24
|
+
dom.className = this.__className;
|
|
25
|
+
inner.className = 'emoji-inner';
|
|
26
|
+
dom.appendChild(inner);
|
|
27
|
+
return dom;
|
|
28
|
+
}
|
|
29
|
+
updateDOM(prevNode, dom, config) {
|
|
30
|
+
const inner = dom.firstChild;
|
|
31
|
+
if (inner === null) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
super.updateDOM(prevNode, inner, config);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
static importJSON(serializedNode) {
|
|
38
|
+
return $createEmojiNode(serializedNode.className, serializedNode.text).updateFromJSON(serializedNode);
|
|
39
|
+
}
|
|
40
|
+
exportJSON() {
|
|
41
|
+
return {
|
|
42
|
+
...super.exportJSON(),
|
|
43
|
+
className: this.getClassName(),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
getClassName() {
|
|
47
|
+
const self = this.getLatest();
|
|
48
|
+
return self.__className;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function $isEmojiNode(node) {
|
|
52
|
+
return node instanceof EmojiNode;
|
|
53
|
+
}
|
|
54
|
+
export function $createEmojiNode(className, emojiText) {
|
|
55
|
+
const node = new EmojiNode(className, emojiText).setMode('token');
|
|
56
|
+
return $applyNodeReplacement(node);
|
|
57
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
9
|
+
import { DecoratorNode } from 'lexical';
|
|
10
|
+
import { type JSX } from 'react';
|
|
11
|
+
export type SerializedEquationNode = Spread<{
|
|
12
|
+
type: 'equation';
|
|
13
|
+
equation: string;
|
|
14
|
+
inline: boolean;
|
|
15
|
+
}, SerializedLexicalNode>;
|
|
16
|
+
export declare class EquationNode extends DecoratorNode<JSX.Element> {
|
|
17
|
+
__equation: string;
|
|
18
|
+
__inline: boolean;
|
|
19
|
+
static getType(): string;
|
|
20
|
+
static clone(node: EquationNode): EquationNode;
|
|
21
|
+
constructor(equation: string, inline?: boolean, key?: NodeKey);
|
|
22
|
+
static importJSON(serializedNode: SerializedEquationNode): EquationNode;
|
|
23
|
+
exportJSON(): SerializedEquationNode;
|
|
24
|
+
createDOM(_config: EditorConfig): HTMLElement;
|
|
25
|
+
updateDOM(prevNode: EquationNode): boolean;
|
|
26
|
+
getEquation(): string;
|
|
27
|
+
setEquation(equation: string): void;
|
|
28
|
+
decorate(): JSX.Element;
|
|
29
|
+
}
|
|
30
|
+
export declare function $createEquationNode(equation?: string, inline?: boolean): EquationNode;
|
|
31
|
+
export declare function $isEquationNode(node: LexicalNode | null | undefined): node is EquationNode;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { DecoratorNode } from 'lexical';
|
|
9
|
+
export class EquationNode extends DecoratorNode {
|
|
10
|
+
__equation;
|
|
11
|
+
__inline;
|
|
12
|
+
static getType() {
|
|
13
|
+
return 'equation';
|
|
14
|
+
}
|
|
15
|
+
static clone(node) {
|
|
16
|
+
return new EquationNode(node.__equation, node.__inline, node.__key);
|
|
17
|
+
}
|
|
18
|
+
constructor(equation, inline, key) {
|
|
19
|
+
super(key);
|
|
20
|
+
this.__equation = equation;
|
|
21
|
+
this.__inline = inline ?? false;
|
|
22
|
+
}
|
|
23
|
+
static importJSON(serializedNode) {
|
|
24
|
+
const node = $createEquationNode(serializedNode.equation, serializedNode.inline);
|
|
25
|
+
return node;
|
|
26
|
+
}
|
|
27
|
+
exportJSON() {
|
|
28
|
+
return {
|
|
29
|
+
equation: this.getEquation(),
|
|
30
|
+
inline: this.__inline,
|
|
31
|
+
type: 'equation',
|
|
32
|
+
version: 1,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
createDOM(_config) {
|
|
36
|
+
return document.createElement(this.__inline ? 'span' : 'div');
|
|
37
|
+
}
|
|
38
|
+
updateDOM(prevNode) {
|
|
39
|
+
// If the inline property changes, replace the element
|
|
40
|
+
return this.__inline !== prevNode.__inline;
|
|
41
|
+
}
|
|
42
|
+
getEquation() {
|
|
43
|
+
return this.__equation;
|
|
44
|
+
}
|
|
45
|
+
setEquation(equation) {
|
|
46
|
+
const writable = this.getWritable();
|
|
47
|
+
writable.__equation = equation;
|
|
48
|
+
}
|
|
49
|
+
decorate() {
|
|
50
|
+
console.warn('dummy equation node');
|
|
51
|
+
return null;
|
|
52
|
+
// return (
|
|
53
|
+
// <Suspense fallback={null}>
|
|
54
|
+
// <EquationComponent equation={this.__equation} inline={this.__inline} nodeKey={this.__key} />
|
|
55
|
+
// </Suspense>
|
|
56
|
+
// );
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function $createEquationNode(equation = '', inline = false) {
|
|
60
|
+
const equationNode = new EquationNode(equation, inline);
|
|
61
|
+
return equationNode;
|
|
62
|
+
}
|
|
63
|
+
export function $isEquationNode(node) {
|
|
64
|
+
return node instanceof EquationNode;
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { NodeKey } from 'lexical';
|
|
9
|
+
import { type JSX } from 'react';
|
|
10
|
+
export default function ExcalidrawComponent({ nodeKey, data }: {
|
|
11
|
+
data: string;
|
|
12
|
+
nodeKey: NodeKey;
|
|
13
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
4
|
+
import { mergeRegister } from '@lexical/utils';
|
|
5
|
+
import { $getNodeByKey, $getSelection, $isNodeSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, } from 'lexical';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import ImageResizer from '../../ui/ImageResizer';
|
|
8
|
+
import { $isExcalidrawNode } from '.';
|
|
9
|
+
import ExcalidrawImage from './ExcalidrawImage';
|
|
10
|
+
import ExcalidrawModal from './ExcalidrawModal';
|
|
11
|
+
import { covertImageWithMediaKitPath } from './utils';
|
|
12
|
+
export default function ExcalidrawComponent({ nodeKey, data }) {
|
|
13
|
+
const [editor] = useLexicalComposerContext();
|
|
14
|
+
const [isModalOpen, setModalOpen] = useState(data === '[]' && editor.isEditable());
|
|
15
|
+
const imageContainerRef = useRef(null);
|
|
16
|
+
const buttonRef = useRef(null);
|
|
17
|
+
const captionButtonRef = useRef(null);
|
|
18
|
+
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
19
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
20
|
+
const initialEditorEditable = useRef(editor.isEditable());
|
|
21
|
+
// 兼容 excalidraw 旧版本数据 - 缺少 "elements" key, 并且是一个 array, 新版本数据是 object
|
|
22
|
+
const parsed = useMemo(() => {
|
|
23
|
+
try {
|
|
24
|
+
const tempData = JSON.parse(data);
|
|
25
|
+
covertImageWithMediaKitPath(tempData.elements, tempData.files);
|
|
26
|
+
return tempData;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.error(e);
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
}, [data]);
|
|
33
|
+
const { files = {}, appState = {}, width: containerWidth, height: containerHeight } = parsed;
|
|
34
|
+
const elements = Array.isArray(parsed) ? parsed : parsed.elements || [];
|
|
35
|
+
const onDelete = useCallback((event) => {
|
|
36
|
+
if (isSelected && $isNodeSelection($getSelection())) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
editor.update(() => {
|
|
39
|
+
const node = $getNodeByKey(nodeKey);
|
|
40
|
+
if ($isExcalidrawNode(node)) {
|
|
41
|
+
node.remove();
|
|
42
|
+
}
|
|
43
|
+
setSelected(false);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}, [editor, isSelected, nodeKey, setSelected]);
|
|
48
|
+
// Set editor to readOnly if excalidraw is open to prevent unwanted changes
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (isModalOpen) {
|
|
51
|
+
editor.setEditable(false);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
editor.setEditable(initialEditorEditable.current);
|
|
55
|
+
}
|
|
56
|
+
}, [isModalOpen, editor]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
return mergeRegister(editor.registerCommand(CLICK_COMMAND, (event) => {
|
|
59
|
+
const buttonElem = buttonRef.current;
|
|
60
|
+
const eventTarget = event.target;
|
|
61
|
+
if (isResizing) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (buttonElem !== null && buttonElem.contains(eventTarget)) {
|
|
65
|
+
if (!event.shiftKey) {
|
|
66
|
+
clearSelection();
|
|
67
|
+
}
|
|
68
|
+
setSelected(!isSelected);
|
|
69
|
+
if (event.detail > 1) {
|
|
70
|
+
setModalOpen(true);
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW));
|
|
76
|
+
}, [clearSelection, editor, isSelected, isResizing, onDelete, setSelected]);
|
|
77
|
+
const deleteNode = useCallback(() => {
|
|
78
|
+
setModalOpen(false);
|
|
79
|
+
return editor.update(() => {
|
|
80
|
+
const node = $getNodeByKey(nodeKey);
|
|
81
|
+
if ($isExcalidrawNode(node)) {
|
|
82
|
+
node.remove();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}, [editor, nodeKey]);
|
|
86
|
+
const setData = (els, aps, fls) => {
|
|
87
|
+
if (!editor.isEditable()) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
return editor.update(() => {
|
|
91
|
+
const node = $getNodeByKey(nodeKey);
|
|
92
|
+
if ($isExcalidrawNode(node)) {
|
|
93
|
+
if (els.length > 0 || Object.keys(fls).length > 0) {
|
|
94
|
+
// covert image with mediaKit path
|
|
95
|
+
covertImageWithMediaKitPath(els, fls);
|
|
96
|
+
node.setData(JSON.stringify({
|
|
97
|
+
appState: aps,
|
|
98
|
+
elements: els,
|
|
99
|
+
files: fls,
|
|
100
|
+
width: containerWidth,
|
|
101
|
+
height: containerHeight,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
node.remove();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const onResizeStart = () => {
|
|
111
|
+
setIsResizing(true);
|
|
112
|
+
};
|
|
113
|
+
const onResizeEnd = (width, height) => {
|
|
114
|
+
updateSize(Array.isArray(parsed) ? { elements: parsed } : parsed, width, height);
|
|
115
|
+
// Delay hiding the resize bars for click case
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
setIsResizing(false);
|
|
118
|
+
}, 200);
|
|
119
|
+
};
|
|
120
|
+
const updateSize = (parsedData, width, height) => {
|
|
121
|
+
if (!editor.isEditable()) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
return editor.update(() => {
|
|
125
|
+
const node = $getNodeByKey(nodeKey);
|
|
126
|
+
if ($isExcalidrawNode(node)) {
|
|
127
|
+
node.setData(JSON.stringify({ ...parsedData, width, height }));
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const handleClick = () => {
|
|
132
|
+
// view mode 仅在 readonly 的 editor 中有效
|
|
133
|
+
if (!initialEditorEditable.current) {
|
|
134
|
+
setModalOpen(true);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const handleClose = () => {
|
|
138
|
+
setModalOpen(false);
|
|
139
|
+
};
|
|
140
|
+
const containerStyles = {
|
|
141
|
+
...(containerWidth && { width: containerWidth }),
|
|
142
|
+
...(containerHeight && { height: containerHeight }),
|
|
143
|
+
maxWidth: '100%',
|
|
144
|
+
};
|
|
145
|
+
// 若从未 resize 过, 则使用 editor width 的 90% 作为默认的显示宽度 (#1178)
|
|
146
|
+
if (!containerWidth && editor.getRootElement()) {
|
|
147
|
+
containerStyles.width = '90%';
|
|
148
|
+
}
|
|
149
|
+
const _appState = !initialEditorEditable.current ? { ...appState, viewModeEnabled: true } : appState;
|
|
150
|
+
return (_jsxs(_Fragment, { children: [_jsx(ExcalidrawModal, { initialElements: elements, initialFiles: files, initialAppState: _appState, isShown: isModalOpen, readonly: !initialEditorEditable.current, onDelete: deleteNode, onClose: handleClose, onSave: (els, aps, fls) => {
|
|
151
|
+
editor.setEditable(true);
|
|
152
|
+
setData(els, aps, fls);
|
|
153
|
+
setModalOpen(false);
|
|
154
|
+
}, closeOnClickOutside: false }), elements.length > 0 && (_jsxs("button", { ref: buttonRef, className: `excalidraw-button ${isSelected ? 'selected' : ''}`, children: [_jsx(ExcalidrawImage, { imageContainerRef: imageContainerRef, className: "image", elements: elements, files: files, appState: appState, onClick: handleClick, style: containerStyles }), (isSelected || isResizing) && (_jsx(ImageResizer, { buttonRef: captionButtonRef, showCaption: true, setShowCaption: () => null, imageRef: imageContainerRef, editor: editor, onResizeStart: onResizeStart, onResizeEnd: onResizeEnd, captionsEnabled: true }))] }))] }));
|
|
155
|
+
}
|