@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,185 @@
|
|
|
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 { $convertFromMarkdownString, $convertToMarkdownString, CHECK_LIST, ELEMENT_TRANSFORMERS, MULTILINE_ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, } from '@lexical/markdown';
|
|
9
|
+
import { $createHorizontalRuleNode, $isHorizontalRuleNode, HorizontalRuleNode, } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
10
|
+
import { $createTableCellNode, $createTableNode, $createTableRowNode, $isTableCellNode, $isTableNode, $isTableRowNode, TableCellHeaderStates, TableCellNode, TableNode, TableRowNode, } from '@lexical/table';
|
|
11
|
+
import { $isParagraphNode, $isTextNode } from 'lexical';
|
|
12
|
+
import { $createImageNode, $isImageNode, ImageNode } from '../../nodes/ImageNode';
|
|
13
|
+
export const HR = {
|
|
14
|
+
dependencies: [HorizontalRuleNode],
|
|
15
|
+
export: (node) => {
|
|
16
|
+
return $isHorizontalRuleNode(node) ? '***' : null;
|
|
17
|
+
},
|
|
18
|
+
regExp: /^(---|\*\*\*|___)\s?$/,
|
|
19
|
+
replace: (parentNode, _1, _2, isImport) => {
|
|
20
|
+
const line = $createHorizontalRuleNode();
|
|
21
|
+
// TODO: Get rid of isImport flag
|
|
22
|
+
if (isImport || parentNode.getNextSibling() != null) {
|
|
23
|
+
parentNode.replace(line);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
parentNode.insertBefore(line);
|
|
27
|
+
}
|
|
28
|
+
line.selectNext();
|
|
29
|
+
},
|
|
30
|
+
type: 'element',
|
|
31
|
+
};
|
|
32
|
+
export const IMAGE = {
|
|
33
|
+
dependencies: [ImageNode],
|
|
34
|
+
export: (node) => {
|
|
35
|
+
if (!$isImageNode(node)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return `})`;
|
|
39
|
+
},
|
|
40
|
+
importRegExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))/,
|
|
41
|
+
regExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,
|
|
42
|
+
replace: (textNode, match) => {
|
|
43
|
+
const [, altText, src] = match;
|
|
44
|
+
const imageNode = $createImageNode({
|
|
45
|
+
altText,
|
|
46
|
+
maxWidth: 800,
|
|
47
|
+
src,
|
|
48
|
+
});
|
|
49
|
+
textNode.replace(imageNode);
|
|
50
|
+
},
|
|
51
|
+
trigger: ')',
|
|
52
|
+
type: 'text-match',
|
|
53
|
+
};
|
|
54
|
+
// Very primitive table setup
|
|
55
|
+
const TABLE_ROW_REG_EXP = /^(?:\|)(.+)(?:\|)\s?$/;
|
|
56
|
+
const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
|
|
57
|
+
export const TABLE = {
|
|
58
|
+
dependencies: [TableNode, TableRowNode, TableCellNode],
|
|
59
|
+
export: (node) => {
|
|
60
|
+
if (!$isTableNode(node)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const output = [];
|
|
64
|
+
for (const row of node.getChildren()) {
|
|
65
|
+
const rowOutput = [];
|
|
66
|
+
if (!$isTableRowNode(row)) {
|
|
67
|
+
// eslint-disable-next-line no-continue
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
let isHeaderRow = false;
|
|
71
|
+
for (const cell of row.getChildren()) {
|
|
72
|
+
// It's TableCellNode so it's just to make flow happy
|
|
73
|
+
if ($isTableCellNode(cell)) {
|
|
74
|
+
rowOutput.push($convertToMarkdownString(PLAYGROUND_TRANSFORMERS, cell).replace(/\n/g, '\\n').trim());
|
|
75
|
+
if (cell.__headerState === TableCellHeaderStates.ROW) {
|
|
76
|
+
isHeaderRow = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
output.push(`| ${rowOutput.join(' | ')} |`);
|
|
81
|
+
if (isHeaderRow) {
|
|
82
|
+
output.push(`| ${rowOutput.map((_) => '---').join(' | ')} |`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return output.join('\n');
|
|
86
|
+
},
|
|
87
|
+
regExp: TABLE_ROW_REG_EXP,
|
|
88
|
+
replace: (parentNode, _1, match) => {
|
|
89
|
+
// Header row
|
|
90
|
+
if (TABLE_ROW_DIVIDER_REG_EXP.test(match[0])) {
|
|
91
|
+
const table = parentNode.getPreviousSibling();
|
|
92
|
+
if (!table || !$isTableNode(table)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const rows = table.getChildren();
|
|
96
|
+
const lastRow = rows[rows.length - 1];
|
|
97
|
+
if (!lastRow || !$isTableRowNode(lastRow)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Add header state to row cells
|
|
101
|
+
lastRow.getChildren().forEach((cell) => {
|
|
102
|
+
if (!$isTableCellNode(cell)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
cell.setHeaderStyles(TableCellHeaderStates.ROW, TableCellHeaderStates.ROW);
|
|
106
|
+
});
|
|
107
|
+
// Remove line
|
|
108
|
+
parentNode.remove();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const matchCells = mapToTableCells(match[0]);
|
|
112
|
+
if (matchCells == null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const rows = [matchCells];
|
|
116
|
+
let sibling = parentNode.getPreviousSibling();
|
|
117
|
+
let maxCells = matchCells.length;
|
|
118
|
+
while (sibling) {
|
|
119
|
+
if (!$isParagraphNode(sibling)) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
if (sibling.getChildrenSize() !== 1) {
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
const firstChild = sibling.getFirstChild();
|
|
126
|
+
if (!$isTextNode(firstChild)) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
const cells = mapToTableCells(firstChild.getTextContent());
|
|
130
|
+
if (cells == null) {
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
maxCells = Math.max(maxCells, cells.length);
|
|
134
|
+
rows.unshift(cells);
|
|
135
|
+
const previousSibling = sibling.getPreviousSibling();
|
|
136
|
+
sibling.remove();
|
|
137
|
+
sibling = previousSibling;
|
|
138
|
+
}
|
|
139
|
+
const table = $createTableNode();
|
|
140
|
+
for (const cells of rows) {
|
|
141
|
+
const tableRow = $createTableRowNode();
|
|
142
|
+
table.append(tableRow);
|
|
143
|
+
for (let i = 0; i < maxCells; i++) {
|
|
144
|
+
tableRow.append(i < cells.length ? cells[i] : $createTableCell(''));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const previousSibling = parentNode.getPreviousSibling();
|
|
148
|
+
if ($isTableNode(previousSibling) && getTableColumnsSize(previousSibling) === maxCells) {
|
|
149
|
+
previousSibling.append(...table.getChildren());
|
|
150
|
+
parentNode.remove();
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
parentNode.replace(table);
|
|
154
|
+
}
|
|
155
|
+
table.selectEnd();
|
|
156
|
+
},
|
|
157
|
+
type: 'element',
|
|
158
|
+
};
|
|
159
|
+
function getTableColumnsSize(table) {
|
|
160
|
+
const row = table.getFirstChild();
|
|
161
|
+
return $isTableRowNode(row) ? row.getChildrenSize() : 0;
|
|
162
|
+
}
|
|
163
|
+
const $createTableCell = (textContent) => {
|
|
164
|
+
textContent = textContent.replace(/\\n/g, '\n');
|
|
165
|
+
const cell = $createTableCellNode(TableCellHeaderStates.NO_STATUS);
|
|
166
|
+
$convertFromMarkdownString(textContent, PLAYGROUND_TRANSFORMERS, cell);
|
|
167
|
+
return cell;
|
|
168
|
+
};
|
|
169
|
+
const mapToTableCells = (textContent) => {
|
|
170
|
+
const match = textContent.match(TABLE_ROW_REG_EXP);
|
|
171
|
+
if (!match || !match[1]) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return match[1].split('|').map((text) => $createTableCell(text));
|
|
175
|
+
};
|
|
176
|
+
export const PLAYGROUND_TRANSFORMERS = [
|
|
177
|
+
TABLE,
|
|
178
|
+
HR,
|
|
179
|
+
IMAGE,
|
|
180
|
+
CHECK_LIST,
|
|
181
|
+
...ELEMENT_TRANSFORMERS,
|
|
182
|
+
...MULTILINE_ELEMENT_TRANSFORMERS,
|
|
183
|
+
...TEXT_FORMAT_TRANSFORMERS,
|
|
184
|
+
...TEXT_MATCH_TRANSFORMERS,
|
|
185
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare function MaxLengthPlugin({ maxLength }: {
|
|
9
|
+
maxLength: number;
|
|
10
|
+
}): null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
+
import { $trimTextContentFromAnchor } from '@lexical/selection';
|
|
10
|
+
import { $restoreEditorState } from '@lexical/utils';
|
|
11
|
+
import { $getSelection, $isRangeSelection, RootNode } from 'lexical';
|
|
12
|
+
import { useEffect } from 'react';
|
|
13
|
+
export function MaxLengthPlugin({ maxLength }) {
|
|
14
|
+
const [editor] = useLexicalComposerContext();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
let lastRestoredEditorState = null;
|
|
17
|
+
return editor.registerNodeTransform(RootNode, (rootNode) => {
|
|
18
|
+
const selection = $getSelection();
|
|
19
|
+
if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const prevEditorState = editor.getEditorState();
|
|
23
|
+
const prevTextContentSize = prevEditorState.read(() => rootNode.getTextContentSize());
|
|
24
|
+
const textContentSize = rootNode.getTextContentSize();
|
|
25
|
+
if (prevTextContentSize !== textContentSize) {
|
|
26
|
+
const delCount = textContentSize - maxLength;
|
|
27
|
+
const { anchor } = selection;
|
|
28
|
+
if (delCount > 0) {
|
|
29
|
+
// Restore the old editor state instead if the last
|
|
30
|
+
// text content was already at the limit.
|
|
31
|
+
if (prevTextContentSize === maxLength && lastRestoredEditorState !== prevEditorState) {
|
|
32
|
+
lastRestoredEditorState = prevEditorState;
|
|
33
|
+
$restoreEditorState(editor, prevEditorState);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
$trimTextContentFromAnchor(editor, anchor, delCount);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}, [editor, maxLength]);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEditorConfig } from '../../../config';
|
|
3
|
+
export default function HighlightStyle() {
|
|
4
|
+
const { userService } = useEditorConfig();
|
|
5
|
+
const currentUserDid = userService?.getCurrentUserDid?.();
|
|
6
|
+
if (currentUserDid) {
|
|
7
|
+
return (_jsx("style", { children: `.mention[data-did="${currentUserDid}"] {
|
|
8
|
+
color: #222!important;
|
|
9
|
+
background-color: #fff9cc!important;
|
|
10
|
+
}` }));
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { type JSX } from 'react';
|
|
9
|
+
export default function NewMentionsPlugin(): JSX.Element | null;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable no-useless-concat */
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
11
|
+
import { LexicalTypeaheadMenuPlugin, useBasicTypeaheadTriggerMatch, } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
12
|
+
import { $createTextNode, $insertNodes } from 'lexical';
|
|
13
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import debounce from 'lodash/debounce';
|
|
15
|
+
import { Box } from '@mui/material';
|
|
16
|
+
import { $createMentionNode } from '../../nodes/MentionNode';
|
|
17
|
+
import { useEditorConfig } from '../../../config';
|
|
18
|
+
import HighlightStyle from './HighlightStyle';
|
|
19
|
+
import sortArrayByKey from '../../../libs/sort-array-by-key';
|
|
20
|
+
import { TypeaheadOption } from '../LexicalTypeaheadMenuPlugin';
|
|
21
|
+
import createPortal from '../../../components/createPortal';
|
|
22
|
+
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
23
|
+
const NAME = `\\b[A-Z][^\\s${PUNCTUATION}]`;
|
|
24
|
+
const DocumentMentionsRegex = {
|
|
25
|
+
NAME,
|
|
26
|
+
PUNCTUATION,
|
|
27
|
+
};
|
|
28
|
+
const PUNC = DocumentMentionsRegex.PUNCTUATION;
|
|
29
|
+
const TRIGGERS = ['@'].join('');
|
|
30
|
+
// Chars we expect to see in a mention (non-space, non-punctuation).
|
|
31
|
+
const VALID_CHARS = `[^${TRIGGERS}${PUNC}\\s]`;
|
|
32
|
+
// Non-standard series of chars. Each series must be preceded and followed by
|
|
33
|
+
// a valid char.
|
|
34
|
+
const VALID_JOINS = '(?:' +
|
|
35
|
+
'\\.[ |$]|' + // E.g. "r. " in "Mr. Smith"
|
|
36
|
+
' |' + // E.g. " " in "Josh Duck"
|
|
37
|
+
`[${PUNC}]|` + // E.g. "-' in "Salier-Hellendag"
|
|
38
|
+
')';
|
|
39
|
+
const LENGTH_LIMIT = 75;
|
|
40
|
+
const AtSignMentionsRegex = new RegExp('(^|\\s|\\()(' + `[${TRIGGERS}]` + `((?:${VALID_CHARS}${VALID_JOINS}){0,${LENGTH_LIMIT}})` + ')$');
|
|
41
|
+
// 50 is the longest alias length limit.
|
|
42
|
+
const ALIAS_LENGTH_LIMIT = 50;
|
|
43
|
+
// Regex used to match alias.
|
|
44
|
+
const AtSignMentionsRegexAliasRegex = new RegExp('(^|\\s|\\()(' + `[${TRIGGERS}]` + `((?:${VALID_CHARS}){0,${ALIAS_LENGTH_LIMIT}})` + ')$');
|
|
45
|
+
// At most, 5 suggestions are shown in the popup.
|
|
46
|
+
const SUGGESTION_LIST_LENGTH_LIMIT = 5;
|
|
47
|
+
const mentionsCache = new Map();
|
|
48
|
+
function useMentionLookupService(mentionString) {
|
|
49
|
+
const { userService } = useEditorConfig();
|
|
50
|
+
const [results, setResults] = useState([]);
|
|
51
|
+
const { current: search } = useRef(debounce(async (_mentionString) => {
|
|
52
|
+
if (userService) {
|
|
53
|
+
const searchUsers = await userService.search(_mentionString);
|
|
54
|
+
const users = sortArrayByKey(searchUsers, _mentionString, 'fullName');
|
|
55
|
+
if (Array.isArray(users)) {
|
|
56
|
+
mentionsCache.set(_mentionString, users);
|
|
57
|
+
setResults(users);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, 300));
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const cachedResults = mentionsCache.get(mentionString);
|
|
63
|
+
if (mentionString == null) {
|
|
64
|
+
setResults([]);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (cachedResults === null) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (cachedResults !== undefined) {
|
|
71
|
+
setResults(cachedResults);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
mentionsCache.set(mentionString, null);
|
|
75
|
+
search(mentionString);
|
|
76
|
+
}, [mentionString]);
|
|
77
|
+
return results;
|
|
78
|
+
}
|
|
79
|
+
function checkForAtSignMentions(text, minMatchLength) {
|
|
80
|
+
// 输入 @ 符号立即显示用户列表 (#383)
|
|
81
|
+
if (/([\s]|^)@$/.test(text)) {
|
|
82
|
+
return {
|
|
83
|
+
leadOffset: 1,
|
|
84
|
+
matchingString: '',
|
|
85
|
+
replaceableString: '@',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
let match = AtSignMentionsRegex.exec(text);
|
|
89
|
+
if (match === null) {
|
|
90
|
+
match = AtSignMentionsRegexAliasRegex.exec(text);
|
|
91
|
+
}
|
|
92
|
+
if (match !== null) {
|
|
93
|
+
// The strategy ignores leading whitespace but we need to know it's
|
|
94
|
+
// length to add it to the leadOffset
|
|
95
|
+
const maybeLeadingWhitespace = match[1];
|
|
96
|
+
const matchingString = match[3];
|
|
97
|
+
if (matchingString.length >= minMatchLength) {
|
|
98
|
+
return {
|
|
99
|
+
leadOffset: match.index + maybeLeadingWhitespace.length,
|
|
100
|
+
matchingString,
|
|
101
|
+
replaceableString: match[2],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function getPossibleQueryMatch(text) {
|
|
108
|
+
return checkForAtSignMentions(text, 1);
|
|
109
|
+
}
|
|
110
|
+
class MentionTypeaheadOption extends TypeaheadOption {
|
|
111
|
+
user;
|
|
112
|
+
constructor(user) {
|
|
113
|
+
super(user.fullName);
|
|
114
|
+
this.user = user;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function MentionsTypeaheadMenuItem({ index, isSelected, onClick, onMouseEnter, option, }) {
|
|
118
|
+
let className = 'item';
|
|
119
|
+
if (isSelected) {
|
|
120
|
+
className += ' selected';
|
|
121
|
+
}
|
|
122
|
+
return (_jsxs("li", { tabIndex: -1, className: className, style: { display: 'flex', alignItems: 'center', gap: 8 }, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id: `typeahead-item-${index}`, onMouseEnter: onMouseEnter, onClick: onClick, children: [option.user.avatar ? (_jsx("div", { className: "mention-typeahead-item-avatar", style: { backgroundImage: `url(${option.user.avatar})` } })) : (_jsx("i", { className: "icon user" })), _jsx("span", { className: "text", children: option.user.fullName })] }, option.key));
|
|
123
|
+
}
|
|
124
|
+
export default function NewMentionsPlugin() {
|
|
125
|
+
const [editor] = useLexicalComposerContext();
|
|
126
|
+
const [queryString, setQueryString] = useState(null);
|
|
127
|
+
const results = useMentionLookupService(queryString);
|
|
128
|
+
const checkForSlashTriggerMatch = useBasicTypeaheadTriggerMatch('/', {
|
|
129
|
+
minLength: 0,
|
|
130
|
+
});
|
|
131
|
+
const options = useMemo(() => results.map((result) => new MentionTypeaheadOption(result)).slice(0, SUGGESTION_LIST_LENGTH_LIMIT), [results]);
|
|
132
|
+
const onSelectOption = useCallback((selectedOption, nodeToReplace, closeMenu) => {
|
|
133
|
+
editor.update(() => {
|
|
134
|
+
const mentionNode = $createMentionNode(selectedOption.user.did, selectedOption.user.fullName);
|
|
135
|
+
if (nodeToReplace) {
|
|
136
|
+
nodeToReplace.replace(mentionNode);
|
|
137
|
+
}
|
|
138
|
+
mentionNode.select();
|
|
139
|
+
$insertNodes([$createTextNode(' ')]);
|
|
140
|
+
closeMenu();
|
|
141
|
+
});
|
|
142
|
+
}, [editor]);
|
|
143
|
+
const checkForMentionMatch = useCallback((text) => {
|
|
144
|
+
const slashMatch = checkForSlashTriggerMatch(text, editor);
|
|
145
|
+
if (slashMatch !== null) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
return getPossibleQueryMatch(text);
|
|
149
|
+
}, [checkForSlashTriggerMatch, editor]);
|
|
150
|
+
return (_jsxs(_Fragment, { children: [_jsx(LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: checkForMentionMatch, options: options, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
151
|
+
return anchorElementRef.current && results.length
|
|
152
|
+
? createPortal(_jsx(Box, { className: "typeahead-popover mentions-menu", sx: {
|
|
153
|
+
border: 1,
|
|
154
|
+
borderColor: 'divider',
|
|
155
|
+
color: 'text.primary',
|
|
156
|
+
bgcolor: 'background.default',
|
|
157
|
+
'li.selected': {
|
|
158
|
+
bgcolor: 'action.selected',
|
|
159
|
+
},
|
|
160
|
+
'li:hover': {
|
|
161
|
+
bgcolor: 'action.hover',
|
|
162
|
+
},
|
|
163
|
+
}, children: _jsx("ul", { children: options.map((option, i) => (_jsx(MentionsTypeaheadMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
|
|
164
|
+
setHighlightedIndex(i);
|
|
165
|
+
selectOptionAndCleanUp(option);
|
|
166
|
+
}, onMouseEnter: () => {
|
|
167
|
+
setHighlightedIndex(i);
|
|
168
|
+
// hover option 时显示用户 did
|
|
169
|
+
if (option?.ref?.current) {
|
|
170
|
+
option.ref.current.title = option.user.did;
|
|
171
|
+
}
|
|
172
|
+
}, option: option }, option.key))) }) }), anchorElementRef.current)
|
|
173
|
+
: null;
|
|
174
|
+
} }), _jsx(HighlightStyle, {})] }));
|
|
175
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
+
import { $getSelection, $isRangeSelection, $setSelection, FOCUS_COMMAND } from 'lexical';
|
|
10
|
+
import { useEffect } from 'react';
|
|
11
|
+
const COMMAND_PRIORITY_LOW = 1;
|
|
12
|
+
const TAB_TO_FOCUS_INTERVAL = 100;
|
|
13
|
+
let lastTabKeyDownTimestamp = 0;
|
|
14
|
+
let hasRegisteredKeyDownListener = false;
|
|
15
|
+
function registerKeyTimeStampTracker() {
|
|
16
|
+
window.addEventListener('keydown', (event) => {
|
|
17
|
+
// Tab
|
|
18
|
+
if (event.keyCode === 9) {
|
|
19
|
+
lastTabKeyDownTimestamp = event.timeStamp;
|
|
20
|
+
}
|
|
21
|
+
}, true);
|
|
22
|
+
}
|
|
23
|
+
export default function TabFocusPlugin() {
|
|
24
|
+
const [editor] = useLexicalComposerContext();
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!hasRegisteredKeyDownListener) {
|
|
27
|
+
registerKeyTimeStampTracker();
|
|
28
|
+
hasRegisteredKeyDownListener = true;
|
|
29
|
+
}
|
|
30
|
+
return editor.registerCommand(FOCUS_COMMAND, (event) => {
|
|
31
|
+
const selection = $getSelection();
|
|
32
|
+
if ($isRangeSelection(selection)) {
|
|
33
|
+
if (lastTabKeyDownTimestamp + TAB_TO_FOCUS_INTERVAL > event.timeStamp) {
|
|
34
|
+
$setSelection(selection.clone());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}, COMMAND_PRIORITY_LOW);
|
|
39
|
+
}, [editor]);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
@@ -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 { ReactPortal } from 'react';
|
|
9
|
+
export default function TableActionMenuPlugin({ anchorElem, cellMerge, }: {
|
|
10
|
+
anchorElem?: HTMLElement;
|
|
11
|
+
cellMerge?: boolean;
|
|
12
|
+
}): null | ReactPortal;
|