@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,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 { ReactNode, type JSX } from 'react';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
export declare function DropDownItem({ children, className, onClick, title, }: {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
className: string;
|
|
13
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
14
|
+
title?: string;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default function DropDown({ disabled, buttonLabel, buttonAriaLabel, buttonClassName, buttonIconClassName, buttonIconData, children, stopCloseOnClickSelf, }: {
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
buttonAriaLabel?: string;
|
|
19
|
+
buttonClassName: string;
|
|
20
|
+
buttonIconClassName?: string;
|
|
21
|
+
buttonIconData?: string;
|
|
22
|
+
buttonLabel?: string;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
stopCloseOnClickSelf?: boolean;
|
|
25
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,146 @@
|
|
|
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 { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import { createPortal } from 'react-dom';
|
|
12
|
+
import styled from '@emotion/styled';
|
|
13
|
+
import { Box } from '@mui/material';
|
|
14
|
+
const DropDownContext = React.createContext(null);
|
|
15
|
+
export function DropDownItem({ children, className, onClick, title, }) {
|
|
16
|
+
const ref = useRef(null);
|
|
17
|
+
const dropDownContext = React.useContext(DropDownContext);
|
|
18
|
+
if (dropDownContext === null) {
|
|
19
|
+
throw new Error('DropDownItem must be used within a DropDown');
|
|
20
|
+
}
|
|
21
|
+
const { registerItem } = dropDownContext;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (ref && ref.current) {
|
|
24
|
+
registerItem(ref);
|
|
25
|
+
}
|
|
26
|
+
}, [ref, registerItem]);
|
|
27
|
+
return (_jsx("button", { className: className, onClick: onClick, ref: ref, title: title, children: children }));
|
|
28
|
+
}
|
|
29
|
+
function DropDownItems({ children, dropDownRef, onClose, }) {
|
|
30
|
+
const [items, setItems] = useState();
|
|
31
|
+
const [highlightedItem, setHighlightedItem] = useState();
|
|
32
|
+
const registerItem = useCallback((itemRef) => {
|
|
33
|
+
setItems((prev) => (prev ? [...prev, itemRef] : [itemRef]));
|
|
34
|
+
}, [setItems]);
|
|
35
|
+
const handleKeyDown = (event) => {
|
|
36
|
+
if (!items)
|
|
37
|
+
return;
|
|
38
|
+
const { key } = event;
|
|
39
|
+
if (['Escape', 'ArrowUp', 'ArrowDown', 'Tab'].includes(key)) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
}
|
|
42
|
+
if (key === 'Escape' || key === 'Tab') {
|
|
43
|
+
onClose();
|
|
44
|
+
}
|
|
45
|
+
else if (key === 'ArrowUp') {
|
|
46
|
+
setHighlightedItem((prev) => {
|
|
47
|
+
if (!prev)
|
|
48
|
+
return items[0];
|
|
49
|
+
const index = items.indexOf(prev) - 1;
|
|
50
|
+
return items[index === -1 ? items.length - 1 : index];
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else if (key === 'ArrowDown') {
|
|
54
|
+
setHighlightedItem((prev) => {
|
|
55
|
+
if (!prev)
|
|
56
|
+
return items[0];
|
|
57
|
+
return items[items.indexOf(prev) + 1];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const contextValue = useMemo(() => ({
|
|
62
|
+
registerItem,
|
|
63
|
+
}), [registerItem]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (items && !highlightedItem) {
|
|
66
|
+
setHighlightedItem(items[0]);
|
|
67
|
+
}
|
|
68
|
+
if (highlightedItem && highlightedItem.current) {
|
|
69
|
+
highlightedItem.current.focus();
|
|
70
|
+
}
|
|
71
|
+
}, [items, highlightedItem]);
|
|
72
|
+
return (_jsx(DropDownContext.Provider, { value: contextValue, children: _jsx(Box, { className: "dropdown", ref: dropDownRef, onKeyDown: handleKeyDown, children: children }) }));
|
|
73
|
+
}
|
|
74
|
+
export default function DropDown({ disabled = false, buttonLabel, buttonAriaLabel, buttonClassName, buttonIconClassName, buttonIconData, children, stopCloseOnClickSelf, }) {
|
|
75
|
+
const dropDownRef = useRef(null);
|
|
76
|
+
const buttonRef = useRef(null);
|
|
77
|
+
const [showDropDown, setShowDropDown] = useState(false);
|
|
78
|
+
const handleClose = () => {
|
|
79
|
+
setShowDropDown(false);
|
|
80
|
+
if (buttonRef && buttonRef.current) {
|
|
81
|
+
buttonRef.current.focus();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const button = buttonRef.current;
|
|
86
|
+
const dropDown = dropDownRef.current;
|
|
87
|
+
if (showDropDown && button !== null && dropDown !== null) {
|
|
88
|
+
const { top, left } = button.getBoundingClientRect();
|
|
89
|
+
const dropDownRect = dropDown.getBoundingClientRect();
|
|
90
|
+
const dropDownTop = top + 40;
|
|
91
|
+
dropDown.style.top = `${dropDownTop}px`;
|
|
92
|
+
dropDown.style.left = `${Math.min(left, window.innerWidth - dropDown.offsetWidth - 20)}px`;
|
|
93
|
+
// 避免 dropdown menu 溢出 viewport 底部
|
|
94
|
+
if (dropDownTop + dropDownRect.height > window.innerHeight) {
|
|
95
|
+
dropDown.style.bottom = '8px';
|
|
96
|
+
dropDown.style.overflowY = 'auto';
|
|
97
|
+
// fix: safari dropdown menu 出现水平滚动条
|
|
98
|
+
dropDown.style.overflowX = 'hidden';
|
|
99
|
+
}
|
|
100
|
+
// dropdown menu 显示后监听页面所有的 (除 dropdown menu) scroll 事件, 触发时隐藏 dropdown menu (#299)
|
|
101
|
+
const onScroll = (e) => {
|
|
102
|
+
if (e.target !== dropDown) {
|
|
103
|
+
handleClose();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
document.addEventListener('scroll', onScroll, true);
|
|
107
|
+
return () => document.removeEventListener('scroll', onScroll, true);
|
|
108
|
+
}
|
|
109
|
+
}, [dropDownRef, buttonRef, showDropDown]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const button = buttonRef.current;
|
|
112
|
+
if (button !== null && showDropDown) {
|
|
113
|
+
const handle = (event) => {
|
|
114
|
+
const { target } = event;
|
|
115
|
+
if (stopCloseOnClickSelf) {
|
|
116
|
+
if (dropDownRef.current && dropDownRef.current.contains(target))
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (!button.contains(target)) {
|
|
120
|
+
setShowDropDown(false);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
document.addEventListener('click', handle);
|
|
124
|
+
return () => {
|
|
125
|
+
document.removeEventListener('click', handle);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf]);
|
|
129
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropdownButton, { disabled: disabled, "aria-label": buttonAriaLabel || buttonLabel, className: buttonClassName, onClick: () => setShowDropDown(!showDropDown), ref: buttonRef, children: [buttonIconClassName && _jsx("span", { className: `icon ${buttonIconClassName}`, "data-icon": buttonIconData }), buttonLabel && _jsx("span", { className: "text dropdown-button-text", children: buttonLabel })] }), showDropDown &&
|
|
130
|
+
createPortal(_jsx(DropDownItems, { dropDownRef: dropDownRef, onClose: handleClose, children: children }), document.body)] }));
|
|
131
|
+
}
|
|
132
|
+
const DropdownButton = styled.button `
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
|
|
136
|
+
> .icon {
|
|
137
|
+
font-size: 1.4em;
|
|
138
|
+
width: 1.6em;
|
|
139
|
+
opacity: 0.6;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
> .chevron-down {
|
|
143
|
+
font-size: 1em;
|
|
144
|
+
color: gray;
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { JSX } from 'react';
|
|
9
|
+
import './Input.css';
|
|
10
|
+
type Props = Readonly<{
|
|
11
|
+
'data-test-id'?: string;
|
|
12
|
+
accept?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
onChange: (files: FileList | null) => void;
|
|
15
|
+
}>;
|
|
16
|
+
export default function FileInput({ accept, label, onChange, 'data-test-id': dataTestId }: Props): JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './Input.css';
|
|
3
|
+
export default function FileInput({ accept, label, onChange, 'data-test-id': dataTestId }) {
|
|
4
|
+
return (_jsxs("div", { className: "Input__wrapper", children: [_jsx("label", { className: "Input__label", children: label }), _jsx("input", { type: "file", accept: accept, className: "Input__input", onChange: (e) => onChange(e.target.files), "data-test-id": dataTestId })] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.browser-mockup {
|
|
2
|
+
border-top: 2em solid rgba(230, 230, 230, 0.7);
|
|
3
|
+
box-shadow: 0 0.1em 1em 0 rgba(0, 0, 0, 0.4);
|
|
4
|
+
position: relative;
|
|
5
|
+
border-radius: 3px 3px 0 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.browser-mockup:before {
|
|
9
|
+
display: block;
|
|
10
|
+
position: absolute;
|
|
11
|
+
content: '';
|
|
12
|
+
top: -1.25em;
|
|
13
|
+
left: 1em;
|
|
14
|
+
width: 0.5em;
|
|
15
|
+
height: 0.5em;
|
|
16
|
+
border-radius: 50%;
|
|
17
|
+
background-color: #f44;
|
|
18
|
+
box-shadow: 0 0 0 2px #f44, 1.5em 0 0 2px #9b3, 3em 0 0 2px #fb5;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.browser-mockup.with-tab:after {
|
|
22
|
+
display: block;
|
|
23
|
+
position: absolute;
|
|
24
|
+
content: '';
|
|
25
|
+
top: -2em;
|
|
26
|
+
left: 5.5em;
|
|
27
|
+
width: 20%;
|
|
28
|
+
height: 0em;
|
|
29
|
+
border-bottom: 2em solid white;
|
|
30
|
+
border-left: 0.8em solid transparent;
|
|
31
|
+
border-right: 0.8em solid transparent;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.browser-mockup.with-url:after {
|
|
35
|
+
display: block;
|
|
36
|
+
position: absolute;
|
|
37
|
+
content: '';
|
|
38
|
+
top: -1.6em;
|
|
39
|
+
left: 5.5em;
|
|
40
|
+
width: calc(100% - 6em);
|
|
41
|
+
height: 1.2em;
|
|
42
|
+
border-radius: 2px;
|
|
43
|
+
background-color: white;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.browser-mockup > * {
|
|
47
|
+
display: block;
|
|
48
|
+
}
|
|
49
|
+
.browser-mockup {
|
|
50
|
+
margin: 2em;
|
|
51
|
+
flex: 1;
|
|
52
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import './browser.css';
|
|
3
|
+
export declare const browsers: readonly [{
|
|
4
|
+
readonly id: "chrome";
|
|
5
|
+
readonly name: "Chrome";
|
|
6
|
+
}, {
|
|
7
|
+
readonly id: "chrome-with-url";
|
|
8
|
+
readonly name: "Chrome (With URL)";
|
|
9
|
+
}];
|
|
10
|
+
export declare const isBrowserType: (id: string) => boolean;
|
|
11
|
+
export declare function BrowserMockup({ type, ...rest }: PropsWithChildren<{
|
|
12
|
+
type: string;
|
|
13
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import './browser.css';
|
|
4
|
+
function Chrome({ children, ...rest }) {
|
|
5
|
+
return (_jsx(Box, { className: "browser-mockup", ...rest, children: children }));
|
|
6
|
+
}
|
|
7
|
+
function ChromeWithUrl({ children, ...rest }) {
|
|
8
|
+
return (_jsx(Box, { className: "browser-mockup with-url", ...rest, children: children }));
|
|
9
|
+
}
|
|
10
|
+
export const browsers = [
|
|
11
|
+
{ id: 'chrome', name: 'Chrome' },
|
|
12
|
+
{ id: 'chrome-with-url', name: 'Chrome (With URL)' },
|
|
13
|
+
];
|
|
14
|
+
export const isBrowserType = (id) => browsers.some((frame) => frame.id === id);
|
|
15
|
+
const Components = {
|
|
16
|
+
chrome: Chrome,
|
|
17
|
+
'chrome-with-url': ChromeWithUrl,
|
|
18
|
+
};
|
|
19
|
+
export function BrowserMockup({ type, ...rest }) {
|
|
20
|
+
const Compnent = Components[type];
|
|
21
|
+
return _jsx(Compnent, { ...rest });
|
|
22
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type BoxProps } from '@mui/material';
|
|
2
|
+
export declare const deviceFrames: readonly [{
|
|
3
|
+
readonly id: "iphone-x";
|
|
4
|
+
readonly name: "iPhone X";
|
|
5
|
+
}, {
|
|
6
|
+
readonly id: "iphone-8";
|
|
7
|
+
readonly name: "iPhone 8";
|
|
8
|
+
}, {
|
|
9
|
+
readonly id: "ipad-pro";
|
|
10
|
+
readonly name: "iPad Pro";
|
|
11
|
+
}, {
|
|
12
|
+
readonly id: "imac-pro";
|
|
13
|
+
readonly name: "iMac Pro";
|
|
14
|
+
}, {
|
|
15
|
+
readonly id: "macbook";
|
|
16
|
+
readonly name: "MacBook";
|
|
17
|
+
}, {
|
|
18
|
+
readonly id: "macbook-pro";
|
|
19
|
+
readonly name: "MacBook Pro";
|
|
20
|
+
}, {
|
|
21
|
+
readonly id: "surface-pro";
|
|
22
|
+
readonly name: "Surface Pro";
|
|
23
|
+
}, {
|
|
24
|
+
readonly id: "surface-book";
|
|
25
|
+
readonly name: "Surface Book";
|
|
26
|
+
}, {
|
|
27
|
+
readonly id: "surface-studio";
|
|
28
|
+
readonly name: "Surface Studio";
|
|
29
|
+
}, {
|
|
30
|
+
readonly id: "galaxy-s8";
|
|
31
|
+
readonly name: "Galaxy S8";
|
|
32
|
+
}, {
|
|
33
|
+
readonly id: "google-pixel";
|
|
34
|
+
readonly name: "Google Pixel";
|
|
35
|
+
}, {
|
|
36
|
+
readonly id: "google-pixel-2-xl";
|
|
37
|
+
readonly name: "Google Pixel 2 XL";
|
|
38
|
+
}, {
|
|
39
|
+
readonly id: "apple-watch";
|
|
40
|
+
readonly name: "Apple Watch";
|
|
41
|
+
}];
|
|
42
|
+
export declare const isDeviceFrame: (id: string) => boolean;
|
|
43
|
+
export declare const shadowFrames: readonly [{
|
|
44
|
+
readonly id: "shadow";
|
|
45
|
+
readonly name: "Shadow";
|
|
46
|
+
}, {
|
|
47
|
+
readonly id: "shadow-sm";
|
|
48
|
+
readonly name: "Shadow Small";
|
|
49
|
+
}, {
|
|
50
|
+
readonly id: "shadow-lg";
|
|
51
|
+
readonly name: "Shadow Large";
|
|
52
|
+
}];
|
|
53
|
+
export declare const isShadowFrame: (id: string) => boolean;
|
|
54
|
+
export declare const frames: ({
|
|
55
|
+
readonly id: "chrome";
|
|
56
|
+
readonly name: "Chrome";
|
|
57
|
+
} | {
|
|
58
|
+
readonly id: "chrome-with-url";
|
|
59
|
+
readonly name: "Chrome (With URL)";
|
|
60
|
+
} | {
|
|
61
|
+
readonly id: "iphone-x";
|
|
62
|
+
readonly name: "iPhone X";
|
|
63
|
+
} | {
|
|
64
|
+
readonly id: "iphone-8";
|
|
65
|
+
readonly name: "iPhone 8";
|
|
66
|
+
} | {
|
|
67
|
+
readonly id: "ipad-pro";
|
|
68
|
+
readonly name: "iPad Pro";
|
|
69
|
+
} | {
|
|
70
|
+
readonly id: "imac-pro";
|
|
71
|
+
readonly name: "iMac Pro";
|
|
72
|
+
} | {
|
|
73
|
+
readonly id: "macbook";
|
|
74
|
+
readonly name: "MacBook";
|
|
75
|
+
} | {
|
|
76
|
+
readonly id: "macbook-pro";
|
|
77
|
+
readonly name: "MacBook Pro";
|
|
78
|
+
} | {
|
|
79
|
+
readonly id: "surface-pro";
|
|
80
|
+
readonly name: "Surface Pro";
|
|
81
|
+
} | {
|
|
82
|
+
readonly id: "surface-book";
|
|
83
|
+
readonly name: "Surface Book";
|
|
84
|
+
} | {
|
|
85
|
+
readonly id: "surface-studio";
|
|
86
|
+
readonly name: "Surface Studio";
|
|
87
|
+
} | {
|
|
88
|
+
readonly id: "galaxy-s8";
|
|
89
|
+
readonly name: "Galaxy S8";
|
|
90
|
+
} | {
|
|
91
|
+
readonly id: "google-pixel";
|
|
92
|
+
readonly name: "Google Pixel";
|
|
93
|
+
} | {
|
|
94
|
+
readonly id: "google-pixel-2-xl";
|
|
95
|
+
readonly name: "Google Pixel 2 XL";
|
|
96
|
+
} | {
|
|
97
|
+
readonly id: "apple-watch";
|
|
98
|
+
readonly name: "Apple Watch";
|
|
99
|
+
} | {
|
|
100
|
+
readonly id: "shadow";
|
|
101
|
+
readonly name: "Shadow";
|
|
102
|
+
} | {
|
|
103
|
+
readonly id: "shadow-sm";
|
|
104
|
+
readonly name: "Shadow Small";
|
|
105
|
+
} | {
|
|
106
|
+
readonly id: "shadow-lg";
|
|
107
|
+
readonly name: "Shadow Large";
|
|
108
|
+
})[];
|
|
109
|
+
interface FrameMockupProps {
|
|
110
|
+
type: string;
|
|
111
|
+
}
|
|
112
|
+
export declare function FrameMockup({ ref, type, sx, children, ...rest }: FrameMockupProps & BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
113
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Screenshot from '@arcblock/ux/lib/Screenshot';
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
import { isBrowserType, BrowserMockup, browsers } from './browser';
|
|
5
|
+
export const deviceFrames = [
|
|
6
|
+
{ id: 'iphone-x', name: 'iPhone X' },
|
|
7
|
+
{ id: 'iphone-8', name: 'iPhone 8' },
|
|
8
|
+
{ id: 'ipad-pro', name: 'iPad Pro' },
|
|
9
|
+
{ id: 'imac-pro', name: 'iMac Pro' },
|
|
10
|
+
{ id: 'macbook', name: 'MacBook' },
|
|
11
|
+
{ id: 'macbook-pro', name: 'MacBook Pro' },
|
|
12
|
+
{ id: 'surface-pro', name: 'Surface Pro' },
|
|
13
|
+
{ id: 'surface-book', name: 'Surface Book' },
|
|
14
|
+
{ id: 'surface-studio', name: 'Surface Studio' },
|
|
15
|
+
{ id: 'galaxy-s8', name: 'Galaxy S8' },
|
|
16
|
+
{ id: 'google-pixel', name: 'Google Pixel' },
|
|
17
|
+
{ id: 'google-pixel-2-xl', name: 'Google Pixel 2 XL' },
|
|
18
|
+
{ id: 'apple-watch', name: 'Apple Watch' },
|
|
19
|
+
];
|
|
20
|
+
export const isDeviceFrame = (id) => deviceFrames.some((frame) => frame.id === id);
|
|
21
|
+
export const shadowFrames = [
|
|
22
|
+
{ id: 'shadow', name: 'Shadow' },
|
|
23
|
+
{ id: 'shadow-sm', name: 'Shadow Small' },
|
|
24
|
+
{ id: 'shadow-lg', name: 'Shadow Large' },
|
|
25
|
+
];
|
|
26
|
+
export const isShadowFrame = (id) => shadowFrames.some((frame) => frame.id === id);
|
|
27
|
+
export const frames = [...deviceFrames, ...browsers, ...shadowFrames];
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
export function FrameMockup({ ref = undefined, type, sx, children, ...rest }) {
|
|
30
|
+
const mergedSx = [{}, ...(Array.isArray(sx) ? sx : [sx])];
|
|
31
|
+
const renderInner = () => {
|
|
32
|
+
if (isDeviceFrame(type)) {
|
|
33
|
+
mergedSx.push({
|
|
34
|
+
img: {
|
|
35
|
+
objectFit: 'contain!important',
|
|
36
|
+
bgcolor: '#000!important',
|
|
37
|
+
borderRadius: '0!important',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
return _jsx(Screenshot, { type: type, children: children });
|
|
42
|
+
}
|
|
43
|
+
if (isBrowserType(type)) {
|
|
44
|
+
mergedSx.push({
|
|
45
|
+
img: {
|
|
46
|
+
borderRadius: '0!important',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return _jsx(BrowserMockup, { type: type, children: children });
|
|
50
|
+
}
|
|
51
|
+
if (isShadowFrame(type)) {
|
|
52
|
+
const styles = {
|
|
53
|
+
'shadow-sm': { boxShadow: '0 0.1em 0.5em 0 rgba(0, 0, 0, 0.2);' },
|
|
54
|
+
shadow: { boxShadow: '0 0.1em 1em 0 rgba(0, 0, 0, 0.3);' },
|
|
55
|
+
'shadow-lg': { boxShadow: '0 0.1em 1.5em 0 rgba(0, 0, 0, 0.4);' },
|
|
56
|
+
};
|
|
57
|
+
return _jsx(Box, { sx: { p: 3, img: styles[type] }, children: children });
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return (_jsx(Box, { ref: ref, sx: mergedSx, ...rest, children: renderInner() }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type BoxProps } from '@mui/material';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { ImageSizeMode } from '../../types';
|
|
4
|
+
interface ImageAnnotationProps {
|
|
5
|
+
editing: boolean;
|
|
6
|
+
setEditing: (editing: boolean) => void;
|
|
7
|
+
imageRef: {
|
|
8
|
+
current: null | HTMLImageElement;
|
|
9
|
+
};
|
|
10
|
+
markerState?: string;
|
|
11
|
+
onChange: (markerState: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function ImageAnnotation({ editing, setEditing, imageRef, markerState, onChange }: ImageAnnotationProps): null;
|
|
14
|
+
interface ImageAnnotationViewProps {
|
|
15
|
+
imageRef: {
|
|
16
|
+
current: null | HTMLImageElement;
|
|
17
|
+
};
|
|
18
|
+
markerState?: string;
|
|
19
|
+
sx?: BoxProps['sx'];
|
|
20
|
+
}
|
|
21
|
+
export declare function ImageAnnotationView({ imageRef, markerState, sx, ...rest }: ImageAnnotationViewProps & BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
interface ImageEnhancerProps {
|
|
23
|
+
sizeMode?: ImageSizeMode;
|
|
24
|
+
frame?: string;
|
|
25
|
+
onSizeModeChange: (sizeMode: ImageSizeMode) => void;
|
|
26
|
+
onFrameChange: (frame?: string) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare function ImageEnhancer({ sizeMode, frame, onSizeModeChange, onFrameChange, children, }: PropsWithChildren<ImageEnhancerProps>): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, ToggleButtonGroup, ToggleButton, Select, MenuItem } from '@mui/material';
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import * as markerjs2 from 'markerjs2';
|
|
5
|
+
import * as mjslive from 'markerjs-live';
|
|
6
|
+
import { frames } from './FrameMockup';
|
|
7
|
+
import { useEditorSize } from '../hooks/hooks';
|
|
8
|
+
const parseMarkerState = (markerState) => {
|
|
9
|
+
if (!markerState)
|
|
10
|
+
return null;
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(markerState);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
console.error(e);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export function ImageAnnotation({ editing, setEditing, imageRef, markerState, onChange }) {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (editing && imageRef.current) {
|
|
22
|
+
const markerArea = new markerjs2.MarkerArea(imageRef.current);
|
|
23
|
+
markerArea.addEventListener('render', (event) => {
|
|
24
|
+
if (imageRef.current) {
|
|
25
|
+
onChange(JSON.stringify(event.state));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
markerArea.addEventListener('close', () => setEditing(false));
|
|
29
|
+
markerArea.settings.displayMode = 'popup';
|
|
30
|
+
markerArea.uiStyleSettings.zIndex = '99999999';
|
|
31
|
+
markerArea.show();
|
|
32
|
+
const parsed = parseMarkerState(markerState);
|
|
33
|
+
if (parsed) {
|
|
34
|
+
setTimeout(() => markerArea.restoreState(parsed), 400);
|
|
35
|
+
}
|
|
36
|
+
return () => {
|
|
37
|
+
markerArea.close();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}, [editing]);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
export function ImageAnnotationView({ imageRef, markerState, sx, ...rest }) {
|
|
44
|
+
const viewRef = useRef(null);
|
|
45
|
+
const mergedSx = [
|
|
46
|
+
{
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
left: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
top: 0,
|
|
51
|
+
bottom: 0,
|
|
52
|
+
zIndex: 0,
|
|
53
|
+
pointerEvents: 'none',
|
|
54
|
+
// fix: 点击 markerView 时可以正常触发原图片的点击, 进而进入 resize 模式
|
|
55
|
+
svg: { pointerEvents: 'none!important' },
|
|
56
|
+
},
|
|
57
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
58
|
+
];
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const parsed = parseMarkerState(markerState);
|
|
61
|
+
if (parsed && imageRef.current && viewRef.current) {
|
|
62
|
+
const markerView = new mjslive.MarkerView(imageRef.current);
|
|
63
|
+
// fix error - "Failed to execute 'setRotate' on 'SVGTransform'"
|
|
64
|
+
const timer = setTimeout(() => {
|
|
65
|
+
markerView.targetRoot = viewRef.current;
|
|
66
|
+
markerView.show(parsed);
|
|
67
|
+
if (imageRef.current) {
|
|
68
|
+
const scaleFactor = imageRef.current.width / parsed.width;
|
|
69
|
+
markerView.markers.forEach((marker) => {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
if (marker.setStrokeWidth)
|
|
72
|
+
marker.setStrokeWidth(marker.strokeWidth * scaleFactor);
|
|
73
|
+
if (marker instanceof mjslive.ArrowMarker) {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
marker.arrowBaseWidth *= scaleFactor;
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
marker.arrowBaseHeight *= scaleFactor;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, 400);
|
|
82
|
+
return () => {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
markerView.close();
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}, [markerState, imageRef]);
|
|
88
|
+
return _jsx(Box, { sx: mergedSx, ref: viewRef, ...rest });
|
|
89
|
+
}
|
|
90
|
+
export function ImageEnhancer({ sizeMode, frame, onSizeModeChange, onFrameChange, children, }) {
|
|
91
|
+
const handleFrameChange = (value) => {
|
|
92
|
+
onFrameChange(value === 'none' ? undefined : value);
|
|
93
|
+
};
|
|
94
|
+
const size = useEditorSize();
|
|
95
|
+
return (
|
|
96
|
+
// zIndex 必须为 modal (或以下), 否则如果高于 Select.MuiPaper-root, 会导致点击 Select 无法显示选项, 且导致 image 失焦
|
|
97
|
+
// 上述问题在 discussion/blog 中可复现, doc 中未复现, 其它的解决方法是在 Select#onClick 中调用 e.stopPropagation 或提高 Select.MuiPaper-root 的 zIndex
|
|
98
|
+
_jsx(Box, { sx: {
|
|
99
|
+
position: 'relative',
|
|
100
|
+
zIndex: 'modal',
|
|
101
|
+
whiteSpace: 'nowrap',
|
|
102
|
+
mt: 1,
|
|
103
|
+
}, children: _jsxs(Box, { sx: {
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
flexWrap: 'wrap',
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
gap: 1,
|
|
109
|
+
...(size?.width && { width: size.width - 36 }),
|
|
110
|
+
}, children: [_jsxs(ToggleButtonGroup, { color: "standard", value: sizeMode, size: "small", exclusive: true, onChange: (_, v) => onSizeModeChange(v), sx: { bgcolor: 'background.default' }, children: [_jsx(ToggleButton, { value: "small", children: "Small" }), _jsx(ToggleButton, { value: "best-fit", children: "Best fit" }), _jsx(ToggleButton, { value: "original", children: "Original size" })] }), _jsxs(Select, { value: frame ?? 'none', onChange: (e) => handleFrameChange(e.target.value), sx: { width: { xs: 100, sm: 'auto' } }, MenuProps: { sx: { '.MuiPaper-root': { maxHeight: 400 } }, disablePortal: false }, children: [_jsx(MenuItem, { value: "none", children: "Select frame mockup" }), frames.map((x) => {
|
|
111
|
+
return (_jsx(MenuItem, { value: x.id, children: x.name }, x.id));
|
|
112
|
+
})] }), children] }) }));
|
|
113
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { LexicalEditor } from 'lexical';
|
|
9
|
+
import { type JSX } from 'react';
|
|
10
|
+
export default function ImageResizer({ onResizeStart, onResizeEnd, buttonRef, imageRef, maxWidth, editor, showCaption, setShowCaption, captionsEnabled, }: {
|
|
11
|
+
editor: LexicalEditor;
|
|
12
|
+
buttonRef: {
|
|
13
|
+
current: null | HTMLButtonElement;
|
|
14
|
+
};
|
|
15
|
+
imageRef: {
|
|
16
|
+
current: null | HTMLElement;
|
|
17
|
+
};
|
|
18
|
+
maxWidth?: number;
|
|
19
|
+
onResizeEnd: (width: 'inherit' | number, height: 'inherit' | number) => void;
|
|
20
|
+
onResizeStart: () => void;
|
|
21
|
+
setShowCaption: (show: boolean) => void;
|
|
22
|
+
showCaption: boolean;
|
|
23
|
+
captionsEnabled: boolean;
|
|
24
|
+
}): JSX.Element;
|