@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,24 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { $patchStyleText } from '@lexical/selection';
|
|
3
|
+
import { $getSelection, $isRangeSelection } from 'lexical';
|
|
4
|
+
import { useCallback, useState } from 'react';
|
|
5
|
+
import ColorPicker from '../../ui/ColorPicker';
|
|
6
|
+
export default function ColorPickerButton({ editor }) {
|
|
7
|
+
const [fontColor] = useState('rgb(208, 2, 27)');
|
|
8
|
+
const [bgColor] = useState('#fff');
|
|
9
|
+
const applyStyleText = useCallback((styles) => {
|
|
10
|
+
editor.update(() => {
|
|
11
|
+
const selection = $getSelection();
|
|
12
|
+
if ($isRangeSelection(selection)) {
|
|
13
|
+
$patchStyleText(selection, styles);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}, [editor]);
|
|
17
|
+
const onFontColorSelect = useCallback((value) => {
|
|
18
|
+
applyStyleText({ color: value });
|
|
19
|
+
}, [applyStyleText]);
|
|
20
|
+
const onBgColorSelect = useCallback((value) => {
|
|
21
|
+
applyStyleText({ 'background-color': value });
|
|
22
|
+
}, [applyStyleText]);
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx(ColorPicker, { buttonClassName: "popup-item spaced popup-item-color", buttonAriaLabel: "Formatting text color", buttonIconClassName: "iconify", buttonIconData: "mdi:format-color-text", color: fontColor, onChange: onFontColorSelect, title: "text color" }), _jsx(ColorPicker, { buttonClassName: "popup-item spaced popup-item-background", buttonAriaLabel: "Formatting background color", buttonIconClassName: "iconify", buttonIconData: "mdi:format-color-fill", color: bgColor, onChange: onBgColorSelect, title: "bg color" })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
@container blocklet-editor (max-width: 700px) {
|
|
2
|
+
.floating-text-format-popup .popup-item-subscript,
|
|
3
|
+
.floating-text-format-popup .popup-item-superscript,
|
|
4
|
+
.floating-text-format-popup .popup-item-color,
|
|
5
|
+
.floating-text-format-popup .popup-item-background {
|
|
6
|
+
display: none !important;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.floating-text-format-popup {
|
|
11
|
+
display: flex;
|
|
12
|
+
padding: 4px;
|
|
13
|
+
vertical-align: middle;
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
opacity: 0;
|
|
18
|
+
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
transition: opacity 0.5s;
|
|
21
|
+
will-change: transform;
|
|
22
|
+
z-index: 1201;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.floating-text-format-popup button.popup-item {
|
|
26
|
+
border: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
background: none;
|
|
29
|
+
border-radius: 10px;
|
|
30
|
+
padding: 8px;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
vertical-align: middle;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.floating-text-format-popup button.popup-item:disabled {
|
|
36
|
+
cursor: not-allowed;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.floating-text-format-popup button.popup-item.spaced {
|
|
40
|
+
margin-right: 2px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.floating-text-format-popup button.popup-item i.format {
|
|
44
|
+
background-size: contain;
|
|
45
|
+
display: inline-block;
|
|
46
|
+
height: 18px;
|
|
47
|
+
width: 18px;
|
|
48
|
+
margin-top: 2px;
|
|
49
|
+
vertical-align: -0.25em;
|
|
50
|
+
display: flex;
|
|
51
|
+
opacity: 0.6;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.floating-text-format-popup button.popup-item:disabled i.format {
|
|
55
|
+
opacity: 0.2;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.floating-text-format-popup button.popup-item.active i {
|
|
59
|
+
opacity: 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.floating-text-format-popup select.popup-item {
|
|
63
|
+
border: 0;
|
|
64
|
+
display: flex;
|
|
65
|
+
background: none;
|
|
66
|
+
border-radius: 10px;
|
|
67
|
+
padding: 8px;
|
|
68
|
+
vertical-align: middle;
|
|
69
|
+
-webkit-appearance: none;
|
|
70
|
+
-moz-appearance: none;
|
|
71
|
+
width: 70px;
|
|
72
|
+
font-size: 14px;
|
|
73
|
+
color: #777;
|
|
74
|
+
text-overflow: ellipsis;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.floating-text-format-popup select.code-language {
|
|
78
|
+
text-transform: capitalize;
|
|
79
|
+
width: 130px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.floating-text-format-popup .popup-item .text {
|
|
83
|
+
display: flex;
|
|
84
|
+
line-height: 20px;
|
|
85
|
+
width: 200px;
|
|
86
|
+
vertical-align: middle;
|
|
87
|
+
font-size: 14px;
|
|
88
|
+
color: #777;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
width: 70px;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
height: 20px;
|
|
93
|
+
text-align: left;
|
|
94
|
+
margin-left: 8px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.floating-text-format-popup .popup-item .icon {
|
|
98
|
+
display: flex;
|
|
99
|
+
width: 20px;
|
|
100
|
+
height: 20px;
|
|
101
|
+
user-select: none;
|
|
102
|
+
line-height: 16px;
|
|
103
|
+
background-size: contain;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.floating-text-format-popup i.chevron-down {
|
|
107
|
+
margin-top: 3px;
|
|
108
|
+
width: 16px;
|
|
109
|
+
height: 16px;
|
|
110
|
+
display: flex;
|
|
111
|
+
user-select: none;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.floating-text-format-popup i.chevron-down.inside {
|
|
115
|
+
width: 16px;
|
|
116
|
+
height: 16px;
|
|
117
|
+
display: flex;
|
|
118
|
+
margin-left: -25px;
|
|
119
|
+
margin-top: 11px;
|
|
120
|
+
margin-right: 10px;
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.floating-text-format-popup .divider {
|
|
125
|
+
width: 1px;
|
|
126
|
+
background-color: #eee;
|
|
127
|
+
margin: 0 4px;
|
|
128
|
+
}
|
|
@@ -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 { type JSX } from 'react';
|
|
9
|
+
import './index.css';
|
|
10
|
+
export default function FloatingTextFormatToolbarPlugin({ anchorElem, }: {
|
|
11
|
+
anchorElem?: HTMLElement;
|
|
12
|
+
}): JSX.Element | null;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { $isCodeHighlightNode } from '@lexical/code';
|
|
3
|
+
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
4
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
+
import { mergeRegister } from '@lexical/utils';
|
|
6
|
+
import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, } from 'lexical';
|
|
7
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
9
|
+
import { Box } from '@mui/material';
|
|
10
|
+
import { getDOMRangeRect } from '../../utils/getDOMRangeRect';
|
|
11
|
+
import { getSelectedNode } from '../../utils/getSelectedNode';
|
|
12
|
+
import { setFloatingElemPosition } from '../../utils/setFloatingElemPosition';
|
|
13
|
+
import { AideFloatingToolbarButton } from '../../../ext/AIPlugin';
|
|
14
|
+
import './index.css';
|
|
15
|
+
import ColorPickerButton from './ColorPickerButton';
|
|
16
|
+
function TextFormatFloatingToolbar({ editor, anchorElem, isLink, isBold, isItalic, isUnderline, isCode, isStrikethrough, isSubscript, isSuperscript, }) {
|
|
17
|
+
const popupCharStylesEditorRef = useRef(null);
|
|
18
|
+
const insertLink = useCallback(() => {
|
|
19
|
+
if (!isLink) {
|
|
20
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, 'https://');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
24
|
+
}
|
|
25
|
+
}, [editor, isLink]);
|
|
26
|
+
function mouseMoveListener(e) {
|
|
27
|
+
if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {
|
|
28
|
+
popupCharStylesEditorRef.current.style.pointerEvents = 'none';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function mouseUpListener(e) {
|
|
32
|
+
if (popupCharStylesEditorRef?.current) {
|
|
33
|
+
popupCharStylesEditorRef.current.style.pointerEvents = 'auto';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (popupCharStylesEditorRef?.current) {
|
|
38
|
+
document.addEventListener('mousemove', mouseMoveListener);
|
|
39
|
+
document.addEventListener('mouseup', mouseUpListener);
|
|
40
|
+
return () => {
|
|
41
|
+
document.removeEventListener('mousemove', mouseMoveListener);
|
|
42
|
+
document.removeEventListener('mouseup', mouseUpListener);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}, [popupCharStylesEditorRef]);
|
|
46
|
+
const updateTextFormatFloatingToolbar = useCallback(() => {
|
|
47
|
+
const selection = $getSelection();
|
|
48
|
+
const popupCharStylesEditorElem = popupCharStylesEditorRef.current;
|
|
49
|
+
const nativeSelection = window.getSelection();
|
|
50
|
+
if (popupCharStylesEditorElem === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const rootElement = editor.getRootElement();
|
|
54
|
+
if (selection !== null &&
|
|
55
|
+
nativeSelection !== null &&
|
|
56
|
+
!nativeSelection.isCollapsed &&
|
|
57
|
+
rootElement !== null &&
|
|
58
|
+
rootElement.contains(nativeSelection.anchorNode)) {
|
|
59
|
+
const rangeRect = getDOMRangeRect(nativeSelection, rootElement);
|
|
60
|
+
setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem);
|
|
61
|
+
}
|
|
62
|
+
}, [editor, anchorElem]);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const scrollerElem = anchorElem.parentElement;
|
|
65
|
+
const update = () => {
|
|
66
|
+
editor.getEditorState().read(() => {
|
|
67
|
+
updateTextFormatFloatingToolbar();
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
window.addEventListener('resize', update);
|
|
71
|
+
if (scrollerElem) {
|
|
72
|
+
scrollerElem.addEventListener('scroll', update);
|
|
73
|
+
}
|
|
74
|
+
return () => {
|
|
75
|
+
window.removeEventListener('resize', update);
|
|
76
|
+
if (scrollerElem) {
|
|
77
|
+
scrollerElem.removeEventListener('scroll', update);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [editor, updateTextFormatFloatingToolbar, anchorElem]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
editor.getEditorState().read(() => {
|
|
83
|
+
updateTextFormatFloatingToolbar();
|
|
84
|
+
});
|
|
85
|
+
return mergeRegister(editor.registerUpdateListener((payload) => {
|
|
86
|
+
if (!payload)
|
|
87
|
+
return;
|
|
88
|
+
const { editorState } = payload;
|
|
89
|
+
editorState.read(() => {
|
|
90
|
+
updateTextFormatFloatingToolbar();
|
|
91
|
+
});
|
|
92
|
+
}), editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
|
|
93
|
+
updateTextFormatFloatingToolbar();
|
|
94
|
+
return false;
|
|
95
|
+
}, COMMAND_PRIORITY_LOW));
|
|
96
|
+
}, [editor, updateTextFormatFloatingToolbar]);
|
|
97
|
+
return (_jsx(Box, { ref: popupCharStylesEditorRef, className: "floating-text-format-popup", sx: {
|
|
98
|
+
border: 1,
|
|
99
|
+
borderColor: 'divider',
|
|
100
|
+
bgcolor: 'background.default',
|
|
101
|
+
'button.popup-item': {
|
|
102
|
+
height: 28,
|
|
103
|
+
color: 'text.primary',
|
|
104
|
+
},
|
|
105
|
+
'button.popup-item.active': {
|
|
106
|
+
bgcolor: 'action.selected',
|
|
107
|
+
},
|
|
108
|
+
'.popup-item:hover:not([disabled])': {
|
|
109
|
+
bgcolor: 'action.hover',
|
|
110
|
+
},
|
|
111
|
+
'> button': {
|
|
112
|
+
display: 'flex',
|
|
113
|
+
alignItems: 'center',
|
|
114
|
+
justifyContent: 'center',
|
|
115
|
+
'& .iconify': {
|
|
116
|
+
fontSize: 16,
|
|
117
|
+
opacity: 0.6,
|
|
118
|
+
},
|
|
119
|
+
'&.active': {
|
|
120
|
+
'& .iconify': {
|
|
121
|
+
opacity: 1,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
}, children: editor.isEditable() && (_jsxs(_Fragment, { children: [_jsx(AideFloatingToolbarButton, {}), _jsx("button", { onClick: () => {
|
|
126
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');
|
|
127
|
+
}, className: `popup-item spaced ${isBold ? 'active' : ''}`, "aria-label": "Format text as bold", children: _jsx("i", { className: "iconify", "data-icon": "mdi:format-bold" }) }), _jsx("button", { onClick: () => {
|
|
128
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');
|
|
129
|
+
}, className: `popup-item spaced ${isItalic ? 'active' : ''}`, "aria-label": "Format text as italics", children: _jsx("i", { className: "iconify", "data-icon": "mdi:format-italic" }) }), _jsx("button", { onClick: () => {
|
|
130
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline');
|
|
131
|
+
}, className: `popup-item spaced ${isUnderline ? 'active' : ''}`, "aria-label": "Format text to underlined", children: _jsx("i", { className: "iconify", "data-icon": "mdi:format-underline" }) }), _jsx("button", { onClick: () => {
|
|
132
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough');
|
|
133
|
+
}, className: `popup-item spaced popup-item-strikethrough ${isStrikethrough ? 'active' : ''}`, "aria-label": "Format text with a strikethrough", children: _jsx("i", { className: "iconify", "data-icon": "mdi:format-strikethrough-variant" }) }), _jsx("button", { onClick: () => {
|
|
134
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'subscript');
|
|
135
|
+
}, className: `popup-item spaced popup-item-subscript ${isSubscript ? 'active' : ''}`, title: "Subscript", "aria-label": "Format Subscript", children: _jsx("i", { className: "iconify", "data-icon": "mdi:format-subscript" }) }), _jsx("button", { onClick: () => {
|
|
136
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'superscript');
|
|
137
|
+
}, className: `popup-item spaced popup-item-superscript ${isSuperscript ? 'active' : ''}`, title: "Superscript", "aria-label": "Format Superscript", children: _jsx("i", { className: "iconify", "data-icon": "mdi:format-superscript" }) }), _jsx("button", { onClick: () => {
|
|
138
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code');
|
|
139
|
+
}, className: `popup-item spaced ${isCode ? 'active' : ''}`, "aria-label": "Insert code block", children: _jsx("i", { className: "iconify", "data-icon": "mdi:code-tags" }) }), _jsx("button", { onClick: insertLink, className: `popup-item spaced ${isLink ? 'active' : ''}`, "aria-label": "Insert link", children: _jsx("i", { className: "iconify", "data-icon": "mdi:link" }) }), _jsx(ColorPickerButton, { editor: editor })] })) }));
|
|
140
|
+
}
|
|
141
|
+
function useFloatingTextFormatToolbar(editor, anchorElem) {
|
|
142
|
+
const [isText, setIsText] = useState(false);
|
|
143
|
+
const [isLink, setIsLink] = useState(false);
|
|
144
|
+
const [isBold, setIsBold] = useState(false);
|
|
145
|
+
const [isItalic, setIsItalic] = useState(false);
|
|
146
|
+
const [isUnderline, setIsUnderline] = useState(false);
|
|
147
|
+
const [isStrikethrough, setIsStrikethrough] = useState(false);
|
|
148
|
+
const [isSubscript, setIsSubscript] = useState(false);
|
|
149
|
+
const [isSuperscript, setIsSuperscript] = useState(false);
|
|
150
|
+
const [isCode, setIsCode] = useState(false);
|
|
151
|
+
const updatePopup = useCallback(() => {
|
|
152
|
+
editor.getEditorState().read(() => {
|
|
153
|
+
// Should not to pop up the floating toolbar when using IME input
|
|
154
|
+
if (editor.isComposing()) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const selection = $getSelection();
|
|
158
|
+
const nativeSelection = window.getSelection();
|
|
159
|
+
const rootElement = editor.getRootElement();
|
|
160
|
+
if (nativeSelection !== null &&
|
|
161
|
+
(!$isRangeSelection(selection) || rootElement === null || !rootElement.contains(nativeSelection.anchorNode))) {
|
|
162
|
+
setIsText(false);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (!$isRangeSelection(selection)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const node = getSelectedNode(selection);
|
|
169
|
+
// Update text format
|
|
170
|
+
setIsBold(selection.hasFormat('bold'));
|
|
171
|
+
setIsItalic(selection.hasFormat('italic'));
|
|
172
|
+
setIsUnderline(selection.hasFormat('underline'));
|
|
173
|
+
setIsStrikethrough(selection.hasFormat('strikethrough'));
|
|
174
|
+
setIsSubscript(selection.hasFormat('subscript'));
|
|
175
|
+
setIsSuperscript(selection.hasFormat('superscript'));
|
|
176
|
+
setIsCode(selection.hasFormat('code'));
|
|
177
|
+
// Update links
|
|
178
|
+
const parent = node.getParent();
|
|
179
|
+
if ($isLinkNode(parent) || $isLinkNode(node)) {
|
|
180
|
+
setIsLink(true);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
setIsLink(false);
|
|
184
|
+
}
|
|
185
|
+
if (!$isCodeHighlightNode(selection.anchor.getNode()) && selection.getTextContent() !== '') {
|
|
186
|
+
setIsText($isTextNode(node));
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
setIsText(false);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}, [editor]);
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
document.addEventListener('selectionchange', updatePopup);
|
|
195
|
+
return () => {
|
|
196
|
+
document.removeEventListener('selectionchange', updatePopup);
|
|
197
|
+
};
|
|
198
|
+
}, [updatePopup]);
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
return mergeRegister(editor.registerUpdateListener(() => {
|
|
201
|
+
updatePopup();
|
|
202
|
+
}), editor.registerRootListener(() => {
|
|
203
|
+
if (editor.getRootElement() === null) {
|
|
204
|
+
setIsText(false);
|
|
205
|
+
}
|
|
206
|
+
}));
|
|
207
|
+
}, [editor, updatePopup]);
|
|
208
|
+
if (!isText || isLink) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
return createPortal(_jsx(TextFormatFloatingToolbar, { editor: editor, anchorElem: anchorElem, isLink: isLink, isBold: isBold, isItalic: isItalic, isStrikethrough: isStrikethrough, isSubscript: isSubscript, isSuperscript: isSuperscript, isUnderline: isUnderline, isCode: isCode }), anchorElem);
|
|
212
|
+
}
|
|
213
|
+
export default function FloatingTextFormatToolbarPlugin({ anchorElem = document.body, }) {
|
|
214
|
+
const [editor] = useLexicalComposerContext();
|
|
215
|
+
return useFloatingTextFormatToolbar(editor, anchorElem);
|
|
216
|
+
}
|
|
@@ -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 { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
+
import { $createHorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
10
|
+
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
11
|
+
import { useEffect } from 'react';
|
|
12
|
+
export default function HorizontalRulePlugin() {
|
|
13
|
+
const [editor] = useLexicalComposerContext();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
return editor.registerCommand(INSERT_HORIZONTAL_RULE_COMMAND, (type) => {
|
|
16
|
+
const selection = $getSelection();
|
|
17
|
+
if (!$isRangeSelection(selection)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const focusNode = selection.focus.getNode();
|
|
21
|
+
if (focusNode !== null) {
|
|
22
|
+
const horizontalRuleNode = $createHorizontalRuleNode();
|
|
23
|
+
selection.insertParagraph();
|
|
24
|
+
selection.focus.getNode().getTopLevelElementOrThrow().insertBefore(horizontalRuleNode);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
28
|
+
}, [editor]);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LexicalCommand } from 'lexical';
|
|
2
|
+
import { type JSX } from 'react';
|
|
3
|
+
import { ImagePayload } from '../../nodes/ImageNode';
|
|
4
|
+
export type InsertImagePayload = Readonly<ImagePayload>;
|
|
5
|
+
export declare const INSERT_IMAGE_COMMAND: LexicalCommand<InsertImagePayload>;
|
|
6
|
+
export default function ImagesPlugin({ captionsEnabled }: {
|
|
7
|
+
captionsEnabled?: boolean;
|
|
8
|
+
}): JSX.Element | null;
|
|
9
|
+
declare global {
|
|
10
|
+
interface DragEvent {
|
|
11
|
+
rangeOffset?: number;
|
|
12
|
+
rangeParent?: Node;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare const isImage: (src: string) => boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
+
import { mergeRegister } from '@lexical/utils';
|
|
10
|
+
import { $createParagraphNode, $insertNodes, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
11
|
+
import { useEffect } from 'react';
|
|
12
|
+
import { $createImageNode, ImageNode } from '../../nodes/ImageNode';
|
|
13
|
+
export const INSERT_IMAGE_COMMAND = createCommand('INSERT_IMAGE_COMMAND');
|
|
14
|
+
export default function ImagesPlugin({ captionsEnabled }) {
|
|
15
|
+
const [editor] = useLexicalComposerContext();
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!editor.hasNodes([ImageNode])) {
|
|
18
|
+
throw new Error('ImagesPlugin: ImageNode not registered on editor');
|
|
19
|
+
}
|
|
20
|
+
return mergeRegister(editor.registerCommand(INSERT_IMAGE_COMMAND, (payload) => {
|
|
21
|
+
const imageNode = $createImageNode(payload);
|
|
22
|
+
// 插入段落再插入图片, 确保图片独自占一行 (#2505)
|
|
23
|
+
const p = $createParagraphNode();
|
|
24
|
+
$insertNodes([p, imageNode, $createParagraphNode()]);
|
|
25
|
+
p.remove();
|
|
26
|
+
return true;
|
|
27
|
+
}, COMMAND_PRIORITY_EDITOR));
|
|
28
|
+
}, [captionsEnabled, editor]);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const TRANSPARENT_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
|
32
|
+
const img = document.createElement('img');
|
|
33
|
+
img.src = TRANSPARENT_IMAGE;
|
|
34
|
+
export const isImage = (src) => {
|
|
35
|
+
return /\.(jpg|jpeg|png|gif|bmp|svg|webp|ico|tiff|tif|raw)$/i.test(src);
|
|
36
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { LexicalCommand, LexicalEditor, NodeKey, TextNode } from 'lexical';
|
|
9
|
+
import { MutableRefObject, ReactPortal, type JSX } from 'react';
|
|
10
|
+
export type QueryMatch = {
|
|
11
|
+
leadOffset: number;
|
|
12
|
+
matchingString: string;
|
|
13
|
+
replaceableString: string;
|
|
14
|
+
};
|
|
15
|
+
export type Resolution = {
|
|
16
|
+
match: QueryMatch;
|
|
17
|
+
getRect: () => DOMRect;
|
|
18
|
+
};
|
|
19
|
+
export declare const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
|
|
20
|
+
export declare class TypeaheadOption {
|
|
21
|
+
key: string;
|
|
22
|
+
ref?: MutableRefObject<HTMLElement | null>;
|
|
23
|
+
constructor(key: string);
|
|
24
|
+
setRefElement(element: HTMLElement | null): void;
|
|
25
|
+
}
|
|
26
|
+
export type MenuRenderFn<TOption extends TypeaheadOption> = (anchorElementRef: MutableRefObject<HTMLElement | null>, itemProps: {
|
|
27
|
+
selectedIndex: number | null;
|
|
28
|
+
selectOptionAndCleanUp: (option: TOption) => void;
|
|
29
|
+
setHighlightedIndex: (index: number) => void;
|
|
30
|
+
options: Array<TOption>;
|
|
31
|
+
}, matchingString: string) => ReactPortal | JSX.Element | null;
|
|
32
|
+
export declare function getScrollParent(element: HTMLElement, includeHidden: boolean): HTMLElement | HTMLBodyElement;
|
|
33
|
+
export declare function useDynamicPositioning(resolution: Resolution | null, targetElement: HTMLElement | null, onReposition: () => void, onVisibilityChange?: (isInView: boolean) => void): void;
|
|
34
|
+
export declare const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{
|
|
35
|
+
index: number;
|
|
36
|
+
option: TypeaheadOption;
|
|
37
|
+
}>;
|
|
38
|
+
export declare function useBasicTypeaheadTriggerMatch(trigger: string, { minLength, maxLength }: {
|
|
39
|
+
minLength?: number;
|
|
40
|
+
maxLength?: number;
|
|
41
|
+
}): TriggerFn;
|
|
42
|
+
export type TypeaheadMenuPluginProps<TOption extends TypeaheadOption> = {
|
|
43
|
+
onQueryChange: (matchingString: string | null) => void;
|
|
44
|
+
onSelectOption: (option: TOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
|
|
45
|
+
options: Array<TOption>;
|
|
46
|
+
menuRenderFn: MenuRenderFn<TOption>;
|
|
47
|
+
triggerFn: TriggerFn;
|
|
48
|
+
onOpen?: (resolution: Resolution) => void;
|
|
49
|
+
onClose?: () => void;
|
|
50
|
+
anchorClassName?: string;
|
|
51
|
+
};
|
|
52
|
+
export type TriggerFn = (text: string, editor: LexicalEditor) => QueryMatch | null;
|
|
53
|
+
export declare function LexicalTypeaheadMenuPlugin<TOption extends TypeaheadOption>({ options, onQueryChange, onSelectOption, onOpen, onClose, menuRenderFn, triggerFn, anchorClassName, }: TypeaheadMenuPluginProps<TOption>): JSX.Element | null;
|
|
54
|
+
type NodeMenuPluginProps<TOption extends TypeaheadOption> = {
|
|
55
|
+
onSelectOption: (option: TOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
|
|
56
|
+
options: Array<TOption>;
|
|
57
|
+
nodeKey: NodeKey | null;
|
|
58
|
+
onClose?: () => void;
|
|
59
|
+
onOpen?: (resolution: Resolution) => void;
|
|
60
|
+
menuRenderFn: MenuRenderFn<TOption>;
|
|
61
|
+
anchorClassName?: string;
|
|
62
|
+
};
|
|
63
|
+
export declare function LexicalNodeMenuPlugin<TOption extends TypeaheadOption>({ options, nodeKey, onClose, onOpen, onSelectOption, menuRenderFn, anchorClassName, }: NodeMenuPluginProps<TOption>): JSX.Element | null;
|
|
64
|
+
export {};
|