@scottjgilbert/lexical-blog-editor 0.1.4 → 1.0.0-beta.2
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/README.md +73 -67
- package/build/Editor.d.ts +8 -3
- package/build/Editor.d.ts.map +1 -1
- package/build/Editor.js +13 -8
- package/build/EditorExport.d.ts +4 -0
- package/build/EditorExport.d.ts.map +1 -0
- package/build/EditorExport.js +13 -0
- package/build/appSettings.d.ts +1 -1
- package/build/appSettings.js +1 -1
- package/build/buildHTMLConfig.d.ts +1 -1
- package/build/buildHTMLConfig.d.ts.map +1 -1
- package/build/buildHTMLConfig.js +35 -11
- package/build/context/FlashMessageContext.d.ts +2 -2
- package/build/context/FlashMessageContext.d.ts.map +1 -1
- package/build/context/FlashMessageContext.js +4 -3
- package/build/context/SharedHistoryContext.d.ts +3 -3
- package/build/context/SharedHistoryContext.d.ts.map +1 -1
- package/build/context/SharedHistoryContext.js +3 -2
- package/build/context/ToolbarContext.d.ts +1 -0
- package/build/context/ToolbarContext.d.ts.map +1 -1
- package/build/context/ToolbarContext.js +2 -0
- package/build/hooks/useModal.d.ts.map +1 -1
- package/build/hooks/useModal.js +1 -0
- package/build/hooks/useReport.d.ts +0 -7
- package/build/hooks/useReport.d.ts.map +1 -1
- package/build/hooks/useReport.js +1 -0
- package/build/index.css +283 -246
- package/build/index.d.ts +3 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/nodes/CodeNode/CodeHighlightNode.d.ts +35 -0
- package/build/nodes/CodeNode/CodeHighlightNode.d.ts.map +1 -0
- package/build/nodes/CodeNode/CodeHighlightNode.js +88 -0
- package/build/nodes/CodeNode/CodeHighlighterShiki.d.ts +22 -0
- package/build/nodes/CodeNode/CodeHighlighterShiki.d.ts.map +1 -0
- package/build/nodes/CodeNode/CodeHighlighterShiki.js +644 -0
- package/build/nodes/CodeNode/CodeNode.d.ts +48 -0
- package/build/nodes/CodeNode/CodeNode.d.ts.map +1 -0
- package/build/nodes/CodeNode/CodeNode.js +367 -0
- package/build/nodes/CodeNode/FacadeShiki.d.ts +18 -0
- package/build/nodes/CodeNode/FacadeShiki.d.ts.map +1 -0
- package/build/nodes/CodeNode/FacadeShiki.js +159 -0
- package/build/nodes/CodeNode/FlatStructureUtils.d.ts +21 -0
- package/build/nodes/CodeNode/FlatStructureUtils.d.ts.map +1 -0
- package/build/nodes/CodeNode/FlatStructureUtils.js +85 -0
- package/build/nodes/CodeNode/invariant.d.ts +2 -0
- package/build/nodes/CodeNode/invariant.d.ts.map +1 -0
- package/build/nodes/CodeNode/invariant.js +6 -0
- package/build/nodes/DateTimeNode/DateTimeComponent.d.ts.map +1 -1
- package/build/nodes/DateTimeNode/DateTimeComponent.js +1 -0
- package/build/nodes/DateTimeNode/DateTimeNode.css +21 -0
- package/build/nodes/FigmaNode/FigmaNode.d.ts.map +1 -0
- package/build/nodes/FigmaNode/ServerFigmaNode.d.ts +21 -0
- package/build/nodes/FigmaNode/ServerFigmaNode.d.ts.map +1 -0
- package/build/nodes/FigmaNode/ServerFigmaNode.js +48 -0
- package/build/nodes/ImageComponent.d.ts.map +1 -1
- package/build/nodes/ImageComponent.js +1 -2
- package/build/nodes/ImageNode.d.ts +7 -7
- package/build/nodes/ImageNode.d.ts.map +1 -1
- package/build/nodes/ImageNode.js +30 -30
- package/build/nodes/LayoutContainerNode.d.ts +2 -2
- package/build/nodes/LayoutContainerNode.d.ts.map +1 -1
- package/build/nodes/LayoutContainerNode.js +10 -10
- package/build/nodes/PlaygroundNodes/PlaygroundNodes.d.ts.map +1 -0
- package/build/nodes/{PlaygroundNodes.js → PlaygroundNodes/PlaygroundNodes.js} +19 -21
- package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.d.ts +11 -0
- package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.d.ts.map +1 -0
- package/build/nodes/PlaygroundNodes/ServerPlaygroundNodes.js +65 -0
- package/build/nodes/TweetNode/ServerTweetNode.d.ts +20 -0
- package/build/nodes/TweetNode/ServerTweetNode.d.ts.map +1 -0
- package/build/nodes/TweetNode/ServerTweetNode.js +59 -0
- package/build/nodes/TweetNode/TweetNode.d.ts.map +1 -0
- package/build/nodes/YouTubeNode/ServerYouTubeNode.d.ts +21 -0
- package/build/nodes/YouTubeNode/ServerYouTubeNode.d.ts.map +1 -0
- package/build/nodes/YouTubeNode/ServerYouTubeNode.js +67 -0
- package/build/nodes/YouTubeNode/YouTubeNode.d.ts.map +1 -0
- package/build/plugins/ActionsPlugin/index.d.ts +0 -7
- package/build/plugins/ActionsPlugin/index.d.ts.map +1 -1
- package/build/plugins/ActionsPlugin/index.js +2 -1
- package/build/plugins/AutoEmbedPlugin/index.d.ts +2 -9
- package/build/plugins/AutoEmbedPlugin/index.d.ts.map +1 -1
- package/build/plugins/AutoEmbedPlugin/index.js +30 -29
- package/build/plugins/AutoLinkPlugin/index.d.ts +1 -1
- package/build/plugins/AutoLinkPlugin/index.d.ts.map +1 -1
- package/build/plugins/AutoLinkPlugin/index.js +3 -2
- package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +1 -1
- package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +7 -6
- package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +2 -2
- package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +25 -24
- package/build/plugins/CodeActionMenuPlugin/index.d.ts +2 -9
- package/build/plugins/CodeActionMenuPlugin/index.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/index.js +22 -20
- package/build/plugins/CodeActionMenuPlugin/utils.d.ts.map +1 -1
- package/build/plugins/CodeActionMenuPlugin/utils.js +3 -2
- package/build/plugins/CodeHighlightPrismPlugin/index.d.ts +1 -1
- package/build/plugins/CodeHighlightPrismPlugin/index.d.ts.map +1 -1
- package/build/plugins/CodeHighlightPrismPlugin/index.js +4 -10
- package/build/plugins/CodeHighlightShikiPlugin/index.d.ts +1 -1
- package/build/plugins/CodeHighlightShikiPlugin/index.d.ts.map +1 -1
- package/build/plugins/CodeHighlightShikiPlugin/index.js +3 -3
- package/build/plugins/CollapsiblePlugin/Collapsible.css +17 -1
- package/build/plugins/CollapsiblePlugin/index.d.ts +1 -1
- package/build/plugins/CollapsiblePlugin/index.d.ts.map +1 -1
- package/build/plugins/CollapsiblePlugin/index.js +11 -10
- package/build/plugins/ComponentPickerPlugin/index.d.ts.map +1 -1
- package/build/plugins/ComponentPickerPlugin/index.js +3 -8
- package/build/plugins/ContextMenuPlugin/index.d.ts +1 -1
- package/build/plugins/ContextMenuPlugin/index.d.ts.map +1 -1
- package/build/plugins/ContextMenuPlugin/index.js +15 -14
- package/build/plugins/DateTimePlugin/index.d.ts +2 -2
- package/build/plugins/DateTimePlugin/index.d.ts.map +1 -1
- package/build/plugins/DateTimePlugin/index.js +8 -14
- package/build/plugins/DragDropPastePlugin/index.d.ts +0 -7
- package/build/plugins/DragDropPastePlugin/index.d.ts.map +1 -1
- package/build/plugins/DragDropPastePlugin/index.js +12 -11
- package/build/plugins/DraggableBlockPlugin/index.css +6 -0
- package/build/plugins/DraggableBlockPlugin/index.d.ts +2 -2
- package/build/plugins/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/build/plugins/DraggableBlockPlugin/index.js +23 -22
- package/build/plugins/EmojiPickerPlugin/index.d.ts +0 -7
- package/build/plugins/EmojiPickerPlugin/index.d.ts.map +1 -1
- package/build/plugins/EmojiPickerPlugin/index.js +1 -0
- package/build/plugins/EmojisPlugin/index.d.ts +1 -8
- package/build/plugins/EmojisPlugin/index.d.ts.map +1 -1
- package/build/plugins/EmojisPlugin/index.js +10 -16
- package/build/plugins/EquationsPlugin/index.d.ts +3 -3
- package/build/plugins/EquationsPlugin/index.d.ts.map +1 -1
- package/build/plugins/EquationsPlugin/index.js +14 -10
- package/build/plugins/FigmaPlugin/index.d.ts +2 -2
- package/build/plugins/FigmaPlugin/index.d.ts.map +1 -1
- package/build/plugins/FigmaPlugin/index.js +8 -14
- package/build/plugins/FloatingLinkEditorPlugin/index.css +11 -0
- package/build/plugins/FloatingLinkEditorPlugin/index.d.ts +3 -3
- package/build/plugins/FloatingLinkEditorPlugin/index.d.ts.map +1 -1
- package/build/plugins/FloatingLinkEditorPlugin/index.js +28 -27
- package/build/plugins/FloatingTextFormatToolbarPlugin/index.css +15 -0
- package/build/plugins/FloatingTextFormatToolbarPlugin/index.d.ts.map +1 -1
- package/build/plugins/FloatingTextFormatToolbarPlugin/index.js +2 -1
- package/build/plugins/ImagesPlugin/index.d.ts +3 -3
- package/build/plugins/ImagesPlugin/index.d.ts.map +1 -1
- package/build/plugins/ImagesPlugin/index.js +38 -37
- package/build/plugins/KeywordsPlugin/index.d.ts +1 -8
- package/build/plugins/KeywordsPlugin/index.d.ts.map +1 -1
- package/build/plugins/KeywordsPlugin/index.js +6 -12
- package/build/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +2 -2
- package/build/plugins/LayoutPlugin/InsertLayoutDialog.d.ts.map +1 -1
- package/build/plugins/LayoutPlugin/InsertLayoutDialog.js +10 -9
- package/build/plugins/LayoutPlugin/LayoutPlugin.d.ts +1 -1
- package/build/plugins/LayoutPlugin/LayoutPlugin.d.ts.map +1 -1
- package/build/plugins/LayoutPlugin/LayoutPlugin.js +8 -14
- package/build/plugins/LinkPlugin/index.d.ts.map +1 -1
- package/build/plugins/LinkPlugin/index.js +1 -0
- package/build/plugins/MarkdownShortcutPlugin/index.d.ts.map +1 -1
- package/build/plugins/MarkdownShortcutPlugin/index.js +1 -0
- package/build/plugins/MarkdownTransformers/index.d.ts +1 -1
- package/build/plugins/MarkdownTransformers/index.d.ts.map +1 -1
- package/build/plugins/MarkdownTransformers/index.js +25 -25
- package/build/plugins/PasteLogPlugin/index.d.ts.map +1 -1
- package/build/plugins/PasteLogPlugin/index.js +1 -0
- package/build/plugins/ShortcutsPlugin/index.d.ts +0 -7
- package/build/plugins/ShortcutsPlugin/index.d.ts.map +1 -1
- package/build/plugins/ShortcutsPlugin/index.js +1 -0
- package/build/plugins/SpeechToTextPlugin/index.d.ts +2 -2
- package/build/plugins/SpeechToTextPlugin/index.d.ts.map +1 -1
- package/build/plugins/SpeechToTextPlugin/index.js +7 -11
- package/build/plugins/TabFocusPlugin/index.d.ts +0 -7
- package/build/plugins/TabFocusPlugin/index.d.ts.map +1 -1
- package/build/plugins/TabFocusPlugin/index.js +6 -5
- package/build/plugins/TableActionMenuPlugin/index.d.ts +1 -8
- package/build/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
- package/build/plugins/TableActionMenuPlugin/index.js +41 -40
- package/build/plugins/TableCellResizer/index.d.ts +2 -2
- package/build/plugins/TableCellResizer/index.d.ts.map +1 -1
- package/build/plugins/TableCellResizer/index.js +43 -42
- package/build/plugins/TableHoverActionsPlugin/index.d.ts +1 -8
- package/build/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/build/plugins/TableHoverActionsPlugin/index.js +19 -18
- package/build/plugins/TableHoverActionsV2Plugin/index.d.ts.map +1 -1
- package/build/plugins/TableHoverActionsV2Plugin/index.js +1 -0
- package/build/plugins/TablePlugin.d.ts +2 -2
- package/build/plugins/TablePlugin.d.ts.map +1 -1
- package/build/plugins/TablePlugin.js +11 -10
- package/build/plugins/TableScrollShadowPlugin/index.d.ts +0 -7
- package/build/plugins/TableScrollShadowPlugin/index.d.ts.map +1 -1
- package/build/plugins/TableScrollShadowPlugin/index.js +9 -8
- package/build/plugins/TestRecorderPlugin/index.d.ts +1 -8
- package/build/plugins/TestRecorderPlugin/index.d.ts.map +1 -1
- package/build/plugins/TestRecorderPlugin/index.js +45 -44
- package/build/plugins/ToolbarPlugin/fontSize.d.ts +2 -2
- package/build/plugins/ToolbarPlugin/fontSize.d.ts.map +1 -1
- package/build/plugins/ToolbarPlugin/fontSize.js +19 -18
- package/build/plugins/ToolbarPlugin/index.d.ts.map +1 -1
- package/build/plugins/ToolbarPlugin/index.js +68 -60
- package/build/plugins/ToolbarPlugin/languages.d.ts +14 -0
- package/build/plugins/ToolbarPlugin/languages.d.ts.map +1 -0
- package/build/plugins/ToolbarPlugin/languages.js +185 -0
- package/build/plugins/ToolbarPlugin/utils.d.ts +2 -2
- package/build/plugins/ToolbarPlugin/utils.js +21 -21
- package/build/plugins/TwitterPlugin/index.d.ts +2 -2
- package/build/plugins/TwitterPlugin/index.d.ts.map +1 -1
- package/build/plugins/TwitterPlugin/index.js +8 -14
- package/build/plugins/YouTubePlugin/index.d.ts +2 -2
- package/build/plugins/YouTubePlugin/index.d.ts.map +1 -1
- package/build/plugins/YouTubePlugin/index.js +8 -14
- package/build/themes/PlaygroundEditorTheme.css +301 -33
- package/build/themes/ViewerTheme.css +899 -0
- package/build/{plugins/MentionsPlugin/index.d.ts → themes/ViewerTheme.d.ts} +5 -3
- package/build/themes/ViewerTheme.d.ts.map +1 -0
- package/build/themes/ViewerTheme.js +124 -0
- package/build/themes/ViewerThemeComplete.css +1043 -0
- package/build/ui/ColorPicker.d.ts +2 -2
- package/build/ui/ColorPicker.d.ts.map +1 -1
- package/build/ui/ColorPicker.js +47 -46
- package/build/ui/DropDown.d.ts.map +1 -1
- package/build/ui/DropDown.js +1 -0
- package/build/ui/FlashMessage.d.ts +3 -3
- package/build/ui/FlashMessage.d.ts.map +1 -1
- package/build/ui/FlashMessage.js +3 -2
- package/build/ui/ImageResizer.d.ts +3 -3
- package/build/ui/ImageResizer.d.ts.map +1 -1
- package/build/ui/ImageResizer.js +20 -19
- package/build/ui/KatexEquationAlterer.css +3 -1
- package/build/ui/KatexEquationAlterer.d.ts.map +1 -1
- package/build/ui/KatexEquationAlterer.js +1 -0
- package/build/ui/KatexRenderer.d.ts.map +1 -1
- package/build/ui/KatexRenderer.js +1 -0
- package/build/ui/Modal.d.ts.map +1 -1
- package/build/ui/Modal.js +1 -0
- package/build/ui/Switch.d.ts +2 -2
- package/build/ui/Switch.d.ts.map +1 -1
- package/build/ui/Switch.js +3 -2
- package/build/ui/TextInput.d.ts.map +1 -1
- package/build/ui/TextInput.js +1 -0
- package/build/utils/ServerBlockWithAlignableContents.d.ts +22 -0
- package/build/utils/ServerBlockWithAlignableContents.d.ts.map +1 -0
- package/build/utils/ServerBlockWithAlignableContents.js +6 -0
- package/build/utils/focusUtils.d.ts.map +1 -1
- package/build/utils/focusUtils.js +4 -3
- package/build/utils/getDOMRangeRect.d.ts.map +1 -1
- package/build/utils/getDOMRangeRect.js +1 -0
- package/build/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/build/utils/setFloatingElemPosition.js +5 -4
- package/build/utils/swipe.d.ts +0 -7
- package/build/utils/swipe.d.ts.map +1 -1
- package/build/utils/swipe.js +5 -11
- package/build/viewer/Viewer.d.ts +18 -0
- package/build/viewer/Viewer.d.ts.map +1 -0
- package/build/viewer/Viewer.js +105 -0
- package/build/viewer/client.d.ts +18 -0
- package/build/viewer/client.d.ts.map +1 -0
- package/build/viewer/client.js +97 -0
- package/build/viewer/index.d.ts +4 -0
- package/build/viewer/index.d.ts.map +1 -0
- package/build/viewer/index.js +2 -0
- package/package.json +58 -36
- package/build/collaboration.d.ts +0 -12
- package/build/collaboration.d.ts.map +0 -1
- package/build/collaboration.js +0 -32
- package/build/nodes/FigmaNode.d.ts.map +0 -1
- package/build/nodes/PageBreakNode/index.css +0 -64
- package/build/nodes/PageBreakNode/index.d.ts +0 -25
- package/build/nodes/PageBreakNode/index.d.ts.map +0 -1
- package/build/nodes/PageBreakNode/index.js +0 -83
- package/build/nodes/PlaygroundNodes.d.ts.map +0 -1
- package/build/nodes/PollComponent.d.ts +0 -17
- package/build/nodes/PollComponent.d.ts.map +0 -1
- package/build/nodes/PollComponent.js +0 -85
- package/build/nodes/PollNode.css +0 -165
- package/build/nodes/PollNode.d.ts +0 -51
- package/build/nodes/PollNode.d.ts.map +0 -1
- package/build/nodes/PollNode.js +0 -153
- package/build/nodes/StickyComponent.d.ts +0 -18
- package/build/nodes/StickyComponent.d.ts.map +0 -1
- package/build/nodes/StickyComponent.js +0 -155
- package/build/nodes/StickyNode.css +0 -37
- package/build/nodes/StickyNode.d.ts +0 -39
- package/build/nodes/StickyNode.d.ts.map +0 -1
- package/build/nodes/StickyNode.js +0 -66
- package/build/nodes/TweetNode.d.ts.map +0 -1
- package/build/nodes/YouTubeNode.d.ts.map +0 -1
- package/build/plugins/DocsPlugin/index.d.ts +0 -10
- package/build/plugins/DocsPlugin/index.d.ts.map +0 -1
- package/build/plugins/DocsPlugin/index.js +0 -4
- package/build/plugins/MaxLengthPlugin/index.d.ts +0 -11
- package/build/plugins/MaxLengthPlugin/index.d.ts.map +0 -1
- package/build/plugins/MaxLengthPlugin/index.js +0 -44
- package/build/plugins/MentionsPlugin/index.d.ts.map +0 -1
- package/build/plugins/MentionsPlugin/index.js +0 -562
- package/build/plugins/PageBreakPlugin/index.d.ts +0 -12
- package/build/plugins/PageBreakPlugin/index.d.ts.map +0 -1
- package/build/plugins/PageBreakPlugin/index.js +0 -34
- package/build/plugins/StickyPlugin/index.d.ts +0 -10
- package/build/plugins/StickyPlugin/index.d.ts.map +0 -1
- package/build/plugins/StickyPlugin/index.js +0 -19
- package/build/plugins/TreeViewPlugin/index.d.ts +0 -10
- package/build/plugins/TreeViewPlugin/index.d.ts.map +0 -1
- package/build/plugins/TreeViewPlugin/index.js +0 -7
- package/build/plugins/TypingPerfPlugin/index.d.ts +0 -10
- package/build/plugins/TypingPerfPlugin/index.d.ts.map +0 -1
- package/build/plugins/TypingPerfPlugin/index.js +0 -100
- package/build/plugins/VersionsPlugin/index.css +0 -57
- package/build/plugins/VersionsPlugin/index.d.ts +0 -14
- package/build/plugins/VersionsPlugin/index.d.ts.map +0 -1
- package/build/plugins/VersionsPlugin/index.js +0 -147
- /package/build/nodes/{FigmaNode.d.ts → FigmaNode/FigmaNode.d.ts} +0 -0
- /package/build/nodes/{FigmaNode.js → FigmaNode/FigmaNode.js} +0 -0
- /package/build/nodes/{PlaygroundNodes.d.ts → PlaygroundNodes/PlaygroundNodes.d.ts} +0 -0
- /package/build/nodes/{TweetNode.d.ts → TweetNode/TweetNode.d.ts} +0 -0
- /package/build/nodes/{TweetNode.js → TweetNode/TweetNode.js} +0 -0
- /package/build/nodes/{YouTubeNode.d.ts → YouTubeNode/YouTubeNode.d.ts} +0 -0
- /package/build/nodes/{YouTubeNode.js → YouTubeNode/YouTubeNode.js} +0 -0
|
@@ -1,22 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { $isCodeNode, CodeNode
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import "./index.css";
|
|
4
|
+
import { $isCodeNode, CodeNode } from "../../nodes/CodeNode/CodeNode";
|
|
5
|
+
import { getLanguageFriendlyName, normalizeCodeLang } from "@lexical/code";
|
|
6
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
7
|
+
import { $getNearestNodeFromDOMNode, isHTMLElement } from "lexical";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
import { CopyButton } from "./components/CopyButton";
|
|
11
|
+
import { canBePrettier, PrettierButton } from "./components/PrettierButton";
|
|
12
|
+
import { useDebounce } from "./utils";
|
|
11
13
|
const CODE_PADDING = 8;
|
|
12
14
|
function CodeActionMenuContainer({ anchorElem, }) {
|
|
13
15
|
const [editor] = useLexicalComposerContext();
|
|
14
|
-
const [lang, setLang] = useState(
|
|
16
|
+
const [lang, setLang] = useState("");
|
|
15
17
|
const [isShown, setShown] = useState(false);
|
|
16
18
|
const [shouldListenMouseMove, setShouldListenMouseMove] = useState(false);
|
|
17
19
|
const [position, setPosition] = useState({
|
|
18
|
-
right:
|
|
19
|
-
top:
|
|
20
|
+
right: "0",
|
|
21
|
+
top: "0",
|
|
20
22
|
});
|
|
21
23
|
const codeSetRef = useRef(new Set());
|
|
22
24
|
const codeDOMNodeRef = useRef(null);
|
|
@@ -34,12 +36,12 @@ function CodeActionMenuContainer({ anchorElem, }) {
|
|
|
34
36
|
}
|
|
35
37
|
codeDOMNodeRef.current = codeDOMNode;
|
|
36
38
|
let codeNode = null;
|
|
37
|
-
let _lang =
|
|
39
|
+
let _lang = "";
|
|
38
40
|
editor.update(() => {
|
|
39
41
|
const maybeCodeNode = $getNearestNodeFromDOMNode(codeDOMNode);
|
|
40
42
|
if ($isCodeNode(maybeCodeNode)) {
|
|
41
43
|
codeNode = maybeCodeNode;
|
|
42
|
-
_lang = codeNode.getLanguage() ||
|
|
44
|
+
_lang = codeNode.getLanguage() || "";
|
|
43
45
|
}
|
|
44
46
|
});
|
|
45
47
|
if (codeNode) {
|
|
@@ -57,11 +59,11 @@ function CodeActionMenuContainer({ anchorElem, }) {
|
|
|
57
59
|
if (!shouldListenMouseMove) {
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
60
|
-
document.addEventListener(
|
|
62
|
+
document.addEventListener("mousemove", debouncedOnMouseMove);
|
|
61
63
|
return () => {
|
|
62
64
|
setShown(false);
|
|
63
65
|
debouncedOnMouseMove.cancel();
|
|
64
|
-
document.removeEventListener(
|
|
66
|
+
document.removeEventListener("mousemove", debouncedOnMouseMove);
|
|
65
67
|
};
|
|
66
68
|
}, [shouldListenMouseMove, debouncedOnMouseMove]);
|
|
67
69
|
useEffect(() => {
|
|
@@ -69,10 +71,10 @@ function CodeActionMenuContainer({ anchorElem, }) {
|
|
|
69
71
|
editor.getEditorState().read(() => {
|
|
70
72
|
for (const [key, type] of mutations) {
|
|
71
73
|
switch (type) {
|
|
72
|
-
case
|
|
74
|
+
case "created":
|
|
73
75
|
codeSetRef.current.add(key);
|
|
74
76
|
break;
|
|
75
|
-
case
|
|
77
|
+
case "destroyed":
|
|
76
78
|
codeSetRef.current.delete(key);
|
|
77
79
|
break;
|
|
78
80
|
default:
|
|
@@ -90,9 +92,9 @@ function CodeActionMenuContainer({ anchorElem, }) {
|
|
|
90
92
|
function getMouseInfo(event) {
|
|
91
93
|
const target = event.target;
|
|
92
94
|
if (isHTMLElement(target)) {
|
|
93
|
-
const codeDOMNode = target.closest(
|
|
95
|
+
const codeDOMNode = target.closest("code.PlaygroundEditorTheme__code");
|
|
94
96
|
const isOutside = !(codeDOMNode ||
|
|
95
|
-
target.closest(
|
|
97
|
+
target.closest("div.code-action-menu-container"));
|
|
96
98
|
return { codeDOMNode, isOutside };
|
|
97
99
|
}
|
|
98
100
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeActionMenuPlugin/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeActionMenuPlugin/utils.ts"],"names":[],"mappings":"AAYA,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,EAC9D,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,4CAQA,UAAU,CAAC,CAAC,CAAC,WAU9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
4
|
*
|
|
@@ -5,8 +6,8 @@
|
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
*
|
|
7
8
|
*/
|
|
8
|
-
import { debounce } from
|
|
9
|
-
import { useMemo, useRef } from
|
|
9
|
+
import { debounce } from "lodash-es";
|
|
10
|
+
import { useMemo, useRef } from "react";
|
|
10
11
|
export function useDebounce(fn, ms, maxWait) {
|
|
11
12
|
const funcRef = useRef(null);
|
|
12
13
|
funcRef.current = fn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeHighlightPrismPlugin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeHighlightPrismPlugin/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAMjC,MAAM,CAAC,OAAO,UAAU,wBAAwB,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAQrE"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import { registerCodeHighlighting } from '@lexical/code';
|
|
9
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
|
-
import { useEffect } from 'react';
|
|
1
|
+
"use client";
|
|
2
|
+
import { registerCodeHighlighting } from "@lexical/code";
|
|
3
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
4
|
+
import { useEffect } from "react";
|
|
11
5
|
export default function CodeHighlightPrismPlugin() {
|
|
12
6
|
const [editor] = useLexicalComposerContext();
|
|
13
7
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeHighlightShikiPlugin/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeHighlightShikiPlugin/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAMjC,MAAM,CAAC,OAAO,UAAU,wBAAwB,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAQrE"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { registerCodeHighlighting } from
|
|
9
|
-
import { useLexicalComposerContext } from
|
|
10
|
-
import { useEffect } from
|
|
8
|
+
import { registerCodeHighlighting } from "../../nodes/CodeNode/CodeHighlighterShiki";
|
|
9
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
10
|
+
import { useEffect } from "react";
|
|
11
11
|
export default function CodeHighlightShikiPlugin() {
|
|
12
12
|
const [editor] = useLexicalComposerContext();
|
|
13
13
|
useEffect(() => {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
border-width: 4px 6px 4px 6px;
|
|
35
35
|
border-left-color: #000;
|
|
36
36
|
display: block;
|
|
37
|
-
content:
|
|
37
|
+
content: "";
|
|
38
38
|
position: absolute;
|
|
39
39
|
left: 7px;
|
|
40
40
|
top: 50%;
|
|
@@ -55,3 +55,19 @@
|
|
|
55
55
|
display: none;
|
|
56
56
|
user-select: none;
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
@media (prefers-color-scheme: dark) {
|
|
60
|
+
.Collapsible__container {
|
|
61
|
+
background: #2a2a2a;
|
|
62
|
+
border: 1px solid #444;
|
|
63
|
+
}
|
|
64
|
+
.Collapsible__title {
|
|
65
|
+
color: #ddd;
|
|
66
|
+
}
|
|
67
|
+
.Collapsible__title:before {
|
|
68
|
+
border-left-color: #ddd;
|
|
69
|
+
}
|
|
70
|
+
.Collapsible__container[open] > .Collapsible__title:before {
|
|
71
|
+
border-top-color: #ddd;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import "./Collapsible.css";
|
|
9
9
|
export declare const INSERT_COLLAPSIBLE_COMMAND: import("lexical").LexicalCommand<void>;
|
|
10
10
|
export default function CollapsiblePlugin(): null;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CollapsiblePlugin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CollapsiblePlugin/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,mBAAmB,CAAC;AAsC3B,eAAO,MAAM,0BAA0B,wCAEtC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,IAAI,CAiMhD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
4
|
*
|
|
@@ -5,15 +6,15 @@
|
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
*
|
|
7
8
|
*/
|
|
8
|
-
import
|
|
9
|
-
import { useLexicalComposerContext } from
|
|
10
|
-
import { $findMatchingParent, $insertNodeToNearestRoot, mergeRegister, } from
|
|
11
|
-
import { $createParagraphNode, $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, createCommand, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, } from
|
|
12
|
-
import { useEffect } from
|
|
13
|
-
import { $createCollapsibleContainerNode, $isCollapsibleContainerNode, CollapsibleContainerNode, } from
|
|
14
|
-
import { $createCollapsibleContentNode, $isCollapsibleContentNode, CollapsibleContentNode, } from
|
|
15
|
-
import { $createCollapsibleTitleNode, $isCollapsibleTitleNode, CollapsibleTitleNode, } from
|
|
16
|
-
export const INSERT_COLLAPSIBLE_COMMAND = createCommand(
|
|
9
|
+
import "./Collapsible.css";
|
|
10
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
11
|
+
import { $findMatchingParent, $insertNodeToNearestRoot, mergeRegister, } from "@lexical/utils";
|
|
12
|
+
import { $createParagraphNode, $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, createCommand, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, } from "lexical";
|
|
13
|
+
import { useEffect } from "react";
|
|
14
|
+
import { $createCollapsibleContainerNode, $isCollapsibleContainerNode, CollapsibleContainerNode, } from "./CollapsibleContainerNode";
|
|
15
|
+
import { $createCollapsibleContentNode, $isCollapsibleContentNode, CollapsibleContentNode, } from "./CollapsibleContentNode";
|
|
16
|
+
import { $createCollapsibleTitleNode, $isCollapsibleTitleNode, CollapsibleTitleNode, } from "./CollapsibleTitleNode";
|
|
17
|
+
export const INSERT_COLLAPSIBLE_COMMAND = createCommand("INSERT_COLLAPSIBLE_COMMAND");
|
|
17
18
|
export default function CollapsiblePlugin() {
|
|
18
19
|
const [editor] = useLexicalComposerContext();
|
|
19
20
|
useEffect(() => {
|
|
@@ -22,7 +23,7 @@ export default function CollapsiblePlugin() {
|
|
|
22
23
|
CollapsibleTitleNode,
|
|
23
24
|
CollapsibleContentNode,
|
|
24
25
|
])) {
|
|
25
|
-
throw new Error(
|
|
26
|
+
throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");
|
|
26
27
|
}
|
|
27
28
|
const $onEscapeUp = () => {
|
|
28
29
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/ComponentPickerPlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/ComponentPickerPlugin/index.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAWjC,OAAO,EAEL,UAAU,EAEX,MAAM,2CAA2C,CAAC;AAInD,OAAO,EAKL,aAAa,EAEd,MAAM,SAAS,CAAC;AAIjB,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAS5C,qBAAa,qBAAsB,SAAQ,UAAU;IAEnD,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;gBAGtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;KACzC;CASJ;AAED,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,UAAU,EACV,OAAO,EACP,YAAY,EACZ,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,EAAE,qBAAqB,CAAC;CAC/B,2CAqBA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,2BA6B3E;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvD,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,2BAiLzE;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,IAAI,GAAG,CAAC,OAAO,CAqF/D"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { $createCodeNode } from "
|
|
3
|
+
import { $createCodeNode } from "../../nodes/CodeNode/CodeNode";
|
|
3
4
|
import { INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, } from "@lexical/list";
|
|
4
5
|
import { INSERT_EMBED_COMMAND } from "@lexical/react/LexicalAutoEmbedPlugin";
|
|
5
6
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
6
|
-
import { INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/
|
|
7
|
+
import { INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/extension";
|
|
7
8
|
import { LexicalTypeaheadMenuPlugin, MenuOption, useBasicTypeaheadTriggerMatch, } from "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
8
9
|
import { $createHeadingNode, $createQuoteNode } from "@lexical/rich-text";
|
|
9
10
|
import { $setBlocksType } from "@lexical/selection";
|
|
@@ -18,7 +19,6 @@ import { INSERT_DATETIME_COMMAND } from "../DateTimePlugin";
|
|
|
18
19
|
import { InsertEquationDialog } from "../EquationsPlugin";
|
|
19
20
|
import { InsertImageDialog } from "../ImagesPlugin";
|
|
20
21
|
import InsertLayoutDialog from "../LayoutPlugin/InsertLayoutDialog";
|
|
21
|
-
import { INSERT_PAGE_BREAK } from "../PageBreakPlugin";
|
|
22
22
|
import { InsertTableDialog } from "../TablePlugin";
|
|
23
23
|
export class ComponentPickerOption extends MenuOption {
|
|
24
24
|
constructor(title, options) {
|
|
@@ -132,11 +132,6 @@ export function getBaseOptions(editor, showModal) {
|
|
|
132
132
|
keywords: ["horizontal rule", "divider", "hr"],
|
|
133
133
|
onSelect: () => editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, undefined),
|
|
134
134
|
}),
|
|
135
|
-
new ComponentPickerOption("Page Break", {
|
|
136
|
-
icon: _jsx("i", { className: "icon page-break" }),
|
|
137
|
-
keywords: ["page break", "divider"],
|
|
138
|
-
onSelect: () => editor.dispatchCommand(INSERT_PAGE_BREAK, undefined),
|
|
139
|
-
}),
|
|
140
135
|
...EmbedConfigs.map((embedConfig) => new ComponentPickerOption(`Embed ${embedConfig.contentName}`, {
|
|
141
136
|
icon: embedConfig.icon,
|
|
142
137
|
keywords: [...embedConfig.keywords, "embed"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/ContextMenuPlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/ContextMenuPlugin/index.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAqBjC,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,GAAG,CAAC,OAAO,CAgIvD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { $isLinkNode, TOGGLE_LINK_COMMAND } from
|
|
3
|
-
import { useLexicalComposerContext } from
|
|
4
|
-
import { NodeContextMenuOption, NodeContextMenuPlugin, NodeContextMenuSeparator, } from
|
|
5
|
-
import { $getSelection, $isDecoratorNode, $isNodeSelection, $isRangeSelection, COPY_COMMAND, CUT_COMMAND, PASTE_COMMAND, } from
|
|
6
|
-
import { useMemo } from
|
|
3
|
+
import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
|
|
4
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
5
|
+
import { NodeContextMenuOption, NodeContextMenuPlugin, NodeContextMenuSeparator, } from "@lexical/react/LexicalNodeContextMenuPlugin";
|
|
6
|
+
import { $getSelection, $isDecoratorNode, $isNodeSelection, $isRangeSelection, COPY_COMMAND, CUT_COMMAND, PASTE_COMMAND, } from "lexical";
|
|
7
|
+
import { useMemo } from "react";
|
|
7
8
|
export default function ContextMenuPlugin() {
|
|
8
9
|
const [editor] = useLexicalComposerContext();
|
|
9
10
|
const items = useMemo(() => {
|
|
@@ -41,17 +42,17 @@ export default function ContextMenuPlugin() {
|
|
|
41
42
|
const item = readClipboardItems[0];
|
|
42
43
|
const permission = await navigator.permissions.query({
|
|
43
44
|
// @ts-expect-error These types are incorrect.
|
|
44
|
-
name:
|
|
45
|
+
name: "clipboard-read",
|
|
45
46
|
});
|
|
46
|
-
if (permission.state ===
|
|
47
|
-
alert(
|
|
47
|
+
if (permission.state === "denied") {
|
|
48
|
+
alert("Not allowed to paste from clipboard.");
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
for (const type of item.types) {
|
|
51
52
|
const dataString = await (await item.getType(type)).text();
|
|
52
53
|
data.setData(type, dataString);
|
|
53
54
|
}
|
|
54
|
-
const event = new ClipboardEvent(
|
|
55
|
+
const event = new ClipboardEvent("paste", {
|
|
55
56
|
clipboardData: data,
|
|
56
57
|
});
|
|
57
58
|
editor.dispatchCommand(PASTE_COMMAND, event);
|
|
@@ -65,16 +66,16 @@ export default function ContextMenuPlugin() {
|
|
|
65
66
|
navigator.clipboard.read().then(async function (...args) {
|
|
66
67
|
const permission = await navigator.permissions.query({
|
|
67
68
|
// @ts-expect-error These types are incorrect.
|
|
68
|
-
name:
|
|
69
|
+
name: "clipboard-read",
|
|
69
70
|
});
|
|
70
|
-
if (permission.state ===
|
|
71
|
-
alert(
|
|
71
|
+
if (permission.state === "denied") {
|
|
72
|
+
alert("Not allowed to paste from clipboard.");
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
const data = new DataTransfer();
|
|
75
76
|
const clipboardText = await navigator.clipboard.readText();
|
|
76
|
-
data.setData(
|
|
77
|
-
const event = new ClipboardEvent(
|
|
77
|
+
data.setData("text/plain", clipboardText);
|
|
78
|
+
const event = new ClipboardEvent("paste", {
|
|
78
79
|
clipboardData: data,
|
|
79
80
|
});
|
|
80
81
|
editor.dispatchCommand(PASTE_COMMAND, event);
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { JSX } from
|
|
9
|
-
import { LexicalCommand } from
|
|
8
|
+
import type { JSX } from "react";
|
|
9
|
+
import { LexicalCommand } from "lexical";
|
|
10
10
|
type CommandPayload = {
|
|
11
11
|
dateTime: Date;
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/DateTimePlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/DateTimePlugin/index.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIjC,OAAO,EAML,cAAc,EACf,MAAM,SAAS,CAAC;AAQjB,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,cAAc,CACzB,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,cAAc,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CA4B3D"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
-
import { $wrapNodeInElement, mergeRegister } from '@lexical/utils';
|
|
10
|
-
import { $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, createCommand, } from 'lexical';
|
|
11
|
-
import { useEffect } from 'react';
|
|
12
|
-
import { $createDateTimeNode, DateTimeNode, } from '../../nodes/DateTimeNode/DateTimeNode';
|
|
13
|
-
export const INSERT_DATETIME_COMMAND = createCommand('INSERT_DATETIME_COMMAND');
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
3
|
+
import { $wrapNodeInElement, mergeRegister } from "@lexical/utils";
|
|
4
|
+
import { $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, createCommand, } from "lexical";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { $createDateTimeNode, DateTimeNode, } from "../../nodes/DateTimeNode/DateTimeNode";
|
|
7
|
+
export const INSERT_DATETIME_COMMAND = createCommand("INSERT_DATETIME_COMMAND");
|
|
14
8
|
export default function DateTimePlugin() {
|
|
15
9
|
const [editor] = useLexicalComposerContext();
|
|
16
10
|
useEffect(() => {
|
|
17
11
|
if (!editor.hasNodes([DateTimeNode])) {
|
|
18
|
-
throw new Error(
|
|
12
|
+
throw new Error("DateTimePlugin: DateTimeNode not registered on editor");
|
|
19
13
|
}
|
|
20
14
|
return mergeRegister(editor.registerCommand(INSERT_DATETIME_COMMAND, (payload) => {
|
|
21
15
|
const { dateTime } = payload;
|
|
@@ -1,9 +1,2 @@
|
|
|
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
1
|
export default function DragDropPaste(): null;
|
|
9
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/DragDropPastePlugin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/DragDropPastePlugin/index.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAC,OAAO,UAAU,aAAa,IAAI,IAAI,CA0B5C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
/**
|
|
2
3
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
4
|
*
|
|
@@ -5,18 +6,18 @@
|
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
*
|
|
7
8
|
*/
|
|
8
|
-
import { useLexicalComposerContext } from
|
|
9
|
-
import { DRAG_DROP_PASTE } from
|
|
10
|
-
import { isMimeType, mediaFileReader } from
|
|
11
|
-
import { COMMAND_PRIORITY_LOW } from
|
|
12
|
-
import { useEffect } from
|
|
13
|
-
import { INSERT_IMAGE_COMMAND } from
|
|
9
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
10
|
+
import { DRAG_DROP_PASTE } from "@lexical/rich-text";
|
|
11
|
+
import { isMimeType, mediaFileReader } from "@lexical/utils";
|
|
12
|
+
import { COMMAND_PRIORITY_LOW } from "lexical";
|
|
13
|
+
import { useEffect } from "react";
|
|
14
|
+
import { INSERT_IMAGE_COMMAND } from "../ImagesPlugin";
|
|
14
15
|
const ACCEPTABLE_IMAGE_TYPES = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
"image/",
|
|
17
|
+
"image/heic",
|
|
18
|
+
"image/heif",
|
|
19
|
+
"image/gif",
|
|
20
|
+
"image/webp",
|
|
20
21
|
];
|
|
21
22
|
export default function DragDropPaste() {
|
|
22
23
|
const [editor] = useLexicalComposerContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,aAAa,CAAC;AAkCrB,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B,GAAG,GAAG,CAAC,OAAO,CAmPd"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useLexicalComposerContext } from
|
|
4
|
-
import { DraggableBlockPlugin_EXPERIMENTAL } from
|
|
5
|
-
import { $createParagraphNode, $createTextNode, $getNearestNodeFromDOMNode, $getNodeByKey, $isParagraphNode, $isTextNode, } from
|
|
6
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from
|
|
7
|
-
import * as ReactDOM from
|
|
8
|
-
import useModal from
|
|
9
|
-
import { ComponentPickerMenuItem, getBaseOptions, getDynamicOptions, } from
|
|
10
|
-
const DRAGGABLE_BLOCK_MENU_CLASSNAME =
|
|
3
|
+
import "./index.css";
|
|
4
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
5
|
+
import { DraggableBlockPlugin_EXPERIMENTAL } from "@lexical/react/LexicalDraggableBlockPlugin";
|
|
6
|
+
import { $createParagraphNode, $createTextNode, $getNearestNodeFromDOMNode, $getNodeByKey, $isParagraphNode, $isTextNode, } from "lexical";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import * as ReactDOM from "react-dom";
|
|
9
|
+
import useModal from "../../hooks/useModal";
|
|
10
|
+
import { ComponentPickerMenuItem, getBaseOptions, getDynamicOptions, } from "../ComponentPickerPlugin";
|
|
11
|
+
const DRAGGABLE_BLOCK_MENU_CLASSNAME = "draggable-block-menu";
|
|
11
12
|
function isOnMenu(element) {
|
|
12
13
|
return !!element.closest(`.${DRAGGABLE_BLOCK_MENU_CLASSNAME}`);
|
|
13
14
|
}
|
|
@@ -21,7 +22,7 @@ export default function DraggableBlockPlugin({ anchorElem = document.body, }) {
|
|
|
21
22
|
const [draggableElement, setDraggableElement] = useState(null);
|
|
22
23
|
const [pickerState, setPickerState] = useState(null);
|
|
23
24
|
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
|
24
|
-
const [queryString, setQueryString] = useState(
|
|
25
|
+
const [queryString, setQueryString] = useState("");
|
|
25
26
|
const [highlightedIndex, setHighlightedIndex] = useState(0);
|
|
26
27
|
const [pickerPosition, setPickerPosition] = useState(null);
|
|
27
28
|
const options = useMemo(() => {
|
|
@@ -29,7 +30,7 @@ export default function DraggableBlockPlugin({ anchorElem = document.body, }) {
|
|
|
29
30
|
if (!queryString) {
|
|
30
31
|
return baseOptions;
|
|
31
32
|
}
|
|
32
|
-
const regex = new RegExp(queryString,
|
|
33
|
+
const regex = new RegExp(queryString, "i");
|
|
33
34
|
return [
|
|
34
35
|
...getDynamicOptions(editor, queryString),
|
|
35
36
|
...baseOptions.filter((option) => regex.test(option.title) ||
|
|
@@ -60,9 +61,9 @@ export default function DraggableBlockPlugin({ anchorElem = document.body, }) {
|
|
|
60
61
|
setIsPickerOpen(false);
|
|
61
62
|
setPickerState(null);
|
|
62
63
|
};
|
|
63
|
-
document.addEventListener(
|
|
64
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
64
65
|
return () => {
|
|
65
|
-
document.removeEventListener(
|
|
66
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
66
67
|
};
|
|
67
68
|
}, [isPickerOpen]);
|
|
68
69
|
const selectOption = useCallback((option) => {
|
|
@@ -77,7 +78,7 @@ export default function DraggableBlockPlugin({ anchorElem = document.body, }) {
|
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
const placeholder = $createParagraphNode();
|
|
80
|
-
const textNode = $createTextNode(
|
|
81
|
+
const textNode = $createTextNode("");
|
|
81
82
|
placeholder.append(textNode);
|
|
82
83
|
if (pickerState.insertBefore) {
|
|
83
84
|
node.insertBefore(placeholder);
|
|
@@ -106,30 +107,30 @@ export default function DraggableBlockPlugin({ anchorElem = document.body, }) {
|
|
|
106
107
|
if (!isPickerOpen || !options.length) {
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
109
|
-
if (event.key ===
|
|
110
|
+
if (event.key === "ArrowDown") {
|
|
110
111
|
event.preventDefault();
|
|
111
112
|
setHighlightedIndex((index) => index + 1 >= options.length ? 0 : index + 1);
|
|
112
113
|
}
|
|
113
|
-
else if (event.key ===
|
|
114
|
+
else if (event.key === "ArrowUp") {
|
|
114
115
|
event.preventDefault();
|
|
115
116
|
setHighlightedIndex((index) => index - 1 < 0 ? options.length - 1 : index - 1);
|
|
116
117
|
}
|
|
117
|
-
else if (event.key ===
|
|
118
|
+
else if (event.key === "Enter") {
|
|
118
119
|
event.preventDefault();
|
|
119
120
|
const option = options[highlightedIndex];
|
|
120
121
|
if (option) {
|
|
121
122
|
selectOption(option);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
else if (event.key ===
|
|
125
|
+
else if (event.key === "Escape") {
|
|
125
126
|
event.preventDefault();
|
|
126
127
|
setIsPickerOpen(false);
|
|
127
128
|
setPickerState(null);
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
|
-
window.addEventListener(
|
|
131
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
131
132
|
return () => {
|
|
132
|
-
window.removeEventListener(
|
|
133
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
133
134
|
};
|
|
134
135
|
}, [highlightedIndex, isPickerOpen, options, selectOption]);
|
|
135
136
|
function openComponentPicker(e) {
|
|
@@ -156,14 +157,14 @@ export default function DraggableBlockPlugin({ anchorElem = document.body, }) {
|
|
|
156
157
|
}
|
|
157
158
|
: null);
|
|
158
159
|
setPickerState({ insertBefore, targetNodeKey });
|
|
159
|
-
setQueryString(
|
|
160
|
+
setQueryString("");
|
|
160
161
|
setHighlightedIndex(0);
|
|
161
162
|
setIsPickerOpen(true);
|
|
162
163
|
}
|
|
163
164
|
return (_jsxs(_Fragment, { children: [modal, isPickerOpen && pickerPosition
|
|
164
165
|
? ReactDOM.createPortal(_jsxs("div", { className: "typeahead-popover component-picker-menu draggable-block-component-picker", ref: pickerRef, style: {
|
|
165
166
|
left: pickerPosition.left,
|
|
166
|
-
position:
|
|
167
|
+
position: "absolute",
|
|
167
168
|
top: pickerPosition.top,
|
|
168
169
|
zIndex: 10,
|
|
169
170
|
}, children: [_jsx("input", { className: "component-picker-search", placeholder: "Filter blocks...", value: queryString, ref: searchInputRef, onChange: (event) => setQueryString(event.target.value) }), _jsx("ul", { children: options.map((option, i) => (_jsx(ComponentPickerMenuItem, { index: i, isSelected: highlightedIndex === i, onClick: () => {
|