@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,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BlockWithAlignableContents } from '@lexical/react/LexicalBlockWithAlignableContents';
|
|
3
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
4
|
+
function FigmaComponent({ className, format, nodeKey, documentID }) {
|
|
5
|
+
return (_jsx(BlockWithAlignableContents, { className: className, format: format, nodeKey: nodeKey, children: _jsx("iframe", { title: "figma", src: `https://www.figma.com/embed?embed_host=lexical&url=\
|
|
6
|
+
https://www.figma.com/file/${documentID}`, allowFullScreen: true, style: { width: '100%', maxWidth: '560px', aspectRatio: 16 / 9 } }) }));
|
|
7
|
+
}
|
|
8
|
+
export class FigmaNode extends DecoratorBlockNode {
|
|
9
|
+
__id;
|
|
10
|
+
static getType() {
|
|
11
|
+
return 'figma';
|
|
12
|
+
}
|
|
13
|
+
static clone(node) {
|
|
14
|
+
return new FigmaNode(node.__id, node.__format, node.__key);
|
|
15
|
+
}
|
|
16
|
+
static importJSON(serializedNode) {
|
|
17
|
+
const node = $createFigmaNode(serializedNode.documentID);
|
|
18
|
+
node.setFormat(serializedNode.format);
|
|
19
|
+
return node;
|
|
20
|
+
}
|
|
21
|
+
exportJSON() {
|
|
22
|
+
return {
|
|
23
|
+
...super.exportJSON(),
|
|
24
|
+
documentID: this.__id,
|
|
25
|
+
type: 'figma',
|
|
26
|
+
version: 1,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
constructor(id, format, key) {
|
|
30
|
+
super(format, key);
|
|
31
|
+
this.__id = id;
|
|
32
|
+
}
|
|
33
|
+
updateDOM() {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
getId() {
|
|
37
|
+
return this.__id;
|
|
38
|
+
}
|
|
39
|
+
getTextContent(_includeInert, _includeDirectionless) {
|
|
40
|
+
return `https://www.figma.com/file/${this.__id}`;
|
|
41
|
+
}
|
|
42
|
+
decorate(_editor, config) {
|
|
43
|
+
const embedBlockTheme = config.theme.embedBlock || {};
|
|
44
|
+
const className = {
|
|
45
|
+
base: embedBlockTheme.base || '',
|
|
46
|
+
focus: embedBlockTheme.focus || '',
|
|
47
|
+
};
|
|
48
|
+
return (_jsx(FigmaComponent, { className: className, format: this.__format, nodeKey: this.getKey(), documentID: this.__id }));
|
|
49
|
+
}
|
|
50
|
+
isInline() {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function $createFigmaNode(documentID) {
|
|
55
|
+
return new FigmaNode(documentID);
|
|
56
|
+
}
|
|
57
|
+
export function $isFigmaNode(node) {
|
|
58
|
+
return node instanceof FigmaNode;
|
|
59
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { LexicalEditor, NodeKey } from 'lexical';
|
|
9
|
+
import { type JSX } from 'react';
|
|
10
|
+
import './ImageNode.css';
|
|
11
|
+
import type { ImageSizeMode } from '../../types';
|
|
12
|
+
export default function ImageComponentWrapper({ file, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled, markerState, frame, sizeMode, }: {
|
|
13
|
+
file?: File;
|
|
14
|
+
altText: string;
|
|
15
|
+
caption: LexicalEditor;
|
|
16
|
+
height: 'inherit' | number;
|
|
17
|
+
maxWidth: number;
|
|
18
|
+
nodeKey: NodeKey;
|
|
19
|
+
resizable: boolean;
|
|
20
|
+
showCaption: boolean;
|
|
21
|
+
src?: string;
|
|
22
|
+
width: 'inherit' | number;
|
|
23
|
+
captionsEnabled: boolean;
|
|
24
|
+
markerState?: string;
|
|
25
|
+
frame?: string;
|
|
26
|
+
sizeMode?: ImageSizeMode;
|
|
27
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 styled from '@emotion/styled';
|
|
10
|
+
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
11
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
12
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
13
|
+
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
14
|
+
import { LexicalNestedComposer } from '@lexical/react/LexicalNestedComposer';
|
|
15
|
+
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
16
|
+
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
17
|
+
import { mergeRegister } from '@lexical/utils';
|
|
18
|
+
import { Alert, Box, Button, Dialog, LinearProgress, Skeleton } from '@mui/material';
|
|
19
|
+
import { $getNodeByKey, $getSelection, $isNodeSelection, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, SELECTION_CHANGE_COMMAND, } from 'lexical';
|
|
20
|
+
import { Suspense, useCallback, useEffect, useRef, useState, lazy, useMemo } from 'react';
|
|
21
|
+
import { createPortal } from 'react-dom';
|
|
22
|
+
import { withQuery, getQuery } from 'ufo';
|
|
23
|
+
import { useEditorConfig } from '../../config';
|
|
24
|
+
import { useSharedHistoryContext } from '../context/SharedHistoryContext';
|
|
25
|
+
import ContentEditable from '../ui/ContentEditable';
|
|
26
|
+
import ImageResizer from '../ui/ImageResizer';
|
|
27
|
+
import Placeholder from '../ui/Placeholder';
|
|
28
|
+
import { $isImageNode } from './ImageNode';
|
|
29
|
+
import './ImageNode.css';
|
|
30
|
+
import { useImageDisplayWidth } from '../hooks/hooks';
|
|
31
|
+
import { useMediumZoom } from '../hooks/medium-zoom';
|
|
32
|
+
import { FrameMockup, isDeviceFrame } from '../ui/FrameMockup';
|
|
33
|
+
import { useSafeArea } from '../../ext/SafeAreaPlugin';
|
|
34
|
+
import { UPDATE_BUSY_COMMAND } from '../../ext/BusyPlugin';
|
|
35
|
+
import { getDevicePixelRatio } from '../utils/images';
|
|
36
|
+
import { HistoryPlugin } from '../../vendor/history/LexicalHistoryPlugin';
|
|
37
|
+
const ImageAnnotation = lazy(() => import('../ui/ImageEnhancer').then((module) => ({ default: module.ImageAnnotation })));
|
|
38
|
+
const ImageAnnotationView = lazy(() => import('../ui/ImageEnhancer').then((module) => ({ default: module.ImageAnnotationView })));
|
|
39
|
+
const ImageEnhancer = lazy(() => import('../ui/ImageEnhancer').then((module) => ({ default: module.ImageEnhancer })));
|
|
40
|
+
const imageCache = new Set();
|
|
41
|
+
// Min size that require user confirm to upload image
|
|
42
|
+
const REQUIRE_CONFIRM_UPLOAD_SIZE = 10 << 20;
|
|
43
|
+
function useSuspenseImage(src) {
|
|
44
|
+
if (!imageCache.has(src)) {
|
|
45
|
+
throw new Promise((resolve) => {
|
|
46
|
+
const img = new Image();
|
|
47
|
+
img.src = src;
|
|
48
|
+
img.onload = () => {
|
|
49
|
+
imageCache.add(src);
|
|
50
|
+
resolve(null);
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function LazyImage({ altText, className, imageRef, src, width, height, }) {
|
|
56
|
+
useSuspenseImage(src);
|
|
57
|
+
const imgProps = {
|
|
58
|
+
style: {
|
|
59
|
+
height,
|
|
60
|
+
width,
|
|
61
|
+
// 图片为 svg 时设置最小宽度以避免图片显示尺寸为 0 (https://github.com/blocklet/image-bin/issues/142)
|
|
62
|
+
...(src?.endsWith('.svg') && { minWidth: 200 }),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
return (_jsx("img", { className: className || undefined, src: src, alt: altText, ref: imageRef, draggable: "false", crossOrigin: "anonymous", ...imgProps }));
|
|
66
|
+
}
|
|
67
|
+
function ImageComponent({ file, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled, markerState, frame, sizeMode, }) {
|
|
68
|
+
const imageFrameRef = useRef(null);
|
|
69
|
+
const imageRef = useRef(null);
|
|
70
|
+
const buttonRef = useRef(null);
|
|
71
|
+
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
72
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
73
|
+
const [editor] = useLexicalComposerContext();
|
|
74
|
+
const [selection, setSelection] = useState(null);
|
|
75
|
+
const activeEditorRef = useRef(null);
|
|
76
|
+
const [markerEditing, setMarkerEditing] = useState(false);
|
|
77
|
+
const isDeviceFrameUsed = frame && isDeviceFrame(frame);
|
|
78
|
+
const [zoomImageVisible, setZoomImageVisible] = useState(false);
|
|
79
|
+
const onDelete = useCallback((payload) => {
|
|
80
|
+
if (isSelected && $isNodeSelection($getSelection())) {
|
|
81
|
+
const event = payload;
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
const node = $getNodeByKey(nodeKey);
|
|
84
|
+
if ($isImageNode(node)) {
|
|
85
|
+
node.remove();
|
|
86
|
+
}
|
|
87
|
+
setSelected(false);
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}, [isSelected, nodeKey, setSelected]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
caption.setEditable(editor.isEditable());
|
|
93
|
+
return editor.registerEditableListener((editable) => {
|
|
94
|
+
caption.setEditable(editable);
|
|
95
|
+
});
|
|
96
|
+
}, [editor, caption]);
|
|
97
|
+
const onEnter = useCallback((event) => {
|
|
98
|
+
const latestSelection = $getSelection();
|
|
99
|
+
const buttonElem = buttonRef.current;
|
|
100
|
+
if (isSelected && $isNodeSelection(latestSelection) && latestSelection.getNodes().length === 1) {
|
|
101
|
+
if (showCaption) {
|
|
102
|
+
// Move focus into nested editor
|
|
103
|
+
$setSelection(null);
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
caption.focus();
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
if (buttonElem !== null && buttonElem !== document.activeElement) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
buttonElem.focus();
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}, [caption, isSelected, showCaption]);
|
|
116
|
+
const onEscape = useCallback((event) => {
|
|
117
|
+
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
118
|
+
$setSelection(null);
|
|
119
|
+
editor.update(() => {
|
|
120
|
+
setSelected(true);
|
|
121
|
+
const parentRootElement = editor.getRootElement();
|
|
122
|
+
if (parentRootElement !== null) {
|
|
123
|
+
parentRootElement.focus();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}, [caption, editor, setSelected]);
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
return mergeRegister(editor.registerUpdateListener((payload) => {
|
|
132
|
+
if (!payload)
|
|
133
|
+
return;
|
|
134
|
+
const { editorState } = payload;
|
|
135
|
+
setSelection(editorState.read(() => $getSelection()));
|
|
136
|
+
}), editor.registerCommand(SELECTION_CHANGE_COMMAND, (_, activeEditor) => {
|
|
137
|
+
activeEditorRef.current = activeEditor;
|
|
138
|
+
return false;
|
|
139
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(CLICK_COMMAND, (payload) => {
|
|
140
|
+
const event = payload;
|
|
141
|
+
if (isResizing || !editor.isEditable()) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (event.target === imageRef.current) {
|
|
145
|
+
if (event.shiftKey) {
|
|
146
|
+
setSelected(!isSelected);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
clearSelection();
|
|
150
|
+
setSelected(true);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ENTER_COMMAND, onEnter, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ESCAPE_COMMAND, onEscape, COMMAND_PRIORITY_LOW));
|
|
156
|
+
}, [clearSelection, editor, isResizing, isSelected, nodeKey, onDelete, onEnter, onEscape, setSelected]);
|
|
157
|
+
const setShowCaption = (value) => {
|
|
158
|
+
editor.update(() => {
|
|
159
|
+
const node = $getNodeByKey(nodeKey);
|
|
160
|
+
if ($isImageNode(node)) {
|
|
161
|
+
node.setShowCaption(value);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
const setMarkerState = (state) => {
|
|
166
|
+
editor.update(() => {
|
|
167
|
+
const node = $getNodeByKey(nodeKey);
|
|
168
|
+
if ($isImageNode(node)) {
|
|
169
|
+
node.setMarkerState(state);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
174
|
+
const setFrame = (frame) => {
|
|
175
|
+
editor.update(() => {
|
|
176
|
+
const node = $getNodeByKey(nodeKey);
|
|
177
|
+
if ($isImageNode(node)) {
|
|
178
|
+
node.setFrame(frame);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
const setSizeMode = (imageSizeMode) => {
|
|
183
|
+
editor.update(() => {
|
|
184
|
+
const node = $getNodeByKey(nodeKey);
|
|
185
|
+
if ($isImageNode(node)) {
|
|
186
|
+
node.setSizeMode(imageSizeMode);
|
|
187
|
+
node.setWidthAndHeight('inherit', 'inherit');
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
const onResizeEnd = (nextWidth, nextHeight) => {
|
|
192
|
+
// Delay hiding the resize bars for click case
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
setIsResizing(false);
|
|
195
|
+
}, 200);
|
|
196
|
+
editor.update(() => {
|
|
197
|
+
const node = $getNodeByKey(nodeKey);
|
|
198
|
+
if ($isImageNode(node)) {
|
|
199
|
+
node.setWidthAndHeight(nextWidth, nextHeight);
|
|
200
|
+
node.setSizeMode(undefined);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
const onResizeStart = () => {
|
|
205
|
+
setIsResizing(true);
|
|
206
|
+
};
|
|
207
|
+
const { historyState } = useSharedHistoryContext();
|
|
208
|
+
const draggable = isSelected && $isNodeSelection(selection);
|
|
209
|
+
const isFocused = isSelected || isResizing;
|
|
210
|
+
const [objectUrl] = useState(() => file && URL.createObjectURL(file));
|
|
211
|
+
const [error, setError] = useState();
|
|
212
|
+
const [loading, setLoading] = useState(false);
|
|
213
|
+
useSafeArea({ enabled: draggable, size: '80px' });
|
|
214
|
+
const config = useEditorConfig();
|
|
215
|
+
const uploadImage = useCallback(async () => {
|
|
216
|
+
if (!config.uploader?.upload) {
|
|
217
|
+
throw new Error('Missing required config `uploader.upload` for Image');
|
|
218
|
+
}
|
|
219
|
+
if (!file) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
setLoading(true);
|
|
224
|
+
editor.dispatchCommand(UPDATE_BUSY_COMMAND, { busy: true });
|
|
225
|
+
setError(undefined);
|
|
226
|
+
const { url } = await config.uploader.upload(file);
|
|
227
|
+
editor.update(() => {
|
|
228
|
+
const node = $getNodeByKey(nodeKey);
|
|
229
|
+
if ($isImageNode(node)) {
|
|
230
|
+
node.setSrc(url);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
catch (e) {
|
|
235
|
+
setError(e?.message || e?.toString() || 'Upload Failed');
|
|
236
|
+
throw e;
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
setLoading(false);
|
|
240
|
+
editor.dispatchCommand(UPDATE_BUSY_COMMAND, { busy: false });
|
|
241
|
+
}
|
|
242
|
+
}, [file]);
|
|
243
|
+
const confirmText = !!file && file.size > REQUIRE_CONFIRM_UPLOAD_SIZE
|
|
244
|
+
? `Image file size is ${formatFileSize(file.size)}, are your sure upload?`
|
|
245
|
+
: false;
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
if (!src && file && !confirmText) {
|
|
248
|
+
uploadImage();
|
|
249
|
+
}
|
|
250
|
+
}, [src, file, confirmText]);
|
|
251
|
+
const placeholder = objectUrl ? (_jsx(ImageContainer, { draggable: draggable, success: !!src, loading: loading, error: error, confirmText: confirmText, uploadImage: uploadImage, placeholder: objectUrl, placeholderProps: { style: { width, height, maxWidth } }, showBorder: !frame })) : (_jsx(Skeleton, { variant: "rectangular", animation: "wave", sx: { width: 300, height: 200, borderRadius: 1 } }));
|
|
252
|
+
const imageDisplayWidth = useImageDisplayWidth({ src: src || objectUrl, sizeMode, width });
|
|
253
|
+
const { zoomOpened, openedImageRef } = useMediumZoom(imageRef, { enabled: !frame });
|
|
254
|
+
const renderImageAnnotationView = () => {
|
|
255
|
+
if (!markerState)
|
|
256
|
+
return null;
|
|
257
|
+
const element = (_jsx(ImageAnnotationView, { imageRef: zoomOpened ? openedImageRef : imageRef, markerState: markerState, sx: {
|
|
258
|
+
...(zoomOpened && {
|
|
259
|
+
zIndex: 999999,
|
|
260
|
+
// transform: openedImageRef.current?.style.transform,
|
|
261
|
+
'.__markerjslive_': {
|
|
262
|
+
// ...pick(openedImageRef.current?.style, ['width', 'height', 'top', 'left']),
|
|
263
|
+
transform: openedImageRef.current?.style.transform,
|
|
264
|
+
},
|
|
265
|
+
}),
|
|
266
|
+
} }));
|
|
267
|
+
// 若使用了 device frame, 禁用 marker view (目前存在冲突, device frame 对图片拉伸导致 marker view 位置不准确)
|
|
268
|
+
if (isDeviceFrameUsed) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
return zoomOpened ? createPortal(element, document.body) : element;
|
|
272
|
+
};
|
|
273
|
+
const renderImage = (imgSrc) => {
|
|
274
|
+
if (frame) {
|
|
275
|
+
return (_jsxs(_Fragment, { children: [_jsxs(FrameMockup, { type: frame, className: "editor-image-frame-container",
|
|
276
|
+
// fix: 点击外壳无法选中 img 并进入 resize 模式
|
|
277
|
+
onClick: (e) => {
|
|
278
|
+
if (!editor.isEditable()) {
|
|
279
|
+
// 点击图片外壳时, 若不是编辑状态, 则放大图片 (因为需要放大的元素也包括 frame, 这里无法基于 medium-zoom 实现)
|
|
280
|
+
setZoomImageVisible(true);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
e.stopPropagation();
|
|
284
|
+
editor.update(() => {
|
|
285
|
+
const node = $getNodeByKey(nodeKey);
|
|
286
|
+
if ($isImageNode(node)) {
|
|
287
|
+
node.selectEnd();
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
if (imageRef.current) {
|
|
291
|
+
editor.dispatchCommand(CLICK_COMMAND, { ...e, target: imageRef.current });
|
|
292
|
+
}
|
|
293
|
+
}, sx: {
|
|
294
|
+
width: imageDisplayWidth,
|
|
295
|
+
height: 'auto!important',
|
|
296
|
+
overflow: 'hidden',
|
|
297
|
+
}, ref: imageFrameRef, children: [_jsx(LazyImage, { className: isFocused ? `focused ${$isNodeSelection(selection) ? 'draggable' : ''}` : null, src: imgSrc, altText: altText, imageRef: imageRef, width: "100%", height: "auto" }), renderImageAnnotationView()] }, `${frame}-${sizeMode}-${imageDisplayWidth}`), zoomImageVisible && (_jsx(Dialog, { open: zoomImageVisible, onClose: () => setZoomImageVisible(false), PaperProps: {
|
|
298
|
+
sx: {
|
|
299
|
+
maxWidth: '100%',
|
|
300
|
+
maxHeight: '100%',
|
|
301
|
+
overflow: 'hidden',
|
|
302
|
+
bgcolor: 'transparent',
|
|
303
|
+
boxShadow: 'none',
|
|
304
|
+
},
|
|
305
|
+
}, children: _jsxs(FrameMockup, { type: frame, ref: imageFrameRef, children: [_jsx(Box, { component: "img", src: src, alt: altText, ref: imageRef, sx: { maxWidth: '100%', maxHeight: '90vh' } }), renderImageAnnotationView()] }) }))] }));
|
|
306
|
+
}
|
|
307
|
+
return (_jsxs(_Fragment, { children: [_jsx(LazyImage, { className: isFocused && editor.isEditable() ? `focused ${$isNodeSelection(selection) ? 'draggable' : ''}` : null, src: imgSrc, altText: altText, imageRef: imageRef, width: imageDisplayWidth, height: height }), renderImageAnnotationView()] }));
|
|
308
|
+
};
|
|
309
|
+
return (_jsx(Suspense, { fallback: placeholder, children: _jsxs(_Fragment, { children: [src ? (_jsxs(ImageContainer, { draggable: draggable, showBorder: !frame, children: [renderImage(src), editor.isEditable() && (_jsx(ImageAnnotation, { editing: markerEditing, setEditing: setMarkerEditing, imageRef: imageRef, markerState: markerState, onChange: setMarkerState }))] })) : (placeholder), showCaption && (_jsx("div", { className: "image-caption-container", children: _jsxs(LexicalNestedComposer, { initialEditor: caption, children: [_jsx(AutoFocusPlugin, {}), _jsx(LinkPlugin, {}), _jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "ImageNode__contentEditable" }), placeholder: editor.isEditable() ? (_jsx(Placeholder, { className: "ImageNode__placeholder", children: "Enter a caption..." })) : null, ErrorBoundary: LexicalErrorBoundary })] }) })), resizable && $isNodeSelection(selection) && isFocused && (_jsxs(_Fragment, { children: [_jsx(ImageResizer, { showCaption: showCaption, setShowCaption: setShowCaption, editor: editor, buttonRef: buttonRef, imageRef: imageFrameRef.current ? imageFrameRef : imageRef,
|
|
310
|
+
// maxWidth={maxWidth}
|
|
311
|
+
onResizeStart: onResizeStart, onResizeEnd: onResizeEnd, captionsEnabled: false }), _jsxs(ImageEnhancer, { frame: frame, sizeMode: width === 'inherit' ? sizeMode || 'best-fit' : undefined, onSizeModeChange: setSizeMode, onFrameChange: setFrame, children: [_jsx(Button, { disabled: !!isDeviceFrameUsed, onClick: () => setMarkerEditing(true), variant: "outlined", size: "small", sx: {
|
|
312
|
+
minWidth: 36,
|
|
313
|
+
height: 36,
|
|
314
|
+
p: 0,
|
|
315
|
+
borderColor: 'grey.400',
|
|
316
|
+
'.MuiButton-icon': { m: 0 },
|
|
317
|
+
}, startIcon: _jsx("i", { className: "iconify", "data-icon": "tabler:photo-edit" }) }), captionsEnabled && (_jsx(Button, { onClick: () => {
|
|
318
|
+
setShowCaption(!showCaption);
|
|
319
|
+
}, variant: "outlined", size: "small", sx: {
|
|
320
|
+
minWidth: 36,
|
|
321
|
+
height: 36,
|
|
322
|
+
p: 0,
|
|
323
|
+
borderColor: 'grey.400',
|
|
324
|
+
'.MuiButton-icon': { m: 0 },
|
|
325
|
+
}, startIcon: showCaption ? (_jsx("i", { className: "iconify", "data-icon": "tabler:heading-off" })) : (_jsx("i", { className: "iconify", "data-icon": "tabler:text-caption" })), title: showCaption ? 'Remove Caption' : 'Add Caption' }))] })] }))] }) }));
|
|
326
|
+
}
|
|
327
|
+
const ImageContainer = ({ success, loading, error, confirmText, uploadImage, placeholder, placeholderProps, showBorder = true, ...props }) => {
|
|
328
|
+
const [showMask, setShowMask] = useState(false);
|
|
329
|
+
return (_jsxs(Box, { sx: {
|
|
330
|
+
position: 'relative',
|
|
331
|
+
...(showBorder && {
|
|
332
|
+
p: 1,
|
|
333
|
+
border: 1,
|
|
334
|
+
borderColor: 'divider',
|
|
335
|
+
borderRadius: 2,
|
|
336
|
+
}),
|
|
337
|
+
}, children: [props.children ||
|
|
338
|
+
(!!placeholder && _jsx("img", { alt: "", ...placeholderProps, onLoad: () => setShowMask(true), src: placeholder })), !showMask || success ? null : loading ? (_jsx(Mask, { children: _jsx(LinearProgress, {}) })) : error ? (_jsx(Mask, { children: _jsx(Alert, { severity: "error", action: _jsx(Button, { size: "small", onClick: uploadImage, children: "Retry" }), children: error }) })) : confirmText ? (_jsx(Mask, { children: _jsx(Alert, { severity: "warning", action: _jsx(Button, { size: "small", onClick: uploadImage, children: "Upload" }), children: confirmText }) })) : null] }));
|
|
339
|
+
};
|
|
340
|
+
const Mask = styled.div `
|
|
341
|
+
position: absolute;
|
|
342
|
+
left: 0;
|
|
343
|
+
top: 0;
|
|
344
|
+
right: 0;
|
|
345
|
+
bottom: 0;
|
|
346
|
+
background-color: rgba(255, 255, 255, 0.8);
|
|
347
|
+
|
|
348
|
+
> .MuiAlert-root {
|
|
349
|
+
position: absolute;
|
|
350
|
+
left: 0;
|
|
351
|
+
top: 0;
|
|
352
|
+
white-space: nowrap;
|
|
353
|
+
}
|
|
354
|
+
`;
|
|
355
|
+
const KB = 1 << 10;
|
|
356
|
+
const MB = 1 << 20;
|
|
357
|
+
const GB = 1 << 30;
|
|
358
|
+
function formatFileSize(size) {
|
|
359
|
+
const [factor, symbol] = size >= GB ? [GB, 'GB'] : size >= MB ? [MB, 'MB'] : size >= KB ? [KB, 'KB'] : [1, 'B'];
|
|
360
|
+
return `${Number((size / factor).toFixed(2))}${symbol}`;
|
|
361
|
+
}
|
|
362
|
+
function SimpleImageComponent({ src, altText = '', width, height, }) {
|
|
363
|
+
const [loaded, setLoaded] = useState(false);
|
|
364
|
+
const imageRef = useRef(null);
|
|
365
|
+
const containerRef = useRef(null);
|
|
366
|
+
const hasFixedSize = typeof width === 'number' && typeof height === 'number' && width > 0 && height > 0;
|
|
367
|
+
const { maxContentWidth } = useEditorConfig();
|
|
368
|
+
const displaySrc = useMemo(() => {
|
|
369
|
+
if (!maxContentWidth)
|
|
370
|
+
return src;
|
|
371
|
+
try {
|
|
372
|
+
const qs = getQuery(src);
|
|
373
|
+
const dpr = getDevicePixelRatio();
|
|
374
|
+
if (qs?.imageFilter)
|
|
375
|
+
return src;
|
|
376
|
+
// 图片剪裁,限制最大宽度
|
|
377
|
+
return withQuery(src, {
|
|
378
|
+
imageFilter: 'resize',
|
|
379
|
+
f: 'webp',
|
|
380
|
+
w: Math.round(maxContentWidth * dpr),
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
return src;
|
|
385
|
+
}
|
|
386
|
+
}, [src, maxContentWidth]);
|
|
387
|
+
// 当图片出现在 viewport 中时,预加载原图
|
|
388
|
+
useEffect(() => {
|
|
389
|
+
if (!containerRef.current || displaySrc === src)
|
|
390
|
+
return;
|
|
391
|
+
const observer = new IntersectionObserver((entries) => {
|
|
392
|
+
entries.forEach((entry) => {
|
|
393
|
+
if (entry.isIntersecting) {
|
|
394
|
+
const preloadImg = new Image();
|
|
395
|
+
preloadImg.src = src;
|
|
396
|
+
observer.disconnect();
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}, {
|
|
400
|
+
rootMargin: '50px',
|
|
401
|
+
});
|
|
402
|
+
observer.observe(containerRef.current);
|
|
403
|
+
return () => {
|
|
404
|
+
observer.disconnect();
|
|
405
|
+
};
|
|
406
|
+
}, [src, displaySrc]);
|
|
407
|
+
useMediumZoom(imageRef);
|
|
408
|
+
const renderSkeleton = () => {
|
|
409
|
+
if (hasFixedSize) {
|
|
410
|
+
return (_jsx(Box, { sx: { position: 'relative', height: 0, pt: `${100 / (width / height)}%`, maxWidth: width, mx: 'auto' }, children: _jsx(Skeleton, { variant: "rectangular", animation: "wave", sx: { position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', borderRadius: 1 } }) }));
|
|
411
|
+
}
|
|
412
|
+
return _jsx(Skeleton, { variant: "rectangular", animation: "wave", sx: { width: 300, height: 200, borderRadius: 1 } });
|
|
413
|
+
};
|
|
414
|
+
return (_jsxs(_Fragment, { children: [!loaded && renderSkeleton(), _jsx(Box, { ref: containerRef, sx: {
|
|
415
|
+
p: 1,
|
|
416
|
+
border: 1,
|
|
417
|
+
borderColor: 'divider',
|
|
418
|
+
borderRadius: 2,
|
|
419
|
+
display: loaded ? 'block' : 'none',
|
|
420
|
+
...(hasFixedSize && { maxWidth: width, mx: 'auto' }),
|
|
421
|
+
}, children: _jsx(Box, { component: "img", src: displaySrc, alt: altText || '', "data-zoom-src": src, onLoad: () => {
|
|
422
|
+
setLoaded(true);
|
|
423
|
+
}, sx: { width, height }, ref: imageRef }) })] }));
|
|
424
|
+
}
|
|
425
|
+
export default function ImageComponentWrapper({ file, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled, markerState, frame, sizeMode, }) {
|
|
426
|
+
const [editor] = useLexicalComposerContext();
|
|
427
|
+
const config = useEditorConfig();
|
|
428
|
+
if (!editor.isEditable() && config.simpleImageComponent && src) {
|
|
429
|
+
return _jsx(SimpleImageComponent, { src: src, altText: altText, width: width, height: height });
|
|
430
|
+
}
|
|
431
|
+
return (_jsx(ImageComponent, { file: file, src: src, altText: altText, nodeKey: nodeKey, width: width, height: height, maxWidth: maxWidth, resizable: resizable, showCaption: showCaption, caption: caption, captionsEnabled: captionsEnabled, markerState: markerState, frame: frame, sizeMode: sizeMode }));
|
|
432
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
*/
|
|
9
|
+
|
|
10
|
+
.ImageNode__contentEditable {
|
|
11
|
+
min-height: 20px;
|
|
12
|
+
border: 0px;
|
|
13
|
+
resize: none;
|
|
14
|
+
cursor: text;
|
|
15
|
+
caret-color: rgb(5, 5, 5);
|
|
16
|
+
display: block;
|
|
17
|
+
position: relative;
|
|
18
|
+
tab-size: 1;
|
|
19
|
+
outline: 0px;
|
|
20
|
+
padding: 10px;
|
|
21
|
+
user-select: text;
|
|
22
|
+
|
|
23
|
+
width: calc(100% - 20px);
|
|
24
|
+
white-space: pre-wrap;
|
|
25
|
+
word-break: break-word;
|
|
26
|
+
p {
|
|
27
|
+
font-size: 12px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ImageNode__placeholder {
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
color: #888;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
position: absolute;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
top: 0;
|
|
38
|
+
bottom: 0;
|
|
39
|
+
margin: auto;
|
|
40
|
+
left: 0;
|
|
41
|
+
user-select: none;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
display: inline-block;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
padding: 10px;
|
|
46
|
+
line-height: inherit;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.image-control-wrapper--resizing {
|
|
50
|
+
touch-action: none;
|
|
51
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedEditor, SerializedLexicalNode, Spread } from 'lexical';
|
|
9
|
+
import { DecoratorNode } from 'lexical';
|
|
10
|
+
import { type JSX } from 'react';
|
|
11
|
+
import type { ImageSizeMode } from '../../types';
|
|
12
|
+
export interface ImagePayload {
|
|
13
|
+
file?: File;
|
|
14
|
+
altText: string;
|
|
15
|
+
caption?: LexicalEditor;
|
|
16
|
+
height?: number;
|
|
17
|
+
key?: NodeKey;
|
|
18
|
+
maxWidth?: number;
|
|
19
|
+
showCaption?: boolean;
|
|
20
|
+
src?: string;
|
|
21
|
+
width?: number;
|
|
22
|
+
captionsEnabled?: boolean;
|
|
23
|
+
markerState?: string;
|
|
24
|
+
frame?: string;
|
|
25
|
+
sizeMode?: ImageSizeMode;
|
|
26
|
+
}
|
|
27
|
+
export type SerializedImageNode = Spread<{
|
|
28
|
+
altText: string;
|
|
29
|
+
caption: SerializedEditor;
|
|
30
|
+
height?: number;
|
|
31
|
+
maxWidth: number;
|
|
32
|
+
showCaption: boolean;
|
|
33
|
+
src?: string;
|
|
34
|
+
width?: number;
|
|
35
|
+
markerState?: string;
|
|
36
|
+
frame?: string;
|
|
37
|
+
sizeMode?: ImageSizeMode;
|
|
38
|
+
type: 'image';
|
|
39
|
+
version: 1;
|
|
40
|
+
}, SerializedLexicalNode>;
|
|
41
|
+
export declare class ImageNode extends DecoratorNode<JSX.Element> {
|
|
42
|
+
file?: File;
|
|
43
|
+
__src?: string;
|
|
44
|
+
__altText: string;
|
|
45
|
+
__width: 'inherit' | number;
|
|
46
|
+
__height: 'inherit' | number;
|
|
47
|
+
__maxWidth: number;
|
|
48
|
+
__showCaption: boolean;
|
|
49
|
+
__caption: LexicalEditor;
|
|
50
|
+
__markerState?: string;
|
|
51
|
+
__frame?: string;
|
|
52
|
+
__sizeMode?: ImageSizeMode;
|
|
53
|
+
__captionsEnabled: boolean;
|
|
54
|
+
static getType(): string;
|
|
55
|
+
static clone(node: ImageNode): ImageNode;
|
|
56
|
+
static importJSON(serializedNode: SerializedImageNode): ImageNode;
|
|
57
|
+
exportDOM(): DOMExportOutput;
|
|
58
|
+
static importDOM(): DOMConversionMap | null;
|
|
59
|
+
constructor(src: string | undefined, altText: string, maxWidth: number, width?: 'inherit' | number, height?: 'inherit' | number, showCaption?: boolean, caption?: LexicalEditor, captionsEnabled?: boolean, key?: NodeKey, file?: File, markerState?: string, frame?: string, sizeMode?: ImageSizeMode);
|
|
60
|
+
exportJSON(): SerializedImageNode;
|
|
61
|
+
setWidthAndHeight(width: 'inherit' | number, height: 'inherit' | number): void;
|
|
62
|
+
setShowCaption(showCaption: boolean): void;
|
|
63
|
+
setMarkerState(markerState: string): void;
|
|
64
|
+
setFrame(frame?: string): void;
|
|
65
|
+
setSizeMode(sizeMode?: ImageSizeMode): void;
|
|
66
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
67
|
+
updateDOM(): false;
|
|
68
|
+
getSrc(): string | undefined;
|
|
69
|
+
setSrc(src: string): void;
|
|
70
|
+
getAltText(): string;
|
|
71
|
+
decorate(): JSX.Element;
|
|
72
|
+
}
|
|
73
|
+
export declare function $createImageNode({ altText, height, maxWidth, captionsEnabled, src, width, showCaption, caption, key, file, markerState, frame, sizeMode, }: ImagePayload): ImageNode;
|
|
74
|
+
export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
|