@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,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
const Context = createContext([(_cb) => () => { }, (_newSuggestion) => { }]);
|
|
4
|
+
export function SharedAutocompleteContext({ children }) {
|
|
5
|
+
const context = useMemo(() => {
|
|
6
|
+
let suggestion = null;
|
|
7
|
+
const listeners = new Set();
|
|
8
|
+
return [
|
|
9
|
+
(cb) => {
|
|
10
|
+
cb(suggestion);
|
|
11
|
+
listeners.add(cb);
|
|
12
|
+
return () => {
|
|
13
|
+
listeners.delete(cb);
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
(newSuggestion) => {
|
|
17
|
+
suggestion = newSuggestion;
|
|
18
|
+
for (const listener of listeners) {
|
|
19
|
+
listener(newSuggestion);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
}, []);
|
|
24
|
+
return _jsx(Context.Provider, { value: context, children: children });
|
|
25
|
+
}
|
|
26
|
+
export const useSharedAutocompleteContext = () => {
|
|
27
|
+
const [subscribe, publish] = useContext(Context);
|
|
28
|
+
const [suggestion, setSuggestion] = useState(null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
return subscribe((newSuggestion) => {
|
|
31
|
+
setSuggestion(newSuggestion);
|
|
32
|
+
});
|
|
33
|
+
}, [subscribe]);
|
|
34
|
+
return [suggestion, publish];
|
|
35
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { ReactNode, type JSX } from 'react';
|
|
9
|
+
import type { HistoryState } from '../../vendor/history/history';
|
|
10
|
+
type ContextShape = {
|
|
11
|
+
historyState?: HistoryState;
|
|
12
|
+
};
|
|
13
|
+
export declare function SharedHistoryContext({ children }: {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}): JSX.Element;
|
|
16
|
+
export declare const useSharedHistoryContext: () => ContextShape;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
import { createEmptyHistoryState } from '../../vendor/history/history';
|
|
4
|
+
const Context = createContext({});
|
|
5
|
+
export function SharedHistoryContext({ children }) {
|
|
6
|
+
const historyContext = useMemo(() => ({ historyState: createEmptyHistoryState() }), []);
|
|
7
|
+
return _jsx(Context.Provider, { value: historyContext, children: children });
|
|
8
|
+
}
|
|
9
|
+
export const useSharedHistoryContext = () => {
|
|
10
|
+
return useContext(Context);
|
|
11
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Box, styled } from '@mui/material';
|
|
2
|
+
export const EditorRoot = styled(Box)(({ theme }) => {
|
|
3
|
+
const { palette } = theme;
|
|
4
|
+
return {
|
|
5
|
+
container: 'blocklet-editor / inline-size',
|
|
6
|
+
margin: '0 auto',
|
|
7
|
+
borderRadius: '4px',
|
|
8
|
+
position: 'relative',
|
|
9
|
+
lineHeight: '1.7',
|
|
10
|
+
fontWeight: '400',
|
|
11
|
+
textAlign: 'left',
|
|
12
|
+
// mui-*
|
|
13
|
+
'--mui-palette-grey-50': palette.grey[50],
|
|
14
|
+
'--mui-palette-grey-200': palette.grey[200],
|
|
15
|
+
'--mui-palette-background-paper': palette.background.paper,
|
|
16
|
+
'--mui-palette-divider': palette.divider,
|
|
17
|
+
'--mui-palette-primary-main': palette.primary.main,
|
|
18
|
+
'--mui-palette-primary-light': palette.primary.light,
|
|
19
|
+
'--mui-palette-text-primary': palette.text.primary,
|
|
20
|
+
'--mui-palette-text-secondary': palette.text.secondary,
|
|
21
|
+
// lexical-*
|
|
22
|
+
'--lexical-text-code': 'inherit',
|
|
23
|
+
// lexical-code-*
|
|
24
|
+
'--lexical-code-comment': '#1e8449',
|
|
25
|
+
'--lexical-code-punctuation': '#2c3e50',
|
|
26
|
+
'--lexical-code-property': '#e67e22',
|
|
27
|
+
'--lexical-code-selector': '#c0392b',
|
|
28
|
+
'--lexical-code-operator': '#8e44ad',
|
|
29
|
+
'--lexical-code-attr': '#2980b9',
|
|
30
|
+
'--lexical-code-variable': '#27ae60',
|
|
31
|
+
'--lexical-code-function': '#f39c12',
|
|
32
|
+
// dark mode
|
|
33
|
+
'&[data-mode="dark"]': {
|
|
34
|
+
'--lexical-text-code': palette.grey[800],
|
|
35
|
+
// lexical-code-*
|
|
36
|
+
'--lexical-code-comment': '#6a9955',
|
|
37
|
+
'--lexical-code-punctuation': '#d4d4d4',
|
|
38
|
+
'--lexical-code-property': '#9cdcfe',
|
|
39
|
+
'--lexical-code-selector': '#d7ba7d',
|
|
40
|
+
'--lexical-code-operator': '#d4d4d4',
|
|
41
|
+
'--lexical-code-attr': '#9cdcfe',
|
|
42
|
+
'--lexical-code-variable': '#9cdcfe',
|
|
43
|
+
'--lexical-code-function': '#dcdcaa',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { MutableRefObject, ReactNode, type JSX } from 'react';
|
|
9
|
+
import { EditorState, LexicalEditor } from 'lexical';
|
|
10
|
+
export interface EditorProps {
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
prepend?: ReactNode;
|
|
13
|
+
placeholder?: ReactNode;
|
|
14
|
+
onChange?: (editorState: EditorState, editor: LexicalEditor) => void;
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
showToolbar?: boolean;
|
|
17
|
+
editorRef?: React.RefCallback<LexicalEditor> | MutableRefObject<LexicalEditor | null>;
|
|
18
|
+
onReady?: () => void;
|
|
19
|
+
enableHeadingsIdPlugin?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export default function Editor({ children, prepend, placeholder, onChange, autoFocus, showToolbar, editorRef, onReady, enableHeadingsIdPlugin, }: EditorProps): JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { cx } from '@emotion/css';
|
|
10
|
+
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
11
|
+
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
|
|
12
|
+
import { ClearEditorPlugin } from '@lexical/react/LexicalClearEditorPlugin';
|
|
13
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
14
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
15
|
+
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
16
|
+
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
|
|
17
|
+
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
18
|
+
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
19
|
+
import { TablePlugin } from '@lexical/react/LexicalTablePlugin';
|
|
20
|
+
import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin';
|
|
21
|
+
import { useEffect, useState } from 'react';
|
|
22
|
+
import { useSharedHistoryContext } from './context/SharedHistoryContext';
|
|
23
|
+
import useHasNodes from './hooks/useHasNodes';
|
|
24
|
+
import AutoEmbedPlugin from './plugins/AutoEmbedPlugin';
|
|
25
|
+
import AutoLinkPlugin from './plugins/AutoLinkPlugin';
|
|
26
|
+
import ClickableLinkPlugin from './plugins/ClickableLinkPlugin';
|
|
27
|
+
import CodeHighlightPlugin from './plugins/CodeHighlightPlugin';
|
|
28
|
+
import CollapsiblePlugin from './plugins/CollapsiblePlugin';
|
|
29
|
+
import ComponentPickerPlugin from './plugins/ComponentPickerPlugin';
|
|
30
|
+
import DragDropPaste from './plugins/DragDropPastePlugin';
|
|
31
|
+
import DraggableBlockPlugin from './plugins/DraggableBlockPlugin';
|
|
32
|
+
import ExcalidrawPlugin from './plugins/ExcalidrawPlugin';
|
|
33
|
+
import FigmaPlugin from './plugins/FigmaPlugin';
|
|
34
|
+
import FloatingLinkEditorPlugin from './plugins/FloatingLinkEditorPlugin';
|
|
35
|
+
import FloatingTextFormatToolbarPlugin from './plugins/FloatingTextFormatToolbarPlugin';
|
|
36
|
+
import HorizontalRulePlugin from './plugins/HorizontalRulePlugin';
|
|
37
|
+
import ImagesPlugin from './plugins/ImagesPlugin';
|
|
38
|
+
import MarkdownShortcutPlugin from './plugins/MarkdownShortcutPlugin';
|
|
39
|
+
import { CharacterLimitPlugin } from '../ext/CharacterLimitPlugin';
|
|
40
|
+
import MentionsPlugin from './plugins/MentionsPlugin';
|
|
41
|
+
import TabFocusPlugin from './plugins/TabFocusPlugin';
|
|
42
|
+
import TableCellActionMenuPlugin from './plugins/TableActionMenuPlugin';
|
|
43
|
+
import TableCellResizer from './plugins/TableCellResizer';
|
|
44
|
+
import ToolbarPlugin from './plugins/ToolbarPlugin';
|
|
45
|
+
import TwitterPlugin from './plugins/TwitterPlugin';
|
|
46
|
+
import YouTubePlugin from './plugins/YouTubePlugin';
|
|
47
|
+
import BilibiliPlugin from '../ext/BilibiliPlugin';
|
|
48
|
+
import ContentEditable from './ui/ContentEditable';
|
|
49
|
+
import BlockletEmbedPlugin from '../ext/BlockletEmbedPlugin';
|
|
50
|
+
import PostLinkEmbedPlugin from '../ext/PostLinkEmbedPlugin';
|
|
51
|
+
import PasteSlackImagePlugin from '../ext/PasteSlackImagePlugin';
|
|
52
|
+
import BookmarkPlugin from '../ext/BookmarkPlugin';
|
|
53
|
+
import Placeholder from './ui/Placeholder';
|
|
54
|
+
import { useEditorConfig } from '../config';
|
|
55
|
+
import AidePlugin from '../ext/AIPlugin';
|
|
56
|
+
import { EditorRefPlugin } from '../ext/LexicalEditorRefPlugin';
|
|
57
|
+
import AlertPlugin from '../ext/Alert/AlertPlugin';
|
|
58
|
+
import { HeadingsIdPlugin } from '../ext/HeadingsIdPlugin';
|
|
59
|
+
import { EditorReadyPlugin } from '../ext/EditorReadyPlugin';
|
|
60
|
+
import { VideoPlugin } from '../ext/VideoPlugin';
|
|
61
|
+
import { FilePlugin } from '../ext/FilePlugin';
|
|
62
|
+
import { EditorHolderPlugin } from '../ext/EditorHolderPlugin';
|
|
63
|
+
import { StyledEditorContent } from './styled-editor-content';
|
|
64
|
+
// import { CodeCopyPlugin } from '../ext/CodeCopyPlugin';
|
|
65
|
+
import { VideoPathFixerPlugin } from '../ext/VideoPathFixerPlugin';
|
|
66
|
+
import ImagePathFixerPlugin from '../ext/ImagePathFixerPlugin';
|
|
67
|
+
import { SafeAreaPlugin } from '../ext/SafeAreaPlugin';
|
|
68
|
+
import { HistoryPlugin } from '../vendor/history/LexicalHistoryPlugin';
|
|
69
|
+
const ENABLE_EDITOR_PLUGIN_CHAR_LIMIT = window.blocklet?.ENABLE_EDITOR_PLUGIN_CHAR_LIMIT !== 'false';
|
|
70
|
+
export default function Editor({ children, prepend, placeholder, onChange, autoFocus = true, showToolbar = true, editorRef, onReady, enableHeadingsIdPlugin, }) {
|
|
71
|
+
const [editor] = useLexicalComposerContext();
|
|
72
|
+
const [editable, setEditable] = useState(false);
|
|
73
|
+
const config = useEditorConfig();
|
|
74
|
+
const { minimalMode, characterLimitConfig } = config;
|
|
75
|
+
const hasUploader = !!config.uploader;
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
setEditable(editor.isEditable());
|
|
78
|
+
return editor.registerEditableListener((e) => {
|
|
79
|
+
setEditable(e);
|
|
80
|
+
});
|
|
81
|
+
}, [editor]);
|
|
82
|
+
const hasNodes = useHasNodes();
|
|
83
|
+
const { historyState } = useSharedHistoryContext();
|
|
84
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
85
|
+
const onRef = (_floatingAnchorElem) => {
|
|
86
|
+
if (_floatingAnchorElem !== null) {
|
|
87
|
+
setFloatingAnchorElem(_floatingAnchorElem);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (hasNodes('image') && !hasUploader) {
|
|
92
|
+
console.warn('You need to configure uploader to use ImagesPlugin');
|
|
93
|
+
}
|
|
94
|
+
}, [hasNodes('image'), hasUploader]);
|
|
95
|
+
if (minimalMode) {
|
|
96
|
+
return (_jsxs(_Fragment, { children: [prepend, _jsx(VideoPathFixerPlugin, {}), _jsx(ImagePathFixerPlugin, {}), editable && showToolbar && _jsx(ToolbarPlugin, {}), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), _jsx(PasteSlackImagePlugin, {}), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('autolink') && !!editable && _jsx(AutoLinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), _jsx(TabFocusPlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && hasNodes('link') && (_jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem })), !!characterLimitConfig?.maxLength && ENABLE_EDITOR_PLUGIN_CHAR_LIMIT && (_jsx(CharacterLimitPlugin, { maxLength: characterLimitConfig.maxLength, charLimitIndicatorStyle: characterLimitConfig.indicatorStyle, alignLeft: characterLimitConfig.alignLeft })), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), children] }));
|
|
97
|
+
}
|
|
98
|
+
return (_jsxs(_Fragment, { children: [prepend, _jsx(VideoPathFixerPlugin, {}), _jsx(ImagePathFixerPlugin, {}), editable && showToolbar && _jsx(ToolbarPlugin, {}), !!characterLimitConfig?.maxLength && ENABLE_EDITOR_PLUGIN_CHAR_LIMIT && (_jsx(CharacterLimitPlugin, { maxLength: characterLimitConfig.maxLength, charLimitIndicatorStyle: characterLimitConfig.indicatorStyle, alignLeft: characterLimitConfig.alignLeft })), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('autolink') && !!editable && _jsx(AutoLinkPlugin, {}), _jsxs(_Fragment, { children: [_jsx(PasteSlackImagePlugin, {}), _jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('table', 'tablerow', 'tablecell') && (_jsx(TablePlugin, { hasCellMerge: true, hasCellBackgroundColor: true, hasHorizontalScroll: true })), hasNodes('table', 'tablerow', 'tablecell') && _jsx(TableCellResizer, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(BilibiliPlugin, {}), _jsx(BlockletEmbedPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), _jsx(AidePlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), _jsx(TabFocusPlugin, {}), hasNodes('collapsible-container', 'collapsible-content', 'collapsible-title') && _jsx(CollapsiblePlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), hasNodes('table') && _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {})] }), _jsx(EditorHolderPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), config.enableSafeAreaPlugin && _jsx(SafeAreaPlugin, {}), children] }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ImageSizeMode } from '../../types';
|
|
2
|
+
export declare const useEditorSize: () => {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
} | undefined;
|
|
6
|
+
export declare const useMaxImageWidth: () => number;
|
|
7
|
+
export declare const useImageNaturalSize: (src: string) => {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const useImageDisplayWidth: ({ src, sizeMode, width, }: {
|
|
12
|
+
src: string;
|
|
13
|
+
sizeMode?: ImageSizeMode | undefined;
|
|
14
|
+
width: number | 'inherit';
|
|
15
|
+
}) => number;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { useSize } from 'ahooks';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useMediaQuery } from '@mui/material';
|
|
5
|
+
import { scaleImage } from '../utils/images';
|
|
6
|
+
export const useEditorSize = () => {
|
|
7
|
+
const [editor] = useLexicalComposerContext();
|
|
8
|
+
return useSize(() => editor.getRootElement());
|
|
9
|
+
};
|
|
10
|
+
export const useMaxImageWidth = () => {
|
|
11
|
+
const size = useEditorSize();
|
|
12
|
+
if (size?.width) {
|
|
13
|
+
return size.width - 54;
|
|
14
|
+
}
|
|
15
|
+
return document.documentElement.clientWidth;
|
|
16
|
+
};
|
|
17
|
+
export const useImageNaturalSize = (src) => {
|
|
18
|
+
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const img = new Image();
|
|
21
|
+
img.onload = () => setSize({ width: img.width, height: img.height });
|
|
22
|
+
img.src = src;
|
|
23
|
+
}, [src]);
|
|
24
|
+
return size;
|
|
25
|
+
};
|
|
26
|
+
export const useImageDisplayWidth = ({ src, sizeMode = 'best-fit', width, }) => {
|
|
27
|
+
const upLg = useMediaQuery((theme) => theme.breakpoints.up('lg'));
|
|
28
|
+
const naturalSize = useImageNaturalSize(src);
|
|
29
|
+
const maxImageWidth = useMaxImageWidth();
|
|
30
|
+
// 显式设置过宽度
|
|
31
|
+
if (width !== 'inherit') {
|
|
32
|
+
return Math.min(width, maxImageWidth);
|
|
33
|
+
}
|
|
34
|
+
if (!naturalSize) {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
if (sizeMode === 'small') {
|
|
38
|
+
return scaleImage({ width: naturalSize.width, height: naturalSize.height, maxSize: 200 }).width;
|
|
39
|
+
}
|
|
40
|
+
if (sizeMode === 'original') {
|
|
41
|
+
return Math.min(maxImageWidth, naturalSize.width);
|
|
42
|
+
}
|
|
43
|
+
const bestFitSize = upLg ? 560 : 400;
|
|
44
|
+
return scaleImage({
|
|
45
|
+
width: naturalSize.width,
|
|
46
|
+
height: naturalSize.height,
|
|
47
|
+
maxSize: Math.min(bestFitSize, maxImageWidth),
|
|
48
|
+
}).width;
|
|
49
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'medium-zoom/dist/style.css';
|
|
2
|
+
interface MediumZoomOption {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const useMediumZoom: (imageRef: React.RefObject<HTMLImageElement | null>, options?: MediumZoomOption) => {
|
|
6
|
+
zoomOpened: boolean;
|
|
7
|
+
openedImageRef: import("react").MutableRefObject<HTMLImageElement | null>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import mediumZoom from 'medium-zoom/dist/pure';
|
|
4
|
+
import 'medium-zoom/dist/style.css';
|
|
5
|
+
export const useMediumZoom = (imageRef, options) => {
|
|
6
|
+
const [editor] = useLexicalComposerContext();
|
|
7
|
+
const editable = editor.isEditable();
|
|
8
|
+
const openedImageRef = useRef(null);
|
|
9
|
+
const [zoomOpened, setZoomOpened] = useState(false);
|
|
10
|
+
const enabled = options?.enabled ?? true;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!editable && imageRef.current) {
|
|
13
|
+
if (!enabled) {
|
|
14
|
+
return () => { };
|
|
15
|
+
}
|
|
16
|
+
const zoom = mediumZoom(imageRef.current, { background: 'rgba(0,0,0,.5)' });
|
|
17
|
+
zoom.on('opened', (e) => {
|
|
18
|
+
const openedImage = document.querySelector('.medium-zoom-image--opened');
|
|
19
|
+
if (openedImage) {
|
|
20
|
+
openedImageRef.current = openedImage;
|
|
21
|
+
setZoomOpened(true);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
zoom.on('close', (e) => {
|
|
25
|
+
openedImageRef.current = null;
|
|
26
|
+
setZoomOpened(false);
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
zoom.detach();
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}, [editable, imageRef.current, enabled]);
|
|
33
|
+
return { zoomOpened, openedImageRef };
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useBeforeUnload: (dirty: boolean) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export const useBeforeUnload = (dirty) => {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
const showPrompt = (e) => {
|
|
5
|
+
if (dirty) {
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
e.returnValue = '';
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
window.addEventListener('beforeunload', showPrompt);
|
|
11
|
+
return () => {
|
|
12
|
+
window.removeEventListener('beforeunload', showPrompt);
|
|
13
|
+
};
|
|
14
|
+
}, [dirty]);
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useHasNodes(): (...types: string[]) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
export default function useHasNodes() {
|
|
4
|
+
const [editor] = useLexicalComposerContext();
|
|
5
|
+
return useCallback((...types) => editor.hasNodes(types.map((type) => ({
|
|
6
|
+
getType: () => type,
|
|
7
|
+
}))), [editor]);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsFocused: () => boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { BLUR_COMMAND, COMMAND_PRIORITY_NORMAL, FOCUS_COMMAND } from 'lexical';
|
|
3
|
+
import { useLayoutEffect, useState } from 'react';
|
|
4
|
+
export const useIsFocused = () => {
|
|
5
|
+
const [editor] = useLexicalComposerContext();
|
|
6
|
+
const [hasFocus, setHasFocus] = useState(() => editor.getRootElement() === document.activeElement);
|
|
7
|
+
useLayoutEffect(() => {
|
|
8
|
+
return editor.registerCommand(FOCUS_COMMAND, () => {
|
|
9
|
+
setHasFocus(true);
|
|
10
|
+
return false;
|
|
11
|
+
}, COMMAND_PRIORITY_NORMAL);
|
|
12
|
+
}, [editor]);
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
return editor.registerCommand(BLUR_COMMAND, () => {
|
|
15
|
+
setHasFocus(false);
|
|
16
|
+
return false;
|
|
17
|
+
}, COMMAND_PRIORITY_NORMAL);
|
|
18
|
+
}, [editor]);
|
|
19
|
+
return hasFocus;
|
|
20
|
+
};
|
|
@@ -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
|
+
export default function useModal(): [
|
|
10
|
+
JSX.Element | null,
|
|
11
|
+
(title: string, showModal: (onClose: () => void) => JSX.Element) => void
|
|
12
|
+
];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
10
|
+
import Modal from '../ui/Modal';
|
|
11
|
+
export default function useModal() {
|
|
12
|
+
const [modalContent, setModalContent] = useState(null);
|
|
13
|
+
const onClose = useCallback(() => {
|
|
14
|
+
setModalContent(null);
|
|
15
|
+
}, []);
|
|
16
|
+
const modal = useMemo(() => {
|
|
17
|
+
if (modalContent === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const { title, content, closeOnClickOutside } = modalContent;
|
|
21
|
+
return (_jsx(Modal, { onClose: onClose, title: title, closeOnClickOutside: closeOnClickOutside, children: content }));
|
|
22
|
+
}, [modalContent, onClose]);
|
|
23
|
+
const showModal = useCallback((title,
|
|
24
|
+
// eslint-disable-next-line no-shadow
|
|
25
|
+
getContent, closeOnClickOutside = false) => {
|
|
26
|
+
setModalContent({
|
|
27
|
+
closeOnClickOutside,
|
|
28
|
+
content: getContent(onClose),
|
|
29
|
+
title,
|
|
30
|
+
});
|
|
31
|
+
}, [onClose]);
|
|
32
|
+
return [modal, showModal];
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export default function useReport(): (arg0: string) => ReturnType<typeof setTimeout>;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { useCallback, useEffect, useRef } from 'react';
|
|
9
|
+
const getElement = () => {
|
|
10
|
+
let element = document.getElementById('report-container');
|
|
11
|
+
if (element === null) {
|
|
12
|
+
element = document.createElement('div');
|
|
13
|
+
element.id = 'report-container';
|
|
14
|
+
element.style.position = 'fixed';
|
|
15
|
+
element.style.top = '50%';
|
|
16
|
+
element.style.left = '50%';
|
|
17
|
+
element.style.fontSize = '32px';
|
|
18
|
+
element.style.transform = 'translate(-50%, -50px)';
|
|
19
|
+
element.style.padding = '20px';
|
|
20
|
+
element.style.background = 'rgba(240, 240, 240, 0.4)';
|
|
21
|
+
element.style.borderRadius = '20px';
|
|
22
|
+
if (document.body) {
|
|
23
|
+
document.body.appendChild(element);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return element;
|
|
27
|
+
};
|
|
28
|
+
export default function useReport() {
|
|
29
|
+
const timer = useRef(null);
|
|
30
|
+
const cleanup = useCallback(() => {
|
|
31
|
+
if (timer !== null) {
|
|
32
|
+
clearTimeout(timer.current);
|
|
33
|
+
}
|
|
34
|
+
if (document.body) {
|
|
35
|
+
document.body.removeChild(getElement());
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
return cleanup;
|
|
40
|
+
}, [cleanup]);
|
|
41
|
+
return useCallback((content) => {
|
|
42
|
+
const element = getElement();
|
|
43
|
+
clearTimeout(timer.current);
|
|
44
|
+
element.innerHTML = content;
|
|
45
|
+
timer.current = setTimeout(cleanup, 1000);
|
|
46
|
+
return timer.current;
|
|
47
|
+
}, [cleanup]);
|
|
48
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { $isTableRowNode, TableNode } from '@lexical/table';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { $createParagraphNode } from 'lexical';
|
|
5
|
+
import { $wrapNodeInElement } from '@lexical/utils';
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* 支持 (block 级别的) 水平滚动
|
|
9
|
+
*/
|
|
10
|
+
export const useResponsiveTable = () => {
|
|
11
|
+
const [editor] = useLexicalComposerContext();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
return editor.registerNodeTransform(TableNode, (tableNode) => {
|
|
14
|
+
const tableRows = tableNode.getChildren();
|
|
15
|
+
const firstRow = tableRows[0];
|
|
16
|
+
const editorWidth = editor.getRootElement()?.getBoundingClientRect().width;
|
|
17
|
+
if (!$isTableRowNode(firstRow) || !editorWidth) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const parentNode = tableNode.getParent();
|
|
21
|
+
// 如果 table 直接在 root 中, 包裹一层 paragraph, 使其可以使用表格内滚动条
|
|
22
|
+
if (parentNode?.getType() === 'root') {
|
|
23
|
+
$wrapNodeInElement(tableNode, () => {
|
|
24
|
+
const p = $createParagraphNode();
|
|
25
|
+
return p;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return tableNode;
|
|
29
|
+
});
|
|
30
|
+
}, [editor]);
|
|
31
|
+
};
|