@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,154 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
function clamp(value, min, max) {
|
|
4
|
+
return Math.min(Math.max(value, min), max);
|
|
5
|
+
}
|
|
6
|
+
const Direction = {
|
|
7
|
+
east: 1 << 0,
|
|
8
|
+
north: 1 << 3,
|
|
9
|
+
south: 1 << 1,
|
|
10
|
+
west: 1 << 2,
|
|
11
|
+
};
|
|
12
|
+
export default function ImageResizer({ onResizeStart, onResizeEnd, buttonRef, imageRef, maxWidth, editor, showCaption, setShowCaption, captionsEnabled, }) {
|
|
13
|
+
const controlWrapperRef = useRef(null);
|
|
14
|
+
const userSelect = useRef({
|
|
15
|
+
priority: '',
|
|
16
|
+
value: 'default',
|
|
17
|
+
});
|
|
18
|
+
const positioningRef = useRef({
|
|
19
|
+
currentHeight: 0,
|
|
20
|
+
currentWidth: 0,
|
|
21
|
+
direction: 0,
|
|
22
|
+
isResizing: false,
|
|
23
|
+
ratio: 0,
|
|
24
|
+
startHeight: 0,
|
|
25
|
+
startWidth: 0,
|
|
26
|
+
startX: 0,
|
|
27
|
+
startY: 0,
|
|
28
|
+
});
|
|
29
|
+
const editorRootElement = editor.getRootElement();
|
|
30
|
+
// Find max width, accounting for editor padding.
|
|
31
|
+
const maxWidthContainer = maxWidth || (editorRootElement !== null ? editorRootElement.getBoundingClientRect().width - 20 : 100);
|
|
32
|
+
const maxHeightContainer = editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;
|
|
33
|
+
const minWidth = 100;
|
|
34
|
+
const minHeight = 100;
|
|
35
|
+
const setStartCursor = (direction) => {
|
|
36
|
+
const ew = direction === Direction.east || direction === Direction.west;
|
|
37
|
+
const ns = direction === Direction.north || direction === Direction.south;
|
|
38
|
+
const nwse = (direction & Direction.north && direction & Direction.west) ||
|
|
39
|
+
(direction & Direction.south && direction & Direction.east);
|
|
40
|
+
const cursorDir = ew ? 'ew' : ns ? 'ns' : nwse ? 'nwse' : 'nesw';
|
|
41
|
+
if (editorRootElement !== null) {
|
|
42
|
+
editorRootElement.style.setProperty('cursor', `${cursorDir}-resize`, 'important');
|
|
43
|
+
}
|
|
44
|
+
if (document.body !== null) {
|
|
45
|
+
document.body.style.setProperty('cursor', `${cursorDir}-resize`, 'important');
|
|
46
|
+
userSelect.current.value = document.body.style.getPropertyValue('-webkit-user-select');
|
|
47
|
+
userSelect.current.priority = document.body.style.getPropertyPriority('-webkit-user-select');
|
|
48
|
+
document.body.style.setProperty('-webkit-user-select', 'none', 'important');
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const setEndCursor = () => {
|
|
52
|
+
if (editorRootElement !== null) {
|
|
53
|
+
editorRootElement.style.setProperty('cursor', 'default');
|
|
54
|
+
}
|
|
55
|
+
if (document.body !== null) {
|
|
56
|
+
document.body.style.setProperty('cursor', 'default');
|
|
57
|
+
document.body.style.setProperty('-webkit-user-select', userSelect.current.value, userSelect.current.priority);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const handlePointerDown = (event, direction) => {
|
|
61
|
+
const image = imageRef.current;
|
|
62
|
+
const controlWrapper = controlWrapperRef.current;
|
|
63
|
+
if (image !== null && controlWrapper !== null) {
|
|
64
|
+
const { width, height } = image.getBoundingClientRect();
|
|
65
|
+
const positioning = positioningRef.current;
|
|
66
|
+
positioning.startWidth = width;
|
|
67
|
+
positioning.startHeight = height;
|
|
68
|
+
positioning.ratio = width / height;
|
|
69
|
+
positioning.currentWidth = width;
|
|
70
|
+
positioning.currentHeight = height;
|
|
71
|
+
positioning.startX = event.clientX;
|
|
72
|
+
positioning.startY = event.clientY;
|
|
73
|
+
positioning.isResizing = true;
|
|
74
|
+
positioning.direction = direction;
|
|
75
|
+
setStartCursor(direction);
|
|
76
|
+
onResizeStart();
|
|
77
|
+
controlWrapper.classList.add('image-control-wrapper--resizing');
|
|
78
|
+
image.style.height = `${height}px`;
|
|
79
|
+
image.style.width = `${width}px`;
|
|
80
|
+
document.addEventListener('pointermove', handlePointerMove);
|
|
81
|
+
document.addEventListener('pointerup', handlePointerUp);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const handlePointerMove = (event) => {
|
|
85
|
+
const image = imageRef.current;
|
|
86
|
+
const positioning = positioningRef.current;
|
|
87
|
+
const isHorizontal = positioning.direction & (Direction.east | Direction.west);
|
|
88
|
+
const isVertical = positioning.direction & (Direction.south | Direction.north);
|
|
89
|
+
if (image !== null && positioning.isResizing) {
|
|
90
|
+
// Corner cursor
|
|
91
|
+
if (isHorizontal && isVertical) {
|
|
92
|
+
let diff = Math.floor(positioning.startX - event.clientX);
|
|
93
|
+
diff = positioning.direction & Direction.east ? -diff : diff;
|
|
94
|
+
const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
|
|
95
|
+
const height = width / positioning.ratio;
|
|
96
|
+
image.style.width = `${width}px`;
|
|
97
|
+
image.style.height = `${height}px`;
|
|
98
|
+
positioning.currentHeight = height;
|
|
99
|
+
positioning.currentWidth = width;
|
|
100
|
+
}
|
|
101
|
+
else if (isVertical) {
|
|
102
|
+
let diff = Math.floor(positioning.startY - event.clientY);
|
|
103
|
+
diff = positioning.direction & Direction.south ? -diff : diff;
|
|
104
|
+
const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);
|
|
105
|
+
image.style.height = `${height}px`;
|
|
106
|
+
positioning.currentHeight = height;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
let diff = Math.floor(positioning.startX - event.clientX);
|
|
110
|
+
diff = positioning.direction & Direction.east ? -diff : diff;
|
|
111
|
+
const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
|
|
112
|
+
image.style.width = `${width}px`;
|
|
113
|
+
positioning.currentWidth = width;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const handlePointerUp = () => {
|
|
118
|
+
const image = imageRef.current;
|
|
119
|
+
const positioning = positioningRef.current;
|
|
120
|
+
const controlWrapper = controlWrapperRef.current;
|
|
121
|
+
if (image !== null && controlWrapper !== null && positioning.isResizing) {
|
|
122
|
+
const width = positioning.currentWidth;
|
|
123
|
+
const height = positioning.currentHeight;
|
|
124
|
+
positioning.startWidth = 0;
|
|
125
|
+
positioning.startHeight = 0;
|
|
126
|
+
positioning.ratio = 0;
|
|
127
|
+
positioning.startX = 0;
|
|
128
|
+
positioning.startY = 0;
|
|
129
|
+
positioning.currentWidth = 0;
|
|
130
|
+
positioning.currentHeight = 0;
|
|
131
|
+
positioning.isResizing = false;
|
|
132
|
+
controlWrapper.classList.remove('image-control-wrapper--resizing');
|
|
133
|
+
setEndCursor();
|
|
134
|
+
onResizeEnd(width, height);
|
|
135
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
136
|
+
document.removeEventListener('pointerup', handlePointerUp);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return (_jsxs("div", { ref: controlWrapperRef, children: [captionsEnabled && (_jsx("button", { className: "image-caption-button", ref: buttonRef, onClick: () => {
|
|
140
|
+
setShowCaption(!showCaption);
|
|
141
|
+
}, children: showCaption ? 'Remove Caption' : 'Add Caption' })), _jsx("div", { className: "image-resizer image-resizer-ne", onPointerDown: (event) => {
|
|
142
|
+
handlePointerDown(event, Direction.north | Direction.east);
|
|
143
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-e", onPointerDown: (event) => {
|
|
144
|
+
handlePointerDown(event, Direction.east);
|
|
145
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-se", onPointerDown: (event) => {
|
|
146
|
+
handlePointerDown(event, Direction.south | Direction.east);
|
|
147
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-sw", onPointerDown: (event) => {
|
|
148
|
+
handlePointerDown(event, Direction.south | Direction.west);
|
|
149
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-w", onPointerDown: (event) => {
|
|
150
|
+
handlePointerDown(event, Direction.west);
|
|
151
|
+
} }), _jsx("div", { className: "image-resizer image-resizer-nw", onPointerDown: (event) => {
|
|
152
|
+
handlePointerDown(event, Direction.north | Direction.west);
|
|
153
|
+
} })] }));
|
|
154
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
.Input__wrapper {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
align-items: center;
|
|
14
|
+
margin-bottom: 10px;
|
|
15
|
+
}
|
|
16
|
+
.Input__label {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex: 1;
|
|
19
|
+
}
|
|
20
|
+
.Input__input {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex: 2;
|
|
23
|
+
padding-top: 7px;
|
|
24
|
+
padding-bottom: 7px;
|
|
25
|
+
padding-left: 10px;
|
|
26
|
+
padding-right: 10px;
|
|
27
|
+
font-size: 16px;
|
|
28
|
+
border-radius: 5px;
|
|
29
|
+
min-width: 0;
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
.Modal__overlay {
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
position: fixed;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
top: 0px;
|
|
17
|
+
bottom: 0px;
|
|
18
|
+
left: 0px;
|
|
19
|
+
right: 0px;
|
|
20
|
+
background-color: rgba(40, 40, 40, 0.6);
|
|
21
|
+
flex-grow: 0px;
|
|
22
|
+
flex-shrink: 1px;
|
|
23
|
+
z-index: 10001;
|
|
24
|
+
}
|
|
25
|
+
.Modal__modal {
|
|
26
|
+
padding: 20px;
|
|
27
|
+
min-height: 100px;
|
|
28
|
+
min-width: 300px;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-grow: 0px;
|
|
31
|
+
background-color: #fff;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
position: relative;
|
|
34
|
+
box-shadow: 0 0 20px 0 #444;
|
|
35
|
+
border-radius: 10px;
|
|
36
|
+
}
|
|
37
|
+
.Modal__title {
|
|
38
|
+
color: #444;
|
|
39
|
+
margin: 0px;
|
|
40
|
+
padding-bottom: 10px;
|
|
41
|
+
border-bottom: 1px solid #ccc;
|
|
42
|
+
}
|
|
43
|
+
.Modal__closeButton {
|
|
44
|
+
border: 0px;
|
|
45
|
+
position: absolute;
|
|
46
|
+
right: 20px;
|
|
47
|
+
border-radius: 20px;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
align-items: center;
|
|
50
|
+
display: flex;
|
|
51
|
+
width: 30px;
|
|
52
|
+
height: 30px;
|
|
53
|
+
text-align: center;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
background-color: #eee;
|
|
56
|
+
}
|
|
57
|
+
.Modal__closeButton:hover {
|
|
58
|
+
background-color: #ddd;
|
|
59
|
+
}
|
|
60
|
+
.Modal__content {
|
|
61
|
+
padding-top: 20px;
|
|
62
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 './Modal.css';
|
|
9
|
+
import { ReactNode, type JSX } from 'react';
|
|
10
|
+
export default function Modal({ onClose, children, title, closeOnClickOutside, }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
closeOnClickOutside?: boolean;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
title: string;
|
|
15
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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 './Modal.css';
|
|
10
|
+
import { useEffect, useRef } from 'react';
|
|
11
|
+
import { createPortal } from 'react-dom';
|
|
12
|
+
function PortalImpl({ onClose, children, title, closeOnClickOutside, }) {
|
|
13
|
+
const modalRef = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (modalRef.current !== null) {
|
|
16
|
+
modalRef.current.focus();
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
let modalOverlayElement = null;
|
|
21
|
+
const handler = (event) => {
|
|
22
|
+
if (event.keyCode === 27) {
|
|
23
|
+
onClose();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const clickOutsideHandler = (event) => {
|
|
27
|
+
const { target } = event;
|
|
28
|
+
if (modalRef.current !== null && !modalRef.current.contains(target) && closeOnClickOutside) {
|
|
29
|
+
onClose();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (modalRef.current !== null) {
|
|
33
|
+
modalOverlayElement = modalRef.current?.parentElement;
|
|
34
|
+
if (modalOverlayElement !== null) {
|
|
35
|
+
modalOverlayElement?.addEventListener('click', clickOutsideHandler);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
window.addEventListener('keydown', handler);
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener('keydown', handler);
|
|
41
|
+
if (modalOverlayElement !== null) {
|
|
42
|
+
modalOverlayElement?.removeEventListener('click', clickOutsideHandler);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}, [closeOnClickOutside, onClose]);
|
|
46
|
+
return (_jsx("div", { className: "Modal__overlay", role: "dialog", children: _jsxs("div", { className: "Modal__modal", tabIndex: -1, ref: modalRef, children: [_jsx("h2", { className: "Modal__title", children: title }), _jsx("button", { className: "Modal__closeButton", "aria-label": "Close modal", type: "button", onClick: onClose, children: "X" }), _jsx("div", { className: "Modal__content", children: children })] }) }));
|
|
47
|
+
}
|
|
48
|
+
export default function Modal({ onClose, children, title, closeOnClickOutside = false, }) {
|
|
49
|
+
return createPortal(_jsx(PortalImpl, { onClose: onClose, title: title, closeOnClickOutside: closeOnClickOutside, children: children }), document.body);
|
|
50
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface PlaceholderProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
3
|
+
}
|
|
4
|
+
export default function Placeholder({ ref, ...props }: PlaceholderProps & {
|
|
5
|
+
ref?: React.RefObject<HTMLDivElement | null>;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
export default function Placeholder({ ref = undefined, ...props }) {
|
|
4
|
+
return _jsx(PlaceholderRoot, { ...props, ref: ref });
|
|
5
|
+
}
|
|
6
|
+
const PlaceholderRoot = styled.div `
|
|
7
|
+
font-size: 15px;
|
|
8
|
+
color: #999;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
position: absolute;
|
|
11
|
+
text-overflow: ellipsis;
|
|
12
|
+
// edit mode 下首个元素 (段落或标题) margin-top 设置为 0 后, top 需要设置为 0, 以解决 placeholder 与光标位置不对齐的问题
|
|
13
|
+
top: 8px;
|
|
14
|
+
left: 28px;
|
|
15
|
+
right: 28px;
|
|
16
|
+
user-select: none;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
display: inline-block;
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import { HTMLInputTypeAttribute } from 'react';
|
|
11
|
+
type Props = Readonly<{
|
|
12
|
+
'data-test-id'?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
onChange: (val: string) => void;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
value: string;
|
|
17
|
+
type?: HTMLInputTypeAttribute;
|
|
18
|
+
}>;
|
|
19
|
+
export default function TextInput({ label, value, onChange, placeholder, 'data-test-id': dataTestId, type, }: Props): JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './Input.css';
|
|
3
|
+
import { styled, useTheme } from '@mui/material';
|
|
4
|
+
export default function TextInput({ label, value, onChange, placeholder = '', 'data-test-id': dataTestId, type = 'text', }) {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
return (_jsxs("div", { className: "Input__wrapper", children: [_jsx("label", { className: "Input__label", style: { color: theme.palette.grey[500] }, children: label }), _jsx(Input, { type: type, className: "Input__input", placeholder: placeholder, value: value, onChange: (e) => {
|
|
7
|
+
onChange(e.target.value);
|
|
8
|
+
}, "data-test-id": dataTestId })] }));
|
|
9
|
+
}
|
|
10
|
+
const Input = styled('input') `
|
|
11
|
+
background-color: ${(props) => props.theme.palette.background.paper};
|
|
12
|
+
color: ${(props) => props.theme.palette.grey[500]};
|
|
13
|
+
border: 1px solid ${(props) => props.theme.palette.divider};
|
|
14
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export declare function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect;
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
export function getDOMRangeRect(nativeSelection, rootElement) {
|
|
9
|
+
const domRange = nativeSelection.getRangeAt(0);
|
|
10
|
+
let rect;
|
|
11
|
+
if (nativeSelection.anchorNode === rootElement) {
|
|
12
|
+
let inner = rootElement;
|
|
13
|
+
while (inner.firstElementChild != null) {
|
|
14
|
+
inner = inner.firstElementChild;
|
|
15
|
+
}
|
|
16
|
+
rect = inner.getBoundingClientRect();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
rect = domRange.getBoundingClientRect();
|
|
20
|
+
}
|
|
21
|
+
return rect;
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { $isAtNodeEnd } from '@lexical/selection';
|
|
9
|
+
export function getSelectedNode(selection) {
|
|
10
|
+
const { anchor } = selection;
|
|
11
|
+
const { focus } = selection;
|
|
12
|
+
const anchorNode = selection.anchor.getNode();
|
|
13
|
+
const focusNode = selection.focus.getNode();
|
|
14
|
+
if (anchorNode === focusNode) {
|
|
15
|
+
return anchorNode;
|
|
16
|
+
}
|
|
17
|
+
const isBackward = selection.isBackward();
|
|
18
|
+
if (isBackward) {
|
|
19
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
20
|
+
}
|
|
21
|
+
return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export declare function isHTMLElement(x: unknown): x is HTMLElement;
|
|
9
|
+
/**
|
|
10
|
+
* Determines if the specified font is too tall
|
|
11
|
+
*/
|
|
12
|
+
export declare function isFontTooTall(fontFamily: string): boolean;
|
|
13
|
+
export declare const isHeadFontTooTall: boolean;
|
|
14
|
+
export declare const isBodyFontTooTall: boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
export function isHTMLElement(x) {
|
|
9
|
+
return x instanceof HTMLElement;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Determines if the specified font is too tall
|
|
13
|
+
*/
|
|
14
|
+
export function isFontTooTall(fontFamily) {
|
|
15
|
+
const fontSizePx = 16;
|
|
16
|
+
const threshold = 1.1;
|
|
17
|
+
const container = document.createElement('div');
|
|
18
|
+
container.style.fontSize = `${fontSizePx}px`;
|
|
19
|
+
container.style.fontFamily = fontFamily;
|
|
20
|
+
container.style.opacity = '0';
|
|
21
|
+
container.style.whiteSpace = 'nowrap';
|
|
22
|
+
container.style.position = 'absolute';
|
|
23
|
+
container.style.pointerEvents = 'none';
|
|
24
|
+
const span = document.createElement('span');
|
|
25
|
+
span.textContent = 'Éy';
|
|
26
|
+
container.appendChild(span);
|
|
27
|
+
document.body.appendChild(container);
|
|
28
|
+
const renderHeight = span.getBoundingClientRect().height;
|
|
29
|
+
document.body.removeChild(container);
|
|
30
|
+
return renderHeight > fontSizePx * threshold;
|
|
31
|
+
}
|
|
32
|
+
const typography = window?.blocklet?.theme?.common?.typography;
|
|
33
|
+
const headFont = typography?.h1?.fontFamily;
|
|
34
|
+
const bodyFont = typography?.fontFamily;
|
|
35
|
+
export const isHeadFontTooTall = headFont ? isFontTooTall(headFont) : false;
|
|
36
|
+
export const isBodyFontTooTall = bodyFont ? isFontTooTall(bodyFont) : false;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const scaleImage = ({ width, height, maxSize }) => {
|
|
2
|
+
const longAxis = Math.max(width, height);
|
|
3
|
+
const scaleFactor = maxSize / longAxis;
|
|
4
|
+
let newWidth = maxSize;
|
|
5
|
+
let newHeight = maxSize;
|
|
6
|
+
if (width !== longAxis) {
|
|
7
|
+
newWidth = Math.floor(scaleFactor * width);
|
|
8
|
+
}
|
|
9
|
+
if (height !== longAxis) {
|
|
10
|
+
newHeight = Math.floor(scaleFactor * height);
|
|
11
|
+
}
|
|
12
|
+
return { width: newWidth, height: newHeight, scaleFactor };
|
|
13
|
+
};
|
|
14
|
+
export function getDevicePixelRatio() {
|
|
15
|
+
return window?.devicePixelRatio || 1;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export default function joinClasses(...args: Array<string | boolean | null | undefined>): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export default function joinClasses(...args) {
|
|
9
|
+
return args.filter(Boolean).join(' ');
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
export declare class Point {
|
|
9
|
+
private readonly _x;
|
|
10
|
+
private readonly _y;
|
|
11
|
+
constructor(x: number, y: number);
|
|
12
|
+
get x(): number;
|
|
13
|
+
get y(): number;
|
|
14
|
+
equals({ x, y }: Point): boolean;
|
|
15
|
+
calcDeltaXTo({ x }: Point): number;
|
|
16
|
+
calcDeltaYTo({ y }: Point): number;
|
|
17
|
+
calcHorizontalDistanceTo(point: Point): number;
|
|
18
|
+
calcVerticalDistance(point: Point): number;
|
|
19
|
+
calcDistanceTo(point: Point): number;
|
|
20
|
+
}
|
|
21
|
+
export declare function isPoint(x: unknown): x is Point;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
export class Point {
|
|
9
|
+
_x;
|
|
10
|
+
_y;
|
|
11
|
+
constructor(x, y) {
|
|
12
|
+
this._x = x;
|
|
13
|
+
this._y = y;
|
|
14
|
+
}
|
|
15
|
+
get x() {
|
|
16
|
+
return this._x;
|
|
17
|
+
}
|
|
18
|
+
get y() {
|
|
19
|
+
return this._y;
|
|
20
|
+
}
|
|
21
|
+
equals({ x, y }) {
|
|
22
|
+
return this.x === x && this.y === y;
|
|
23
|
+
}
|
|
24
|
+
calcDeltaXTo({ x }) {
|
|
25
|
+
return this.x - x;
|
|
26
|
+
}
|
|
27
|
+
calcDeltaYTo({ y }) {
|
|
28
|
+
return this.y - y;
|
|
29
|
+
}
|
|
30
|
+
calcHorizontalDistanceTo(point) {
|
|
31
|
+
return Math.abs(this.calcDeltaXTo(point));
|
|
32
|
+
}
|
|
33
|
+
calcVerticalDistance(point) {
|
|
34
|
+
return Math.abs(this.calcDeltaYTo(point));
|
|
35
|
+
}
|
|
36
|
+
calcDistanceTo(point) {
|
|
37
|
+
return Math.sqrt(this.calcDeltaXTo(point) ** 2 + this.calcDeltaYTo(point) ** 2);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function isPoint(x) {
|
|
41
|
+
return x instanceof Point;
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Avoid handling upload success multiple times for the same file within a short interval
|
|
2
|
+
// ref: https://github.com/blocklet/media-kit/issues/428
|
|
3
|
+
// Module-level array to store recent uploaded files with timestamps
|
|
4
|
+
const recentUploads = [];
|
|
5
|
+
export function preventDuplicateUploadSuccess(handler) {
|
|
6
|
+
return (...args) => {
|
|
7
|
+
const fileHash = args[0]?.file?.hashFileName;
|
|
8
|
+
if (!fileHash) {
|
|
9
|
+
handler(...args);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
// Check if this file was recently uploaded
|
|
13
|
+
const isDuplicate = recentUploads.some((record) => record.fileHash === fileHash);
|
|
14
|
+
if (isDuplicate) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
// Add new upload record
|
|
18
|
+
const newRecord = { fileHash };
|
|
19
|
+
recentUploads.push(newRecord);
|
|
20
|
+
handler(...args);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function clearRecentUploads() {
|
|
24
|
+
recentUploads.length = 0;
|
|
25
|
+
}
|