@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,151 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createEditor, DecoratorNode } from 'lexical';
|
|
3
|
+
import { Suspense } from 'react';
|
|
4
|
+
import ImageComponent from './ImageComponent';
|
|
5
|
+
function convertImageElement(domNode) {
|
|
6
|
+
if (domNode instanceof HTMLImageElement) {
|
|
7
|
+
const { alt: altText, src } = domNode;
|
|
8
|
+
const node = $createImageNode({ altText, src });
|
|
9
|
+
return { node };
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
export class ImageNode extends DecoratorNode {
|
|
14
|
+
file;
|
|
15
|
+
__src;
|
|
16
|
+
__altText;
|
|
17
|
+
__width;
|
|
18
|
+
__height;
|
|
19
|
+
__maxWidth;
|
|
20
|
+
__showCaption;
|
|
21
|
+
__caption;
|
|
22
|
+
__markerState;
|
|
23
|
+
__frame;
|
|
24
|
+
__sizeMode;
|
|
25
|
+
// Captions cannot yet be used within editor cells
|
|
26
|
+
__captionsEnabled;
|
|
27
|
+
static getType() {
|
|
28
|
+
return 'image';
|
|
29
|
+
}
|
|
30
|
+
static clone(node) {
|
|
31
|
+
return new ImageNode(node.__src, node.__altText, node.__maxWidth, node.__width, node.__height, node.__showCaption, node.__caption, node.__captionsEnabled, node.__key, node.file, node.__markerState, node.__frame, node.__sizeMode);
|
|
32
|
+
}
|
|
33
|
+
static importJSON(serializedNode) {
|
|
34
|
+
const { altText, height, width, maxWidth, caption, src, showCaption, markerState, frame, sizeMode } = serializedNode;
|
|
35
|
+
const node = $createImageNode({
|
|
36
|
+
altText,
|
|
37
|
+
height,
|
|
38
|
+
maxWidth,
|
|
39
|
+
showCaption,
|
|
40
|
+
src,
|
|
41
|
+
width,
|
|
42
|
+
markerState,
|
|
43
|
+
frame,
|
|
44
|
+
sizeMode,
|
|
45
|
+
});
|
|
46
|
+
const nestedEditor = node.__caption;
|
|
47
|
+
const editorState = nestedEditor.parseEditorState(caption.editorState);
|
|
48
|
+
if (!editorState.isEmpty()) {
|
|
49
|
+
nestedEditor.setEditorState(editorState);
|
|
50
|
+
}
|
|
51
|
+
return node;
|
|
52
|
+
}
|
|
53
|
+
exportDOM() {
|
|
54
|
+
const element = document.createElement('img');
|
|
55
|
+
element.setAttribute('src', this.__src || '');
|
|
56
|
+
element.setAttribute('alt', this.__altText);
|
|
57
|
+
return { element };
|
|
58
|
+
}
|
|
59
|
+
static importDOM() {
|
|
60
|
+
return {
|
|
61
|
+
img: (node) => ({
|
|
62
|
+
conversion: convertImageElement,
|
|
63
|
+
priority: 0,
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
constructor(src, altText, maxWidth, width, height, showCaption, caption, captionsEnabled, key, file, markerState, frame, sizeMode) {
|
|
68
|
+
super(key);
|
|
69
|
+
this.__src = src;
|
|
70
|
+
this.__altText = altText;
|
|
71
|
+
this.__maxWidth = maxWidth;
|
|
72
|
+
this.__width = width || 'inherit';
|
|
73
|
+
this.__height = height || 'inherit';
|
|
74
|
+
this.__showCaption = showCaption || false;
|
|
75
|
+
this.__caption = caption || createEditor();
|
|
76
|
+
this.__captionsEnabled = captionsEnabled || captionsEnabled === undefined;
|
|
77
|
+
this.file = file;
|
|
78
|
+
this.__markerState = markerState;
|
|
79
|
+
this.__frame = frame;
|
|
80
|
+
this.__sizeMode = sizeMode;
|
|
81
|
+
}
|
|
82
|
+
exportJSON() {
|
|
83
|
+
return {
|
|
84
|
+
altText: this.getAltText(),
|
|
85
|
+
caption: this.__caption.toJSON(),
|
|
86
|
+
height: this.__height === 'inherit' ? 0 : this.__height,
|
|
87
|
+
maxWidth: this.__maxWidth,
|
|
88
|
+
showCaption: this.__showCaption,
|
|
89
|
+
src: this.getSrc(),
|
|
90
|
+
type: 'image',
|
|
91
|
+
version: 1,
|
|
92
|
+
width: this.__width === 'inherit' ? 0 : this.__width,
|
|
93
|
+
markerState: this.__markerState,
|
|
94
|
+
frame: this.__frame,
|
|
95
|
+
sizeMode: this.__sizeMode,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
setWidthAndHeight(width, height) {
|
|
99
|
+
const writable = this.getWritable();
|
|
100
|
+
writable.__width = width;
|
|
101
|
+
writable.__height = height;
|
|
102
|
+
}
|
|
103
|
+
setShowCaption(showCaption) {
|
|
104
|
+
const writable = this.getWritable();
|
|
105
|
+
writable.__showCaption = showCaption;
|
|
106
|
+
}
|
|
107
|
+
setMarkerState(markerState) {
|
|
108
|
+
const writable = this.getWritable();
|
|
109
|
+
writable.__markerState = markerState;
|
|
110
|
+
}
|
|
111
|
+
setFrame(frame) {
|
|
112
|
+
const writable = this.getWritable();
|
|
113
|
+
writable.__frame = frame;
|
|
114
|
+
}
|
|
115
|
+
setSizeMode(sizeMode) {
|
|
116
|
+
const writable = this.getWritable();
|
|
117
|
+
writable.__sizeMode = sizeMode;
|
|
118
|
+
}
|
|
119
|
+
// View
|
|
120
|
+
createDOM(config) {
|
|
121
|
+
const span = document.createElement('span');
|
|
122
|
+
const { theme } = config;
|
|
123
|
+
const className = theme.image;
|
|
124
|
+
if (className !== undefined) {
|
|
125
|
+
span.className = `${className} be-image`;
|
|
126
|
+
}
|
|
127
|
+
return span;
|
|
128
|
+
}
|
|
129
|
+
updateDOM() {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
getSrc() {
|
|
133
|
+
return this.__src;
|
|
134
|
+
}
|
|
135
|
+
setSrc(src) {
|
|
136
|
+
const writable = this.getWritable();
|
|
137
|
+
writable.__src = src;
|
|
138
|
+
}
|
|
139
|
+
getAltText() {
|
|
140
|
+
return this.__altText;
|
|
141
|
+
}
|
|
142
|
+
decorate() {
|
|
143
|
+
return (_jsx(Suspense, { fallback: null, children: _jsx(ImageComponent, { src: this.__src, file: this.file, altText: this.__altText, width: this.__width, height: this.__height, maxWidth: this.__maxWidth, nodeKey: this.getKey(), showCaption: this.__showCaption, caption: this.__caption, captionsEnabled: this.__captionsEnabled, markerState: this.__markerState, frame: this.__frame, sizeMode: this.__sizeMode, resizable: true }) }));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export function $createImageNode({ altText, height, maxWidth = 500, captionsEnabled, src, width, showCaption, caption, key, file, markerState, frame, sizeMode, }) {
|
|
147
|
+
return new ImageNode(src, altText, maxWidth, width, height, showCaption, caption, captionsEnabled, key, file, markerState, frame, sizeMode);
|
|
148
|
+
}
|
|
149
|
+
export function $isImageNode(node) {
|
|
150
|
+
return node instanceof ImageNode;
|
|
151
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { EditorConfig, LexicalNode, SerializedTextNode, Spread } from 'lexical';
|
|
9
|
+
import { TextNode } from 'lexical';
|
|
10
|
+
export type SerializedKeywordNode = Spread<{
|
|
11
|
+
type: 'keyword';
|
|
12
|
+
version: 1;
|
|
13
|
+
}, SerializedTextNode>;
|
|
14
|
+
export declare class KeywordNode extends TextNode {
|
|
15
|
+
static getType(): string;
|
|
16
|
+
static clone(node: KeywordNode): KeywordNode;
|
|
17
|
+
static importJSON(serializedNode: SerializedKeywordNode): KeywordNode;
|
|
18
|
+
exportJSON(): SerializedKeywordNode;
|
|
19
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
20
|
+
canInsertTextBefore(): boolean;
|
|
21
|
+
canInsertTextAfter(): boolean;
|
|
22
|
+
isTextEntity(): true;
|
|
23
|
+
}
|
|
24
|
+
export declare function $createKeywordNode(keyword: string): KeywordNode;
|
|
25
|
+
export declare function $isKeywordNode(node: LexicalNode | null | undefined | undefined): boolean;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { TextNode } from 'lexical';
|
|
9
|
+
export class KeywordNode extends TextNode {
|
|
10
|
+
static getType() {
|
|
11
|
+
return 'keyword';
|
|
12
|
+
}
|
|
13
|
+
static clone(node) {
|
|
14
|
+
return new KeywordNode(node.__text, node.__key);
|
|
15
|
+
}
|
|
16
|
+
static importJSON(serializedNode) {
|
|
17
|
+
const node = $createKeywordNode(serializedNode.text);
|
|
18
|
+
node.setFormat(serializedNode.format);
|
|
19
|
+
node.setDetail(serializedNode.detail);
|
|
20
|
+
node.setMode(serializedNode.mode);
|
|
21
|
+
node.setStyle(serializedNode.style);
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
exportJSON() {
|
|
25
|
+
return {
|
|
26
|
+
...super.exportJSON(),
|
|
27
|
+
type: 'keyword',
|
|
28
|
+
version: 1,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
createDOM(config) {
|
|
32
|
+
const dom = super.createDOM(config);
|
|
33
|
+
dom.style.cursor = 'default';
|
|
34
|
+
dom.className = 'keyword';
|
|
35
|
+
return dom;
|
|
36
|
+
}
|
|
37
|
+
canInsertTextBefore() {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
canInsertTextAfter() {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
isTextEntity() {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function $createKeywordNode(keyword) {
|
|
48
|
+
return new KeywordNode(keyword);
|
|
49
|
+
}
|
|
50
|
+
export function $isKeywordNode(node) {
|
|
51
|
+
return node instanceof KeywordNode;
|
|
52
|
+
}
|
|
@@ -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 { type Spread, type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalNode, type NodeKey, type SerializedTextNode, TextNode } from 'lexical';
|
|
9
|
+
export type SerializedMentionNode = Spread<{
|
|
10
|
+
mentionName: string;
|
|
11
|
+
type: 'mention';
|
|
12
|
+
version: 1;
|
|
13
|
+
}, SerializedTextNode>;
|
|
14
|
+
export declare class MentionNode extends TextNode {
|
|
15
|
+
__mention: string;
|
|
16
|
+
static getType(): string;
|
|
17
|
+
static clone(node: MentionNode): MentionNode;
|
|
18
|
+
static importJSON(serializedNode: SerializedMentionNode): MentionNode;
|
|
19
|
+
constructor(mentionName: string, text?: string, key?: NodeKey);
|
|
20
|
+
exportJSON(): SerializedMentionNode;
|
|
21
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
22
|
+
exportDOM(): DOMExportOutput;
|
|
23
|
+
static importDOM(): DOMConversionMap | null;
|
|
24
|
+
isTextEntity(): true;
|
|
25
|
+
}
|
|
26
|
+
export declare function $createMentionNode(mentionName: string, text?: string, key?: NodeKey): MentionNode;
|
|
27
|
+
export declare function $isMentionNode(node: LexicalNode | null | undefined): node is MentionNode;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { $applyNodeReplacement, TextNode, } from 'lexical';
|
|
9
|
+
function convertMentionElement(domNode) {
|
|
10
|
+
const { textContent } = domNode;
|
|
11
|
+
if (textContent !== null) {
|
|
12
|
+
const node = $createMentionNode(textContent);
|
|
13
|
+
return {
|
|
14
|
+
node,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const mentionStyle = 'background-color: transparent; font-weight: bold;';
|
|
20
|
+
// node.__mention 用于存储/访问 user did, node.__text 负责显示 user name
|
|
21
|
+
export class MentionNode extends TextNode {
|
|
22
|
+
__mention;
|
|
23
|
+
static getType() {
|
|
24
|
+
return 'mention';
|
|
25
|
+
}
|
|
26
|
+
static clone(node) {
|
|
27
|
+
return new MentionNode(node.__mention, node.__text, node.__key);
|
|
28
|
+
}
|
|
29
|
+
static importJSON(serializedNode) {
|
|
30
|
+
const node = $createMentionNode(serializedNode.mentionName);
|
|
31
|
+
node.setTextContent(serializedNode.text);
|
|
32
|
+
node.setFormat(serializedNode.format);
|
|
33
|
+
node.setDetail(serializedNode.detail);
|
|
34
|
+
node.setMode(serializedNode.mode);
|
|
35
|
+
node.setStyle(serializedNode.style);
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
constructor(mentionName, text, key) {
|
|
39
|
+
super(text ?? mentionName, key);
|
|
40
|
+
this.__mention = mentionName;
|
|
41
|
+
}
|
|
42
|
+
exportJSON() {
|
|
43
|
+
return {
|
|
44
|
+
...super.exportJSON(),
|
|
45
|
+
mentionName: this.__mention,
|
|
46
|
+
type: 'mention',
|
|
47
|
+
version: 1,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
createDOM(config) {
|
|
51
|
+
const dom = super.createDOM(config);
|
|
52
|
+
dom.style.cssText = mentionStyle;
|
|
53
|
+
dom.className = 'mention';
|
|
54
|
+
// 添加属性: data-did="<did>"
|
|
55
|
+
dom.dataset.did = this.__mention;
|
|
56
|
+
return dom;
|
|
57
|
+
}
|
|
58
|
+
exportDOM() {
|
|
59
|
+
const element = document.createElement('span');
|
|
60
|
+
element.setAttribute('data-lexical-mention', 'true');
|
|
61
|
+
element.textContent = this.__text;
|
|
62
|
+
return { element };
|
|
63
|
+
}
|
|
64
|
+
static importDOM() {
|
|
65
|
+
return {
|
|
66
|
+
span: (domNode) => {
|
|
67
|
+
if (!domNode.hasAttribute('data-lexical-mention')) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
conversion: convertMentionElement,
|
|
72
|
+
priority: 1,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
isTextEntity() {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function $createMentionNode(mentionName, text, key) {
|
|
82
|
+
const mentionNode = new MentionNode(mentionName, text, key);
|
|
83
|
+
mentionNode.setMode('segmented').toggleDirectionless();
|
|
84
|
+
return $applyNodeReplacement(mentionNode);
|
|
85
|
+
}
|
|
86
|
+
export function $isMentionNode(node) {
|
|
87
|
+
return node instanceof MentionNode;
|
|
88
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { Klass, LexicalNode } from 'lexical';
|
|
9
|
+
declare const PlaygroundNodes: Array<Klass<LexicalNode>>;
|
|
10
|
+
export default PlaygroundNodes;
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
9
|
+
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
10
|
+
import { ListItemNode, ListNode } from '@lexical/list';
|
|
11
|
+
import { MarkNode } from '@lexical/mark';
|
|
12
|
+
import { OverflowNode } from '@lexical/overflow';
|
|
13
|
+
import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
14
|
+
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
15
|
+
import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
16
|
+
import { CollapsibleContainerNode } from '../plugins/CollapsiblePlugin/CollapsibleContainerNode';
|
|
17
|
+
import { CollapsibleContentNode } from '../plugins/CollapsiblePlugin/CollapsibleContentNode';
|
|
18
|
+
import { CollapsibleTitleNode } from '../plugins/CollapsiblePlugin/CollapsibleTitleNode';
|
|
19
|
+
import { EmojiNode } from './EmojiNode';
|
|
20
|
+
import { EquationNode } from './EquationNode';
|
|
21
|
+
import { ExcalidrawNode } from './ExcalidrawNode';
|
|
22
|
+
import { FigmaNode } from './FigmaNode';
|
|
23
|
+
import { ImageNode } from './ImageNode';
|
|
24
|
+
import { MentionNode } from './MentionNode';
|
|
25
|
+
import { TweetNode } from './TweetNode';
|
|
26
|
+
import { YouTubeNode } from './YouTubeNode';
|
|
27
|
+
import { BilibiliNode } from '../../ext/BilibiliPlugin/BilibiliNode';
|
|
28
|
+
import { BlockletEmbedNode } from '../../ext/BlockletEmbedPlugin/BlockletEmbedNode';
|
|
29
|
+
import { PostLinkNode } from '../../ext/PostLinkEmbedPlugin/PostLinkNode';
|
|
30
|
+
import { BookmarkNode } from '../../ext/BookmarkPlugin/BookmarkNode';
|
|
31
|
+
import { GithubNode } from '../../ext/nodes/GithubNode';
|
|
32
|
+
import { AlertNode } from '../../ext/Alert/AlertNode';
|
|
33
|
+
import { VideoNode } from '../../ext/VideoPlugin';
|
|
34
|
+
import { FileNode } from '../../ext/FilePlugin';
|
|
35
|
+
const PlaygroundNodes = [
|
|
36
|
+
HeadingNode,
|
|
37
|
+
ListNode,
|
|
38
|
+
ListItemNode,
|
|
39
|
+
QuoteNode,
|
|
40
|
+
CodeNode,
|
|
41
|
+
TableNode,
|
|
42
|
+
TableCellNode,
|
|
43
|
+
TableRowNode,
|
|
44
|
+
CodeHighlightNode,
|
|
45
|
+
AutoLinkNode,
|
|
46
|
+
LinkNode,
|
|
47
|
+
OverflowNode,
|
|
48
|
+
ImageNode,
|
|
49
|
+
VideoNode,
|
|
50
|
+
MentionNode,
|
|
51
|
+
EmojiNode,
|
|
52
|
+
ExcalidrawNode,
|
|
53
|
+
EquationNode,
|
|
54
|
+
HorizontalRuleNode,
|
|
55
|
+
TweetNode,
|
|
56
|
+
YouTubeNode,
|
|
57
|
+
BilibiliNode,
|
|
58
|
+
BlockletEmbedNode,
|
|
59
|
+
PostLinkNode,
|
|
60
|
+
BookmarkNode,
|
|
61
|
+
FigmaNode,
|
|
62
|
+
MarkNode,
|
|
63
|
+
CollapsibleContainerNode,
|
|
64
|
+
CollapsibleContentNode,
|
|
65
|
+
CollapsibleTitleNode,
|
|
66
|
+
GithubNode,
|
|
67
|
+
AlertNode,
|
|
68
|
+
FileNode,
|
|
69
|
+
];
|
|
70
|
+
export default PlaygroundNodes;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
|
|
9
|
+
import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
10
|
+
import { type JSX } from 'react';
|
|
11
|
+
export type SerializedTweetNode = Spread<{
|
|
12
|
+
id: string;
|
|
13
|
+
type: 'tweet';
|
|
14
|
+
version: 1;
|
|
15
|
+
}, SerializedDecoratorBlockNode>;
|
|
16
|
+
export declare class TweetNode extends DecoratorBlockNode {
|
|
17
|
+
__id: string;
|
|
18
|
+
static getType(): string;
|
|
19
|
+
static clone(node: TweetNode): TweetNode;
|
|
20
|
+
static importJSON(serializedNode: SerializedTweetNode): TweetNode;
|
|
21
|
+
exportJSON(): SerializedTweetNode;
|
|
22
|
+
static importDOM(): DOMConversionMap<HTMLDivElement> | null;
|
|
23
|
+
exportDOM(): DOMExportOutput;
|
|
24
|
+
constructor(id: string, format?: ElementFormatType, key?: NodeKey);
|
|
25
|
+
getId(): string;
|
|
26
|
+
getTextContent(_includeInert?: boolean | undefined, _includeDirectionless?: false | undefined): string;
|
|
27
|
+
decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element;
|
|
28
|
+
isInline(): false;
|
|
29
|
+
}
|
|
30
|
+
export declare function $createTweetNode(tweetID: string): TweetNode;
|
|
31
|
+
export declare function $isTweetNode(node: TweetNode | LexicalNode | null | undefined): node is TweetNode;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BlockWithAlignableContents } from '@lexical/react/LexicalBlockWithAlignableContents';
|
|
3
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
const WIDGET_SCRIPT_URL = 'https://platform.twitter.com/widgets.js';
|
|
6
|
+
function convertTweetElement(domNode) {
|
|
7
|
+
const id = domNode.getAttribute('data-lexical-tweet-id');
|
|
8
|
+
if (id) {
|
|
9
|
+
const node = $createTweetNode(id);
|
|
10
|
+
return { node };
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let isTwitterScriptLoading = true;
|
|
15
|
+
function TweetComponent({ className, format, loadingComponent, nodeKey, onError, onLoad, tweetID, }) {
|
|
16
|
+
const containerRef = useRef(null);
|
|
17
|
+
const previousTweetIDRef = useRef('');
|
|
18
|
+
const [isTweetLoading, setIsTweetLoading] = useState(false);
|
|
19
|
+
const createTweet = useCallback(async () => {
|
|
20
|
+
try {
|
|
21
|
+
// @ts-expect-error Twitter is attached to the window.
|
|
22
|
+
await window.twttr.widgets.createTweet(tweetID, containerRef.current);
|
|
23
|
+
setIsTweetLoading(false);
|
|
24
|
+
isTwitterScriptLoading = false;
|
|
25
|
+
if (onLoad) {
|
|
26
|
+
onLoad();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (onError) {
|
|
31
|
+
onError(String(error));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, [onError, onLoad, tweetID]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (tweetID !== previousTweetIDRef.current) {
|
|
37
|
+
setIsTweetLoading(true);
|
|
38
|
+
if (isTwitterScriptLoading) {
|
|
39
|
+
const script = document.createElement('script');
|
|
40
|
+
script.src = WIDGET_SCRIPT_URL;
|
|
41
|
+
script.async = true;
|
|
42
|
+
document.body?.appendChild(script);
|
|
43
|
+
script.onload = createTweet;
|
|
44
|
+
if (onError) {
|
|
45
|
+
script.onerror = onError;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
createTweet();
|
|
50
|
+
}
|
|
51
|
+
if (previousTweetIDRef) {
|
|
52
|
+
previousTweetIDRef.current = tweetID;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [createTweet, onError, tweetID]);
|
|
56
|
+
return (_jsxs(BlockWithAlignableContents, { className: className, format: format, nodeKey: nodeKey, children: [isTweetLoading ? loadingComponent : null, _jsx("div", { style: { display: 'inline-block', width: '100%' }, ref: containerRef })] }));
|
|
57
|
+
}
|
|
58
|
+
export class TweetNode extends DecoratorBlockNode {
|
|
59
|
+
__id;
|
|
60
|
+
static getType() {
|
|
61
|
+
return 'tweet';
|
|
62
|
+
}
|
|
63
|
+
static clone(node) {
|
|
64
|
+
return new TweetNode(node.__id, node.__format, node.__key);
|
|
65
|
+
}
|
|
66
|
+
static importJSON(serializedNode) {
|
|
67
|
+
const node = $createTweetNode(serializedNode.id);
|
|
68
|
+
node.setFormat(serializedNode.format);
|
|
69
|
+
return node;
|
|
70
|
+
}
|
|
71
|
+
exportJSON() {
|
|
72
|
+
return {
|
|
73
|
+
...super.exportJSON(),
|
|
74
|
+
id: this.getId(),
|
|
75
|
+
type: 'tweet',
|
|
76
|
+
version: 1,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
static importDOM() {
|
|
80
|
+
return {
|
|
81
|
+
div: (domNode) => {
|
|
82
|
+
if (!domNode.hasAttribute('data-lexical-tweet-id')) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
conversion: convertTweetElement,
|
|
87
|
+
priority: 2,
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
exportDOM() {
|
|
93
|
+
const element = document.createElement('div');
|
|
94
|
+
element.setAttribute('data-lexical-tweet-id', this.__id);
|
|
95
|
+
const text = document.createTextNode(this.getTextContent());
|
|
96
|
+
element.append(text);
|
|
97
|
+
return { element };
|
|
98
|
+
}
|
|
99
|
+
constructor(id, format, key) {
|
|
100
|
+
super(format, key);
|
|
101
|
+
this.__id = id;
|
|
102
|
+
}
|
|
103
|
+
getId() {
|
|
104
|
+
return this.__id;
|
|
105
|
+
}
|
|
106
|
+
getTextContent(_includeInert, _includeDirectionless) {
|
|
107
|
+
return `https://twitter.com/i/web/status/${this.__id}`;
|
|
108
|
+
}
|
|
109
|
+
decorate(editor, config) {
|
|
110
|
+
const embedBlockTheme = config.theme.embedBlock || {};
|
|
111
|
+
const className = {
|
|
112
|
+
base: embedBlockTheme.base || '',
|
|
113
|
+
focus: embedBlockTheme.focus || '',
|
|
114
|
+
};
|
|
115
|
+
return (_jsx(TweetComponent, { className: className, format: this.__format, loadingComponent: "Loading...", nodeKey: this.getKey(), tweetID: this.__id }));
|
|
116
|
+
}
|
|
117
|
+
isInline() {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function $createTweetNode(tweetID) {
|
|
122
|
+
return new TweetNode(tweetID);
|
|
123
|
+
}
|
|
124
|
+
export function $isTweetNode(node) {
|
|
125
|
+
return node instanceof TweetNode;
|
|
126
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
|
|
9
|
+
import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
10
|
+
import type { JSX } from 'react';
|
|
11
|
+
export type SerializedYouTubeNode = Spread<{
|
|
12
|
+
videoID: string;
|
|
13
|
+
type: 'youtube';
|
|
14
|
+
version: 1;
|
|
15
|
+
}, SerializedDecoratorBlockNode>;
|
|
16
|
+
export declare class YouTubeNode extends DecoratorBlockNode {
|
|
17
|
+
__id: string;
|
|
18
|
+
static getType(): string;
|
|
19
|
+
static clone(node: YouTubeNode): YouTubeNode;
|
|
20
|
+
static importJSON(serializedNode: SerializedYouTubeNode): YouTubeNode;
|
|
21
|
+
exportJSON(): SerializedYouTubeNode;
|
|
22
|
+
constructor(id: string, format?: ElementFormatType, key?: NodeKey);
|
|
23
|
+
exportDOM(): DOMExportOutput;
|
|
24
|
+
static importDOM(): DOMConversionMap | null;
|
|
25
|
+
updateDOM(): false;
|
|
26
|
+
getId(): string;
|
|
27
|
+
getTextContent(_includeInert?: boolean | undefined, _includeDirectionless?: false | undefined): string;
|
|
28
|
+
decorate(_editor: LexicalEditor, config: EditorConfig): JSX.Element;
|
|
29
|
+
isInline(): false;
|
|
30
|
+
}
|
|
31
|
+
export declare function $createYouTubeNode(videoID: string): YouTubeNode;
|
|
32
|
+
export declare function $isYouTubeNode(node: YouTubeNode | LexicalNode | null | undefined): node is YouTubeNode;
|