@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,84 @@
|
|
|
1
|
+
export type Status = 'initial' | 'activated' | 'waiting' | 'completed' | 'copied';
|
|
2
|
+
export type Mode = 'normal' | 'templates';
|
|
3
|
+
export declare class Template {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
private data;
|
|
8
|
+
options?: string[] | undefined;
|
|
9
|
+
constructor(id: string, name: string, icon: string, data: string, options?: string[] | undefined);
|
|
10
|
+
private formatString;
|
|
11
|
+
hasOptions(): boolean | undefined;
|
|
12
|
+
getPrompt(text: string, ...args: string[]): string;
|
|
13
|
+
}
|
|
14
|
+
export type FetchTemplateTags = () => Promise<string[]>;
|
|
15
|
+
export interface FetchTemplatesRequest {
|
|
16
|
+
offset?: number;
|
|
17
|
+
limit?: number;
|
|
18
|
+
tag?: string;
|
|
19
|
+
}
|
|
20
|
+
export type FetchTemplates = (payload?: FetchTemplatesRequest) => Promise<ParameterizedTemplate[]>;
|
|
21
|
+
export type Completions = (payload: CompletionsPayload) => Promise<string>;
|
|
22
|
+
export type Parameter = StringParameter | NumberParameter | SelectParameter | LanguageParameter;
|
|
23
|
+
export interface ParameterizedTemplate {
|
|
24
|
+
id: string;
|
|
25
|
+
type: 'image' | 'function' | 'prompt' | 'api';
|
|
26
|
+
name: string;
|
|
27
|
+
icon: string;
|
|
28
|
+
description: string;
|
|
29
|
+
parameters?: Parameter[];
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
source: string;
|
|
33
|
+
projectId?: string;
|
|
34
|
+
ref?: string;
|
|
35
|
+
resourceComponentDid?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface BaseParameter {
|
|
38
|
+
key?: string;
|
|
39
|
+
label?: string;
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
helper?: string;
|
|
42
|
+
required?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface StringParameter extends BaseParameter {
|
|
45
|
+
type?: 'string';
|
|
46
|
+
value?: string;
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
multiline?: boolean;
|
|
49
|
+
minLength?: number;
|
|
50
|
+
maxLength?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface NumberParameter extends BaseParameter {
|
|
53
|
+
type: 'number';
|
|
54
|
+
value?: number;
|
|
55
|
+
defaultValue?: number;
|
|
56
|
+
min?: number;
|
|
57
|
+
max?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface SelectParameter extends BaseParameter {
|
|
60
|
+
type: 'select';
|
|
61
|
+
value?: string;
|
|
62
|
+
defaultValue?: string;
|
|
63
|
+
options?: {
|
|
64
|
+
id: string;
|
|
65
|
+
label: string;
|
|
66
|
+
value: string;
|
|
67
|
+
}[];
|
|
68
|
+
}
|
|
69
|
+
export interface LanguageParameter extends BaseParameter {
|
|
70
|
+
type: 'language';
|
|
71
|
+
value?: string;
|
|
72
|
+
defaultValue?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ParameterizedTemplateCompletionsPayload {
|
|
75
|
+
source: string;
|
|
76
|
+
projectId?: string;
|
|
77
|
+
ref?: string;
|
|
78
|
+
resourceComponentDid?: string;
|
|
79
|
+
assistantId: string;
|
|
80
|
+
parameters: {
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export type CompletionsPayload = string | ParameterizedTemplateCompletionsPayload;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class Template {
|
|
2
|
+
id;
|
|
3
|
+
name;
|
|
4
|
+
icon;
|
|
5
|
+
data;
|
|
6
|
+
options;
|
|
7
|
+
constructor(id, name, icon, data, options) {
|
|
8
|
+
this.id = id;
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.icon = icon;
|
|
11
|
+
this.data = data;
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
formatString(str, ...args) {
|
|
15
|
+
return str.replace(/{([0-9]+)}/g, (match, index) => {
|
|
16
|
+
return typeof args[index] === 'undefined' ? match : args[index];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
hasOptions() {
|
|
20
|
+
return this.options && this.options.length > 0;
|
|
21
|
+
}
|
|
22
|
+
getPrompt(text, ...args) {
|
|
23
|
+
return this.data ? this.formatString(this.data, text, ...args) : text;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useAideContext } from './context';
|
|
3
|
+
export function withAiAvailable(WrappedComponent) {
|
|
4
|
+
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
5
|
+
const ComponentWithAiAvailable = (props) => {
|
|
6
|
+
const { available } = useAideContext();
|
|
7
|
+
return available ? _jsx(WrappedComponent, { ...props }) : null;
|
|
8
|
+
};
|
|
9
|
+
ComponentWithAiAvailable.displayName = `withAiAvailable(${displayName})`;
|
|
10
|
+
return ComponentWithAiAvailable;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AlertColor } from '@mui/material';
|
|
2
|
+
import { RangeSelection } from 'lexical';
|
|
3
|
+
import { type JSX } from 'react';
|
|
4
|
+
type AlertComponentProps = {
|
|
5
|
+
text: string;
|
|
6
|
+
severity: AlertColor;
|
|
7
|
+
onChange?: (text: string, selection?: RangeSelection) => void;
|
|
8
|
+
};
|
|
9
|
+
export default function AlertComponent({ text, severity, onChange }: AlertComponentProps): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { Alert, Box } from '@mui/material';
|
|
4
|
+
import { $getSelection, $isRangeSelection } from 'lexical';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
export default function AlertComponent({ text, severity, onChange }) {
|
|
7
|
+
const [editor] = useLexicalComposerContext();
|
|
8
|
+
const [editing, setEditing] = useState(false);
|
|
9
|
+
const [value, setValue] = useState(text);
|
|
10
|
+
const selectionRef = useRef(undefined);
|
|
11
|
+
// 初始化时若 text 为空则自动进入 editing 状态
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!text) {
|
|
14
|
+
setTimeout(edit);
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
const handleChange = () => {
|
|
18
|
+
setEditing(false);
|
|
19
|
+
// 若 value 为空值则保存一个 "空格", 避免 editor 初始化时因 text 为空导致 Alert 自动进入 editing 状态
|
|
20
|
+
onChange?.(value || ' ', selectionRef.current);
|
|
21
|
+
};
|
|
22
|
+
const edit = () => {
|
|
23
|
+
if (editor.isEditable()) {
|
|
24
|
+
const selection = editor.getEditorState().read($getSelection);
|
|
25
|
+
if ($isRangeSelection(selection)) {
|
|
26
|
+
selectionRef.current = selection;
|
|
27
|
+
}
|
|
28
|
+
setEditing(true);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return (_jsxs(Alert, { severity: severity, sx: { '.MuiAlert-message': { width: '100%' } }, children: [!editing && (_jsx(Box, { onClick: edit, sx: { ...(!text && { height: '1em' }) }, children: text })), editing && (_jsx(Box, { component: "input", type: "text", value: value, onClick: (e) => e.stopPropagation(), onChange: (e) => setValue(e.target.value), onBlur: handleChange, onKeyDown: (e) => {
|
|
32
|
+
if (e.key === 'Enter') {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
handleChange();
|
|
36
|
+
}
|
|
37
|
+
}, autoFocus: true, sx: { width: '100%', border: 0, outline: 0, lineHeight: '24px' } }))] }));
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type ElementFormatType, type LexicalEditor, type LexicalNode, type NodeKey, type Spread } from 'lexical';
|
|
2
|
+
import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
3
|
+
import { AlertColor } from '@mui/material/Alert';
|
|
4
|
+
import type { JSX } from 'react';
|
|
5
|
+
export type SerializedAlertNode = Spread<{
|
|
6
|
+
type: 'alert';
|
|
7
|
+
text: string;
|
|
8
|
+
severity: AlertColor;
|
|
9
|
+
}, SerializedDecoratorBlockNode>;
|
|
10
|
+
export declare class AlertNode extends DecoratorBlockNode {
|
|
11
|
+
__text: string;
|
|
12
|
+
__severity: AlertColor;
|
|
13
|
+
static getType(): string;
|
|
14
|
+
static clone(node: AlertNode): AlertNode;
|
|
15
|
+
constructor(text: string, severity: AlertColor, format?: ElementFormatType, key?: NodeKey);
|
|
16
|
+
exportDOM(): DOMExportOutput;
|
|
17
|
+
static importDOM(): DOMConversionMap | null;
|
|
18
|
+
static importJSON(serializedNode: SerializedAlertNode): AlertNode;
|
|
19
|
+
exportJSON(): SerializedAlertNode;
|
|
20
|
+
getText(): string;
|
|
21
|
+
setText(text: string): void;
|
|
22
|
+
getSeverity(): string;
|
|
23
|
+
setSeverity(severity: AlertColor): void;
|
|
24
|
+
decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element;
|
|
25
|
+
isInline(): false;
|
|
26
|
+
}
|
|
27
|
+
export declare function $createAlertNode(text: string, severity: AlertColor): AlertNode;
|
|
28
|
+
export declare function $isAlertNode(node: LexicalNode | null | undefined): node is AlertNode;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $setSelection, } from 'lexical';
|
|
3
|
+
import { BlockWithAlignableContents } from '@lexical/react/LexicalBlockWithAlignableContents';
|
|
4
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
5
|
+
import AlertComponent from './AlertComponent';
|
|
6
|
+
function convertAlertElement(domNode) {
|
|
7
|
+
const alertStr = domNode.getAttribute('data-lexical-alert');
|
|
8
|
+
try {
|
|
9
|
+
const parsed = JSON.parse(alertStr);
|
|
10
|
+
if (parsed) {
|
|
11
|
+
const node = $createAlertNode(parsed.text, parsed.severity);
|
|
12
|
+
return { node };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
console.warn(`Failed to parse: ${alertStr}`, e);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
export class AlertNode extends DecoratorBlockNode {
|
|
21
|
+
__text;
|
|
22
|
+
__severity;
|
|
23
|
+
static getType() {
|
|
24
|
+
return 'alert';
|
|
25
|
+
}
|
|
26
|
+
static clone(node) {
|
|
27
|
+
return new AlertNode(node.__text, node.__severity, node.__format, node.__key);
|
|
28
|
+
}
|
|
29
|
+
constructor(text, severity, format, key) {
|
|
30
|
+
super(format, key);
|
|
31
|
+
this.__text = text;
|
|
32
|
+
this.__severity = severity;
|
|
33
|
+
}
|
|
34
|
+
exportDOM() {
|
|
35
|
+
const element = document.createElement('div');
|
|
36
|
+
element.setAttribute('data-lexical-alert', JSON.stringify({ text: this.__text, severity: this.__severity }));
|
|
37
|
+
return { element };
|
|
38
|
+
}
|
|
39
|
+
static importDOM() {
|
|
40
|
+
return {
|
|
41
|
+
div: (domNode) => {
|
|
42
|
+
if (!domNode.hasAttribute('data-lexical-alert')) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
conversion: convertAlertElement,
|
|
47
|
+
priority: 1,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static importJSON(serializedNode) {
|
|
53
|
+
const node = $createAlertNode(serializedNode.text, serializedNode.severity);
|
|
54
|
+
return node;
|
|
55
|
+
}
|
|
56
|
+
exportJSON() {
|
|
57
|
+
return {
|
|
58
|
+
...super.exportJSON(),
|
|
59
|
+
type: 'alert',
|
|
60
|
+
text: this.__text,
|
|
61
|
+
severity: this.__severity,
|
|
62
|
+
version: 1,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
getText() {
|
|
66
|
+
return this.__text;
|
|
67
|
+
}
|
|
68
|
+
setText(text) {
|
|
69
|
+
const writable = this.getWritable();
|
|
70
|
+
writable.__text = text;
|
|
71
|
+
}
|
|
72
|
+
getSeverity() {
|
|
73
|
+
return this.__severity;
|
|
74
|
+
}
|
|
75
|
+
setSeverity(severity) {
|
|
76
|
+
const writable = this.getWritable();
|
|
77
|
+
writable.__severity = severity;
|
|
78
|
+
}
|
|
79
|
+
decorate(editor, config) {
|
|
80
|
+
const alertTheme = config.theme.alert || {};
|
|
81
|
+
const className = {
|
|
82
|
+
base: alertTheme.base || '',
|
|
83
|
+
focus: alertTheme.focus || '',
|
|
84
|
+
};
|
|
85
|
+
const handleOnChange = (text, selection) => {
|
|
86
|
+
editor.update(() => {
|
|
87
|
+
this.setText(text);
|
|
88
|
+
if (selection) {
|
|
89
|
+
$setSelection(selection.clone());
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
return (_jsx(BlockWithAlignableContents, { className: className, format: this.__format, nodeKey: this.__key, children: _jsx(AlertComponent, { text: this.__text, severity: this.__severity, onChange: handleOnChange }) }));
|
|
94
|
+
}
|
|
95
|
+
isInline() {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export function $createAlertNode(text, severity) {
|
|
100
|
+
const alertNode = new AlertNode(text, severity);
|
|
101
|
+
return alertNode;
|
|
102
|
+
}
|
|
103
|
+
export function $isAlertNode(node) {
|
|
104
|
+
return node instanceof AlertNode;
|
|
105
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LexicalCommand, LexicalEditor } from 'lexical';
|
|
2
|
+
import { type JSX } from 'react';
|
|
3
|
+
import { AlertColor } from '@mui/material/Alert';
|
|
4
|
+
type CommandPayload = {
|
|
5
|
+
text: string;
|
|
6
|
+
severity: AlertColor;
|
|
7
|
+
};
|
|
8
|
+
export declare const INSERT_ALERT_COMMAND: LexicalCommand<CommandPayload>;
|
|
9
|
+
export default function AlertPlugin(): JSX.Element | null;
|
|
10
|
+
export declare const $insertAlert: (editor: LexicalEditor, severity: AlertColor) => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
3
|
+
import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, createCommand, } from 'lexical';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { $createAlertNode, AlertNode } from './AlertNode';
|
|
6
|
+
export const INSERT_ALERT_COMMAND = createCommand('INSERT_ALERT_COMMAND');
|
|
7
|
+
export default function AlertPlugin() {
|
|
8
|
+
const [editor] = useLexicalComposerContext();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!editor.hasNodes([AlertNode])) {
|
|
11
|
+
throw new Error('AlertPlugins: AlertNode not registered on editor');
|
|
12
|
+
}
|
|
13
|
+
return editor.registerCommand(INSERT_ALERT_COMMAND, (payload) => {
|
|
14
|
+
const { text, severity } = payload;
|
|
15
|
+
const alertNode = $createAlertNode(text, severity);
|
|
16
|
+
$insertNodeToNearestRoot(alertNode);
|
|
17
|
+
return true;
|
|
18
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
19
|
+
}, [editor]);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export const $insertAlert = (editor, severity) => {
|
|
23
|
+
editor.update(() => {
|
|
24
|
+
const selection = $getSelection();
|
|
25
|
+
if ($isRangeSelection(selection)) {
|
|
26
|
+
const { anchor } = selection;
|
|
27
|
+
const anchorNode = anchor.getNode();
|
|
28
|
+
const anchorNodeParent = anchorNode.getParent();
|
|
29
|
+
if ($isRootOrShadowRoot(anchorNodeParent)) {
|
|
30
|
+
editor.dispatchCommand(INSERT_ALERT_COMMAND, { text: '', severity });
|
|
31
|
+
}
|
|
32
|
+
else if (anchorNodeParent) {
|
|
33
|
+
editor.dispatchCommand(INSERT_ALERT_COMMAND, {
|
|
34
|
+
text: anchorNodeParent.getTextContent(),
|
|
35
|
+
severity,
|
|
36
|
+
});
|
|
37
|
+
selection.getNodes().forEach((x) => x.remove());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
|
|
2
|
+
import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
3
|
+
import type { JSX } from 'react';
|
|
4
|
+
export interface BilibiliVideoPayload {
|
|
5
|
+
id: string;
|
|
6
|
+
page: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export type SerializedBilibiliNode = Spread<{
|
|
9
|
+
videoID: string;
|
|
10
|
+
page?: string;
|
|
11
|
+
type: 'bilibili';
|
|
12
|
+
version: 1;
|
|
13
|
+
}, SerializedDecoratorBlockNode>;
|
|
14
|
+
export declare class BilibiliNode extends DecoratorBlockNode {
|
|
15
|
+
__id: string;
|
|
16
|
+
__page?: string;
|
|
17
|
+
static getType(): string;
|
|
18
|
+
static clone(node: BilibiliNode): BilibiliNode;
|
|
19
|
+
static importJSON(serializedNode: SerializedBilibiliNode): BilibiliNode;
|
|
20
|
+
exportJSON(): SerializedBilibiliNode;
|
|
21
|
+
constructor(id: string, page: string | undefined, format?: ElementFormatType, key?: NodeKey);
|
|
22
|
+
exportDOM(): DOMExportOutput;
|
|
23
|
+
static importDOM(): DOMConversionMap | null;
|
|
24
|
+
updateDOM(): false;
|
|
25
|
+
getId(): string;
|
|
26
|
+
getTextContent(_includeInert?: boolean | undefined, _includeDirectionless?: false | undefined): string;
|
|
27
|
+
decorate(_editor: LexicalEditor, config: EditorConfig): JSX.Element;
|
|
28
|
+
isInline(): false;
|
|
29
|
+
}
|
|
30
|
+
export declare function $createBilibiliNode({ id, page }: BilibiliVideoPayload): BilibiliNode;
|
|
31
|
+
export declare function $isBilibiliNode(node: BilibiliNode | LexicalNode | null | undefined): node is BilibiliNode;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BlockWithAlignableContents } from '@lexical/react/LexicalBlockWithAlignableContents';
|
|
3
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
4
|
+
import BilibiliVideo from './BilibiliVideo';
|
|
5
|
+
function BilibiliComponent({ className, format, nodeKey, videoID, page }) {
|
|
6
|
+
return (_jsx(BlockWithAlignableContents, { className: className, format: format, nodeKey: nodeKey, children: _jsx(BilibiliVideo, { videoID: videoID, page: page }) }));
|
|
7
|
+
}
|
|
8
|
+
function convertBilibiliElement(domNode) {
|
|
9
|
+
const videoID = domNode.getAttribute('data-lexical-bilibili');
|
|
10
|
+
const page = domNode.getAttribute('data-lexical-bilibili-page') || undefined;
|
|
11
|
+
if (videoID) {
|
|
12
|
+
const node = $createBilibiliNode({ id: videoID, page });
|
|
13
|
+
return { node };
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
export class BilibiliNode extends DecoratorBlockNode {
|
|
18
|
+
__id;
|
|
19
|
+
__page;
|
|
20
|
+
static getType() {
|
|
21
|
+
return 'bilibili';
|
|
22
|
+
}
|
|
23
|
+
static clone(node) {
|
|
24
|
+
return new BilibiliNode(node.__id, node.__page, node.__format, node.__key);
|
|
25
|
+
}
|
|
26
|
+
static importJSON(serializedNode) {
|
|
27
|
+
const node = $createBilibiliNode({ id: serializedNode.videoID, page: serializedNode.page });
|
|
28
|
+
node.setFormat(serializedNode.format);
|
|
29
|
+
return node;
|
|
30
|
+
}
|
|
31
|
+
exportJSON() {
|
|
32
|
+
return {
|
|
33
|
+
...super.exportJSON(),
|
|
34
|
+
type: 'bilibili',
|
|
35
|
+
version: 1,
|
|
36
|
+
videoID: this.__id,
|
|
37
|
+
page: this.__page,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
constructor(id, page, format, key) {
|
|
41
|
+
super(format, key);
|
|
42
|
+
this.__id = id;
|
|
43
|
+
this.__page = page;
|
|
44
|
+
}
|
|
45
|
+
exportDOM() {
|
|
46
|
+
const element = document.createElement('iframe');
|
|
47
|
+
element.setAttribute('data-lexical-bilibili', this.__id);
|
|
48
|
+
element.setAttribute('data-lexical-bilibili-page', this.__page || '');
|
|
49
|
+
element.setAttribute('width', '560');
|
|
50
|
+
element.setAttribute('height', '315');
|
|
51
|
+
element.setAttribute('src', `//player.bilibili.com/player.html?bvid=${this.__id}&page=${this.__page}`);
|
|
52
|
+
element.setAttribute('frameborder', '0');
|
|
53
|
+
element.setAttribute('title', 'Bilibili video');
|
|
54
|
+
return { element };
|
|
55
|
+
}
|
|
56
|
+
static importDOM() {
|
|
57
|
+
return {
|
|
58
|
+
iframe: (domNode) => {
|
|
59
|
+
if (!domNode.hasAttribute('data-lexical-bilibili')) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
conversion: convertBilibiliElement,
|
|
64
|
+
priority: 1,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
updateDOM() {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
getId() {
|
|
73
|
+
return this.__id;
|
|
74
|
+
}
|
|
75
|
+
getTextContent(_includeInert, _includeDirectionless) {
|
|
76
|
+
return `//player.bilibili.com/player.html?bvid=${this.__id}&page=${this.__page}`;
|
|
77
|
+
}
|
|
78
|
+
decorate(_editor, config) {
|
|
79
|
+
const embedBlockTheme = config.theme.embedBlock || {};
|
|
80
|
+
const className = {
|
|
81
|
+
base: embedBlockTheme.base || '',
|
|
82
|
+
focus: embedBlockTheme.focus || '',
|
|
83
|
+
};
|
|
84
|
+
return (_jsx(BilibiliComponent, { className: className, format: this.__format, nodeKey: this.getKey(), videoID: this.__id, page: this.__page }));
|
|
85
|
+
}
|
|
86
|
+
isInline() {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function $createBilibiliNode({ id, page }) {
|
|
91
|
+
return new BilibiliNode(id, page);
|
|
92
|
+
}
|
|
93
|
+
export function $isBilibiliNode(node) {
|
|
94
|
+
return node instanceof BilibiliNode;
|
|
95
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
export default function BilibiliVideo({ videoID, page }) {
|
|
4
|
+
return (_jsx(BilibiliVideoRoot, { children: _jsx("div", { className: "be-bilibili-video-inner", children: _jsx("div", { className: "be-bilibili-video-box", children: _jsx("iframe", { src: `//player.bilibili.com/player.html?bvid=${videoID}&high_quality=1&page=${page}`, style: { border: 0 }, title: "Bilibili video", allowFullScreen: true }) }) }) }));
|
|
5
|
+
}
|
|
6
|
+
const BilibiliVideoRoot = styled.div `
|
|
7
|
+
.be-bilibili-video-inner {
|
|
8
|
+
max-width: 800px;
|
|
9
|
+
margin: 0 auto;
|
|
10
|
+
}
|
|
11
|
+
.be-bilibili-video-box {
|
|
12
|
+
display: flex;
|
|
13
|
+
position: relative;
|
|
14
|
+
padding-top: 75%;
|
|
15
|
+
|
|
16
|
+
iframe {
|
|
17
|
+
position: absolute;
|
|
18
|
+
left: 0;
|
|
19
|
+
top: 0;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { INSERT_BILIBILI_COMMAND } from '.';
|
|
3
|
+
import { wrap } from '../../main/plugins/AutoEmbedPlugin/urlParseCache';
|
|
4
|
+
const parsePage = (url) => {
|
|
5
|
+
try {
|
|
6
|
+
const urlObj = new URL(url);
|
|
7
|
+
return urlObj.searchParams.get('p') || '';
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
console.error(e);
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const BilibiliEmbedConfig = {
|
|
15
|
+
contentName: 'Bilibili Video',
|
|
16
|
+
exampleUrl: 'https://www.bilibili.com/video/BV1w7411g7jn/?vd_source=d607e476d26705d4d7bd9852f9a3f5bf',
|
|
17
|
+
// Icon for display.
|
|
18
|
+
icon: _jsx("i", { className: "iconify", "data-icon": "ri:bilibili-fill" }),
|
|
19
|
+
insertNode: (editor, result) => {
|
|
20
|
+
editor.dispatchCommand(INSERT_BILIBILI_COMMAND, {
|
|
21
|
+
id: result.id,
|
|
22
|
+
page: result.data.page,
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
keywords: ['bilibili', 'video'],
|
|
26
|
+
// Determine if a given URL is a match and return url data.
|
|
27
|
+
parseUrl: wrap((url) => {
|
|
28
|
+
const match = /^https?:\/\/(?:www\.)?bilibili\.(?:com|tv)\/(?:video\/)?([BV][A-Za-z0-9]{10,})/.exec(url);
|
|
29
|
+
const id = match?.[1];
|
|
30
|
+
if (id) {
|
|
31
|
+
return {
|
|
32
|
+
id,
|
|
33
|
+
url,
|
|
34
|
+
data: { page: parsePage(url) },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}, 'bilibili-video'),
|
|
39
|
+
type: 'bilibili-video',
|
|
40
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LexicalCommand } from 'lexical';
|
|
2
|
+
import { type JSX } from 'react';
|
|
3
|
+
import { BilibiliVideoPayload } from './BilibiliNode';
|
|
4
|
+
export declare const INSERT_BILIBILI_COMMAND: LexicalCommand<BilibiliVideoPayload>;
|
|
5
|
+
export default function BilibiliPlugin(): JSX.Element | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
3
|
+
import { COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { $createBilibiliNode, BilibiliNode } from './BilibiliNode';
|
|
6
|
+
export const INSERT_BILIBILI_COMMAND = createCommand('INSERT_BILIBILI_COMMAND');
|
|
7
|
+
export default function BilibiliPlugin() {
|
|
8
|
+
const [editor] = useLexicalComposerContext();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!editor.hasNodes([BilibiliNode])) {
|
|
11
|
+
throw new Error('BilibiliPlugin: BilibiliNode not registered on editor');
|
|
12
|
+
}
|
|
13
|
+
return editor.registerCommand(INSERT_BILIBILI_COMMAND, (payload) => {
|
|
14
|
+
const bilibiliNode = $createBilibiliNode(payload);
|
|
15
|
+
$insertNodeToNearestRoot(bilibiliNode);
|
|
16
|
+
return true;
|
|
17
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
18
|
+
}, [editor]);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from 'react';
|
|
3
|
+
import { useReactive, useTimeout } from 'ahooks';
|
|
4
|
+
import { Box, CircularProgress, IconButton } from '@mui/material';
|
|
5
|
+
import CachedIcon from '@mui/icons-material/Cached';
|
|
6
|
+
import WarningTwoToneIcon from '@mui/icons-material/WarningTwoTone';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import { EmbedIframe } from '@blocklet/embed/react';
|
|
9
|
+
const getHost = (url) => {
|
|
10
|
+
try {
|
|
11
|
+
return new URL(url).host;
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
return url;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const timeout = 8000;
|
|
18
|
+
function BlockletEmbed({ title, url, originalUrl }) {
|
|
19
|
+
const id = `embed_${useId()}`;
|
|
20
|
+
const state = useReactive({
|
|
21
|
+
loading: true,
|
|
22
|
+
error: '',
|
|
23
|
+
});
|
|
24
|
+
const [delay, setDelay] = useState(timeout);
|
|
25
|
+
useTimeout(() => {
|
|
26
|
+
if (state.loading) {
|
|
27
|
+
state.error = 'Timeout';
|
|
28
|
+
setDelay(undefined);
|
|
29
|
+
}
|
|
30
|
+
}, delay);
|
|
31
|
+
const handleLoadIframe = () => {
|
|
32
|
+
state.loading = false;
|
|
33
|
+
// 取消 timeout
|
|
34
|
+
setDelay(undefined);
|
|
35
|
+
};
|
|
36
|
+
const reload = (e) => {
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
state.error = '';
|
|
39
|
+
setDelay(timeout);
|
|
40
|
+
};
|
|
41
|
+
return (_jsxs(Box, { sx: { display: 'inline-block', width: '100%', my: 1 }, children: [(state.loading || state.error) && (_jsxs(Box, { onClick: () => window.open(originalUrl, '_blank'), sx: {
|
|
42
|
+
position: 'relative',
|
|
43
|
+
p: 2,
|
|
44
|
+
border: '1px solid rgba(55, 53, 47, 0.16)',
|
|
45
|
+
borderRadius: '4px',
|
|
46
|
+
color: 'grey.700',
|
|
47
|
+
cursor: 'pointer',
|
|
48
|
+
':hover': { bgcolor: 'grey.50' },
|
|
49
|
+
}, children: [state.loading && !state.error && (_jsxs(Box, { children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(CircularProgress, { size: 14, sx: { color: 'grey.400' } }), _jsx("span", { children: "Discovering" })] }), _jsx(Box, { sx: { mt: 0.5, fontSize: 12 }, children: originalUrl })] })), state.error && (_jsxs(Box, { children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(WarningTwoToneIcon, { sx: { color: 'warning.light' } }), _jsx(Box, { children: getHost(originalUrl) })] }), _jsx(Box, { sx: { mt: 0.5, fontSize: 12 }, children: originalUrl }), _jsx(Box, { sx: { position: 'absolute', right: 8, top: 8 }, children: _jsx(IconButton, { size: "small", sx: { borderRadius: 2 }, onClick: reload, children: _jsx(CachedIcon, {}) }) })] }))] })), !state.error && _jsx(EmbedIframe, { embedId: id, src: url, onLoad: handleLoadIframe, height: "100%" })] }));
|
|
50
|
+
}
|
|
51
|
+
export default BlockletEmbed;
|