@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,493 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable func-names */
|
|
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 { mergeRegister } from '@lexical/utils';
|
|
12
|
+
import { $getNodeByKey, $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_HIGH, createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, } from 'lexical';
|
|
13
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import useLayoutEffect from '../../../shared/useLayoutEffect';
|
|
16
|
+
export const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
17
|
+
export class TypeaheadOption {
|
|
18
|
+
key;
|
|
19
|
+
ref;
|
|
20
|
+
constructor(key) {
|
|
21
|
+
this.key = key;
|
|
22
|
+
this.ref = { current: null };
|
|
23
|
+
this.setRefElement = this.setRefElement.bind(this);
|
|
24
|
+
}
|
|
25
|
+
setRefElement(element) {
|
|
26
|
+
this.ref = { current: element };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const scrollIntoViewIfNeeded = (target) => {
|
|
30
|
+
const container = document.getElementById('typeahead-menu');
|
|
31
|
+
if (container) {
|
|
32
|
+
const parentNode = target.parentNode;
|
|
33
|
+
if (parentNode) {
|
|
34
|
+
const parentRect = parentNode.getBoundingClientRect();
|
|
35
|
+
if (parentRect.top + parentRect.height > window.innerHeight) {
|
|
36
|
+
parentNode.scrollIntoView(false);
|
|
37
|
+
}
|
|
38
|
+
parentNode.scrollTop = target.offsetTop - target.clientHeight;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
target.scrollIntoView(false);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
function getTextUpToAnchor(selection) {
|
|
46
|
+
const { anchor } = selection;
|
|
47
|
+
if (anchor.type !== 'text') {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const anchorNode = anchor.getNode();
|
|
51
|
+
if (!anchorNode.isSimpleText()) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const anchorOffset = anchor.offset;
|
|
55
|
+
return anchorNode.getTextContent().slice(0, anchorOffset);
|
|
56
|
+
}
|
|
57
|
+
function tryToPositionRange(leadOffset, range) {
|
|
58
|
+
const domSelection = window.getSelection();
|
|
59
|
+
if (domSelection === null || !domSelection.isCollapsed) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const { anchorNode } = domSelection;
|
|
63
|
+
const startOffset = leadOffset;
|
|
64
|
+
const endOffset = domSelection.anchorOffset;
|
|
65
|
+
if (anchorNode == null || endOffset == null) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
range.setStart(anchorNode, startOffset);
|
|
70
|
+
range.setEnd(anchorNode, endOffset);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
function getQueryTextForSearch(editor) {
|
|
78
|
+
let text = null;
|
|
79
|
+
editor.getEditorState().read(() => {
|
|
80
|
+
const selection = $getSelection();
|
|
81
|
+
if (!$isRangeSelection(selection)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
text = getTextUpToAnchor(selection);
|
|
85
|
+
});
|
|
86
|
+
return text;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Walk backwards along user input and forward through entity title to try
|
|
90
|
+
* and replace more of the user's text with entity.
|
|
91
|
+
*/
|
|
92
|
+
function getFullMatchOffset(documentText, entryText, offset) {
|
|
93
|
+
let triggerOffset = offset;
|
|
94
|
+
for (let i = triggerOffset; i <= entryText.length; i++) {
|
|
95
|
+
if (documentText.substr(-i) === entryText.substr(0, i)) {
|
|
96
|
+
triggerOffset = i;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return triggerOffset;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Split Lexical TextNode and return a new TextNode only containing matched text.
|
|
103
|
+
* Common use cases include: removing the node, replacing with a new node.
|
|
104
|
+
*/
|
|
105
|
+
function splitNodeContainingQuery(editor, match) {
|
|
106
|
+
const selection = $getSelection();
|
|
107
|
+
if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const { anchor } = selection;
|
|
111
|
+
if (anchor.type !== 'text') {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const anchorNode = anchor.getNode();
|
|
115
|
+
if (!anchorNode.isSimpleText()) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const selectionOffset = anchor.offset;
|
|
119
|
+
const textContent = anchorNode.getTextContent().slice(0, selectionOffset);
|
|
120
|
+
const characterOffset = match.replaceableString.length;
|
|
121
|
+
const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset);
|
|
122
|
+
const startOffset = selectionOffset - queryOffset;
|
|
123
|
+
if (startOffset < 0) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
let newNode;
|
|
127
|
+
if (startOffset === 0) {
|
|
128
|
+
[newNode] = anchorNode.splitText(selectionOffset);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
[, newNode] = anchorNode.splitText(startOffset, selectionOffset);
|
|
132
|
+
}
|
|
133
|
+
return newNode;
|
|
134
|
+
}
|
|
135
|
+
function isSelectionOnEntityBoundary(editor, offset) {
|
|
136
|
+
if (offset !== 0) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return editor.getEditorState().read(() => {
|
|
140
|
+
const selection = $getSelection();
|
|
141
|
+
if ($isRangeSelection(selection)) {
|
|
142
|
+
const { anchor } = selection;
|
|
143
|
+
const anchorNode = anchor.getNode();
|
|
144
|
+
const prevSibling = anchorNode.getPreviousSibling();
|
|
145
|
+
return $isTextNode(prevSibling) && prevSibling.isTextEntity();
|
|
146
|
+
}
|
|
147
|
+
return false;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function startTransition(callback) {
|
|
151
|
+
if (React.startTransition) {
|
|
152
|
+
React.startTransition(callback);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
callback();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Got from https://stackoverflow.com/a/42543908/2013580
|
|
159
|
+
export function getScrollParent(element, includeHidden) {
|
|
160
|
+
let style = getComputedStyle(element);
|
|
161
|
+
const excludeStaticParent = style.position === 'absolute';
|
|
162
|
+
const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
|
|
163
|
+
if (style.position === 'fixed') {
|
|
164
|
+
return document.body;
|
|
165
|
+
}
|
|
166
|
+
// eslint-disable-next-line no-cond-assign
|
|
167
|
+
for (let parent = element; (parent = parent.parentElement);) {
|
|
168
|
+
style = getComputedStyle(parent);
|
|
169
|
+
if (excludeStaticParent && style.position === 'static') {
|
|
170
|
+
// eslint-disable-next-line no-continue
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {
|
|
174
|
+
return parent;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return document.body;
|
|
178
|
+
}
|
|
179
|
+
function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
|
|
180
|
+
const tRect = targetElement.getBoundingClientRect();
|
|
181
|
+
const cRect = containerElement.getBoundingClientRect();
|
|
182
|
+
return tRect.top > cRect.top && tRect.top < cRect.bottom;
|
|
183
|
+
}
|
|
184
|
+
// Reposition the menu on scroll, window resize, and element resize.
|
|
185
|
+
export function useDynamicPositioning(resolution, targetElement, onReposition, onVisibilityChange) {
|
|
186
|
+
const [editor] = useLexicalComposerContext();
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (targetElement != null && resolution != null) {
|
|
189
|
+
const rootElement = editor.getRootElement();
|
|
190
|
+
const rootScrollParent = rootElement != null ? getScrollParent(rootElement, false) : document.body;
|
|
191
|
+
let ticking = false;
|
|
192
|
+
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
193
|
+
const handleScroll = function () {
|
|
194
|
+
if (!ticking) {
|
|
195
|
+
window.requestAnimationFrame(function () {
|
|
196
|
+
onReposition();
|
|
197
|
+
ticking = false;
|
|
198
|
+
});
|
|
199
|
+
ticking = true;
|
|
200
|
+
}
|
|
201
|
+
const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
202
|
+
if (isInView !== previousIsInView) {
|
|
203
|
+
previousIsInView = isInView;
|
|
204
|
+
if (onVisibilityChange != null) {
|
|
205
|
+
onVisibilityChange(isInView);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const resizeObserver = new ResizeObserver(onReposition);
|
|
210
|
+
window.addEventListener('resize', onReposition);
|
|
211
|
+
document.addEventListener('scroll', handleScroll, {
|
|
212
|
+
capture: true,
|
|
213
|
+
passive: true,
|
|
214
|
+
});
|
|
215
|
+
resizeObserver.observe(targetElement);
|
|
216
|
+
return () => {
|
|
217
|
+
resizeObserver.unobserve(targetElement);
|
|
218
|
+
window.removeEventListener('resize', onReposition);
|
|
219
|
+
document.removeEventListener('scroll', handleScroll);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}, [targetElement, editor, onVisibilityChange, onReposition, resolution]);
|
|
223
|
+
}
|
|
224
|
+
export const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND');
|
|
225
|
+
function LexicalPopoverMenu({ close, editor, anchorElementRef, resolution, options, menuRenderFn, onSelectOption, }) {
|
|
226
|
+
const [selectedIndex, setHighlightedIndex] = useState(null);
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
setHighlightedIndex(0);
|
|
229
|
+
}, [resolution.match.matchingString]);
|
|
230
|
+
const selectOptionAndCleanUp = useCallback((selectedEntry) => {
|
|
231
|
+
editor.update(() => {
|
|
232
|
+
const textNodeContainingQuery = splitNodeContainingQuery(editor, resolution.match);
|
|
233
|
+
onSelectOption(selectedEntry, textNodeContainingQuery, close, resolution.match.matchingString);
|
|
234
|
+
});
|
|
235
|
+
}, [close, editor, resolution.match, onSelectOption]);
|
|
236
|
+
const updateSelectedIndex = useCallback((index) => {
|
|
237
|
+
const rootElem = editor.getRootElement();
|
|
238
|
+
if (rootElem !== null) {
|
|
239
|
+
rootElem.setAttribute('aria-activedescendant', `typeahead-item-${index}`);
|
|
240
|
+
setHighlightedIndex(index);
|
|
241
|
+
}
|
|
242
|
+
}, [editor]);
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
return () => {
|
|
245
|
+
const rootElem = editor.getRootElement();
|
|
246
|
+
if (rootElem !== null) {
|
|
247
|
+
rootElem.removeAttribute('aria-activedescendant');
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
}, [editor]);
|
|
251
|
+
useLayoutEffect(() => {
|
|
252
|
+
if (options === null) {
|
|
253
|
+
setHighlightedIndex(null);
|
|
254
|
+
}
|
|
255
|
+
else if (selectedIndex === null) {
|
|
256
|
+
updateSelectedIndex(0);
|
|
257
|
+
}
|
|
258
|
+
}, [options, selectedIndex, updateSelectedIndex]);
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
return mergeRegister(editor.registerCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, ({ option }) => {
|
|
261
|
+
if (option.ref && option.ref.current != null) {
|
|
262
|
+
scrollIntoViewIfNeeded(option.ref.current);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
return false;
|
|
266
|
+
}, COMMAND_PRIORITY_LOW));
|
|
267
|
+
}, [editor, updateSelectedIndex]);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
return mergeRegister(editor.registerCommand(KEY_ARROW_DOWN_COMMAND, (payload) => {
|
|
270
|
+
const event = payload;
|
|
271
|
+
if (options !== null && options.length && selectedIndex !== null) {
|
|
272
|
+
const newSelectedIndex = selectedIndex !== options.length - 1 ? selectedIndex + 1 : 0;
|
|
273
|
+
updateSelectedIndex(newSelectedIndex);
|
|
274
|
+
const option = options[newSelectedIndex];
|
|
275
|
+
if (option.ref != null && option.ref.current) {
|
|
276
|
+
editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {
|
|
277
|
+
index: newSelectedIndex,
|
|
278
|
+
option,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
event.stopImmediatePropagation();
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_UP_COMMAND, (payload) => {
|
|
286
|
+
const event = payload;
|
|
287
|
+
if (options !== null && options.length && selectedIndex !== null) {
|
|
288
|
+
const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : options.length - 1;
|
|
289
|
+
updateSelectedIndex(newSelectedIndex);
|
|
290
|
+
const option = options[newSelectedIndex];
|
|
291
|
+
if (option.ref != null && option.ref.current) {
|
|
292
|
+
scrollIntoViewIfNeeded(option.ref.current);
|
|
293
|
+
}
|
|
294
|
+
event.preventDefault();
|
|
295
|
+
event.stopImmediatePropagation();
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ESCAPE_COMMAND, (payload) => {
|
|
299
|
+
const event = payload;
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
event.stopImmediatePropagation();
|
|
302
|
+
close();
|
|
303
|
+
return true;
|
|
304
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_TAB_COMMAND, (payload) => {
|
|
305
|
+
const event = payload;
|
|
306
|
+
if (options === null || selectedIndex === null || options[selectedIndex] == null) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
event.stopImmediatePropagation();
|
|
311
|
+
selectOptionAndCleanUp(options[selectedIndex]);
|
|
312
|
+
return true;
|
|
313
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ENTER_COMMAND, (event) => {
|
|
314
|
+
if (options === null || selectedIndex === null || options[selectedIndex] == null) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
if (event !== null) {
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
event.stopImmediatePropagation();
|
|
320
|
+
}
|
|
321
|
+
selectOptionAndCleanUp(options[selectedIndex]);
|
|
322
|
+
return true;
|
|
323
|
+
}, COMMAND_PRIORITY_HIGH));
|
|
324
|
+
}, [selectOptionAndCleanUp, close, editor, options, selectedIndex, updateSelectedIndex]);
|
|
325
|
+
const listItemProps = useMemo(() => ({
|
|
326
|
+
options,
|
|
327
|
+
selectOptionAndCleanUp,
|
|
328
|
+
selectedIndex,
|
|
329
|
+
setHighlightedIndex,
|
|
330
|
+
}), [selectOptionAndCleanUp, selectedIndex, options]);
|
|
331
|
+
return menuRenderFn(anchorElementRef, listItemProps, resolution.match.matchingString);
|
|
332
|
+
}
|
|
333
|
+
export function useBasicTypeaheadTriggerMatch(trigger, { minLength = 1, maxLength = 75 }) {
|
|
334
|
+
return useCallback((text) => {
|
|
335
|
+
const validChars = `[^${trigger}${PUNCTUATION}\\s]`;
|
|
336
|
+
const TypeaheadTriggerRegex = new RegExp(
|
|
337
|
+
// eslint-disable-next-line no-useless-concat
|
|
338
|
+
'(^|\\s|\\()(' + `[${trigger}]` + `((?:${validChars}){0,${maxLength}})` + ')$');
|
|
339
|
+
const match = TypeaheadTriggerRegex.exec(text);
|
|
340
|
+
if (match !== null) {
|
|
341
|
+
const maybeLeadingWhitespace = match[1];
|
|
342
|
+
const matchingString = match[3];
|
|
343
|
+
if (matchingString.length >= minLength) {
|
|
344
|
+
return {
|
|
345
|
+
leadOffset: match.index + maybeLeadingWhitespace.length,
|
|
346
|
+
matchingString,
|
|
347
|
+
replaceableString: match[2],
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return null;
|
|
352
|
+
}, [maxLength, minLength, trigger]);
|
|
353
|
+
}
|
|
354
|
+
function useMenuAnchorRef(resolution, setResolution, className) {
|
|
355
|
+
const [editor] = useLexicalComposerContext();
|
|
356
|
+
const anchorElementRef = useRef(document.createElement('div'));
|
|
357
|
+
const positionMenu = useCallback(() => {
|
|
358
|
+
const rootElement = editor.getRootElement();
|
|
359
|
+
const containerDiv = anchorElementRef.current;
|
|
360
|
+
if (rootElement !== null && resolution !== null) {
|
|
361
|
+
const { left, top, width, height } = resolution.getRect();
|
|
362
|
+
containerDiv.style.top = `${top + window.pageYOffset}px`;
|
|
363
|
+
containerDiv.style.left = `${left + width}px`;
|
|
364
|
+
containerDiv.style.height = `${height}px`;
|
|
365
|
+
containerDiv.style.width = `${width}px`;
|
|
366
|
+
if (!containerDiv.isConnected) {
|
|
367
|
+
if (className != null) {
|
|
368
|
+
containerDiv.className = className;
|
|
369
|
+
}
|
|
370
|
+
containerDiv.setAttribute('aria-label', 'Typeahead menu');
|
|
371
|
+
containerDiv.setAttribute('id', 'typeahead-menu');
|
|
372
|
+
containerDiv.setAttribute('role', 'listbox');
|
|
373
|
+
containerDiv.style.display = 'block';
|
|
374
|
+
containerDiv.style.position = 'absolute';
|
|
375
|
+
document.body.append(containerDiv);
|
|
376
|
+
}
|
|
377
|
+
anchorElementRef.current = containerDiv;
|
|
378
|
+
rootElement.setAttribute('aria-controls', 'typeahead-menu');
|
|
379
|
+
}
|
|
380
|
+
}, [editor, resolution, className]);
|
|
381
|
+
useEffect(() => {
|
|
382
|
+
const rootElement = editor.getRootElement();
|
|
383
|
+
if (resolution !== null) {
|
|
384
|
+
positionMenu();
|
|
385
|
+
return () => {
|
|
386
|
+
if (rootElement !== null) {
|
|
387
|
+
rootElement.removeAttribute('aria-controls');
|
|
388
|
+
}
|
|
389
|
+
const containerDiv = anchorElementRef.current;
|
|
390
|
+
if (containerDiv !== null && containerDiv.isConnected) {
|
|
391
|
+
containerDiv.remove();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
}, [editor, positionMenu, resolution]);
|
|
396
|
+
const onVisibilityChange = useCallback((isInView) => {
|
|
397
|
+
if (resolution !== null) {
|
|
398
|
+
if (!isInView) {
|
|
399
|
+
setResolution(null);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}, [resolution, setResolution]);
|
|
403
|
+
useDynamicPositioning(resolution, anchorElementRef.current, positionMenu, onVisibilityChange);
|
|
404
|
+
return anchorElementRef;
|
|
405
|
+
}
|
|
406
|
+
export function LexicalTypeaheadMenuPlugin({ options, onQueryChange, onSelectOption, onOpen, onClose, menuRenderFn, triggerFn, anchorClassName, }) {
|
|
407
|
+
const [editor] = useLexicalComposerContext();
|
|
408
|
+
const [resolution, setResolution] = useState(null);
|
|
409
|
+
const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName);
|
|
410
|
+
const closeTypeahead = useCallback(() => {
|
|
411
|
+
setResolution(null);
|
|
412
|
+
if (onClose != null && resolution !== null) {
|
|
413
|
+
onClose();
|
|
414
|
+
}
|
|
415
|
+
}, [onClose, resolution]);
|
|
416
|
+
const openTypeahead = useCallback((res) => {
|
|
417
|
+
setResolution(res);
|
|
418
|
+
if (onOpen != null && resolution === null) {
|
|
419
|
+
onOpen(res);
|
|
420
|
+
}
|
|
421
|
+
}, [onOpen, resolution]);
|
|
422
|
+
useEffect(() => {
|
|
423
|
+
const updateListener = () => {
|
|
424
|
+
editor.getEditorState().read(() => {
|
|
425
|
+
const range = document.createRange();
|
|
426
|
+
const selection = $getSelection();
|
|
427
|
+
const text = getQueryTextForSearch(editor);
|
|
428
|
+
if (!$isRangeSelection(selection) || !selection.isCollapsed() || text === null || range === null) {
|
|
429
|
+
closeTypeahead();
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const match = triggerFn(text, editor);
|
|
433
|
+
onQueryChange(match ? match.matchingString : null);
|
|
434
|
+
if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {
|
|
435
|
+
const isRangePositioned = tryToPositionRange(match.leadOffset, range);
|
|
436
|
+
if (isRangePositioned !== null) {
|
|
437
|
+
startTransition(() => openTypeahead({
|
|
438
|
+
getRect: () => range.getBoundingClientRect(),
|
|
439
|
+
match,
|
|
440
|
+
}));
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
closeTypeahead();
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
const removeUpdateListener = editor.registerUpdateListener(updateListener);
|
|
448
|
+
return () => {
|
|
449
|
+
removeUpdateListener();
|
|
450
|
+
};
|
|
451
|
+
}, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead]);
|
|
452
|
+
return resolution === null || editor === null ? null : (_jsx(LexicalPopoverMenu, { close: closeTypeahead, resolution: resolution, editor: editor, anchorElementRef: anchorElementRef, options: options, menuRenderFn: menuRenderFn, onSelectOption: onSelectOption }));
|
|
453
|
+
}
|
|
454
|
+
export function LexicalNodeMenuPlugin({ options, nodeKey, onClose, onOpen, onSelectOption, menuRenderFn, anchorClassName, }) {
|
|
455
|
+
const [editor] = useLexicalComposerContext();
|
|
456
|
+
const [resolution, setResolution] = useState(null);
|
|
457
|
+
const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName);
|
|
458
|
+
const closeNodeMenu = useCallback(() => {
|
|
459
|
+
setResolution(null);
|
|
460
|
+
if (onClose != null && resolution !== null) {
|
|
461
|
+
onClose();
|
|
462
|
+
}
|
|
463
|
+
}, [onClose, resolution]);
|
|
464
|
+
const openNodeMenu = useCallback((res) => {
|
|
465
|
+
setResolution(res);
|
|
466
|
+
if (onOpen != null && resolution === null) {
|
|
467
|
+
onOpen(res);
|
|
468
|
+
}
|
|
469
|
+
}, [onOpen, resolution]);
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
if (nodeKey && resolution == null) {
|
|
472
|
+
editor.update(() => {
|
|
473
|
+
const node = $getNodeByKey(nodeKey);
|
|
474
|
+
const domElement = editor.getElementByKey(nodeKey);
|
|
475
|
+
if (node != null && domElement != null) {
|
|
476
|
+
const text = node.getTextContent();
|
|
477
|
+
startTransition(() => openNodeMenu({
|
|
478
|
+
getRect: () => domElement.getBoundingClientRect(),
|
|
479
|
+
match: {
|
|
480
|
+
leadOffset: text.length,
|
|
481
|
+
matchingString: text,
|
|
482
|
+
replaceableString: text,
|
|
483
|
+
},
|
|
484
|
+
}));
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
else if (nodeKey == null && resolution != null) {
|
|
489
|
+
closeNodeMenu();
|
|
490
|
+
}
|
|
491
|
+
}, [closeNodeMenu, editor, nodeKey, openNodeMenu, resolution]);
|
|
492
|
+
return resolution === null || editor === null ? null : (_jsx(LexicalPopoverMenu, { close: closeNodeMenu, resolution: resolution, editor: editor, anchorElementRef: anchorElementRef, options: options, menuRenderFn: menuRenderFn, onSelectOption: onSelectOption }));
|
|
493
|
+
}
|
|
@@ -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 MarkdownShortcutPlugin(): JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
|
+
import { MarkdownShortcutPlugin as OfficialMarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin';
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
import { PLAYGROUND_TRANSFORMERS } from '../MarkdownTransformers';
|
|
13
|
+
export default function MarkdownShortcutPlugin() {
|
|
14
|
+
const [editor] = useLexicalComposerContext();
|
|
15
|
+
const transformers = useMemo(() => PLAYGROUND_TRANSFORMERS.filter((i) => {
|
|
16
|
+
if (i.type === 'element' || i.type === 'text-match') {
|
|
17
|
+
return editor.hasNodes(i.dependencies);
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}), [editor]);
|
|
21
|
+
return _jsx(OfficialMarkdownShortcutPlugin, { transformers: transformers });
|
|
22
|
+
}
|
|
@@ -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 { ElementTransformer, TextMatchTransformer, Transformer } from '@lexical/markdown';
|
|
9
|
+
export declare const HR: ElementTransformer;
|
|
10
|
+
export declare const IMAGE: TextMatchTransformer;
|
|
11
|
+
export declare const TABLE: ElementTransformer;
|
|
12
|
+
export declare const PLAYGROUND_TRANSFORMERS: Array<Transformer>;
|