@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,94 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BlockWithAlignableContents } from '@lexical/react/LexicalBlockWithAlignableContents';
|
|
3
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
4
|
+
function YouTubeComponent({ className, format, nodeKey, videoID }) {
|
|
5
|
+
return (_jsx(BlockWithAlignableContents, { className: className, format: format, nodeKey: nodeKey, children: _jsx("iframe", {
|
|
6
|
+
// width="560"
|
|
7
|
+
// height="315"
|
|
8
|
+
src: `https://www.youtube.com/embed/${videoID}`, frameBorder: "0", allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture", allowFullScreen: true, title: "YouTube video", style: { width: '100%', maxWidth: '560px', aspectRatio: 16 / 9 } }) }));
|
|
9
|
+
}
|
|
10
|
+
function convertYoutubeElement(domNode) {
|
|
11
|
+
const videoID = domNode.getAttribute('data-lexical-youtube');
|
|
12
|
+
if (videoID) {
|
|
13
|
+
const node = $createYouTubeNode(videoID);
|
|
14
|
+
return { node };
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export class YouTubeNode extends DecoratorBlockNode {
|
|
19
|
+
__id;
|
|
20
|
+
static getType() {
|
|
21
|
+
return 'youtube';
|
|
22
|
+
}
|
|
23
|
+
static clone(node) {
|
|
24
|
+
return new YouTubeNode(node.__id, node.__format, node.__key);
|
|
25
|
+
}
|
|
26
|
+
static importJSON(serializedNode) {
|
|
27
|
+
const node = $createYouTubeNode(serializedNode.videoID);
|
|
28
|
+
node.setFormat(serializedNode.format);
|
|
29
|
+
return node;
|
|
30
|
+
}
|
|
31
|
+
exportJSON() {
|
|
32
|
+
return {
|
|
33
|
+
...super.exportJSON(),
|
|
34
|
+
type: 'youtube',
|
|
35
|
+
version: 1,
|
|
36
|
+
videoID: this.__id,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
constructor(id, format, key) {
|
|
40
|
+
super(format, key);
|
|
41
|
+
this.__id = id;
|
|
42
|
+
}
|
|
43
|
+
exportDOM() {
|
|
44
|
+
const element = document.createElement('iframe');
|
|
45
|
+
element.setAttribute('data-lexical-youtube', this.__id);
|
|
46
|
+
element.setAttribute('width', '560');
|
|
47
|
+
element.setAttribute('height', '315');
|
|
48
|
+
element.setAttribute('src', `https://www.youtube.com/embed/${this.__id}`);
|
|
49
|
+
element.setAttribute('frameborder', '0');
|
|
50
|
+
element.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture');
|
|
51
|
+
element.setAttribute('allowfullscreen', 'true');
|
|
52
|
+
element.setAttribute('title', 'YouTube video');
|
|
53
|
+
return { element };
|
|
54
|
+
}
|
|
55
|
+
static importDOM() {
|
|
56
|
+
return {
|
|
57
|
+
iframe: (domNode) => {
|
|
58
|
+
if (!domNode.hasAttribute('data-lexical-youtube')) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
conversion: convertYoutubeElement,
|
|
63
|
+
priority: 1,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
updateDOM() {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
getId() {
|
|
72
|
+
return this.__id;
|
|
73
|
+
}
|
|
74
|
+
getTextContent(_includeInert, _includeDirectionless) {
|
|
75
|
+
return `https://www.youtube.com/watch?v=${this.__id}`;
|
|
76
|
+
}
|
|
77
|
+
decorate(_editor, config) {
|
|
78
|
+
const embedBlockTheme = config.theme.embedBlock || {};
|
|
79
|
+
const className = {
|
|
80
|
+
base: embedBlockTheme.base || '',
|
|
81
|
+
focus: embedBlockTheme.focus || '',
|
|
82
|
+
};
|
|
83
|
+
return (_jsx(YouTubeComponent, { className: className, format: this.__format, nodeKey: this.getKey(), videoID: this.__id }));
|
|
84
|
+
}
|
|
85
|
+
isInline() {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export function $createYouTubeNode(videoID) {
|
|
90
|
+
return new YouTubeNode(videoID);
|
|
91
|
+
}
|
|
92
|
+
export function $isYouTubeNode(node) {
|
|
93
|
+
return node instanceof YouTubeNode;
|
|
94
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { EmbedConfig } from '@lexical/react/LexicalAutoEmbedPlugin';
|
|
9
|
+
import { type JSX } from 'react';
|
|
10
|
+
export interface PlaygroundEmbedConfig extends EmbedConfig {
|
|
11
|
+
contentName: string;
|
|
12
|
+
icon?: JSX.Element;
|
|
13
|
+
exampleUrl: string;
|
|
14
|
+
keywords: Array<string>;
|
|
15
|
+
description?: string;
|
|
16
|
+
skipDefaultEmbedOption?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const YoutubeEmbedConfig: PlaygroundEmbedConfig;
|
|
19
|
+
export declare const TwitterEmbedConfig: PlaygroundEmbedConfig;
|
|
20
|
+
export declare const FigmaEmbedConfig: PlaygroundEmbedConfig;
|
|
21
|
+
export declare const GithubConfig: PlaygroundEmbedConfig;
|
|
22
|
+
export declare const EmbedConfigs: PlaygroundEmbedConfig[];
|
|
23
|
+
export declare function AutoEmbedDialog({ embedConfig, onClose, }: {
|
|
24
|
+
embedConfig: PlaygroundEmbedConfig;
|
|
25
|
+
onClose: () => void;
|
|
26
|
+
}): JSX.Element;
|
|
27
|
+
export default function AutoEmbedPlugin(): JSX.Element;
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { $getSelection, $isRangeSelection, $createTextNode, COMMAND_PRIORITY_EDITOR, KEY_DOWN_COMMAND, } from 'lexical';
|
|
10
|
+
import { AutoEmbedOption, URL_MATCHER, LexicalAutoEmbedPlugin, } from '@lexical/react/LexicalAutoEmbedPlugin';
|
|
11
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
12
|
+
import { useMemo, useState, useEffect, useRef } from 'react';
|
|
13
|
+
import { $getNearestNodeOfType } from '@lexical/utils';
|
|
14
|
+
import { LinkNode, $createLinkNode } from '@lexical/link';
|
|
15
|
+
import compact from 'lodash/compact';
|
|
16
|
+
import { Box } from '@mui/material';
|
|
17
|
+
import useModal from '../../hooks/useModal';
|
|
18
|
+
import Button from '../../ui/Button';
|
|
19
|
+
import { DialogActions } from '../../ui/Dialog';
|
|
20
|
+
import { INSERT_FIGMA_COMMAND } from '../FigmaPlugin';
|
|
21
|
+
import { INSERT_TWEET_COMMAND } from '../TwitterPlugin';
|
|
22
|
+
import { INSERT_YOUTUBE_COMMAND } from '../YouTubePlugin';
|
|
23
|
+
import { createBlockletEmbedOption } from '../../../ext/BlockletEmbedPlugin';
|
|
24
|
+
import { createBookmarkOption } from '../../../ext/BookmarkPlugin';
|
|
25
|
+
import { get as getFromUrlParseCache, wrap } from './urlParseCache';
|
|
26
|
+
import { BilibiliEmbedConfig } from '../../../ext/BilibiliPlugin/config';
|
|
27
|
+
import { createPostLinkAutoEmbedOption } from '../../../ext/PostLinkEmbedPlugin';
|
|
28
|
+
import { $createGithubNode } from '../../../ext/nodes/GithubNode';
|
|
29
|
+
import { $createEmojiNode } from '../../nodes/EmojiNode';
|
|
30
|
+
import { useEditorConfig } from '../../../config';
|
|
31
|
+
import { fetchOpenGraphInfo } from '../../../ext/utils';
|
|
32
|
+
import createPortal from '../../../components/createPortal';
|
|
33
|
+
import { icons } from '../../icons';
|
|
34
|
+
export const YoutubeEmbedConfig = {
|
|
35
|
+
contentName: 'Youtube Video',
|
|
36
|
+
exampleUrl: 'https://www.youtube.com/watch?v=jNQXAC9IVRw',
|
|
37
|
+
// Icon for display.
|
|
38
|
+
icon: _jsx("i", { className: "iconify", "data-icon": "mdi:youtube" }),
|
|
39
|
+
insertNode: (editor, result) => {
|
|
40
|
+
editor.dispatchCommand(INSERT_YOUTUBE_COMMAND, result.id);
|
|
41
|
+
},
|
|
42
|
+
keywords: ['youtube', 'video'],
|
|
43
|
+
// Determine if a given URL is a match and return url data.
|
|
44
|
+
parseUrl: wrap((url) => {
|
|
45
|
+
const match = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(url);
|
|
46
|
+
const id = match ? (match?.[2].length === 11 ? match[2] : null) : null;
|
|
47
|
+
if (id != null) {
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
url,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}, 'youtube-video'),
|
|
55
|
+
type: 'youtube-video',
|
|
56
|
+
};
|
|
57
|
+
export const TwitterEmbedConfig = {
|
|
58
|
+
// e.g. Tweet or Google Map.
|
|
59
|
+
contentName: 'X',
|
|
60
|
+
exampleUrl: 'https://twitter.com/jack/status/20',
|
|
61
|
+
// Icon for display.
|
|
62
|
+
icon: _jsx("i", { className: "iconify", "data-icon": icons.brandX }),
|
|
63
|
+
// Create the Lexical embed node from the url data.
|
|
64
|
+
insertNode: (editor, result) => {
|
|
65
|
+
editor.dispatchCommand(INSERT_TWEET_COMMAND, result.id);
|
|
66
|
+
},
|
|
67
|
+
// For extra searching.
|
|
68
|
+
keywords: ['tweet', 'twitter'],
|
|
69
|
+
// Determine if a given URL is a match and return url data.
|
|
70
|
+
parseUrl: wrap((text) => {
|
|
71
|
+
const match = /^https:\/\/(?:twitter|x)\.com\/(#!\/)?(\w+)\/status(es)*\/(\d+)/.exec(text);
|
|
72
|
+
if (match != null) {
|
|
73
|
+
return {
|
|
74
|
+
id: match[4],
|
|
75
|
+
url: match[0],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}, 'tweet'),
|
|
80
|
+
type: 'tweet',
|
|
81
|
+
};
|
|
82
|
+
export const FigmaEmbedConfig = {
|
|
83
|
+
contentName: 'Figma',
|
|
84
|
+
exampleUrl: 'https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File',
|
|
85
|
+
icon: _jsx("i", { className: "iconify", "data-icon": icons.brandFigma }),
|
|
86
|
+
insertNode: (editor, result) => {
|
|
87
|
+
editor.dispatchCommand(INSERT_FIGMA_COMMAND, result.id);
|
|
88
|
+
},
|
|
89
|
+
keywords: ['figma', 'figma.com', 'mock-up'],
|
|
90
|
+
// Determine if a given URL is a match and return url data.
|
|
91
|
+
parseUrl: wrap((text) => {
|
|
92
|
+
const match = /https:\/\/([\w.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/.exec(text);
|
|
93
|
+
if (match != null) {
|
|
94
|
+
return {
|
|
95
|
+
id: match[3],
|
|
96
|
+
url: match[0],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}, 'figma'),
|
|
101
|
+
type: 'figma',
|
|
102
|
+
};
|
|
103
|
+
export const GithubConfig = {
|
|
104
|
+
contentName: 'GitHub',
|
|
105
|
+
exampleUrl: 'https://github.com/blocklet/discuss-kit/pull/722',
|
|
106
|
+
// Icon for display.
|
|
107
|
+
icon: _jsx("i", { className: "iconify", "data-icon": "tabler:brand-github" }),
|
|
108
|
+
// Create the Lexical embed node from the url data.
|
|
109
|
+
insertNode: (editor, result) => { },
|
|
110
|
+
// For extra searching.
|
|
111
|
+
keywords: ['github'],
|
|
112
|
+
// Determine if a given URL is a match and return url data.
|
|
113
|
+
parseUrl: wrap((text) => {
|
|
114
|
+
const GITHUB = 'github.com';
|
|
115
|
+
try {
|
|
116
|
+
const { origin, pathname } = new URL(text);
|
|
117
|
+
if (origin.includes(GITHUB)) {
|
|
118
|
+
const [, , , id] = pathname.split('/').filter(Boolean);
|
|
119
|
+
return { id, url: text };
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}, 'github'),
|
|
127
|
+
skipDefaultEmbedOption: true,
|
|
128
|
+
type: 'github',
|
|
129
|
+
};
|
|
130
|
+
const LinkFallbackConfig = {
|
|
131
|
+
contentName: '',
|
|
132
|
+
exampleUrl: '',
|
|
133
|
+
insertNode: (editor, result) => { },
|
|
134
|
+
keywords: [],
|
|
135
|
+
parseUrl: async (text) => {
|
|
136
|
+
const prevs = await Promise.all(['github', 'youtube-video', 'tweet', 'figma', 'bilibili-video'].map((type) => getFromUrlParseCache(text, type)));
|
|
137
|
+
if (prevs.some((v) => v)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return { id: text, url: text };
|
|
141
|
+
},
|
|
142
|
+
skipDefaultEmbedOption: true,
|
|
143
|
+
type: 'link-fallback',
|
|
144
|
+
};
|
|
145
|
+
export const EmbedConfigs = [
|
|
146
|
+
TwitterEmbedConfig,
|
|
147
|
+
YoutubeEmbedConfig,
|
|
148
|
+
FigmaEmbedConfig,
|
|
149
|
+
BilibiliEmbedConfig,
|
|
150
|
+
GithubConfig,
|
|
151
|
+
LinkFallbackConfig,
|
|
152
|
+
];
|
|
153
|
+
function AutoEmbedMenuItem({ index, isSelected, onClick, onMouseEnter, option, }) {
|
|
154
|
+
let className = 'item';
|
|
155
|
+
if (isSelected) {
|
|
156
|
+
className += ' selected';
|
|
157
|
+
}
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
if (option.disabled) {
|
|
160
|
+
className += ' embed-option-disabled';
|
|
161
|
+
}
|
|
162
|
+
const handleClick = () => {
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
if (!option.disabled) {
|
|
165
|
+
onClick();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return (_jsx("li", { tabIndex: -1, className: className, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id: `typeahead-item-${index}`, onMouseEnter: onMouseEnter, onClick: handleClick, children: _jsx("span", { className: "text", children: option.title }) }, option.key));
|
|
169
|
+
}
|
|
170
|
+
function AutoEmbedMenu({ options, selectedItemIndex, onOptionClick, onOptionMouseEnter, }) {
|
|
171
|
+
return (_jsx("div", { className: "typeahead-popover", children: _jsx("ul", { children: options.map((option, i) => (_jsx(AutoEmbedMenuItem, { index: i, isSelected: selectedItemIndex === i, onClick: () => onOptionClick(option, i), onMouseEnter: () => onOptionMouseEnter(i), option: option }, option.key))) }) }));
|
|
172
|
+
}
|
|
173
|
+
const debounce = (callback, delay) => {
|
|
174
|
+
let timeoutId;
|
|
175
|
+
return (text) => {
|
|
176
|
+
window.clearTimeout(timeoutId);
|
|
177
|
+
timeoutId = window.setTimeout(() => {
|
|
178
|
+
callback(text);
|
|
179
|
+
}, delay);
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
export function AutoEmbedDialog({ embedConfig, onClose, }) {
|
|
183
|
+
const [text, setText] = useState('');
|
|
184
|
+
const [editor] = useLexicalComposerContext();
|
|
185
|
+
const [embedResult, setEmbedResult] = useState(null);
|
|
186
|
+
const validateText = useMemo(() => debounce((inputText) => {
|
|
187
|
+
const urlMatch = URL_MATCHER.exec(inputText);
|
|
188
|
+
if (embedConfig != null && inputText != null && urlMatch != null) {
|
|
189
|
+
Promise.resolve(embedConfig.parseUrl(inputText)).then((parseResult) => {
|
|
190
|
+
setEmbedResult(parseResult);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
else if (embedResult != null) {
|
|
194
|
+
setEmbedResult(null);
|
|
195
|
+
}
|
|
196
|
+
}, 200), [embedConfig, embedResult]);
|
|
197
|
+
const onClick = () => {
|
|
198
|
+
if (embedResult != null) {
|
|
199
|
+
embedConfig.insertNode(editor, embedResult);
|
|
200
|
+
onClose();
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
return (_jsxs(Box, { sx: { width: { xs: 300, sm: 400, md: 600 } }, children: [_jsx("div", { className: "Input__wrapper", children: _jsx("input", { type: "text", className: "Input__input", placeholder: embedConfig.exampleUrl, value: text, "data-test-id": `${embedConfig.type}-embed-modal-url`, onChange: (e) => {
|
|
204
|
+
const { value } = e.target;
|
|
205
|
+
setText(value);
|
|
206
|
+
validateText(value);
|
|
207
|
+
} }) }), _jsx(DialogActions, { children: _jsx(Button, { disabled: !embedResult, onClick: onClick, "data-test-id": `${embedConfig.type}-embed-modal-submit-btn`, children: "Embed" }) })] }));
|
|
208
|
+
}
|
|
209
|
+
export default function AutoEmbedPlugin() {
|
|
210
|
+
const [editor] = useLexicalComposerContext();
|
|
211
|
+
const [modal, showModal] = useModal();
|
|
212
|
+
const editorConfig = useEditorConfig();
|
|
213
|
+
const dismissFnRef = useRef(null);
|
|
214
|
+
const openEmbedModal = (embedConfig) => {
|
|
215
|
+
showModal(`Embed ${embedConfig.contentName}`, (onClose) => (_jsx(AutoEmbedDialog, { embedConfig: embedConfig, onClose: onClose })));
|
|
216
|
+
};
|
|
217
|
+
// Dismiss the menu when moving the cursor
|
|
218
|
+
// (https://community.arcblock.io/discussions/29f1b7a4-2af6-407f-8653-1267067d8899)
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
return editor.registerUpdateListener(() => {
|
|
221
|
+
dismissFnRef.current?.();
|
|
222
|
+
});
|
|
223
|
+
}, [editor]);
|
|
224
|
+
const getMenuOptions = (activeEmbedConfig, embedFn, dismissFn) => {
|
|
225
|
+
dismissFnRef.current = dismissFn;
|
|
226
|
+
return compact([
|
|
227
|
+
new AutoEmbedOption('Dismiss', {
|
|
228
|
+
onSelect: dismissFn,
|
|
229
|
+
}),
|
|
230
|
+
...(activeEmbedConfig.skipDefaultEmbedOption !== true
|
|
231
|
+
? [
|
|
232
|
+
new AutoEmbedOption(`Embed ${activeEmbedConfig.contentName}`, {
|
|
233
|
+
onSelect: embedFn,
|
|
234
|
+
}),
|
|
235
|
+
]
|
|
236
|
+
: []),
|
|
237
|
+
createPostLinkAutoEmbedOption(editor, editorConfig),
|
|
238
|
+
createBlockletEmbedOption(editor, editorConfig),
|
|
239
|
+
createBookmarkOption(editor, editorConfig),
|
|
240
|
+
...(editorConfig.openGraphEndpoint
|
|
241
|
+
? [
|
|
242
|
+
activeEmbedConfig.type === 'github'
|
|
243
|
+
? new AutoEmbedOption('Create mention', {
|
|
244
|
+
onSelect: () => {
|
|
245
|
+
editor.update(async () => {
|
|
246
|
+
const selection = $getSelection();
|
|
247
|
+
if ($isRangeSelection(selection)) {
|
|
248
|
+
const anchorNode = selection.anchor.getNode();
|
|
249
|
+
const anchorTopLevelElement = anchorNode.getTopLevelElementOrThrow();
|
|
250
|
+
const linkNode = $getNearestNodeOfType(anchorNode, LinkNode);
|
|
251
|
+
const linkUrl = anchorNode.getTextContent();
|
|
252
|
+
const reg = /^https?:\/\/github.com\//;
|
|
253
|
+
if (linkUrl && reg.test(linkUrl)) {
|
|
254
|
+
anchorNode.replace($createEmojiNode('global-loading', ''));
|
|
255
|
+
if (linkNode) {
|
|
256
|
+
linkNode.append($createEmojiNode('empty-text', ' '));
|
|
257
|
+
linkNode.selectEnd();
|
|
258
|
+
}
|
|
259
|
+
anchorTopLevelElement.selectEnd();
|
|
260
|
+
const openGraphInfo = await fetchOpenGraphInfo(editorConfig.openGraphEndpoint, linkUrl);
|
|
261
|
+
if (openGraphInfo) {
|
|
262
|
+
editor.update(() => {
|
|
263
|
+
anchorTopLevelElement.selectEnd();
|
|
264
|
+
let link = null;
|
|
265
|
+
if (openGraphInfo.url) {
|
|
266
|
+
link = $createGithubNode({
|
|
267
|
+
title: openGraphInfo.title,
|
|
268
|
+
image: openGraphInfo.image || '',
|
|
269
|
+
link: linkUrl || '',
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
link = $createLinkNode(linkUrl).append($createTextNode(linkUrl));
|
|
274
|
+
}
|
|
275
|
+
if (linkNode) {
|
|
276
|
+
linkNode.replace(link);
|
|
277
|
+
}
|
|
278
|
+
const linkParent = link.getParent();
|
|
279
|
+
linkParent?.append($createTextNode(' '));
|
|
280
|
+
linkParent?.selectEnd();
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
editor.update(() => {
|
|
285
|
+
anchorTopLevelElement.selectEnd();
|
|
286
|
+
let link = null;
|
|
287
|
+
link = $createLinkNode(linkUrl).append($createTextNode(linkUrl));
|
|
288
|
+
if (linkNode) {
|
|
289
|
+
linkNode.replace(link);
|
|
290
|
+
}
|
|
291
|
+
const linkParent = link.getParent();
|
|
292
|
+
linkParent?.append($createTextNode(' '));
|
|
293
|
+
linkParent?.selectEnd();
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
})
|
|
301
|
+
: null,
|
|
302
|
+
]
|
|
303
|
+
: []),
|
|
304
|
+
]);
|
|
305
|
+
};
|
|
306
|
+
// shortcut: ctrl+z
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
let timer = null;
|
|
309
|
+
return editor.registerCommand(KEY_DOWN_COMMAND, (e) => {
|
|
310
|
+
if ((e.metaKey || e.ctrlKey) && e.key === 'z') {
|
|
311
|
+
timer = setTimeout(() => {
|
|
312
|
+
const loading = document.querySelector('.global-loading');
|
|
313
|
+
if (loading) {
|
|
314
|
+
editor.update(() => {
|
|
315
|
+
const selection = $getSelection();
|
|
316
|
+
if ($isRangeSelection(selection)) {
|
|
317
|
+
const anchorNode = selection.anchor.getNode();
|
|
318
|
+
const linkNode = $getNearestNodeOfType(anchorNode, LinkNode);
|
|
319
|
+
linkNode?.remove();
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
clearTimeout(timer);
|
|
324
|
+
}, 0);
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
329
|
+
}, [editor]);
|
|
330
|
+
return (_jsxs(_Fragment, { children: [modal, _jsx(LexicalAutoEmbedPlugin, { embedConfigs: EmbedConfigs, onOpenEmbedModalForConfig: openEmbedModal, getMenuOptions: getMenuOptions, menuRenderFn: (anchorElementRef, { selectedIndex, options, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
331
|
+
return anchorElementRef.current
|
|
332
|
+
? createPortal(_jsx(Box, { className: "typeahead-popover auto-embed-menu", sx: {
|
|
333
|
+
marginLeft: `${Math.max(parseFloat(anchorElementRef.current.style.width) - 200, 0)}px`,
|
|
334
|
+
width: 200,
|
|
335
|
+
border: 1,
|
|
336
|
+
borderColor: 'divider',
|
|
337
|
+
color: 'text.primary',
|
|
338
|
+
bgcolor: 'background.default',
|
|
339
|
+
'li.selected': {
|
|
340
|
+
bgcolor: 'action.selected',
|
|
341
|
+
},
|
|
342
|
+
'li:hover': {
|
|
343
|
+
bgcolor: 'action.hover',
|
|
344
|
+
},
|
|
345
|
+
}, children: _jsx(AutoEmbedMenu, { options: options, selectedItemIndex: selectedIndex, onOptionClick: (option, index) => {
|
|
346
|
+
setHighlightedIndex(index);
|
|
347
|
+
selectOptionAndCleanUp(option);
|
|
348
|
+
}, onOptionMouseEnter: (index) => {
|
|
349
|
+
setHighlightedIndex(index);
|
|
350
|
+
} }) }), anchorElementRef.current)
|
|
351
|
+
: null;
|
|
352
|
+
} })] }));
|
|
353
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const get: (url: string, type: string) => import("@lexical/react/LexicalAutoEmbedPlugin").EmbedMatchResult<unknown> | Promise<import("@lexical/react/LexicalAutoEmbedPlugin").EmbedMatchResult<unknown> | null> | null;
|
|
2
|
+
export declare const wrap: <T extends (text: string) => import("@lexical/react/LexicalAutoEmbedPlugin").EmbedMatchResult<unknown> | Promise<import("@lexical/react/LexicalAutoEmbedPlugin").EmbedMatchResult<unknown> | null> | null>(parseUrl: T, type: string) => (url: string) => import("@lexical/react/LexicalAutoEmbedPlugin").EmbedMatchResult<unknown> | Promise<import("@lexical/react/LexicalAutoEmbedPlugin").EmbedMatchResult<unknown> | null> | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const cache = {};
|
|
2
|
+
const getKey = (url, type) => `${url}_${type}`;
|
|
3
|
+
export const get = (url, type) => {
|
|
4
|
+
return cache[getKey(url, type)];
|
|
5
|
+
};
|
|
6
|
+
export const wrap = (parseUrl, type) => {
|
|
7
|
+
return (url) => {
|
|
8
|
+
const key = getKey(url, type);
|
|
9
|
+
if (!cache[key]) {
|
|
10
|
+
cache[key] = parseUrl(url);
|
|
11
|
+
}
|
|
12
|
+
return cache[key];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export default function LexicalAutoLinkPlugin(): JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { AutoLinkPlugin } from '@lexical/react/LexicalAutoLinkPlugin';
|
|
10
|
+
// `\u00A0-\uD7FF\uE000-\uFFFD`: 支持常用字符集 (#1423)
|
|
11
|
+
const URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,63}\b([-a-zA-Z0-9\u00A0-\uD7FF\uE000-\uFFFD()@:%_+.~#?&//=]*)/;
|
|
12
|
+
const EMAIL_MATCHER = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
13
|
+
const MATCHERS = [
|
|
14
|
+
(text) => {
|
|
15
|
+
const match = URL_MATCHER.exec(text);
|
|
16
|
+
if (match === null) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const fullMatch = match[0];
|
|
20
|
+
return {
|
|
21
|
+
index: match.index,
|
|
22
|
+
length: fullMatch.length,
|
|
23
|
+
text: fullMatch,
|
|
24
|
+
url: fullMatch.startsWith('http') ? fullMatch : `https://${fullMatch}`,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
(text) => {
|
|
28
|
+
const match = EMAIL_MATCHER.exec(text);
|
|
29
|
+
return (match && {
|
|
30
|
+
index: match.index,
|
|
31
|
+
length: match[0].length,
|
|
32
|
+
text: match[0],
|
|
33
|
+
url: `mailto:${match[0]}`,
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
export default function LexicalAutoLinkPlugin() {
|
|
38
|
+
return _jsx(AutoLinkPlugin, { matchers: MATCHERS });
|
|
39
|
+
}
|