@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,10 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { $isCodeNode
|
|
3
|
-
import { getCodeLanguageOptions as getCodeLanguageOptionsShiki, getCodeThemeOptions as getCodeThemeOptionsShiki, normalizeCodeLanguage as normalizeCodeLanguageShiki, } from "
|
|
3
|
+
import { $isCodeNode } from "../../nodes/CodeNode/CodeNode";
|
|
4
|
+
import { getCodeLanguageOptions as getCodeLanguageOptionsShiki, getCodeThemeOptions as getCodeThemeOptionsShiki, normalizeCodeLanguage as normalizeCodeLanguageShiki, } from "../../nodes/CodeNode/FacadeShiki";
|
|
4
5
|
import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link";
|
|
5
6
|
import { $isListNode, ListNode } from "@lexical/list";
|
|
6
7
|
import { INSERT_EMBED_COMMAND } from "@lexical/react/LexicalAutoEmbedPlugin";
|
|
7
|
-
import { INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/
|
|
8
|
+
import { INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/extension";
|
|
8
9
|
import { $isHeadingNode } from "@lexical/rich-text";
|
|
9
10
|
import { $getSelectionStyleValueForProperty, $isParentElementRTL, $patchStyleText, } from "@lexical/selection";
|
|
10
11
|
import { $isTableNode, $isTableSelection } from "@lexical/table";
|
|
@@ -22,61 +23,26 @@ import { EmbedConfigs } from "../AutoEmbedPlugin";
|
|
|
22
23
|
import { INSERT_COLLAPSIBLE_COMMAND } from "../CollapsiblePlugin";
|
|
23
24
|
import { INSERT_DATETIME_COMMAND } from "../DateTimePlugin";
|
|
24
25
|
import { InsertEquationDialog } from "../EquationsPlugin";
|
|
25
|
-
import { InsertImageDialog
|
|
26
|
+
import { InsertImageDialog } from "../ImagesPlugin";
|
|
26
27
|
import InsertLayoutDialog from "../LayoutPlugin/InsertLayoutDialog";
|
|
27
|
-
import { INSERT_PAGE_BREAK } from "../PageBreakPlugin";
|
|
28
28
|
import { SHORTCUTS } from "../ShortcutsPlugin/shortcuts";
|
|
29
29
|
import { InsertTableDialog } from "../TablePlugin";
|
|
30
30
|
import FontSize, { parseFontSizeForToolbar } from "./fontSize";
|
|
31
31
|
import { clearFormatting, formatBulletList, formatCheckList, formatCode, formatHeading, formatNumberedList, formatParagraph, formatQuote, } from "./utils";
|
|
32
|
+
import { allLanguages, allLanguagesFlat } from "./languages";
|
|
32
33
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
34
|
const rootTypeToRootName = {
|
|
34
35
|
root: "Root",
|
|
35
36
|
table: "Table",
|
|
36
37
|
};
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"javascript",
|
|
46
|
-
"markdown",
|
|
47
|
-
"objc",
|
|
48
|
-
"objective-c",
|
|
49
|
-
"plain",
|
|
50
|
-
"powershell",
|
|
51
|
-
"py",
|
|
52
|
-
"python",
|
|
53
|
-
"rust",
|
|
54
|
-
"sql",
|
|
55
|
-
"swift",
|
|
56
|
-
"typescript",
|
|
57
|
-
"xml",
|
|
58
|
-
].includes(option[0]));
|
|
59
|
-
const CODE_LANGUAGE_OPTIONS_SHIKI = getCodeLanguageOptionsShiki().filter((option) => [
|
|
60
|
-
"c",
|
|
61
|
-
"clike",
|
|
62
|
-
"cpp",
|
|
63
|
-
"css",
|
|
64
|
-
"html",
|
|
65
|
-
"java",
|
|
66
|
-
"js",
|
|
67
|
-
"javascript",
|
|
68
|
-
"markdown",
|
|
69
|
-
"objc",
|
|
70
|
-
"objective-c",
|
|
71
|
-
"plain",
|
|
72
|
-
"powershell",
|
|
73
|
-
"py",
|
|
74
|
-
"python",
|
|
75
|
-
"rust",
|
|
76
|
-
"sql",
|
|
77
|
-
"typescript",
|
|
78
|
-
"xml",
|
|
79
|
-
].includes(option[0]));
|
|
38
|
+
const CODE_CATEGORIES_AND_LANGUAGES_SHIKI = new Map(Array.from(allLanguages.entries()).map(([category, [categoryName, languages]]) => [
|
|
39
|
+
category,
|
|
40
|
+
[
|
|
41
|
+
categoryName,
|
|
42
|
+
getCodeLanguageOptionsShiki().filter((option) => languages.includes(option[0])),
|
|
43
|
+
],
|
|
44
|
+
]));
|
|
45
|
+
const CODE_LANGUAGE_OPTIONS_SHIKI = getCodeLanguageOptionsShiki().filter((option) => allLanguagesFlat.includes(option[0]));
|
|
80
46
|
const CODE_THEME_OPTIONS_SHIKI = getCodeThemeOptionsShiki().filter((option) => [
|
|
81
47
|
"catppuccin-latte",
|
|
82
48
|
"everforest-light",
|
|
@@ -94,6 +60,14 @@ const CODE_THEME_OPTIONS_SHIKI = getCodeThemeOptionsShiki().filter((option) => [
|
|
|
94
60
|
"solarized-light",
|
|
95
61
|
"vitesse-light",
|
|
96
62
|
].includes(option[0]));
|
|
63
|
+
const getCodeCategoryForLanguage = (language) => {
|
|
64
|
+
for (const [category, [, languages]] of CODE_CATEGORIES_AND_LANGUAGES_SHIKI) {
|
|
65
|
+
if (languages.some(([value]) => value === language)) {
|
|
66
|
+
return category;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return "";
|
|
70
|
+
};
|
|
97
71
|
const FONT_FAMILY_OPTIONS = [
|
|
98
72
|
["Arial", "Arial"],
|
|
99
73
|
["Courier New", "Courier New"],
|
|
@@ -215,6 +189,7 @@ function $findTopLevelElement(node) {
|
|
|
215
189
|
return topLevelElement;
|
|
216
190
|
}
|
|
217
191
|
export default function ToolbarPlugin({ editor, activeEditor, setActiveEditor, setIsLinkEditMode, }) {
|
|
192
|
+
var _a, _b;
|
|
218
193
|
const [selectedElementKey, setSelectedElementKey] = useState(null);
|
|
219
194
|
const [modal, showModal] = useModal();
|
|
220
195
|
const [isEditable, setIsEditable] = useState(() => editor.isEditable());
|
|
@@ -240,7 +215,13 @@ export default function ToolbarPlugin({ editor, activeEditor, setActiveEditor, s
|
|
|
240
215
|
const $handleCodeNode = useCallback((element) => {
|
|
241
216
|
if ($isCodeNode(element)) {
|
|
242
217
|
const language = element.getLanguage();
|
|
243
|
-
|
|
218
|
+
const normalizedLanguage = language
|
|
219
|
+
? normalizeCodeLanguageShiki(language)
|
|
220
|
+
: "";
|
|
221
|
+
updateToolbarState("codeLanguage", normalizedLanguage);
|
|
222
|
+
updateToolbarState("codeCategory", normalizedLanguage
|
|
223
|
+
? getCodeCategoryForLanguage(normalizedLanguage)
|
|
224
|
+
: "");
|
|
244
225
|
const theme = element.getTheme();
|
|
245
226
|
updateToolbarState("codeTheme", theme || "");
|
|
246
227
|
return;
|
|
@@ -399,40 +380,67 @@ export default function ToolbarPlugin({ editor, activeEditor, setActiveEditor, s
|
|
|
399
380
|
activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
400
381
|
}
|
|
401
382
|
}, [activeEditor, setIsLinkEditMode, toolbarState.isLink]);
|
|
383
|
+
const onCodeCategorySelect = useCallback((value) => {
|
|
384
|
+
var _a, _b;
|
|
385
|
+
const nextLanguage = ((_b = (_a = CODE_CATEGORIES_AND_LANGUAGES_SHIKI.get(value)) === null || _a === void 0 ? void 0 : _a[1][0]) === null || _b === void 0 ? void 0 : _b[0]) || "";
|
|
386
|
+
updateToolbarState("codeCategory", value);
|
|
387
|
+
updateToolbarState("codeLanguage", nextLanguage);
|
|
388
|
+
activeEditor.update(() => {
|
|
389
|
+
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG);
|
|
390
|
+
if (selectedElementKey !== null) {
|
|
391
|
+
const node = $getNodeByKey(selectedElementKey);
|
|
392
|
+
if ($isCodeNode(node)) {
|
|
393
|
+
node.setLanguage(nextLanguage);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}, [activeEditor, selectedElementKey, updateToolbarState]);
|
|
402
398
|
const onCodeLanguageSelect = useCallback((value) => {
|
|
399
|
+
updateToolbarState("codeLanguage", value);
|
|
400
|
+
updateToolbarState("codeCategory", getCodeCategoryForLanguage(value));
|
|
401
|
+
console.log("oncodeLanguageSelect called ", value);
|
|
403
402
|
activeEditor.update(() => {
|
|
404
403
|
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG);
|
|
405
404
|
if (selectedElementKey !== null) {
|
|
405
|
+
console.log("oncodeLanguageSelect passed selectedElementKey ");
|
|
406
406
|
const node = $getNodeByKey(selectedElementKey);
|
|
407
|
+
console.log(node);
|
|
407
408
|
if ($isCodeNode(node)) {
|
|
409
|
+
console.log("setting language", value);
|
|
408
410
|
node.setLanguage(value);
|
|
409
411
|
}
|
|
410
412
|
}
|
|
411
413
|
});
|
|
412
|
-
}, [activeEditor, selectedElementKey]);
|
|
414
|
+
}, [activeEditor, selectedElementKey, updateToolbarState]);
|
|
413
415
|
const onCodeThemeSelect = useCallback((value) => {
|
|
416
|
+
updateToolbarState("codeTheme", value);
|
|
417
|
+
console.log("oncodeThemeSelect called ", value);
|
|
414
418
|
activeEditor.update(() => {
|
|
415
419
|
if (selectedElementKey !== null) {
|
|
420
|
+
console.log("oncodeThemeSelect passed selectedElementKey ");
|
|
416
421
|
const node = $getNodeByKey(selectedElementKey);
|
|
422
|
+
console.log(node);
|
|
417
423
|
if ($isCodeNode(node)) {
|
|
424
|
+
console.log("setting theme", value);
|
|
418
425
|
node.setTheme(value);
|
|
419
426
|
}
|
|
420
427
|
}
|
|
421
428
|
});
|
|
422
|
-
}, [activeEditor, selectedElementKey]);
|
|
429
|
+
}, [activeEditor, selectedElementKey, updateToolbarState]);
|
|
423
430
|
const canViewerSeeInsertDropdown = !toolbarState.isImageCaption;
|
|
424
431
|
const canViewerSeeInsertCodeButton = !toolbarState.isImageCaption;
|
|
425
432
|
return (_jsxs("div", { className: "toolbar", children: [_jsx("button", { disabled: !toolbarState.canUndo || !isEditable, onClick: (e) => dispatchToolbarCommand(UNDO_COMMAND, undefined, isKeyboardInput(e)), title: IS_APPLE ? "Undo (⌘Z)" : "Undo (Ctrl+Z)", type: "button", className: "toolbar-item spaced", "aria-label": "Undo", children: _jsx("i", { className: "format undo" }) }), _jsx("button", { disabled: !toolbarState.canRedo || !isEditable, onClick: (e) => dispatchToolbarCommand(REDO_COMMAND, undefined, isKeyboardInput(e)), title: IS_APPLE ? "Redo (⇧⌘Z)" : "Redo (Ctrl+Y)", type: "button", className: "toolbar-item", "aria-label": "Redo", children: _jsx("i", { className: "format redo" }) }), _jsx(Divider, {}), toolbarState.blockType in blockTypeToBlockName &&
|
|
426
|
-
activeEditor === editor && (_jsxs(_Fragment, { children: [_jsx(BlockFormatDropDown, { disabled: !isEditable, blockType: toolbarState.blockType, rootType: toolbarState.rootType, editor: activeEditor }), _jsx(Divider, {})] })), toolbarState.blockType === "code" ? (_jsxs(_Fragment, { children: [_jsx(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item code-language", buttonLabel: (
|
|
427
|
-
|
|
433
|
+
activeEditor === editor && (_jsxs(_Fragment, { children: [_jsx(BlockFormatDropDown, { disabled: !isEditable, blockType: toolbarState.blockType, rootType: toolbarState.rootType, editor: activeEditor }), _jsx(Divider, {})] })), toolbarState.blockType === "code" ? (_jsxs(_Fragment, { children: [_jsx(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item code-language-category", buttonLabel: ((_a = CODE_CATEGORIES_AND_LANGUAGES_SHIKI.get(toolbarState.codeCategory)) === null || _a === void 0 ? void 0 : _a[0]) || "Language Category", buttonAriaLabel: "Select language category", children: Array.from(CODE_CATEGORIES_AND_LANGUAGES_SHIKI.entries()).map(([category, [categoryName]]) => {
|
|
434
|
+
return (_jsx(DropDownItem, { className: `item ${dropDownActiveClass(category === toolbarState.codeCategory)}`, onClick: () => {
|
|
435
|
+
onCodeCategorySelect(category);
|
|
436
|
+
}, children: _jsx("span", { className: "text", children: categoryName }) }, category));
|
|
437
|
+
}) }), _jsx(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item code-language", buttonLabel: (CODE_LANGUAGE_OPTIONS_SHIKI.find((opt) => opt[0] ===
|
|
438
|
+
normalizeCodeLanguageShiki(toolbarState.codeLanguage)) || ["", ""])[1], buttonAriaLabel: "Select language", children: (_b = CODE_CATEGORIES_AND_LANGUAGES_SHIKI.get(toolbarState.codeCategory)) === null || _b === void 0 ? void 0 : _b[1].map(([value, name]) => {
|
|
428
439
|
return (_jsx(DropDownItem, { className: `item ${dropDownActiveClass(value === toolbarState.codeLanguage)}`, onClick: () => onCodeLanguageSelect(value), children: _jsx("span", { className: "text", children: name }) }, value));
|
|
429
|
-
}) }),
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
return (_jsx(DropDownItem, { className: `item ${dropDownActiveClass(value === toolbarState.codeTheme)}`, onClick: () => onCodeThemeSelect(value), children: _jsx("span", { className: "text", children: name }) }, value));
|
|
434
|
-
}) })] })] })) : (_jsxs(_Fragment, { children: [_jsx(FontDropDown, { disabled: !isEditable, style: "font-family", value: toolbarState.fontFamily, editor: activeEditor }), _jsx(Divider, {}), _jsx(FontSize, { selectionFontSize: parseFontSizeForToolbar(toolbarState.fontSize).slice(0, -2), editor: activeEditor, disabled: !isEditable }), _jsx(Divider, {}), _jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("bold", isKeyboardInput(e)), className: "toolbar-item spaced " + (toolbarState.isBold ? "active" : ""), title: `Bold (${SHORTCUTS.BOLD})`, type: "button", "aria-label": `Format text as bold. Shortcut: ${SHORTCUTS.BOLD}`, children: _jsx("i", { className: "format bold" }) }), _jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("italic", isKeyboardInput(e)), className: "toolbar-item spaced " + (toolbarState.isItalic ? "active" : ""), title: `Italic (${SHORTCUTS.ITALIC})`, type: "button", "aria-label": `Format text as italics. Shortcut: ${SHORTCUTS.ITALIC}`, children: _jsx("i", { className: "format italic" }) }), _jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("underline", isKeyboardInput(e)), className: "toolbar-item spaced " +
|
|
435
|
-
(toolbarState.isUnderline ? "active" : ""), title: `Underline (${SHORTCUTS.UNDERLINE})`, type: "button", "aria-label": `Format text to underlined. Shortcut: ${SHORTCUTS.UNDERLINE}`, children: _jsx("i", { className: "format underline" }) }), canViewerSeeInsertCodeButton && (_jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("code", isKeyboardInput(e)), className: "toolbar-item spaced " + (toolbarState.isCode ? "active" : ""), title: `Insert code block (${SHORTCUTS.INSERT_CODE_BLOCK})`, type: "button", "aria-label": "Insert code block", children: _jsx("i", { className: "format code" }) })), _jsx("button", { disabled: !isEditable, onClick: insertLink, className: "toolbar-item spaced " + (toolbarState.isLink ? "active" : ""), "aria-label": "Insert link", title: `Insert link (${SHORTCUTS.INSERT_LINK})`, type: "button", children: _jsx("i", { className: "format link" }) }), _jsx(DropdownColorPicker, { disabled: !isEditable, buttonClassName: "toolbar-item color-picker", buttonAriaLabel: "Formatting text color", buttonIconClassName: "icon font-color", color: toolbarState.fontColor, onChange: onFontColorSelect, title: "text color" }), _jsx(DropdownColorPicker, { disabled: !isEditable, buttonClassName: "toolbar-item color-picker", buttonAriaLabel: "Formatting background color", buttonIconClassName: "icon bg-color", color: toolbarState.bgColor, onChange: onBgColorSelect, title: "bg color" }), _jsxs(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item spaced", buttonLabel: "", buttonAriaLabel: "Formatting options for additional text styles", buttonIconClassName: "icon dropdown-more", children: [_jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("lowercase", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isLowercase), title: "Lowercase", "aria-label": "Format text to lowercase", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon lowercase" }), _jsx("span", { className: "text", children: "Lowercase" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.LOWERCASE })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("uppercase", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isUppercase), title: "Uppercase", "aria-label": "Format text to uppercase", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon uppercase" }), _jsx("span", { className: "text", children: "Uppercase" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.UPPERCASE })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("capitalize", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isCapitalize), title: "Capitalize", "aria-label": "Format text to capitalize", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon capitalize" }), _jsx("span", { className: "text", children: "Capitalize" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.CAPITALIZE })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("strikethrough", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isStrikethrough), title: "Strikethrough", "aria-label": "Format text with a strikethrough", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon strikethrough" }), _jsx("span", { className: "text", children: "Strikethrough" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.STRIKETHROUGH })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("subscript", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isSubscript), title: "Subscript", "aria-label": "Format text with a subscript", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon subscript" }), _jsx("span", { className: "text", children: "Subscript" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.SUBSCRIPT })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("superscript", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isSuperscript), title: "Superscript", "aria-label": "Format text with a superscript", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon superscript" }), _jsx("span", { className: "text", children: "Superscript" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.SUPERSCRIPT })] }), _jsx(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("highlight", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isHighlight), title: "Highlight", "aria-label": "Format text with a highlight", children: _jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon highlight" }), _jsx("span", { className: "text", children: "Highlight" })] }) }), _jsxs(DropDownItem, { onClick: (e) => clearFormatting(activeEditor, isKeyboardInput(e)), className: "item wide", title: "Clear text formatting", "aria-label": "Clear all text formatting", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon clear" }), _jsx("span", { className: "text", children: "Clear Formatting" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.CLEAR_FORMATTING })] })] }), canViewerSeeInsertDropdown && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsxs(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item spaced", buttonLabel: "Insert", buttonAriaLabel: "Insert specialized editor node", buttonIconClassName: "icon plus", children: [_jsxs(DropDownItem, { onClick: () => dispatchToolbarCommand(INSERT_HORIZONTAL_RULE_COMMAND), className: "item", children: [_jsx("i", { className: "icon horizontal-rule" }), _jsx("span", { className: "text", children: "Horizontal Rule" })] }), _jsxs(DropDownItem, { onClick: () => dispatchToolbarCommand(INSERT_PAGE_BREAK), className: "item", children: [_jsx("i", { className: "icon page-break" }), _jsx("span", { className: "text", children: "Page Break" })] }), _jsxs(DropDownItem, { onClick: () => {
|
|
440
|
+
}) }), _jsx(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item code-language", buttonLabel: (CODE_THEME_OPTIONS_SHIKI.find((opt) => opt[0] === toolbarState.codeTheme) || ["", ""])[1], buttonAriaLabel: "Select theme", children: CODE_THEME_OPTIONS_SHIKI.map(([value, name]) => {
|
|
441
|
+
return (_jsx(DropDownItem, { className: `item ${dropDownActiveClass(value === toolbarState.codeTheme)}`, onClick: () => onCodeThemeSelect(value), children: _jsx("span", { className: "text", children: name }) }, value));
|
|
442
|
+
}) })] })) : (_jsxs(_Fragment, { children: [_jsx(FontDropDown, { disabled: !isEditable, style: "font-family", value: toolbarState.fontFamily, editor: activeEditor }), _jsx(Divider, {}), _jsx(FontSize, { selectionFontSize: parseFontSizeForToolbar(toolbarState.fontSize).slice(0, -2), editor: activeEditor, disabled: !isEditable }), _jsx(Divider, {}), _jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("bold", isKeyboardInput(e)), className: "toolbar-item spaced " + (toolbarState.isBold ? "active" : ""), title: `Bold (${SHORTCUTS.BOLD})`, type: "button", "aria-label": `Format text as bold. Shortcut: ${SHORTCUTS.BOLD}`, children: _jsx("i", { className: "format bold" }) }), _jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("italic", isKeyboardInput(e)), className: "toolbar-item spaced " + (toolbarState.isItalic ? "active" : ""), title: `Italic (${SHORTCUTS.ITALIC})`, type: "button", "aria-label": `Format text as italics. Shortcut: ${SHORTCUTS.ITALIC}`, children: _jsx("i", { className: "format italic" }) }), _jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("underline", isKeyboardInput(e)), className: "toolbar-item spaced " +
|
|
443
|
+
(toolbarState.isUnderline ? "active" : ""), title: `Underline (${SHORTCUTS.UNDERLINE})`, type: "button", "aria-label": `Format text to underlined. Shortcut: ${SHORTCUTS.UNDERLINE}`, children: _jsx("i", { className: "format underline" }) }), canViewerSeeInsertCodeButton && (_jsx("button", { disabled: !isEditable, onClick: (e) => dispatchFormatTextCommand("code", isKeyboardInput(e)), className: "toolbar-item spaced " + (toolbarState.isCode ? "active" : ""), title: `Insert code block (${SHORTCUTS.INSERT_CODE_BLOCK})`, type: "button", "aria-label": "Insert code block", children: _jsx("i", { className: "format code" }) })), _jsx("button", { disabled: !isEditable, onClick: insertLink, className: "toolbar-item spaced " + (toolbarState.isLink ? "active" : ""), "aria-label": "Insert link", title: `Insert link (${SHORTCUTS.INSERT_LINK})`, type: "button", children: _jsx("i", { className: "format link" }) }), _jsx(DropdownColorPicker, { disabled: !isEditable, buttonClassName: "toolbar-item color-picker", buttonAriaLabel: "Formatting text color", buttonIconClassName: "icon font-color", color: toolbarState.fontColor, onChange: onFontColorSelect, title: "text color" }), _jsx(DropdownColorPicker, { disabled: !isEditable, buttonClassName: "toolbar-item color-picker", buttonAriaLabel: "Formatting background color", buttonIconClassName: "icon bg-color", color: toolbarState.bgColor, onChange: onBgColorSelect, title: "bg color" }), _jsxs(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item spaced", buttonLabel: "", buttonAriaLabel: "Formatting options for additional text styles", buttonIconClassName: "icon dropdown-more", children: [_jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("lowercase", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isLowercase), title: "Lowercase", "aria-label": "Format text to lowercase", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon lowercase" }), _jsx("span", { className: "text", children: "Lowercase" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.LOWERCASE })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("uppercase", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isUppercase), title: "Uppercase", "aria-label": "Format text to uppercase", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon uppercase" }), _jsx("span", { className: "text", children: "Uppercase" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.UPPERCASE })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("capitalize", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isCapitalize), title: "Capitalize", "aria-label": "Format text to capitalize", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon capitalize" }), _jsx("span", { className: "text", children: "Capitalize" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.CAPITALIZE })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("strikethrough", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isStrikethrough), title: "Strikethrough", "aria-label": "Format text with a strikethrough", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon strikethrough" }), _jsx("span", { className: "text", children: "Strikethrough" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.STRIKETHROUGH })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("subscript", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isSubscript), title: "Subscript", "aria-label": "Format text with a subscript", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon subscript" }), _jsx("span", { className: "text", children: "Subscript" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.SUBSCRIPT })] }), _jsxs(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("superscript", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isSuperscript), title: "Superscript", "aria-label": "Format text with a superscript", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon superscript" }), _jsx("span", { className: "text", children: "Superscript" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.SUPERSCRIPT })] }), _jsx(DropDownItem, { onClick: (e) => dispatchFormatTextCommand("highlight", isKeyboardInput(e)), className: "item wide " + dropDownActiveClass(toolbarState.isHighlight), title: "Highlight", "aria-label": "Format text with a highlight", children: _jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon highlight" }), _jsx("span", { className: "text", children: "Highlight" })] }) }), _jsxs(DropDownItem, { onClick: (e) => clearFormatting(activeEditor, isKeyboardInput(e)), className: "item wide", title: "Clear text formatting", "aria-label": "Clear all text formatting", children: [_jsxs("div", { className: "icon-text-container", children: [_jsx("i", { className: "icon clear" }), _jsx("span", { className: "text", children: "Clear Formatting" })] }), _jsx("span", { className: "shortcut", children: SHORTCUTS.CLEAR_FORMATTING })] })] }), canViewerSeeInsertDropdown && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsxs(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item spaced", buttonLabel: "Insert", buttonAriaLabel: "Insert specialized editor node", buttonIconClassName: "icon plus", children: [_jsxs(DropDownItem, { onClick: () => dispatchToolbarCommand(INSERT_HORIZONTAL_RULE_COMMAND), className: "item", children: [_jsx("i", { className: "icon horizontal-rule" }), _jsx("span", { className: "text", children: "Horizontal Rule" })] }), _jsxs(DropDownItem, { onClick: () => {
|
|
436
444
|
showModal("Insert Image", (onClose) => (_jsx(InsertImageDialog, { activeEditor: activeEditor, onClose: onClose })));
|
|
437
445
|
}, className: "item", children: [_jsx("i", { className: "icon image" }), _jsx("span", { className: "text", children: "Image" })] }), _jsxs(DropDownItem, { onClick: () => {
|
|
438
446
|
showModal("Insert Table", (onClose) => (_jsx(InsertTableDialog, { activeEditor: activeEditor, onClose: onClose })));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const webFrontend: string[];
|
|
2
|
+
export declare const backendGeneral: string[];
|
|
3
|
+
export declare const systemsLowLevel: string[];
|
|
4
|
+
export declare const mobileDevelopment: string[];
|
|
5
|
+
export declare const dataScienceMath: string[];
|
|
6
|
+
export declare const functionalProgramming: string[];
|
|
7
|
+
export declare const databaseQuery: string[];
|
|
8
|
+
export declare const devOpsConfig: string[];
|
|
9
|
+
export declare const shellAutomation: string[];
|
|
10
|
+
export declare const markupDocs: string[];
|
|
11
|
+
export declare const miscellaneous: string[];
|
|
12
|
+
export declare const allLanguages: Map<string, [string, string[]]>;
|
|
13
|
+
export declare const allLanguagesFlat: string[];
|
|
14
|
+
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../../src/plugins/ToolbarPlugin/languages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UA4BvB,CAAC;AAEF,eAAO,MAAM,cAAc,UA6B1B,CAAC;AAEF,eAAO,MAAM,eAAe,UAc3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAO7B,CAAC;AAEF,eAAO,MAAM,eAAe,UAW3B,CAAC;AAEF,eAAO,MAAM,qBAAqB,UAcjC,CAAC;AAEF,eAAO,MAAM,aAAa,UAA6B,CAAC;AAExD,eAAO,MAAM,YAAY,UAgBxB,CAAC;AAEF,eAAO,MAAM,eAAe,UAS3B,CAAC;AAEF,eAAO,MAAM,UAAU,UAUtB,CAAC;AAEF,eAAO,MAAM,aAAa,UAqBzB,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAYvD,CAAC;AAEH,eAAO,MAAM,gBAAgB,UAE5B,CAAC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export const webFrontend = [
|
|
2
|
+
"coffeescript",
|
|
3
|
+
"csp",
|
|
4
|
+
"css",
|
|
5
|
+
"css-extras",
|
|
6
|
+
"flow",
|
|
7
|
+
"graphql",
|
|
8
|
+
"haml",
|
|
9
|
+
"handlebars",
|
|
10
|
+
"javascript",
|
|
11
|
+
"json",
|
|
12
|
+
"jsx",
|
|
13
|
+
"less",
|
|
14
|
+
"liquid",
|
|
15
|
+
"livescript",
|
|
16
|
+
"markup",
|
|
17
|
+
"markup-templating",
|
|
18
|
+
"n4js",
|
|
19
|
+
"pug",
|
|
20
|
+
"sass",
|
|
21
|
+
"scss",
|
|
22
|
+
"smarty",
|
|
23
|
+
"soy",
|
|
24
|
+
"stylus",
|
|
25
|
+
"tsx",
|
|
26
|
+
"twig",
|
|
27
|
+
"typescript",
|
|
28
|
+
"velocity",
|
|
29
|
+
];
|
|
30
|
+
export const backendGeneral = [
|
|
31
|
+
"abap",
|
|
32
|
+
"aspnet",
|
|
33
|
+
"basic",
|
|
34
|
+
"crystal",
|
|
35
|
+
"csharp",
|
|
36
|
+
"d",
|
|
37
|
+
"django",
|
|
38
|
+
"eiffel",
|
|
39
|
+
"erb",
|
|
40
|
+
"go",
|
|
41
|
+
"groovy",
|
|
42
|
+
"haxe",
|
|
43
|
+
"java",
|
|
44
|
+
"lua",
|
|
45
|
+
"nim",
|
|
46
|
+
"pascal",
|
|
47
|
+
"perl",
|
|
48
|
+
"php",
|
|
49
|
+
"php-extras",
|
|
50
|
+
"python",
|
|
51
|
+
"ruby",
|
|
52
|
+
"rust",
|
|
53
|
+
"scala",
|
|
54
|
+
"smalltalk",
|
|
55
|
+
"tcl",
|
|
56
|
+
"vbnet",
|
|
57
|
+
"visual-basic",
|
|
58
|
+
"xojo",
|
|
59
|
+
];
|
|
60
|
+
export const systemsLowLevel = [
|
|
61
|
+
"ada",
|
|
62
|
+
"arduino",
|
|
63
|
+
"asm6502",
|
|
64
|
+
"c",
|
|
65
|
+
"clike",
|
|
66
|
+
"cpp",
|
|
67
|
+
"fortran",
|
|
68
|
+
"glsl",
|
|
69
|
+
"nasm",
|
|
70
|
+
"opencl",
|
|
71
|
+
"verilog",
|
|
72
|
+
"vhdl",
|
|
73
|
+
"wasm",
|
|
74
|
+
];
|
|
75
|
+
export const mobileDevelopment = [
|
|
76
|
+
"actionscript",
|
|
77
|
+
"dart",
|
|
78
|
+
"kotlin",
|
|
79
|
+
"monkey",
|
|
80
|
+
"objectivec",
|
|
81
|
+
"swift",
|
|
82
|
+
];
|
|
83
|
+
export const dataScienceMath = [
|
|
84
|
+
"apl",
|
|
85
|
+
"arff",
|
|
86
|
+
"julia",
|
|
87
|
+
"matlab",
|
|
88
|
+
"mizar",
|
|
89
|
+
"parigp",
|
|
90
|
+
"prolog",
|
|
91
|
+
"q",
|
|
92
|
+
"r",
|
|
93
|
+
"sas",
|
|
94
|
+
];
|
|
95
|
+
export const functionalProgramming = [
|
|
96
|
+
"clojure",
|
|
97
|
+
"elixir",
|
|
98
|
+
"elm",
|
|
99
|
+
"erlang",
|
|
100
|
+
"fsharp",
|
|
101
|
+
"haskell",
|
|
102
|
+
"io",
|
|
103
|
+
"lisp",
|
|
104
|
+
"ocaml",
|
|
105
|
+
"oz",
|
|
106
|
+
"pure",
|
|
107
|
+
"reason",
|
|
108
|
+
"scheme",
|
|
109
|
+
];
|
|
110
|
+
export const databaseQuery = ["plsql", "sql", "xquery"];
|
|
111
|
+
export const devOpsConfig = [
|
|
112
|
+
"apacheconf",
|
|
113
|
+
"docker",
|
|
114
|
+
"git",
|
|
115
|
+
"hpkp",
|
|
116
|
+
"hsts",
|
|
117
|
+
"http",
|
|
118
|
+
"ini",
|
|
119
|
+
"makefile",
|
|
120
|
+
"nginx",
|
|
121
|
+
"nix",
|
|
122
|
+
"properties",
|
|
123
|
+
"protobuf",
|
|
124
|
+
"puppet",
|
|
125
|
+
"roboconf",
|
|
126
|
+
"yaml",
|
|
127
|
+
];
|
|
128
|
+
export const shellAutomation = [
|
|
129
|
+
"applescript",
|
|
130
|
+
"autohotkey",
|
|
131
|
+
"autoit",
|
|
132
|
+
"bash",
|
|
133
|
+
"batch",
|
|
134
|
+
"nsis",
|
|
135
|
+
"powershell",
|
|
136
|
+
"vim",
|
|
137
|
+
];
|
|
138
|
+
export const markupDocs = [
|
|
139
|
+
"asciidoc",
|
|
140
|
+
"diff",
|
|
141
|
+
"gedcom",
|
|
142
|
+
"gherkin",
|
|
143
|
+
"latex",
|
|
144
|
+
"markdown",
|
|
145
|
+
"rest",
|
|
146
|
+
"textile",
|
|
147
|
+
"wiki",
|
|
148
|
+
];
|
|
149
|
+
export const miscellaneous = [
|
|
150
|
+
"bison",
|
|
151
|
+
"brainfuck",
|
|
152
|
+
"bro",
|
|
153
|
+
"gml",
|
|
154
|
+
"ichigojam",
|
|
155
|
+
"icon",
|
|
156
|
+
"inform7",
|
|
157
|
+
"j",
|
|
158
|
+
"jolie",
|
|
159
|
+
"keyman",
|
|
160
|
+
"lolcode",
|
|
161
|
+
"mel",
|
|
162
|
+
"parser",
|
|
163
|
+
"processing",
|
|
164
|
+
"qore",
|
|
165
|
+
"renpy",
|
|
166
|
+
"rip",
|
|
167
|
+
"tap",
|
|
168
|
+
"tt2",
|
|
169
|
+
"xeora",
|
|
170
|
+
];
|
|
171
|
+
//! The important one, but exported
|
|
172
|
+
export const allLanguages = new Map([
|
|
173
|
+
["backendGeneral", ["Backend", backendGeneral]],
|
|
174
|
+
["databaseQuery", ["Database", databaseQuery]],
|
|
175
|
+
["dataScienceMath", ["Data Science & Math", dataScienceMath]],
|
|
176
|
+
["devOpsConfig", ["DevOps/Config", devOpsConfig]],
|
|
177
|
+
["functionalProgramming", ["Functional Programming", functionalProgramming]],
|
|
178
|
+
["markupDocs", ["Markup & Docs", markupDocs]],
|
|
179
|
+
["mobileDevelopment", ["Mobile Development", mobileDevelopment]],
|
|
180
|
+
["shellAutomation", ["Shell & Automation", shellAutomation]],
|
|
181
|
+
["systemsLowLevel", ["Systems & Low Level", systemsLowLevel]],
|
|
182
|
+
["webFrontend", ["Web Development", webFrontend]],
|
|
183
|
+
["miscellaneous", ["Miscellaneous", miscellaneous]],
|
|
184
|
+
]);
|
|
185
|
+
export const allLanguagesFlat = Array.from(allLanguages.values()).flatMap(([, languages]) => languages);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HeadingTagType } from
|
|
2
|
-
import { LexicalEditor } from
|
|
1
|
+
import { HeadingTagType } from "@lexical/rich-text";
|
|
2
|
+
import { LexicalEditor } from "lexical";
|
|
3
3
|
export declare enum UpdateFontSizeType {
|
|
4
4
|
increment = 1,
|
|
5
5
|
decrement = 2
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { $createCodeNode } from
|
|
9
|
-
import { INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, } from
|
|
10
|
-
import { $isDecoratorBlockNode } from
|
|
11
|
-
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, } from
|
|
12
|
-
import { $patchStyleText, $setBlocksType } from
|
|
13
|
-
import { $isTableSelection } from
|
|
14
|
-
import { $getNearestBlockElementAncestorOrThrow } from
|
|
15
|
-
import { $addUpdateTag, $createParagraphNode, $getSelection, $isRangeSelection, $isTextNode, SKIP_DOM_SELECTION_TAG, SKIP_SELECTION_FOCUS_TAG, } from
|
|
16
|
-
import { DEFAULT_FONT_SIZE, MAX_ALLOWED_FONT_SIZE, MIN_ALLOWED_FONT_SIZE, } from
|
|
8
|
+
import { $createCodeNode } from "../../nodes/CodeNode/CodeNode";
|
|
9
|
+
import { INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, } from "@lexical/list";
|
|
10
|
+
import { $isDecoratorBlockNode } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
11
|
+
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, } from "@lexical/rich-text";
|
|
12
|
+
import { $patchStyleText, $setBlocksType } from "@lexical/selection";
|
|
13
|
+
import { $isTableSelection } from "@lexical/table";
|
|
14
|
+
import { $getNearestBlockElementAncestorOrThrow } from "@lexical/utils";
|
|
15
|
+
import { $addUpdateTag, $createParagraphNode, $getSelection, $isRangeSelection, $isTextNode, SKIP_DOM_SELECTION_TAG, SKIP_SELECTION_FOCUS_TAG, } from "lexical";
|
|
16
|
+
import { DEFAULT_FONT_SIZE, MAX_ALLOWED_FONT_SIZE, MIN_ALLOWED_FONT_SIZE, } from "../../context/ToolbarContext";
|
|
17
17
|
// eslint-disable-next-line no-shadow
|
|
18
18
|
export var UpdateFontSizeType;
|
|
19
19
|
(function (UpdateFontSizeType) {
|
|
@@ -101,16 +101,16 @@ export const updateFontSizeInSelection = (editor, newFontSize, updateType, skipR
|
|
|
101
101
|
const selection = $getSelection();
|
|
102
102
|
if (selection !== null) {
|
|
103
103
|
$patchStyleText(selection, {
|
|
104
|
-
|
|
104
|
+
"font-size": newFontSize || getNextFontSize,
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
110
|
export const updateFontSize = (editor, updateType, inputValue, skipRefocus = false) => {
|
|
111
|
-
if (inputValue !==
|
|
111
|
+
if (inputValue !== "") {
|
|
112
112
|
const nextFontSize = calculateNextFontSize(Number(inputValue), updateType);
|
|
113
|
-
updateFontSizeInSelection(editor, String(nextFontSize) +
|
|
113
|
+
updateFontSizeInSelection(editor, String(nextFontSize) + "px", null, skipRefocus);
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
116
|
updateFontSizeInSelection(editor, null, updateType, skipRefocus);
|
|
@@ -133,7 +133,7 @@ export const formatHeading = (editor, blockType, headingSize) => {
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
export const formatBulletList = (editor, blockType) => {
|
|
136
|
-
if (blockType !==
|
|
136
|
+
if (blockType !== "bullet") {
|
|
137
137
|
editor.update(() => {
|
|
138
138
|
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG);
|
|
139
139
|
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
@@ -144,7 +144,7 @@ export const formatBulletList = (editor, blockType) => {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
export const formatCheckList = (editor, blockType) => {
|
|
147
|
-
if (blockType !==
|
|
147
|
+
if (blockType !== "check") {
|
|
148
148
|
editor.update(() => {
|
|
149
149
|
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG);
|
|
150
150
|
editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined);
|
|
@@ -155,7 +155,7 @@ export const formatCheckList = (editor, blockType) => {
|
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
export const formatNumberedList = (editor, blockType) => {
|
|
158
|
-
if (blockType !==
|
|
158
|
+
if (blockType !== "number") {
|
|
159
159
|
editor.update(() => {
|
|
160
160
|
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG);
|
|
161
161
|
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
@@ -166,7 +166,7 @@ export const formatNumberedList = (editor, blockType) => {
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
export const formatQuote = (editor, blockType) => {
|
|
169
|
-
if (blockType !==
|
|
169
|
+
if (blockType !== "quote") {
|
|
170
170
|
editor.update(() => {
|
|
171
171
|
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG);
|
|
172
172
|
const selection = $getSelection();
|
|
@@ -175,7 +175,7 @@ export const formatQuote = (editor, blockType) => {
|
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
export const formatCode = (editor, blockType) => {
|
|
178
|
-
if (blockType !==
|
|
178
|
+
if (blockType !== "code") {
|
|
179
179
|
editor.update(() => {
|
|
180
180
|
$addUpdateTag(SKIP_SELECTION_FOCUS_TAG);
|
|
181
181
|
let selection = $getSelection();
|
|
@@ -235,15 +235,15 @@ export const clearFormatting = (editor, skipRefocus = false) => {
|
|
|
235
235
|
if (nodes.length === 1 && $isTextNode(extractedTextNode)) {
|
|
236
236
|
textNode = extractedTextNode;
|
|
237
237
|
}
|
|
238
|
-
if (textNode.__style !==
|
|
239
|
-
textNode.setStyle(
|
|
238
|
+
if (textNode.__style !== "") {
|
|
239
|
+
textNode.setStyle("");
|
|
240
240
|
}
|
|
241
241
|
if (textNode.__format !== 0) {
|
|
242
242
|
textNode.setFormat(0);
|
|
243
243
|
}
|
|
244
244
|
const nearestBlockElement = $getNearestBlockElementAncestorOrThrow(textNode);
|
|
245
245
|
if (nearestBlockElement.__format !== 0) {
|
|
246
|
-
nearestBlockElement.setFormat(
|
|
246
|
+
nearestBlockElement.setFormat("");
|
|
247
247
|
}
|
|
248
248
|
if (nearestBlockElement.__indent !== 0) {
|
|
249
249
|
nearestBlockElement.setIndent(0);
|
|
@@ -254,7 +254,7 @@ export const clearFormatting = (editor, skipRefocus = false) => {
|
|
|
254
254
|
node.replace($createParagraphNode(), true);
|
|
255
255
|
}
|
|
256
256
|
else if ($isDecoratorBlockNode(node)) {
|
|
257
|
-
node.setFormat(
|
|
257
|
+
node.setFormat("");
|
|
258
258
|
}
|
|
259
259
|
});
|
|
260
260
|
}
|
|
@@ -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
|
export declare const INSERT_TWEET_COMMAND: LexicalCommand<string>;
|
|
11
11
|
export default function TwitterPlugin(): JSX.Element | null;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/TwitterPlugin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/TwitterPlugin/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIjC,OAAO,EAGL,cAAc,EACf,MAAM,SAAS,CAAC;AAKjB,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,MAAM,CAEvD,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAqB1D"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
9
|
-
import { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
10
|
-
import { COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
11
|
-
import { useEffect } from 'react';
|
|
12
|
-
import { $createTweetNode, TweetNode } from '../../nodes/TweetNode';
|
|
13
|
-
export const INSERT_TWEET_COMMAND = createCommand('INSERT_TWEET_COMMAND');
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
3
|
+
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
4
|
+
import { COMMAND_PRIORITY_EDITOR, createCommand, } from "lexical";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { $createTweetNode, TweetNode } from "../../nodes/TweetNode/TweetNode";
|
|
7
|
+
export const INSERT_TWEET_COMMAND = createCommand("INSERT_TWEET_COMMAND");
|
|
14
8
|
export default function TwitterPlugin() {
|
|
15
9
|
const [editor] = useLexicalComposerContext();
|
|
16
10
|
useEffect(() => {
|
|
17
11
|
if (!editor.hasNodes([TweetNode])) {
|
|
18
|
-
throw new Error(
|
|
12
|
+
throw new Error("TwitterPlugin: TweetNode not registered on editor");
|
|
19
13
|
}
|
|
20
14
|
return editor.registerCommand(INSERT_TWEET_COMMAND, (payload) => {
|
|
21
15
|
const tweetNode = $createTweetNode(payload);
|
|
@@ -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
|
export declare const INSERT_YOUTUBE_COMMAND: LexicalCommand<string>;
|
|
11
11
|
export default function YouTubePlugin(): JSX.Element | null;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/YouTubePlugin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/YouTubePlugin/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIjC,OAAO,EAGL,cAAc,EACf,MAAM,SAAS,CAAC;AAQjB,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,MAAM,CAEzD,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAqB1D"}
|