@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
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2018-2020 ArcBlock
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @blocklet/editor
|
|
2
|
+
|
|
3
|
+
Rich editor powered by lexical.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn add @blocklet/editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Start playground for dev
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
yarn insall
|
|
15
|
+
|
|
16
|
+
cd packages/editor
|
|
17
|
+
|
|
18
|
+
yarn dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Version
|
|
22
|
+
|
|
23
|
+
If you have changed the code of this package and want to publish a new
|
|
24
|
+
version on npm, do the following:
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
# run in packages/editor
|
|
28
|
+
yarn bump-version
|
|
29
|
+
# or run in any where of workspace
|
|
30
|
+
yarn workspace @blocklet/editor run bump-version
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then modify CHANGELOG.md and add commit push changed files.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EditorViewerProps } from './main/viewer/types';
|
|
2
|
+
export declare const BlockletEditorViewer: import("react-lazy-with-preload").PreloadableComponent<typeof import("./main/viewer").BlockletEditorViewer>;
|
|
3
|
+
export declare const useBlockletEditorViewerLoaded: () => boolean;
|
|
4
|
+
export type { EditorViewerProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { lazyWithPreload } from 'react-lazy-with-preload';
|
|
3
|
+
export const BlockletEditorViewer = lazyWithPreload(() => import('./main/viewer').then((m) => ({ default: m.BlockletEditorViewer })));
|
|
4
|
+
export const useBlockletEditorViewerLoaded = () => {
|
|
5
|
+
const [loaded, setLoaded] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
BlockletEditorViewer.preload().then(() => {
|
|
8
|
+
setLoaded(true);
|
|
9
|
+
});
|
|
10
|
+
}, []);
|
|
11
|
+
return loaded;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { lazyWithPreload } from 'react-lazy-with-preload';
|
|
3
|
+
export const BlockletEditor = lazyWithPreload(() => import('./main'));
|
|
4
|
+
export const useBlockletEditorLoaded = () => {
|
|
5
|
+
const [loaded, setLoaded] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
BlockletEditor.preload().then(() => {
|
|
8
|
+
setLoaded(true);
|
|
9
|
+
});
|
|
10
|
+
}, []);
|
|
11
|
+
return loaded;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
export default function Loading({ ...rest }) {
|
|
4
|
+
return (_jsx(Root, { className: "global-loading", ...rest, children: _jsx("span", {}) }));
|
|
5
|
+
}
|
|
6
|
+
const Root = styled.div `
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
height: 36px;
|
|
10
|
+
padding-left: 16px;
|
|
11
|
+
background-color: #d5e1ec;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RangeSelection } from 'lexical';
|
|
2
|
+
import { BoxProps } from '@mui/material';
|
|
3
|
+
interface CommonProps {
|
|
4
|
+
placement?: 'right' | 'bottom-start';
|
|
5
|
+
}
|
|
6
|
+
interface SelectionPopperProps extends CommonProps, BoxProps {
|
|
7
|
+
selection: RangeSelection | null | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface CursorPopperProps extends CommonProps, BoxProps {
|
|
10
|
+
range: Range | null | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function SelectionPopper({ selection, placement, children, ...rest }: SelectionPopperProps): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
export declare function CursorPopper({ range, placement, children, ...rest }: CursorPopperProps): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { createDOMRange } from '@lexical/selection';
|
|
4
|
+
import { $isRangeSelection } from 'lexical';
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { usePopper } from 'react-popper';
|
|
7
|
+
import { Box } from '@mui/material';
|
|
8
|
+
const getRange = (editor, selection) => {
|
|
9
|
+
return editor.getEditorState().read(() => {
|
|
10
|
+
if (!$isRangeSelection(selection)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const { anchor } = selection;
|
|
14
|
+
const { focus } = selection;
|
|
15
|
+
const range = createDOMRange(editor, anchor.getNode(), anchor.offset, focus.getNode(), focus.offset);
|
|
16
|
+
return range;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
function InternalRangePopper({ range, placement, children, sx, ...rest }) {
|
|
20
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
21
|
+
function generateGetBoundingClientRect(x = 0, y = 0) {
|
|
22
|
+
return () => range.getBoundingClientRect();
|
|
23
|
+
}
|
|
24
|
+
const virtualElement = useMemo(() => {
|
|
25
|
+
return {
|
|
26
|
+
getBoundingClientRect: generateGetBoundingClientRect(),
|
|
27
|
+
};
|
|
28
|
+
}, [range]);
|
|
29
|
+
const { update, styles, attributes } = usePopper(virtualElement, popperElement, {
|
|
30
|
+
placement,
|
|
31
|
+
modifiers: [
|
|
32
|
+
{
|
|
33
|
+
name: 'offset',
|
|
34
|
+
options: {
|
|
35
|
+
offset: [0, 8],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
// FIXME: 临时处理 ".be-editable" 元素为滚动容器时, popper 随滚动飘移的问题
|
|
41
|
+
// https://github.com/blocklet/discuss-kit/issues/591
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const _update = () => update?.();
|
|
44
|
+
const editableElement = document.querySelector('.be-editable');
|
|
45
|
+
editableElement?.addEventListener('scroll', _update);
|
|
46
|
+
return () => {
|
|
47
|
+
editableElement?.removeEventListener('scroll', _update);
|
|
48
|
+
};
|
|
49
|
+
}, [update]);
|
|
50
|
+
// zIndex 需要小于 editor toolbar 的 10
|
|
51
|
+
const mergedSx = [{ zIndex: 9 }, ...(Array.isArray(sx) ? sx : [sx])];
|
|
52
|
+
return (_jsx(Box, { ref: setPopperElement, style: styles.popper, ...attributes.popper, sx: mergedSx, ...rest, children: children }));
|
|
53
|
+
}
|
|
54
|
+
export function SelectionPopper({ selection, placement = 'bottom-start', children, ...rest }) {
|
|
55
|
+
const [editor] = useLexicalComposerContext();
|
|
56
|
+
let range = null;
|
|
57
|
+
try {
|
|
58
|
+
range = getRange(editor, selection);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
// ignore error
|
|
62
|
+
}
|
|
63
|
+
if (!range) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return (_jsx(InternalRangePopper, { range: range, placement: placement, ...rest, children: children }));
|
|
67
|
+
}
|
|
68
|
+
export function CursorPopper({ range, placement = 'right', children, ...rest }) {
|
|
69
|
+
if (!range || !range.collapsed) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return (_jsx(InternalRangePopper, { range: range, placement: placement, ...rest, children: children }));
|
|
73
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { css } from '@emotion/css';
|
|
3
|
+
export default function AnimateText({ sentence }) {
|
|
4
|
+
const chars = sentence?.replace(/ /g, '\u00A0').split('');
|
|
5
|
+
return (_jsx("div", { className: animation, children: chars?.map((char, i) => (
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
_jsx("span", { style: { '--i': i }, children: char === '\u00A0' ? '\u00A0' : char }, `text-${char}`))) }));
|
|
8
|
+
}
|
|
9
|
+
const animation = css `
|
|
10
|
+
span {
|
|
11
|
+
animation: zoomup 1.2s ease-in-out infinite;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
animation-delay: calc(100ms * var(--i));
|
|
14
|
+
padding-right: 1px;
|
|
15
|
+
}
|
|
16
|
+
@keyframes zoomup {
|
|
17
|
+
0%,
|
|
18
|
+
100% {
|
|
19
|
+
transform: translateY(0);
|
|
20
|
+
}
|
|
21
|
+
25%,
|
|
22
|
+
75% {
|
|
23
|
+
transform: translateY(-1px);
|
|
24
|
+
}
|
|
25
|
+
50% {
|
|
26
|
+
transform: translateY(1px);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { usePopper } from 'react-popper';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
const CreatePopperElement = ({ portalElement, parentElement, }) => {
|
|
6
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
7
|
+
const { styles, attributes } = usePopper(parentElement, popperElement, {
|
|
8
|
+
placement: 'bottom-start',
|
|
9
|
+
strategy: 'fixed',
|
|
10
|
+
});
|
|
11
|
+
return (_jsx("div", { ref: setPopperElement, style: { ...styles.popper, zIndex: 1 }, ...attributes.popper, children: portalElement }));
|
|
12
|
+
};
|
|
13
|
+
const createPortal = (portalElement, parentElement) => {
|
|
14
|
+
return ReactDOM.createPortal(_jsx(CreatePopperElement, { portalElement: portalElement, parentElement: parentElement }), parentElement);
|
|
15
|
+
};
|
|
16
|
+
export default createPortal;
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SxProps } from '@mui/material';
|
|
3
|
+
import { AI, UserService } from './types';
|
|
4
|
+
export type ToolbarConfigItem = 'component' | 'block' | 'align' | 'font-family' | 'font-size' | 'bold' | 'italic' | 'underline' | 'code' | 'link' | 'image' | 'color' | 'bgcolor' | 'strikethrough' | 'media' | 'alert';
|
|
5
|
+
export interface ToolbarConfig {
|
|
6
|
+
items?: ToolbarConfigItem[];
|
|
7
|
+
}
|
|
8
|
+
export interface Uploader {
|
|
9
|
+
upload?: (file: Blob) => Promise<{
|
|
10
|
+
url: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export interface CharacterLimitConfig {
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
indicatorStyle?: SxProps;
|
|
16
|
+
alignLeft?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface EditorConfig {
|
|
19
|
+
toolbar?: ToolbarConfig;
|
|
20
|
+
uploader?: Uploader;
|
|
21
|
+
userService?: UserService;
|
|
22
|
+
blockletEmbedEndpoint?: string;
|
|
23
|
+
openGraphEndpoint?: string;
|
|
24
|
+
AI?: AI;
|
|
25
|
+
templatePlugin?: any;
|
|
26
|
+
minimalMode?: boolean;
|
|
27
|
+
openLinkInNewTab?: boolean;
|
|
28
|
+
characterLimitConfig?: CharacterLimitConfig;
|
|
29
|
+
simpleImageComponent?: boolean;
|
|
30
|
+
enableSafeAreaPlugin?: boolean;
|
|
31
|
+
maxContentWidth?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function EditorConfigProvider({ children, value }: {
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
value: EditorConfig;
|
|
36
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare const useEditorConfig: () => EditorConfig;
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
const EditorConfigContext = createContext({});
|
|
4
|
+
export function EditorConfigProvider({ children, value }) {
|
|
5
|
+
const parentCtx = useContext(EditorConfigContext);
|
|
6
|
+
const _value = useMemo(() => {
|
|
7
|
+
const result = { ...parentCtx, ...value };
|
|
8
|
+
return result;
|
|
9
|
+
}, [value, parentCtx]);
|
|
10
|
+
return _jsx(EditorConfigContext.Provider, { value: _value, children: children });
|
|
11
|
+
}
|
|
12
|
+
export const useEditorConfig = () => useContext(EditorConfigContext);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
const AIKitIcon = ({ disabled = false }) => {
|
|
4
|
+
const id = useId();
|
|
5
|
+
return (_jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: { flex: '0 0 auto' }, children: [_jsxs("mask", { id: "mask0_1302_392", maskUnits: "userSpaceOnUse", x: "0", y: "1", width: "20", height: "18", children: [_jsx("path", { d: "M15.4167 7.5H4.58333C4.1231 7.5 3.75 7.8731 3.75 8.33333V16.6667C3.75 17.1269 4.1231 17.5 4.58333 17.5H15.4167C15.8769 17.5 16.25 17.1269 16.25 16.6667V8.33333C16.25 7.8731 15.8769 7.5 15.4167 7.5Z", fill: "white" }), _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2.91663 8.33333C2.91663 7.41286 3.66282 6.66666 4.58329 6.66666H15.4166C16.3371 6.66666 17.0833 7.41286 17.0833 8.33333V16.6667C17.0833 17.5871 16.3371 18.3333 15.4166 18.3333H4.58329C3.66282 18.3333 2.91663 17.5871 2.91663 16.6667V8.33333ZM15.4166 8.33333H4.58329V16.6667H15.4166V8.33333Z", fill: "white" }), _jsx("path", { d: "M7.08333 11.6667C7.54357 11.6667 7.91667 11.2936 7.91667 10.8333C7.91667 10.3731 7.54357 10 7.08333 10C6.6231 10 6.25 10.3731 6.25 10.8333C6.25 11.2936 6.6231 11.6667 7.08333 11.6667Z", fill: "black" }), _jsx("path", { d: "M12.9166 11.6667C13.3769 11.6667 13.75 11.2936 13.75 10.8333C13.75 10.3731 13.3769 10 12.9166 10C12.4564 10 12.0833 10.3731 12.0833 10.8333C12.0833 11.2936 12.4564 11.6667 12.9166 11.6667Z", fill: "black" }), _jsx("path", { d: "M8.33333 13.3333C8.11232 13.3333 7.90036 13.4211 7.74408 13.5774C7.5878 13.7337 7.5 13.9456 7.5 14.1667C7.5 14.3877 7.5878 14.5996 7.74408 14.7559C7.90036 14.9122 8.11232 15 8.33333 15V13.3333ZM11.6667 15C11.8877 15 12.0996 14.9122 12.2559 14.7559C12.4122 14.5996 12.5 14.3877 12.5 14.1667C12.5 13.9456 12.4122 13.7337 12.2559 13.5774C12.0996 13.4211 11.8877 13.3333 11.6667 13.3333V15ZM8.33333 15H11.6667V13.3333H8.33333V15Z", fill: "black" }), _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9.99998 3.33333C10.4602 3.33333 10.8333 3.70642 10.8333 4.16666V7.5C10.8333 7.96023 10.4602 8.33333 9.99998 8.33333C9.53974 8.33333 9.16665 7.96023 9.16665 7.5V4.16666C9.16665 3.70642 9.53974 3.33333 9.99998 3.33333ZM1.66665 10C2.12688 10 2.49998 10.3731 2.49998 10.8333V14.1667C2.49998 14.6269 2.12688 15 1.66665 15C1.20641 15 0.833313 14.6269 0.833313 14.1667V10.8333C0.833313 10.3731 1.20641 10 1.66665 10ZM18.3333 10C18.7936 10 19.1666 10.3731 19.1666 10.8333V14.1667C19.1666 14.6269 18.7936 15 18.3333 15C17.8731 15 17.5 14.6269 17.5 14.1667V10.8333C17.5 10.3731 17.8731 10 18.3333 10Z", fill: "white" }), _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M8.33331 3.33333C8.33331 2.41286 9.07951 1.66666 9.99998 1.66666C10.9205 1.66666 11.6666 2.41286 11.6666 3.33333C11.6666 4.25381 10.9205 5 9.99998 5C9.07951 5 8.33331 4.25381 8.33331 3.33333Z", fill: "white" })] }), _jsx("g", { mask: "url(#mask0_1302_392)", children: _jsx("path", { d: "M0 0H20V20H0V0Z", fill: `url(#${id})` }) }), _jsx("defs", { children: _jsxs("linearGradient", { id: id, x1: "9.99983", y1: "19.7225", x2: "9.99983", y2: "0.278048", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: disabled ? 'currentColor' : '#45E4FA' }), _jsx("stop", { offset: "1", stopColor: disabled ? 'currentColor' : '#8A45FA' })] }) })] }));
|
|
6
|
+
};
|
|
7
|
+
export default AIKitIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Arrow(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
export default function Arrow() {
|
|
4
|
+
return (_jsx(Box, { sx: { display: 'inline-flex', alignItems: 'center', cursor: 'pointer', opacity: 0.5, '&:hover': { opacity: 1 } }, children: _jsxs("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: { width: 14, height: 14 }, children: [_jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M1.80002 8.10001C1.30297 8.10001 0.900024 8.50296 0.900024 9.00001C0.900024 9.49707 1.30297 9.90001 1.80002 9.90001H14.0272L9.26364 14.6636C8.91217 15.0151 8.91217 15.5849 9.26364 15.9364C9.61511 16.2879 10.185 16.2879 10.5364 15.9364L16.8347 9.6381C16.8399 9.63295 16.845 9.62773 16.8501 9.62246C16.93 9.53902 16.9908 9.44398 17.0324 9.3429C17.0704 9.25074 17.0936 9.15089 17.0989 9.04633C17.0996 9.03099 17.1 9.01555 17.1 9.00001C17.1 8.99036 17.0999 8.98069 17.0996 8.97104C17.0962 8.86341 17.0739 8.76055 17.0359 8.66566C16.9919 8.5557 16.9255 8.45264 16.8364 8.36361L10.5364 2.06361C10.185 1.71213 9.61511 1.71213 9.26364 2.06361C8.91217 2.41508 8.91217 2.98493 9.26364 3.3364L14.0273 8.10001H1.80002Z", fill: "url(#paint0_linear_1302_347)" }), _jsx("defs", { children: _jsxs("linearGradient", { id: "paint0_linear_1302_347", x1: "16.8752", y1: "9.00012", x2: "1.12524", y2: "9.00012", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: "#45E4FA" }), _jsx("stop", { offset: "1", stopColor: "#8A45FA" })] }) })] }) }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
+
import { useGetState } from 'ahooks';
|
|
6
|
+
import { useAideContext } from '../Aide';
|
|
7
|
+
import { insert, getParagraphText } from './utils';
|
|
8
|
+
import { useIsFocused } from '../../main/hooks/useIsFocused';
|
|
9
|
+
import { withAiAvailable } from '../Aide/withAiAvailable';
|
|
10
|
+
import Arrow from './Arrow';
|
|
11
|
+
import Writing from './Writing';
|
|
12
|
+
import Delayed from '../Aide/Delayed';
|
|
13
|
+
import { CursorPopper } from '../../components/SelectionPopper';
|
|
14
|
+
function TextGeneration() {
|
|
15
|
+
const [editor] = useLexicalComposerContext();
|
|
16
|
+
const hasFocused = useIsFocused();
|
|
17
|
+
const { completions } = useAideContext();
|
|
18
|
+
const [state, setState, getState] = useGetState({
|
|
19
|
+
status: 'initial',
|
|
20
|
+
range: null,
|
|
21
|
+
counter: 1,
|
|
22
|
+
});
|
|
23
|
+
const reset = () => {
|
|
24
|
+
if (getState().status !== 'initial') {
|
|
25
|
+
setState((prev) => ({ ...prev, status: 'initial', range: null }));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const activate = () => {
|
|
29
|
+
setState((prev) => ({
|
|
30
|
+
...prev,
|
|
31
|
+
status: 'activated',
|
|
32
|
+
range: document.getSelection()?.getRangeAt(0)?.cloneRange(),
|
|
33
|
+
counter: prev.counter + 1,
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
const continueWriting = async () => {
|
|
37
|
+
setState((prev) => ({ ...prev, status: 'waiting' }));
|
|
38
|
+
const seedText = getParagraphText(editor);
|
|
39
|
+
const output = await completions(`Generate subsequent content based on input, keeping it within two to three sentences and no more than 60 words. The input is: ${seedText}`);
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
41
|
+
const state = getState();
|
|
42
|
+
if (state.status === 'waiting' && state.range) {
|
|
43
|
+
insert(editor, state.range, output?.trim()?.replace(/\s+/g, ' '));
|
|
44
|
+
setState((prev) => ({ ...prev, status: 'initial' }));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
// 通过 Selection/Range API 判断是选区还是停留光标 (isCollapsed),
|
|
48
|
+
// 对于后者, 如果光标前面有文本且后面无文本, 则调用 activate 显示补全文本的箭头, 否则重置 (隐藏箭头)
|
|
49
|
+
const update = () => {
|
|
50
|
+
const selection = document.getSelection();
|
|
51
|
+
if (selection?.anchorNode?.nodeType === Node.TEXT_NODE) {
|
|
52
|
+
const range = selection.getRangeAt(0);
|
|
53
|
+
const hasTextBeforeCursor = range.endContainer.textContent?.trim();
|
|
54
|
+
const hasTextAfterCursor = range.endContainer.textContent && range.endContainer.textContent.length > range.endOffset;
|
|
55
|
+
if (selection?.isCollapsed && hasTextBeforeCursor && !hasTextAfterCursor) {
|
|
56
|
+
reset();
|
|
57
|
+
activate();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
reset();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
reset();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
// 监听 editor 输入
|
|
69
|
+
return editor.registerUpdateListener(update);
|
|
70
|
+
}, [editor]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
// editor 失去焦点时重置状态 (隐藏补全文本的箭头)
|
|
73
|
+
if (!hasFocused) {
|
|
74
|
+
reset();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
update();
|
|
78
|
+
}
|
|
79
|
+
}, [hasFocused]);
|
|
80
|
+
// shortcut: ctrl+k
|
|
81
|
+
// useEffect(() => {
|
|
82
|
+
// return editor.registerCommand<KeyboardEvent>(
|
|
83
|
+
// KEY_DOWN_COMMAND,
|
|
84
|
+
// (e) => {
|
|
85
|
+
// if ((e.metaKey || e.ctrlKey) && e.key === 'k' && getState().status === 'activated') {
|
|
86
|
+
// continueWriting();
|
|
87
|
+
// return true;
|
|
88
|
+
// }
|
|
89
|
+
// return false;
|
|
90
|
+
// },
|
|
91
|
+
// COMMAND_PRIORITY_EDITOR
|
|
92
|
+
// );
|
|
93
|
+
// }, [editor]);
|
|
94
|
+
const rangeRect = state.range?.getBoundingClientRect();
|
|
95
|
+
// 使用 onMouseDown & preventDefault 避免点击时 editor 失去焦点且不触发事件处理,
|
|
96
|
+
// https://github.com/facebook/lexical/issues/3998
|
|
97
|
+
const handleClick = (e) => {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
continueWriting();
|
|
100
|
+
};
|
|
101
|
+
if (hasFocused && (state.status === 'activated' || state.status === 'waiting') && !!rangeRect) {
|
|
102
|
+
return (_jsx(CursorPopper, { range: state.range, sx: { display: 'flex', alignItems: 'center', height: rangeRect.height }, children: _jsxs(Box, { onMouseDown: handleClick, sx: {
|
|
103
|
+
display: 'inline-flex',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
'&:hover': { color: 'primary.light' },
|
|
106
|
+
}, children: [state.status === 'activated' && (_jsx(Delayed, { delay: 1200, children: _jsxs(Box, { sx: {
|
|
107
|
+
display: 'inline-flex',
|
|
108
|
+
position: 'relative',
|
|
109
|
+
color: 'grey.500',
|
|
110
|
+
'&:hover .text-generation-arrow-label': { display: 'inline-flex' },
|
|
111
|
+
}, children: [_jsx(Arrow, {}), _jsx(Box, { className: "text-generation-arrow-label", sx: {
|
|
112
|
+
display: 'none',
|
|
113
|
+
alignItems: 'center',
|
|
114
|
+
gap: 1,
|
|
115
|
+
position: 'absolute',
|
|
116
|
+
top: 24,
|
|
117
|
+
left: 0,
|
|
118
|
+
transform: 'translateX(-50%)',
|
|
119
|
+
px: 1,
|
|
120
|
+
py: 0.5,
|
|
121
|
+
color: '#fff',
|
|
122
|
+
fontSize: 13,
|
|
123
|
+
fontWeight: 'bold',
|
|
124
|
+
whiteSpace: 'nowrap',
|
|
125
|
+
borderRadius: 1,
|
|
126
|
+
bgcolor: 'grey.600',
|
|
127
|
+
}, children: _jsx("span", { children: "Continue writing with AI Kit " }) })] }) }, state.counter)), state.status === 'waiting' && _jsx(Writing, {})] }) }));
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
export default withAiAvailable(TextGeneration);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Writing(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import AnimateText from '../../components/animateText';
|
|
4
|
+
import AIKitIcon from './AIIcon';
|
|
5
|
+
export default function Writing() {
|
|
6
|
+
return (_jsxs(Box, { sx: { display: 'inline-flex', alignItems: 'center', gap: 0.5 }, children: [_jsx(AIKitIcon, { disabled: true }), _jsx(Box, { sx: { flex: '0 0 auto', fontSize: 14, fontWeight: 'bold', color: '#4598fa' }, children: _jsx(AnimateText, { sentence: "AI Kit is writing ..." }) })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LexicalCommand } from 'lexical';
|
|
2
|
+
import { Mode } from '../Aide/types';
|
|
3
|
+
export declare const ACTIVATE_AI_COMMAND: LexicalCommand<Mode>;
|
|
4
|
+
export declare const AI_TEMPLATES_AVAILABLE_COMMAND: LexicalCommand<boolean>;
|
|
5
|
+
export declare function AideFloatingToolbarButton({ onClick }: {
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function AideToolbarButton(): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default function AidePluginWrapper(): import("react/jsx-runtime").JSX.Element | null;
|