@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,141 @@
|
|
|
1
|
+
import { $isLinkNode } from '@lexical/link';
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { $findMatchingParent, isHTMLAnchorElement } from '@lexical/utils';
|
|
4
|
+
import { $getNearestNodeFromDOMNode, $getSelection, $isElementNode, $isRangeSelection, getNearestEditorFromDOMNode, } from 'lexical';
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
import { useParams, useNavigate } from 'react-router-dom';
|
|
7
|
+
import { useEditorConfig } from '../../../config';
|
|
8
|
+
import { getUTMUrl } from '../../../libs/utm';
|
|
9
|
+
function findMatchingDOM(startNode, predicate) {
|
|
10
|
+
let node = startNode;
|
|
11
|
+
while (node != null) {
|
|
12
|
+
if (predicate(node)) {
|
|
13
|
+
return node;
|
|
14
|
+
}
|
|
15
|
+
node = node.parentNode;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
function isSameOrigin(url) {
|
|
20
|
+
try {
|
|
21
|
+
return new URL(url, window.location.href).origin === window.location.origin;
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
console.error(e);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const PHONE_NUMBER_REGEX = /^\+?[0-9\s()-]{5,}$/;
|
|
29
|
+
function formatUrl(url) {
|
|
30
|
+
// Check if URL already has a protocol
|
|
31
|
+
if (url.match(/^[a-z][a-z0-9+.-]*:/i)) {
|
|
32
|
+
// URL already has a protocol, leave it as is
|
|
33
|
+
return url;
|
|
34
|
+
}
|
|
35
|
+
// Check if it's a relative path (starting with '/', '.', or '#')
|
|
36
|
+
if (url.match(/^[/#.]/)) {
|
|
37
|
+
// Relative path, leave it as is
|
|
38
|
+
return url;
|
|
39
|
+
}
|
|
40
|
+
// Check for email address
|
|
41
|
+
if (url.includes('@')) {
|
|
42
|
+
return `mailto:${url}`;
|
|
43
|
+
}
|
|
44
|
+
// Check for phone number
|
|
45
|
+
if (PHONE_NUMBER_REGEX.test(url)) {
|
|
46
|
+
return `tel:${url}`;
|
|
47
|
+
}
|
|
48
|
+
// For everything else, return with "./" prefix
|
|
49
|
+
return `./${url}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 代码复制自 @lexical/react/LexicalClickableLinkPlugin, 逻辑改动:
|
|
53
|
+
* - url origin 与 window.location.origin 相同时, 避免 newTab 方式跳转
|
|
54
|
+
* - 编辑模式下, 避免当前页面直接跳转 (#1575)
|
|
55
|
+
*/
|
|
56
|
+
export default function LexicalClickableLinkPlugin({ newTab = true }) {
|
|
57
|
+
const [editor] = useLexicalComposerContext();
|
|
58
|
+
const config = useEditorConfig();
|
|
59
|
+
const { boardId } = useParams();
|
|
60
|
+
const navigate = useNavigate();
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const onClick = (event) => {
|
|
63
|
+
const { target } = event;
|
|
64
|
+
if (!(target instanceof Node)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const nearestEditor = getNearestEditorFromDOMNode(target);
|
|
68
|
+
if (nearestEditor === null) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
let url = null;
|
|
72
|
+
let urlTarget = null;
|
|
73
|
+
nearestEditor.update(() => {
|
|
74
|
+
const clickedNode = $getNearestNodeFromDOMNode(target);
|
|
75
|
+
if (clickedNode !== null) {
|
|
76
|
+
const maybeLinkNode = $findMatchingParent(clickedNode, $isElementNode);
|
|
77
|
+
if ($isLinkNode(maybeLinkNode)) {
|
|
78
|
+
url = maybeLinkNode.sanitizeUrl(formatUrl(maybeLinkNode.getURL()));
|
|
79
|
+
urlTarget = maybeLinkNode.getTarget();
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const a = findMatchingDOM(target, isHTMLAnchorElement);
|
|
83
|
+
if (a !== null) {
|
|
84
|
+
url = a.href;
|
|
85
|
+
urlTarget = a.target;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (url === null || url === '') {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Allow user to select link text without follwing url
|
|
94
|
+
const selection = editor.getEditorState().read($getSelection);
|
|
95
|
+
if ($isRangeSelection(selection) && !selection.isCollapsed()) {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const isMiddle = event.type === 'auxclick' && event.button === 1;
|
|
100
|
+
if (isSameOrigin(url) && !editor.isEditable() && config.openLinkInNewTab !== true) {
|
|
101
|
+
// HOTFIX: for docs board
|
|
102
|
+
// if url starts with /docs, use navigate instead of window.open
|
|
103
|
+
if (url && url?.startsWith?.('/docs')) {
|
|
104
|
+
// url should be /docs/:boardId/:locale/:docId, should length === 4 (after remove start trim)
|
|
105
|
+
const segments = url.split('/').filter(Boolean);
|
|
106
|
+
if (segments.length === 3 || segments.length === 2) {
|
|
107
|
+
url = url.replace('/docs', `/docs/${boardId}`);
|
|
108
|
+
}
|
|
109
|
+
// 开启 page group 情况的处理
|
|
110
|
+
if (window.blocklet?.pageGroup === 'doc') {
|
|
111
|
+
url = url.replace(/^\/docs\//, '/');
|
|
112
|
+
}
|
|
113
|
+
navigate(url);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
window.open(url, '_self');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
window.open(getUTMUrl(url), newTab || isMiddle || event.metaKey || event.ctrlKey || urlTarget === '_blank' ? '_blank' : '_self');
|
|
121
|
+
}
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
};
|
|
124
|
+
const onMouseUp = (event) => {
|
|
125
|
+
if (event.button === 1 && editor.isEditable()) {
|
|
126
|
+
onClick(event);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return editor.registerRootListener((rootElement, prevRootElement) => {
|
|
130
|
+
if (prevRootElement !== null) {
|
|
131
|
+
prevRootElement.removeEventListener('click', onClick);
|
|
132
|
+
prevRootElement.removeEventListener('mouseup', onMouseUp);
|
|
133
|
+
}
|
|
134
|
+
if (rootElement !== null) {
|
|
135
|
+
rootElement.addEventListener('click', onClick);
|
|
136
|
+
rootElement.addEventListener('mouseup', onMouseUp);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}, [editor, newTab]);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { $isCodeNode } from '@lexical/code';
|
|
10
|
+
import { $getNearestNodeFromDOMNode, $getSelection, $setSelection } from 'lexical';
|
|
11
|
+
import { useState } from 'react';
|
|
12
|
+
import { Box } from '@mui/material';
|
|
13
|
+
import { useDebounce } from '../../utils';
|
|
14
|
+
import { icons } from '../../../../icons';
|
|
15
|
+
export function CopyButton({ editor, getCodeDOMNode }) {
|
|
16
|
+
const [isCopyCompleted, setCopyCompleted] = useState(false);
|
|
17
|
+
const removeSuccessIcon = useDebounce(() => {
|
|
18
|
+
setCopyCompleted(false);
|
|
19
|
+
}, 1000);
|
|
20
|
+
async function handleClick() {
|
|
21
|
+
const codeDOMNode = getCodeDOMNode();
|
|
22
|
+
if (!codeDOMNode) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let content = '';
|
|
26
|
+
editor.update(() => {
|
|
27
|
+
const codeNode = $getNearestNodeFromDOMNode(codeDOMNode);
|
|
28
|
+
if ($isCodeNode(codeNode)) {
|
|
29
|
+
content = codeNode.getTextContent();
|
|
30
|
+
}
|
|
31
|
+
const selection = $getSelection();
|
|
32
|
+
$setSelection(selection);
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
await navigator.clipboard.writeText(content);
|
|
36
|
+
setCopyCompleted(true);
|
|
37
|
+
removeSuccessIcon();
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error('Failed to copy: ', err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { className: "menu-item", onClick: handleClick, "aria-label": "copy", style: { display: isCopyCompleted ? 'none' : 'inline-block' }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": icons.copy, "data-height": 20 }) }), _jsx("button", { className: "menu-item", "aria-label": "copy", style: { display: isCopyCompleted ? 'inline-block' : 'none' }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": icons.copySuccess, "data-height": 20 }) })] }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.code-action-menu-container {
|
|
2
|
+
height: 35.8px;
|
|
3
|
+
font-size: 10px;
|
|
4
|
+
color: rgba(0, 0, 0, 0.5);
|
|
5
|
+
position: absolute;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
user-select: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.code-action-menu-container .code-highlight-language {
|
|
13
|
+
margin-right: 4px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.code-action-menu-container button.menu-item {
|
|
17
|
+
border: 1px solid transparent;
|
|
18
|
+
border-radius: 4px;
|
|
19
|
+
padding: 4px;
|
|
20
|
+
background: none;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
flex-shrink: 0;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
color: #fff;
|
|
26
|
+
text-transform: uppercase;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.code-action-menu-container button.menu-item i.format {
|
|
30
|
+
height: 16px;
|
|
31
|
+
width: 16px;
|
|
32
|
+
opacity: 0.6;
|
|
33
|
+
display: flex;
|
|
34
|
+
color: rgba(0, 0, 0, 0.5);
|
|
35
|
+
background-size: contain;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.code-action-menu-container button.menu-item:hover {
|
|
39
|
+
border: 1px solid rgba(0, 0, 0, 0.3);
|
|
40
|
+
opacity: 0.9;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.code-action-menu-container button.menu-item:active {
|
|
44
|
+
/* background-color: rgba(223, 232, 250);
|
|
45
|
+
border: 1px solid rgba(0, 0, 0, 0.45); */
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 './index.css';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
export default function CodeActionMenuPlugin({ anchorElem, }: {
|
|
11
|
+
anchorElem?: HTMLElement;
|
|
12
|
+
}): React.ReactPortal | null;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import './index.css';
|
|
3
|
+
import { $isCodeNode, CodeNode } from '@lexical/code';
|
|
4
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
+
import { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';
|
|
6
|
+
import { useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
import { CopyButton } from './components/CopyButton';
|
|
9
|
+
import { useDebounce } from './utils';
|
|
10
|
+
const CODE_PADDING = 8;
|
|
11
|
+
function CodeActionMenuContainer({ anchorElem }) {
|
|
12
|
+
const [editor] = useLexicalComposerContext();
|
|
13
|
+
const [lang, setLang] = useState('');
|
|
14
|
+
const [isShown, setShown] = useState(false);
|
|
15
|
+
const [shouldListenMouseMove, setShouldListenMouseMove] = useState(false);
|
|
16
|
+
const [position, setPosition] = useState({
|
|
17
|
+
right: '0',
|
|
18
|
+
top: '0',
|
|
19
|
+
});
|
|
20
|
+
const codeSetRef = useRef(new Set());
|
|
21
|
+
const codeDOMNodeRef = useRef(null);
|
|
22
|
+
function getCodeDOMNode() {
|
|
23
|
+
return codeDOMNodeRef.current;
|
|
24
|
+
}
|
|
25
|
+
const debouncedOnMouseMove = useDebounce((event) => {
|
|
26
|
+
const { codeDOMNode, isOutside } = getMouseInfo(event);
|
|
27
|
+
if (isOutside) {
|
|
28
|
+
setShown(false);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!codeDOMNode) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
codeDOMNodeRef.current = codeDOMNode;
|
|
35
|
+
let codeNode = null;
|
|
36
|
+
let _lang = '';
|
|
37
|
+
editor.update(() => {
|
|
38
|
+
const maybeCodeNode = $getNearestNodeFromDOMNode(codeDOMNode);
|
|
39
|
+
if ($isCodeNode(maybeCodeNode)) {
|
|
40
|
+
codeNode = maybeCodeNode;
|
|
41
|
+
_lang = codeNode.getLanguage() || '';
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (codeNode) {
|
|
45
|
+
const { y: editorElemY, right: editorElemRight } = anchorElem.getBoundingClientRect();
|
|
46
|
+
const { y, right } = codeDOMNode.getBoundingClientRect();
|
|
47
|
+
setLang(_lang);
|
|
48
|
+
setShown(true);
|
|
49
|
+
setPosition({
|
|
50
|
+
right: `${editorElemRight - right + CODE_PADDING}px`,
|
|
51
|
+
top: `${y - editorElemY}px`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, 50, 1000);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!shouldListenMouseMove) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
document.addEventListener('mousemove', debouncedOnMouseMove);
|
|
60
|
+
return () => {
|
|
61
|
+
setShown(false);
|
|
62
|
+
debouncedOnMouseMove.cancel();
|
|
63
|
+
document.removeEventListener('mousemove', debouncedOnMouseMove);
|
|
64
|
+
};
|
|
65
|
+
}, [shouldListenMouseMove, debouncedOnMouseMove]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
return editor.registerMutationListener(CodeNode, (mutations) => {
|
|
68
|
+
editor.getEditorState().read(() => {
|
|
69
|
+
for (const [key, type] of mutations) {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case 'created':
|
|
72
|
+
codeSetRef.current.add(key);
|
|
73
|
+
break;
|
|
74
|
+
case 'destroyed':
|
|
75
|
+
codeSetRef.current.delete(key);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
setShouldListenMouseMove(codeSetRef.current.size > 0);
|
|
83
|
+
}, { skipInitialization: false });
|
|
84
|
+
}, [editor]);
|
|
85
|
+
return (
|
|
86
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
87
|
+
_jsx(_Fragment, { children: isShown ? (_jsx("div", { className: "code-action-menu-container", style: { ...position }, children: _jsx(CopyButton, { editor: editor, getCodeDOMNode: getCodeDOMNode }) })) : null }));
|
|
88
|
+
}
|
|
89
|
+
function getMouseInfo(event) {
|
|
90
|
+
const { target } = event;
|
|
91
|
+
if (isHTMLElement(target)) {
|
|
92
|
+
const codeDOMNode = target.closest('code');
|
|
93
|
+
const isOutside = !(codeDOMNode || target.closest('div.code-action-menu-container'));
|
|
94
|
+
return { codeDOMNode, isOutside };
|
|
95
|
+
}
|
|
96
|
+
return { codeDOMNode: null, isOutside: true };
|
|
97
|
+
}
|
|
98
|
+
export default function CodeActionMenuPlugin({ anchorElem = document.body, }) {
|
|
99
|
+
return createPortal(_jsx(CodeActionMenuContainer, { anchorElem: anchorElem }), anchorElem);
|
|
100
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 debounce from 'lodash/debounce';
|
|
9
|
+
import { useMemo, useRef } from 'react';
|
|
10
|
+
export function useDebounce(fn, ms, maxWait) {
|
|
11
|
+
const funcRef = useRef(null);
|
|
12
|
+
funcRef.current = fn;
|
|
13
|
+
return useMemo(() => debounce((...args) => {
|
|
14
|
+
if (funcRef.current) {
|
|
15
|
+
funcRef.current(...args);
|
|
16
|
+
}
|
|
17
|
+
}, ms, { maxWait }), [ms, maxWait]);
|
|
18
|
+
}
|
|
@@ -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 CodeHighlightPlugin(): JSX.Element | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { registerCodeHighlighting } from '@lexical/code';
|
|
9
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
|
+
import { useEffect } from 'react';
|
|
11
|
+
export default function CodeHighlightPlugin() {
|
|
12
|
+
const [editor] = useLexicalComposerContext();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
return registerCodeHighlighting(editor);
|
|
15
|
+
}, [editor]);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
.Collapsible__container {
|
|
11
|
+
background: #fcfcfc;
|
|
12
|
+
border: 1px solid #eee;
|
|
13
|
+
border-radius: 10px;
|
|
14
|
+
margin-bottom: 8px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.Collapsible__title {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
padding: 5px 5px 5px 24px;
|
|
20
|
+
position: relative;
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
list-style: none;
|
|
23
|
+
outline: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.Collapsible__title > p {
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.Collapsible__title::marker,
|
|
31
|
+
.Collapsible__title::-webkit-details-marker {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.Collapsible__title:before {
|
|
36
|
+
border-style: solid;
|
|
37
|
+
border-color: transparent;
|
|
38
|
+
border-width: 4px 6px 4px 6px;
|
|
39
|
+
border-left-color: #000;
|
|
40
|
+
display: block;
|
|
41
|
+
content: '';
|
|
42
|
+
position: absolute;
|
|
43
|
+
left: 12px;
|
|
44
|
+
top: 50%;
|
|
45
|
+
transform: translateY(-50%);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.Collapsible__container[open] > .Collapsible__title:before {
|
|
49
|
+
border-color: transparent;
|
|
50
|
+
border-width: 6px 4px 0 4px;
|
|
51
|
+
border-top-color: #000;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.Collapsible__container[open] > .Collapsible__content {
|
|
55
|
+
padding: 0 5px 5px 24px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.Collapsible__collapsed .Collapsible__content {
|
|
59
|
+
display: none;
|
|
60
|
+
user-select: none;
|
|
61
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, ElementNode, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical';
|
|
9
|
+
type SerializedCollapsibleContainerNode = Spread<{
|
|
10
|
+
open: boolean;
|
|
11
|
+
}, SerializedElementNode>;
|
|
12
|
+
export declare function $convertDetailsElement(domNode: HTMLDetailsElement): DOMConversionOutput | null;
|
|
13
|
+
export declare class CollapsibleContainerNode extends ElementNode {
|
|
14
|
+
__open: boolean;
|
|
15
|
+
constructor(open: boolean, key?: NodeKey);
|
|
16
|
+
static getType(): string;
|
|
17
|
+
static clone(node: CollapsibleContainerNode): CollapsibleContainerNode;
|
|
18
|
+
createDOM(config: EditorConfig, editor: LexicalEditor): HTMLElement;
|
|
19
|
+
updateDOM(prevNode: CollapsibleContainerNode, dom: HTMLDetailsElement): boolean;
|
|
20
|
+
static importDOM(): DOMConversionMap<HTMLDetailsElement> | null;
|
|
21
|
+
static importJSON(serializedNode: SerializedCollapsibleContainerNode): CollapsibleContainerNode;
|
|
22
|
+
exportDOM(): DOMExportOutput;
|
|
23
|
+
exportJSON(): SerializedCollapsibleContainerNode;
|
|
24
|
+
setOpen(open: boolean): void;
|
|
25
|
+
getOpen(): boolean;
|
|
26
|
+
toggleOpen(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function $createCollapsibleContainerNode(isOpen: boolean): CollapsibleContainerNode;
|
|
29
|
+
export declare function $isCollapsibleContainerNode(node: LexicalNode | null | undefined): node is CollapsibleContainerNode;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
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 { ElementNode, isHTMLElement, } from 'lexical';
|
|
9
|
+
import { IS_CHROME } from '../../../shared/environment';
|
|
10
|
+
import invariant from '../../../shared/invariant';
|
|
11
|
+
import { setDomHiddenUntilFound } from './CollapsibleUtils';
|
|
12
|
+
export function $convertDetailsElement(domNode) {
|
|
13
|
+
const isOpen = domNode.open !== undefined ? domNode.open : true;
|
|
14
|
+
const node = $createCollapsibleContainerNode(isOpen);
|
|
15
|
+
return {
|
|
16
|
+
node,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export class CollapsibleContainerNode extends ElementNode {
|
|
20
|
+
__open;
|
|
21
|
+
constructor(open, key) {
|
|
22
|
+
super(key);
|
|
23
|
+
this.__open = open;
|
|
24
|
+
}
|
|
25
|
+
static getType() {
|
|
26
|
+
return 'collapsible-container';
|
|
27
|
+
}
|
|
28
|
+
static clone(node) {
|
|
29
|
+
return new CollapsibleContainerNode(node.__open, node.__key);
|
|
30
|
+
}
|
|
31
|
+
createDOM(config, editor) {
|
|
32
|
+
// details is not well supported in Chrome #5582
|
|
33
|
+
let dom;
|
|
34
|
+
if (IS_CHROME) {
|
|
35
|
+
dom = document.createElement('div');
|
|
36
|
+
if (this.__open) {
|
|
37
|
+
dom.setAttribute('open', '');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const detailsDom = document.createElement('details');
|
|
42
|
+
detailsDom.open = this.__open;
|
|
43
|
+
detailsDom.addEventListener('toggle', () => {
|
|
44
|
+
const open = editor.getEditorState().read(() => this.getOpen());
|
|
45
|
+
if (open !== detailsDom.open) {
|
|
46
|
+
editor.update(() => this.toggleOpen());
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
dom = detailsDom;
|
|
50
|
+
}
|
|
51
|
+
dom.classList.add('Collapsible__container');
|
|
52
|
+
return dom;
|
|
53
|
+
}
|
|
54
|
+
updateDOM(prevNode, dom) {
|
|
55
|
+
const currentOpen = this.__open;
|
|
56
|
+
if (prevNode.__open !== currentOpen) {
|
|
57
|
+
// details is not well supported in Chrome #5582
|
|
58
|
+
if (IS_CHROME) {
|
|
59
|
+
const contentDom = dom.children[1];
|
|
60
|
+
invariant(isHTMLElement(contentDom), 'Expected contentDom to be an HTMLElement');
|
|
61
|
+
if (currentOpen) {
|
|
62
|
+
dom.setAttribute('open', '');
|
|
63
|
+
contentDom.hidden = false;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
dom.removeAttribute('open');
|
|
67
|
+
setDomHiddenUntilFound(contentDom);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
dom.open = this.__open;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
static importDOM() {
|
|
77
|
+
return {
|
|
78
|
+
details: (domNode) => {
|
|
79
|
+
return {
|
|
80
|
+
conversion: $convertDetailsElement,
|
|
81
|
+
priority: 1,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
static importJSON(serializedNode) {
|
|
87
|
+
const node = $createCollapsibleContainerNode(serializedNode.open);
|
|
88
|
+
return node;
|
|
89
|
+
}
|
|
90
|
+
exportDOM() {
|
|
91
|
+
const element = document.createElement('details');
|
|
92
|
+
element.classList.add('Collapsible__container');
|
|
93
|
+
element.setAttribute('open', this.__open.toString());
|
|
94
|
+
return { element };
|
|
95
|
+
}
|
|
96
|
+
exportJSON() {
|
|
97
|
+
return {
|
|
98
|
+
...super.exportJSON(),
|
|
99
|
+
open: this.__open,
|
|
100
|
+
type: 'collapsible-container',
|
|
101
|
+
version: 1,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
setOpen(open) {
|
|
105
|
+
const writable = this.getWritable();
|
|
106
|
+
writable.__open = open;
|
|
107
|
+
}
|
|
108
|
+
getOpen() {
|
|
109
|
+
return this.getLatest().__open;
|
|
110
|
+
}
|
|
111
|
+
toggleOpen() {
|
|
112
|
+
this.setOpen(!this.getOpen());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export function $createCollapsibleContainerNode(isOpen) {
|
|
116
|
+
return new CollapsibleContainerNode(isOpen);
|
|
117
|
+
}
|
|
118
|
+
export function $isCollapsibleContainerNode(node) {
|
|
119
|
+
return node instanceof CollapsibleContainerNode;
|
|
120
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, ElementNode, LexicalEditor, LexicalNode, SerializedElementNode } from 'lexical';
|
|
9
|
+
type SerializedCollapsibleContentNode = SerializedElementNode;
|
|
10
|
+
export declare function $convertCollapsibleContentElement(domNode: HTMLElement): DOMConversionOutput | null;
|
|
11
|
+
export declare class CollapsibleContentNode extends ElementNode {
|
|
12
|
+
static getType(): string;
|
|
13
|
+
static clone(node: CollapsibleContentNode): CollapsibleContentNode;
|
|
14
|
+
createDOM(config: EditorConfig, editor: LexicalEditor): HTMLElement;
|
|
15
|
+
updateDOM(prevNode: CollapsibleContentNode, dom: HTMLElement): boolean;
|
|
16
|
+
static importDOM(): DOMConversionMap | null;
|
|
17
|
+
exportDOM(): DOMExportOutput;
|
|
18
|
+
static importJSON(serializedNode: SerializedCollapsibleContentNode): CollapsibleContentNode;
|
|
19
|
+
isShadowRoot(): boolean;
|
|
20
|
+
exportJSON(): SerializedCollapsibleContentNode;
|
|
21
|
+
}
|
|
22
|
+
export declare function $createCollapsibleContentNode(): CollapsibleContentNode;
|
|
23
|
+
export declare function $isCollapsibleContentNode(node: LexicalNode | null | undefined): node is CollapsibleContentNode;
|
|
24
|
+
export {};
|