@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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DecoratorBlockNode, } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
2
|
+
function $convertTweetElement(domNode) {
|
|
3
|
+
const id = domNode.getAttribute("data-lexical-tweet-id");
|
|
4
|
+
if (id) {
|
|
5
|
+
const node = $createTweetNode(id);
|
|
6
|
+
return { node };
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
export class TweetNode extends DecoratorBlockNode {
|
|
11
|
+
static getType() {
|
|
12
|
+
return "tweet";
|
|
13
|
+
}
|
|
14
|
+
static clone(node) {
|
|
15
|
+
return new TweetNode(node.__id, node.__format, node.__key);
|
|
16
|
+
}
|
|
17
|
+
static importJSON(serializedNode) {
|
|
18
|
+
return $createTweetNode(serializedNode.id).updateFromJSON(serializedNode);
|
|
19
|
+
}
|
|
20
|
+
exportJSON() {
|
|
21
|
+
return Object.assign(Object.assign({}, super.exportJSON()), { id: this.getId() });
|
|
22
|
+
}
|
|
23
|
+
static importDOM() {
|
|
24
|
+
return {
|
|
25
|
+
div: (domNode) => {
|
|
26
|
+
if (!domNode.hasAttribute("data-lexical-tweet-id")) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
conversion: $convertTweetElement,
|
|
31
|
+
priority: 2,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exportDOM() {
|
|
37
|
+
const element = document.createElement("div");
|
|
38
|
+
element.setAttribute("data-lexical-tweet-id", this.__id);
|
|
39
|
+
const text = document.createTextNode(this.getTextContent());
|
|
40
|
+
element.append(text);
|
|
41
|
+
return { element };
|
|
42
|
+
}
|
|
43
|
+
constructor(id, format, key) {
|
|
44
|
+
super(format, key);
|
|
45
|
+
this.__id = id;
|
|
46
|
+
}
|
|
47
|
+
getId() {
|
|
48
|
+
return this.__id;
|
|
49
|
+
}
|
|
50
|
+
getTextContent(_includeInert, _includeDirectionless) {
|
|
51
|
+
return `https://x.com/i/web/status/${this.__id}`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function $createTweetNode(tweetID) {
|
|
55
|
+
return new TweetNode(tweetID);
|
|
56
|
+
}
|
|
57
|
+
export function $isTweetNode(node) {
|
|
58
|
+
return node instanceof TweetNode;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TweetNode.d.ts","sourceRoot":"","sources":["../../../src/nodes/TweetNode/TweetNode.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,0CAA0C,CAAC;AAqGlD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC;IACE,EAAE,EAAE,MAAM,CAAC;CACZ,EACD,4BAA4B,CAC7B,CAAC;AAEF,qBAAa,SAAU,SAAQ,kBAAkB;IAC/C,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS;IAIxC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,mBAAmB,GAAG,SAAS;IAIjE,UAAU,IAAI,mBAAmB;IAOjC,MAAM,CAAC,SAAS,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,IAAI;IAc3D,SAAS,IAAI,eAAe;gBAQhB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,OAAO;IAKjE,KAAK,IAAI,MAAM;IAIf,cAAc,CACZ,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,EACnC,qBAAqB,CAAC,EAAE,KAAK,GAAG,SAAS,GACxC,MAAM;IAIT,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;CAgBnE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAE3D;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GAC/C,IAAI,IAAI,SAAS,CAEnB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DOMConversionMap, DOMExportOutput, ElementFormatType, LexicalNode, NodeKey, Spread } from "lexical";
|
|
2
|
+
import { DecoratorBlockNode, SerializedDecoratorBlockNode } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
3
|
+
export type SerializedYouTubeNode = Spread<{
|
|
4
|
+
videoID: string;
|
|
5
|
+
}, SerializedDecoratorBlockNode>;
|
|
6
|
+
export declare class YouTubeNode extends DecoratorBlockNode {
|
|
7
|
+
__id: string;
|
|
8
|
+
static getType(): string;
|
|
9
|
+
static clone(node: YouTubeNode): YouTubeNode;
|
|
10
|
+
static importJSON(serializedNode: SerializedYouTubeNode): YouTubeNode;
|
|
11
|
+
exportJSON(): SerializedYouTubeNode;
|
|
12
|
+
constructor(id: string, format?: ElementFormatType, key?: NodeKey);
|
|
13
|
+
exportDOM(): DOMExportOutput;
|
|
14
|
+
static importDOM(): DOMConversionMap | null;
|
|
15
|
+
updateDOM(): false;
|
|
16
|
+
getId(): string;
|
|
17
|
+
getTextContent(_includeInert?: boolean | undefined, _includeDirectionless?: false | undefined): string;
|
|
18
|
+
}
|
|
19
|
+
export declare function $createYouTubeNode(videoID: string): YouTubeNode;
|
|
20
|
+
export declare function $isYouTubeNode(node: YouTubeNode | LexicalNode | null | undefined): node is YouTubeNode;
|
|
21
|
+
//# sourceMappingURL=ServerYouTubeNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerYouTubeNode.d.ts","sourceRoot":"","sources":["../../../src/nodes/YouTubeNode/ServerYouTubeNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,0CAA0C,CAAC;AAElD,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,OAAO,EAAE,MAAM,CAAC;CACjB,EACD,4BAA4B,CAC7B,CAAC;AAaF,qBAAa,WAAY,SAAQ,kBAAkB;IACjD,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IAI5C,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,qBAAqB,GAAG,WAAW;IAMrE,UAAU,IAAI,qBAAqB;gBAOvB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,OAAO;IAKjE,SAAS,IAAI,eAAe;IAmB5B,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAc3C,SAAS,IAAI,KAAK;IAIlB,KAAK,IAAI,MAAM;IAIf,cAAc,CACZ,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,EACnC,qBAAqB,CAAC,EAAE,KAAK,GAAG,SAAS,GACxC,MAAM;CAGV;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAE/D;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GACjD,IAAI,IAAI,WAAW,CAErB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DecoratorBlockNode, } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
2
|
+
function $convertYoutubeElement(domNode) {
|
|
3
|
+
const videoID = domNode.getAttribute("data-lexical-youtube");
|
|
4
|
+
if (videoID) {
|
|
5
|
+
const node = $createYouTubeNode(videoID);
|
|
6
|
+
return { node };
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
export class YouTubeNode extends DecoratorBlockNode {
|
|
11
|
+
static getType() {
|
|
12
|
+
return "youtube";
|
|
13
|
+
}
|
|
14
|
+
static clone(node) {
|
|
15
|
+
return new YouTubeNode(node.__id, node.__format, node.__key);
|
|
16
|
+
}
|
|
17
|
+
static importJSON(serializedNode) {
|
|
18
|
+
return $createYouTubeNode(serializedNode.videoID).updateFromJSON(serializedNode);
|
|
19
|
+
}
|
|
20
|
+
exportJSON() {
|
|
21
|
+
return Object.assign(Object.assign({}, super.exportJSON()), { videoID: this.__id });
|
|
22
|
+
}
|
|
23
|
+
constructor(id, format, key) {
|
|
24
|
+
super(format, key);
|
|
25
|
+
this.__id = id;
|
|
26
|
+
}
|
|
27
|
+
exportDOM() {
|
|
28
|
+
const element = document.createElement("iframe");
|
|
29
|
+
element.setAttribute("data-lexical-youtube", this.__id);
|
|
30
|
+
element.setAttribute("width", "560");
|
|
31
|
+
element.setAttribute("height", "315");
|
|
32
|
+
element.setAttribute("src", `https://www.youtube-nocookie.com/embed/${this.__id}`);
|
|
33
|
+
element.setAttribute("frameborder", "0");
|
|
34
|
+
element.setAttribute("allow", "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture");
|
|
35
|
+
element.setAttribute("allowfullscreen", "true");
|
|
36
|
+
element.setAttribute("title", "YouTube video");
|
|
37
|
+
return { element };
|
|
38
|
+
}
|
|
39
|
+
static importDOM() {
|
|
40
|
+
return {
|
|
41
|
+
iframe: (domNode) => {
|
|
42
|
+
if (!domNode.hasAttribute("data-lexical-youtube")) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
conversion: $convertYoutubeElement,
|
|
47
|
+
priority: 1,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
updateDOM() {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
getId() {
|
|
56
|
+
return this.__id;
|
|
57
|
+
}
|
|
58
|
+
getTextContent(_includeInert, _includeDirectionless) {
|
|
59
|
+
return `https://www.youtube.com/watch?v=${this.__id}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function $createYouTubeNode(videoID) {
|
|
63
|
+
return new YouTubeNode(videoID);
|
|
64
|
+
}
|
|
65
|
+
export function $isYouTubeNode(node) {
|
|
66
|
+
return node instanceof YouTubeNode;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YouTubeNode.d.ts","sourceRoot":"","sources":["../../../src/nodes/YouTubeNode/YouTubeNode.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,0CAA0C,CAAC;AAqClD,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,OAAO,EAAE,MAAM,CAAC;CACjB,EACD,4BAA4B,CAC7B,CAAC;AAaF,qBAAa,WAAY,SAAQ,kBAAkB;IACjD,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IAI5C,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,qBAAqB,GAAG,WAAW;IAMrE,UAAU,IAAI,qBAAqB;gBAOvB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,OAAO;IAKjE,SAAS,IAAI,eAAe;IAmB5B,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAc3C,SAAS,IAAI,KAAK;IAIlB,KAAK,IAAI,MAAM;IAIf,cAAc,CACZ,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,EACnC,qBAAqB,CAAC,EAAE,KAAK,GAAG,SAAS,GACxC,MAAM;IAIT,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;CAepE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAE/D;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GACjD,IAAI,IAAI,WAAW,CAErB"}
|
|
@@ -1,10 +1,3 @@
|
|
|
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
|
import type { JSX } from "react";
|
|
9
2
|
export default function ActionsPlugin({ shouldPreserveNewLinesInMarkdown, useCollabV2, }: {
|
|
10
3
|
shouldPreserveNewLinesInMarkdown: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/ActionsPlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/ActionsPlugin/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AA4DjC,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,gCAAgC,EAChC,WAAW,GACZ,EAAE;IACD,gCAAgC,EAAE,OAAO,CAAC;IAC1C,WAAW,EAAE,OAAO,CAAC;CACtB,GAAG,GAAG,CAAC,OAAO,CAkKd"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { $createCodeNode, $isCodeNode } from "
|
|
3
|
+
import { $createCodeNode, $isCodeNode } from "../../nodes/CodeNode/CodeNode";
|
|
3
4
|
import { editorStateFromSerializedDocument, exportFile, importFile, } from "@lexical/file";
|
|
4
5
|
import { $convertFromMarkdownString, $convertToMarkdownString, } from "@lexical/markdown";
|
|
5
6
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
import { EmbedConfig } from '@lexical/react/LexicalAutoEmbedPlugin';
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import { EmbedConfig } from "@lexical/react/LexicalAutoEmbedPlugin";
|
|
10
3
|
interface PlaygroundEmbedConfig extends EmbedConfig {
|
|
11
4
|
contentName: string;
|
|
12
5
|
icon?: JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/AutoEmbedPlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/AutoEmbedPlugin/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAEL,WAAW,EAIZ,MAAM,uCAAuC,CAAC;AAY/C,UAAU,qBAAsB,SAAQ,WAAW;IAEjD,WAAW,EAAE,MAAM,CAAC;IAGpB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAGnB,UAAU,EAAE,MAAM,CAAC;IAGnB,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAGxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,EAAE,qBAgChC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,qBAmChC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,qBA+B9B,CAAC;AAEF,eAAO,MAAM,YAAY,yBAIxB,CAAC;AA2EF,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,OAAO,GACR,EAAE;IACD,WAAW,EAAE,qBAAqB,CAAC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAwDd;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,IAAI,GAAG,CAAC,OAAO,CAuErD"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { AutoEmbedOption, LexicalAutoEmbedPlugin, URL_MATCHER, } from
|
|
3
|
-
import { useLexicalComposerContext } from
|
|
4
|
-
import { useMemo, useState } from
|
|
5
|
-
import * as ReactDOM from
|
|
6
|
-
import useModal from
|
|
7
|
-
import Button from
|
|
8
|
-
import { DialogActions } from
|
|
9
|
-
import { INSERT_FIGMA_COMMAND } from
|
|
10
|
-
import { INSERT_TWEET_COMMAND } from
|
|
11
|
-
import { INSERT_YOUTUBE_COMMAND } from
|
|
3
|
+
import { AutoEmbedOption, LexicalAutoEmbedPlugin, URL_MATCHER, } from "@lexical/react/LexicalAutoEmbedPlugin";
|
|
4
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
5
|
+
import { useMemo, useState } from "react";
|
|
6
|
+
import * as ReactDOM from "react-dom";
|
|
7
|
+
import useModal from "../../hooks/useModal";
|
|
8
|
+
import Button from "../../ui/Button";
|
|
9
|
+
import { DialogActions } from "../../ui/Dialog";
|
|
10
|
+
import { INSERT_FIGMA_COMMAND } from "../FigmaPlugin";
|
|
11
|
+
import { INSERT_TWEET_COMMAND } from "../TwitterPlugin";
|
|
12
|
+
import { INSERT_YOUTUBE_COMMAND } from "../YouTubePlugin";
|
|
12
13
|
export const YoutubeEmbedConfig = {
|
|
13
|
-
contentName:
|
|
14
|
-
exampleUrl:
|
|
14
|
+
contentName: "Youtube Video",
|
|
15
|
+
exampleUrl: "https://www.youtube.com/watch?v=jNQXAC9IVRw",
|
|
15
16
|
// Icon for display.
|
|
16
17
|
icon: _jsx("i", { className: "icon youtube" }),
|
|
17
18
|
insertNode: (editor, result) => {
|
|
18
19
|
editor.dispatchCommand(INSERT_YOUTUBE_COMMAND, result.id);
|
|
19
20
|
},
|
|
20
|
-
keywords: [
|
|
21
|
+
keywords: ["youtube", "video"],
|
|
21
22
|
// Determine if a given URL is a match and return url data.
|
|
22
23
|
parseUrl: async (url) => {
|
|
23
24
|
const match = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(url);
|
|
@@ -30,12 +31,12 @@ export const YoutubeEmbedConfig = {
|
|
|
30
31
|
}
|
|
31
32
|
return null;
|
|
32
33
|
},
|
|
33
|
-
type:
|
|
34
|
+
type: "youtube-video",
|
|
34
35
|
};
|
|
35
36
|
export const TwitterEmbedConfig = {
|
|
36
37
|
// e.g. Tweet or Google Map.
|
|
37
|
-
contentName:
|
|
38
|
-
exampleUrl:
|
|
38
|
+
contentName: "X(Tweet)",
|
|
39
|
+
exampleUrl: "https://x.com/jack/status/20",
|
|
39
40
|
// Icon for display.
|
|
40
41
|
icon: _jsx("i", { className: "icon x" }),
|
|
41
42
|
// Create the Lexical embed node from the url data.
|
|
@@ -43,7 +44,7 @@ export const TwitterEmbedConfig = {
|
|
|
43
44
|
editor.dispatchCommand(INSERT_TWEET_COMMAND, result.id);
|
|
44
45
|
},
|
|
45
46
|
// For extra searching.
|
|
46
|
-
keywords: [
|
|
47
|
+
keywords: ["tweet", "twitter", "x"],
|
|
47
48
|
// Determine if a given URL is a match and return url data.
|
|
48
49
|
parseUrl: (text) => {
|
|
49
50
|
const match = /^https:\/\/(twitter|x)\.com\/(#!\/)?(\w+)\/status(es)*\/(\d+)/.exec(text);
|
|
@@ -55,16 +56,16 @@ export const TwitterEmbedConfig = {
|
|
|
55
56
|
}
|
|
56
57
|
return null;
|
|
57
58
|
},
|
|
58
|
-
type:
|
|
59
|
+
type: "tweet",
|
|
59
60
|
};
|
|
60
61
|
export const FigmaEmbedConfig = {
|
|
61
|
-
contentName:
|
|
62
|
-
exampleUrl:
|
|
62
|
+
contentName: "Figma Document",
|
|
63
|
+
exampleUrl: "https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File",
|
|
63
64
|
icon: _jsx("i", { className: "icon figma" }),
|
|
64
65
|
insertNode: (editor, result) => {
|
|
65
66
|
editor.dispatchCommand(INSERT_FIGMA_COMMAND, result.id);
|
|
66
67
|
},
|
|
67
|
-
keywords: [
|
|
68
|
+
keywords: ["figma", "figma.com", "mock-up"],
|
|
68
69
|
// Determine if a given URL is a match and return url data.
|
|
69
70
|
parseUrl: (text) => {
|
|
70
71
|
const match = /https:\/\/([\w.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/.exec(text);
|
|
@@ -76,7 +77,7 @@ export const FigmaEmbedConfig = {
|
|
|
76
77
|
}
|
|
77
78
|
return null;
|
|
78
79
|
},
|
|
79
|
-
type:
|
|
80
|
+
type: "figma",
|
|
80
81
|
};
|
|
81
82
|
export const EmbedConfigs = [
|
|
82
83
|
TwitterEmbedConfig,
|
|
@@ -84,11 +85,11 @@ export const EmbedConfigs = [
|
|
|
84
85
|
FigmaEmbedConfig,
|
|
85
86
|
];
|
|
86
87
|
function AutoEmbedMenuItem({ index, isSelected, onClick, onMouseEnter, option, }) {
|
|
87
|
-
let className =
|
|
88
|
+
let className = "item";
|
|
88
89
|
if (isSelected) {
|
|
89
|
-
className +=
|
|
90
|
+
className += " selected";
|
|
90
91
|
}
|
|
91
|
-
return (_jsx("li", { tabIndex: -1, className: className, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id:
|
|
92
|
+
return (_jsx("li", { tabIndex: -1, className: className, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id: "typeahead-item-" + index, onMouseEnter: onMouseEnter, onClick: onClick, children: _jsx("span", { className: "text", children: option.title }) }, option.key));
|
|
92
93
|
}
|
|
93
94
|
function AutoEmbedMenu({ options, selectedItemIndex, onOptionClick, onOptionMouseEnter, }) {
|
|
94
95
|
return (_jsx("div", { className: "typeahead-popover", children: _jsx("ul", { children: options.map((option, i) => (_jsx(AutoEmbedMenuItem, { index: i, isSelected: selectedItemIndex === i, onClick: () => onOptionClick(option, i), onMouseEnter: () => onOptionMouseEnter(i), option: option }, option.key))) }) }));
|
|
@@ -103,7 +104,7 @@ const debounce = (callback, delay) => {
|
|
|
103
104
|
};
|
|
104
105
|
};
|
|
105
106
|
export function AutoEmbedDialog({ embedConfig, onClose, }) {
|
|
106
|
-
const [text, setText] = useState(
|
|
107
|
+
const [text, setText] = useState("");
|
|
107
108
|
const [editor] = useLexicalComposerContext();
|
|
108
109
|
const [embedResult, setEmbedResult] = useState(null);
|
|
109
110
|
const validateText = useMemo(() => debounce((inputText) => {
|
|
@@ -123,7 +124,7 @@ export function AutoEmbedDialog({ embedConfig, onClose, }) {
|
|
|
123
124
|
onClose();
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
|
-
return (_jsxs("div", { style: { width:
|
|
127
|
+
return (_jsxs("div", { style: { width: "600px" }, children: [_jsx("div", { className: "Input__wrapper", children: _jsx("input", { type: "text", className: "Input__input", placeholder: embedConfig.exampleUrl, value: text, "data-test-id": `${embedConfig.type}-embed-modal-url`, onChange: (e) => {
|
|
127
128
|
const { value } = e.target;
|
|
128
129
|
setText(value);
|
|
129
130
|
validateText(value);
|
|
@@ -136,7 +137,7 @@ export default function AutoEmbedPlugin() {
|
|
|
136
137
|
};
|
|
137
138
|
const getMenuOptions = (activeEmbedConfig, embedFn, dismissFn) => {
|
|
138
139
|
return [
|
|
139
|
-
new AutoEmbedOption(
|
|
140
|
+
new AutoEmbedOption("Dismiss", {
|
|
140
141
|
onSelect: dismissFn,
|
|
141
142
|
}),
|
|
142
143
|
new AutoEmbedOption(`Embed ${activeEmbedConfig.contentName}`, {
|
|
@@ -144,7 +145,7 @@ export default function AutoEmbedPlugin() {
|
|
|
144
145
|
}),
|
|
145
146
|
];
|
|
146
147
|
};
|
|
147
|
-
return (_jsxs(_Fragment, { children: [modal, _jsx(LexicalAutoEmbedPlugin, { embedConfigs: EmbedConfigs, onOpenEmbedModalForConfig: openEmbedModal, getMenuOptions: getMenuOptions, menuRenderFn: (anchorElementRef, { selectedIndex, options, selectOptionAndCleanUp, setHighlightedIndex }) => anchorElementRef.current
|
|
148
|
+
return (_jsxs(_Fragment, { children: [modal, _jsx(LexicalAutoEmbedPlugin, { embedConfigs: EmbedConfigs, onOpenEmbedModalForConfig: openEmbedModal, getMenuOptions: getMenuOptions, menuRenderFn: (anchorElementRef, { selectedIndex, options, selectOptionAndCleanUp, setHighlightedIndex, }) => anchorElementRef.current
|
|
148
149
|
? ReactDOM.createPortal(_jsx("div", { className: "typeahead-popover auto-embed-menu", style: {
|
|
149
150
|
marginLeft: `${Math.max(parseFloat(anchorElementRef.current.style.width) - 200, 0)}px`,
|
|
150
151
|
width: 200,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/AutoLinkPlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/AutoLinkPlugin/index.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAsBjC,MAAM,CAAC,OAAO,UAAU,qBAAqB,IAAI,GAAG,CAAC,OAAO,CAE3D"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { AutoLinkPlugin, createLinkMatcherWithRegExp, } from
|
|
3
|
+
import { AutoLinkPlugin, createLinkMatcherWithRegExp, } from "@lexical/react/LexicalAutoLinkPlugin";
|
|
3
4
|
const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/;
|
|
4
5
|
const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
5
6
|
const MATCHERS = [
|
|
6
7
|
createLinkMatcherWithRegExp(URL_REGEX, (text) => {
|
|
7
|
-
return text.startsWith(
|
|
8
|
+
return text.startsWith("http") ? text : `https://${text}`;
|
|
8
9
|
}),
|
|
9
10
|
createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {
|
|
10
11
|
return `mailto:${text}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAIL,aAAa,EACd,MAAM,SAAS,CAAC;AAKjB,UAAU,KAAK;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,cAAc,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;CAC1C;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,2CA6C3D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
/**
|
|
3
4
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -6,10 +7,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
7
|
* LICENSE file in the root directory of this source tree.
|
|
7
8
|
*
|
|
8
9
|
*/
|
|
9
|
-
import { $isCodeNode } from
|
|
10
|
-
import { $getNearestNodeFromDOMNode, $getSelection, $setSelection, } from
|
|
11
|
-
import { useState } from
|
|
12
|
-
import { useDebounce } from
|
|
10
|
+
import { $isCodeNode } from "../../../../nodes/CodeNode/CodeNode";
|
|
11
|
+
import { $getNearestNodeFromDOMNode, $getSelection, $setSelection, } from "lexical";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
import { useDebounce } from "../../utils";
|
|
13
14
|
export function CopyButton({ editor, getCodeDOMNode }) {
|
|
14
15
|
const [isCopyCompleted, setCopyCompleted] = useState(false);
|
|
15
16
|
const removeSuccessIcon = useDebounce(() => {
|
|
@@ -20,7 +21,7 @@ export function CopyButton({ editor, getCodeDOMNode }) {
|
|
|
20
21
|
if (!codeDOMNode) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
|
-
let content =
|
|
24
|
+
let content = "";
|
|
24
25
|
editor.update(() => {
|
|
25
26
|
const codeNode = $getNearestNodeFromDOMNode(codeDOMNode);
|
|
26
27
|
if ($isCodeNode(codeNode)) {
|
|
@@ -35,7 +36,7 @@ export function CopyButton({ editor, getCodeDOMNode }) {
|
|
|
35
36
|
removeSuccessIcon();
|
|
36
37
|
}
|
|
37
38
|
catch (err) {
|
|
38
|
-
console.error(
|
|
39
|
+
console.error("Failed to copy: ", err);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
return (_jsx("button", { className: "menu-item", onClick: handleClick, "aria-label": "copy", children: isCopyCompleted ? (_jsx("i", { className: "format success" })) : (_jsx("i", { className: "format copy" })) }));
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import { LexicalEditor } from
|
|
8
|
+
import "./index.css";
|
|
9
|
+
import { LexicalEditor } from "lexical";
|
|
10
10
|
interface Props {
|
|
11
11
|
lang: string;
|
|
12
12
|
editor: LexicalEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,aAAa,CAAC;AAGrB,OAAO,EAA8B,aAAa,EAAE,MAAM,SAAS,CAAC;AAIpE,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,cAAc,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;CAC1C;AAyCD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAaD,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,2CAqFrE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
/**
|
|
3
4
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -6,21 +7,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
7
|
* LICENSE file in the root directory of this source tree.
|
|
7
8
|
*
|
|
8
9
|
*/
|
|
9
|
-
import
|
|
10
|
-
import { $isCodeNode } from
|
|
11
|
-
import { $getNearestNodeFromDOMNode } from
|
|
12
|
-
import { useState } from
|
|
10
|
+
import "./index.css";
|
|
11
|
+
import { $isCodeNode } from "../../../../nodes/CodeNode/CodeNode";
|
|
12
|
+
import { $getNearestNodeFromDOMNode } from "lexical";
|
|
13
|
+
import { useState } from "react";
|
|
13
14
|
const PRETTIER_PARSER_MODULES = {
|
|
14
|
-
css: [() => import(
|
|
15
|
-
html: [() => import(
|
|
15
|
+
css: [() => import("prettier/parser-postcss")],
|
|
16
|
+
html: [() => import("prettier/parser-html")],
|
|
16
17
|
js: [
|
|
17
|
-
() => import(
|
|
18
|
-
() => import(
|
|
18
|
+
() => import("prettier/parser-babel"),
|
|
19
|
+
() => import("prettier/plugins/estree"),
|
|
19
20
|
],
|
|
20
|
-
markdown: [() => import(
|
|
21
|
+
markdown: [() => import("prettier/parser-markdown")],
|
|
21
22
|
typescript: [
|
|
22
|
-
() => import(
|
|
23
|
-
() => import(
|
|
23
|
+
() => import("prettier/parser-typescript"),
|
|
24
|
+
() => import("prettier/plugins/estree"),
|
|
24
25
|
],
|
|
25
26
|
};
|
|
26
27
|
async function loadPrettierParserByLang(lang) {
|
|
@@ -29,15 +30,15 @@ async function loadPrettierParserByLang(lang) {
|
|
|
29
30
|
return modules;
|
|
30
31
|
}
|
|
31
32
|
async function loadPrettierFormat() {
|
|
32
|
-
const { format } = await import(
|
|
33
|
+
const { format } = await import("prettier/standalone");
|
|
33
34
|
return format;
|
|
34
35
|
}
|
|
35
36
|
const PRETTIER_OPTIONS_BY_LANG = {
|
|
36
|
-
css: { parser:
|
|
37
|
-
html: { parser:
|
|
38
|
-
js: { parser:
|
|
39
|
-
markdown: { parser:
|
|
40
|
-
typescript: { parser:
|
|
37
|
+
css: { parser: "css" },
|
|
38
|
+
html: { parser: "html" },
|
|
39
|
+
js: { parser: "babel" },
|
|
40
|
+
markdown: { parser: "markdown" },
|
|
41
|
+
typescript: { parser: "typescript" },
|
|
41
42
|
};
|
|
42
43
|
const LANG_CAN_BE_PRETTIER = Object.keys(PRETTIER_OPTIONS_BY_LANG);
|
|
43
44
|
export function canBePrettier(lang) {
|
|
@@ -51,21 +52,21 @@ function getPrettierOptions(lang) {
|
|
|
51
52
|
return options;
|
|
52
53
|
}
|
|
53
54
|
export function PrettierButton({ lang, editor, getCodeDOMNode }) {
|
|
54
|
-
const [syntaxError, setSyntaxError] = useState(
|
|
55
|
+
const [syntaxError, setSyntaxError] = useState("");
|
|
55
56
|
const [tipsVisible, setTipsVisible] = useState(false);
|
|
56
57
|
async function handleClick() {
|
|
57
58
|
const codeDOMNode = getCodeDOMNode();
|
|
58
59
|
if (!codeDOMNode) {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
|
-
let content =
|
|
62
|
+
let content = "";
|
|
62
63
|
editor.update(() => {
|
|
63
64
|
const codeNode = $getNearestNodeFromDOMNode(codeDOMNode);
|
|
64
65
|
if ($isCodeNode(codeNode)) {
|
|
65
66
|
content = codeNode.getTextContent();
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
|
-
if (content ===
|
|
69
|
+
if (content === "") {
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
try {
|
|
@@ -79,7 +80,7 @@ export function PrettierButton({ lang, editor, getCodeDOMNode }) {
|
|
|
79
80
|
if ($isCodeNode(codeNode)) {
|
|
80
81
|
const selection = codeNode.select(0);
|
|
81
82
|
selection.insertText(formattedCode);
|
|
82
|
-
setSyntaxError(
|
|
83
|
+
setSyntaxError("");
|
|
83
84
|
setTipsVisible(false);
|
|
84
85
|
}
|
|
85
86
|
});
|
|
@@ -94,16 +95,16 @@ export function PrettierButton({ lang, editor, getCodeDOMNode }) {
|
|
|
94
95
|
setTipsVisible(true);
|
|
95
96
|
}
|
|
96
97
|
else {
|
|
97
|
-
console.error(
|
|
98
|
+
console.error("Unexpected error: ", error);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
function handleMouseEnter() {
|
|
101
|
-
if (syntaxError !==
|
|
102
|
+
if (syntaxError !== "") {
|
|
102
103
|
setTipsVisible(true);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
function handleMouseLeave() {
|
|
106
|
-
if (syntaxError !==
|
|
107
|
+
if (syntaxError !== "") {
|
|
107
108
|
setTipsVisible(false);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
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 './index.css';
|
|
9
|
-
import * as React from 'react';
|
|
1
|
+
import "./index.css";
|
|
2
|
+
import * as React from "react";
|
|
10
3
|
export default function CodeActionMenuPlugin({ anchorElem, }: {
|
|
11
4
|
anchorElem?: HTMLElement;
|
|
12
5
|
}): React.ReactPortal | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeActionMenuPlugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/CodeActionMenuPlugin/index.tsx"],"names":[],"mappings":"AAYA,OAAO,aAAa,CAAC;AAOrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiK/B,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,CAK3B"}
|