@mdxeditor/editor 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/FormatConstants.d.ts +9 -0
- package/dist/FormatConstants.js +10 -0
- package/dist/MDXEditor.d.ts +60 -0
- package/dist/MDXEditor.js +105 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +29 -0
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
- package/dist/exportMarkdownFromLexical.d.ts +114 -0
- package/dist/exportMarkdownFromLexical.js +199 -0
- package/dist/gurx/index.d.ts +3 -0
- package/dist/gurx/react.d.ts +121 -0
- package/dist/gurx/react.js +112 -0
- package/dist/gurx/realm.d.ts +133 -0
- package/dist/gurx/realm.js +491 -0
- package/dist/gurx/realmFactory.d.ts +58 -0
- package/dist/gurx/realmFactory.js +28 -0
- package/dist/icons/add_column.svg.js +8 -0
- package/dist/icons/add_photo.svg.js +8 -0
- package/dist/icons/add_row.svg.js +8 -0
- package/dist/icons/arrow_drop_down.svg.js +8 -0
- package/dist/icons/arrow_right.svg.js +8 -0
- package/dist/icons/check.svg.js +8 -0
- package/dist/icons/close.svg.js +8 -0
- package/dist/icons/code.svg.js +8 -0
- package/dist/icons/content_copy.svg.js +8 -0
- package/dist/icons/delete.svg.js +8 -0
- package/dist/icons/delete_small.svg.js +8 -0
- package/dist/icons/deployed_code.svg.js +8 -0
- package/dist/icons/difference.svg.js +8 -0
- package/dist/icons/edit.svg.js +8 -0
- package/dist/icons/emergency_home.svg.js +8 -0
- package/dist/icons/format_align_center.svg.js +8 -0
- package/dist/icons/format_align_left.svg.js +8 -0
- package/dist/icons/format_align_right.svg.js +8 -0
- package/dist/icons/format_bold.svg.js +8 -0
- package/dist/icons/format_italic.svg.js +8 -0
- package/dist/icons/format_list_bulleted.svg.js +8 -0
- package/dist/icons/format_list_numbered.svg.js +8 -0
- package/dist/icons/format_underlined.svg.js +8 -0
- package/dist/icons/frame_source.svg.js +8 -0
- package/dist/icons/frontmatter.svg.js +8 -0
- package/dist/icons/horizontal_rule.svg.js +8 -0
- package/dist/icons/insert_col_left.svg.js +8 -0
- package/dist/icons/insert_col_right.svg.js +8 -0
- package/dist/icons/insert_row_above.svg.js +8 -0
- package/dist/icons/insert_row_below.svg.js +8 -0
- package/dist/icons/link.svg.js +8 -0
- package/dist/icons/link_off.svg.js +8 -0
- package/dist/icons/markdown.svg.js +8 -0
- package/dist/icons/more_horiz.svg.js +8 -0
- package/dist/icons/open_in_new.svg.js +8 -0
- package/dist/icons/redo.svg.js +8 -0
- package/dist/icons/rich_text.svg.js +8 -0
- package/dist/icons/settings.svg.js +8 -0
- package/dist/icons/table.svg.js +8 -0
- package/dist/icons/undo.svg.js +8 -0
- package/dist/importMarkdownToLexical.d.ts +84 -0
- package/dist/importMarkdownToLexical.js +65 -0
- package/dist/index.d.ts +49 -1105
- package/dist/index.js +140 -72
- package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
- package/dist/jsx-editors/GenericJsxEditor.js +56 -0
- package/dist/node_modules/react-diff-view/style/index.css.js +4 -0
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +99 -0
- package/dist/plugins/codeblock/CodeBlockNode.js +155 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
- package/dist/plugins/codeblock/index.d.ts +617 -0
- package/dist/plugins/codeblock/index.js +73 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.js +33 -0
- package/dist/plugins/codemirror/index.d.ts +800 -0
- package/dist/plugins/codemirror/index.js +62 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
- package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
- package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalRootVisitor.js +10 -0
- package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
- package/dist/plugins/core/LexicalTextVisitor.js +85 -0
- package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
- package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.js +11 -0
- package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
- package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastRootVisitor.js +9 -0
- package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastTextVisitor.js +10 -0
- package/dist/plugins/core/NestedLexicalEditor.d.ts +96 -0
- package/dist/plugins/core/NestedLexicalEditor.js +181 -0
- package/dist/plugins/core/PropertyPopover.d.ts +23 -0
- package/dist/plugins/core/PropertyPopover.js +36 -0
- package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
- package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
- package/dist/plugins/core/index.d.ts +423 -0
- package/dist/plugins/core/index.js +346 -0
- package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
- package/dist/plugins/core/ui/PopoverUtils.js +17 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
- package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
- package/dist/plugins/diff-source/DiffViewer.js +18 -0
- package/dist/plugins/diff-source/SourceEditor.d.ts +2 -0
- package/dist/plugins/diff-source/SourceEditor.js +27 -0
- package/dist/plugins/diff-source/index.d.ts +544 -0
- package/dist/plugins/diff-source/index.js +55 -0
- package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
- package/dist/plugins/directives/DirectiveNode.js +92 -0
- package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
- package/dist/plugins/directives/DirectiveVisitor.js +10 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
- package/dist/plugins/directives/index.d.ts +603 -0
- package/dist/plugins/directives/index.js +53 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.js +69 -0
- package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
- package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/index.d.ts +523 -0
- package/dist/plugins/frontmatter/index.js +53 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
- package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
- package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
- package/dist/plugins/headings/index.d.ts +118 -0
- package/dist/plugins/headings/index.js +20 -0
- package/dist/plugins/image/ImageEditor.d.ts +9 -0
- package/dist/{ImageEditor-3725ebef.js → plugins/image/ImageEditor.js} +40 -52
- package/dist/plugins/image/ImageNode.d.ts +63 -0
- package/dist/plugins/image/ImageNode.js +136 -0
- package/dist/plugins/image/ImageResizer.d.ts +18 -0
- package/dist/plugins/image/ImageResizer.js +214 -0
- package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
- package/dist/plugins/image/LexicalImageVisitor.js +36 -0
- package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
- package/dist/plugins/image/MdastImageVisitor.js +87 -0
- package/dist/plugins/image/index.d.ts +557 -0
- package/dist/plugins/image/index.js +246 -0
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
- package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
- package/dist/plugins/jsx/index.d.ts +599 -0
- package/dist/plugins/jsx/index.js +59 -0
- package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
- package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
- package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
- package/dist/plugins/link/MdastLinkVisitor.js +14 -0
- package/dist/plugins/link/index.d.ts +68 -0
- package/dist/plugins/link/index.js +22 -0
- package/dist/plugins/link-dialog/LinkDialog.d.ts +12 -0
- package/dist/plugins/link-dialog/LinkDialog.js +174 -0
- package/dist/plugins/link-dialog/index.d.ts +508 -0
- package/dist/plugins/link-dialog/index.js +242 -0
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListItemVisitor.js +22 -0
- package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListVisitor.js +13 -0
- package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
- package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
- package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
- package/dist/plugins/lists/MdastListVisitor.js +18 -0
- package/dist/plugins/lists/index.d.ts +533 -0
- package/dist/plugins/lists/index.js +111 -0
- package/dist/plugins/markdown-shortcut/index.d.ts +63 -0
- package/dist/plugins/markdown-shortcut/index.js +34 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
- package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
- package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
- package/dist/plugins/quote/index.d.ts +361 -0
- package/dist/plugins/quote/index.js +26 -0
- package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
- package/dist/plugins/sandpack/SandpackEditor.js +35 -0
- package/dist/plugins/sandpack/index.d.ts +839 -0
- package/dist/plugins/sandpack/index.js +93 -0
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
- package/dist/{useCodeMirrorRef-0def7994.js → plugins/sandpack/useCodeMirrorRef.js} +22 -10
- package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
- package/dist/plugins/table/LexicalTableVisitor.js +10 -0
- package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
- package/dist/plugins/table/MdastTableVisitor.js +10 -0
- package/dist/plugins/table/TableEditor.d.ts +21 -0
- package/dist/plugins/table/TableEditor.js +384 -0
- package/dist/plugins/table/TableNode.d.ts +52 -0
- package/dist/plugins/table/TableNode.js +147 -0
- package/dist/plugins/table/index.d.ts +523 -0
- package/dist/plugins/table/index.js +59 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/index.d.ts +523 -0
- package/dist/plugins/thematic-break/index.js +39 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +52 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +35 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
- package/dist/plugins/toolbar/components/CodeToggle.js +20 -0
- package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
- package/dist/plugins/toolbar/components/CreateLink.js +11 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +27 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +11 -0
- package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertImage.js +23 -0
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
- package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertTable.js +20 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
- package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.js +32 -0
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
- package/dist/plugins/toolbar/components/UndoRedo.js +59 -0
- package/dist/plugins/toolbar/index.d.ts +428 -0
- package/dist/plugins/toolbar/index.js +39 -0
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
- package/dist/plugins/toolbar/primitives/DialogButton.js +115 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
- package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
- package/dist/plugins/toolbar/primitives/select.js +44 -0
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +160 -0
- package/dist/plugins/toolbar/primitives/toolbar.js +111 -0
- package/dist/style.css +556 -249
- package/dist/styles/globals.css.js +4 -0
- package/dist/styles/lexical-theme.module.css.js +53 -0
- package/dist/styles/lexicalTheme.d.ts +2 -0
- package/dist/styles/lexicalTheme.js +28 -0
- package/dist/styles/ui.module.css.js +254 -0
- package/dist/utils/detectMac.d.ts +2 -0
- package/dist/utils/detectMac.js +6 -0
- package/dist/utils/fp.d.ts +47 -0
- package/dist/utils/fp.js +10 -0
- package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
- package/dist/utils/isPartOftheEditorUI.js +12 -0
- package/dist/utils/lexicalHelpers.d.ts +11 -0
- package/dist/utils/lexicalHelpers.js +49 -0
- package/dist/utils/uuid4.d.ts +1 -0
- package/dist/utils/uuid4.js +10 -0
- package/dist/utils/voidEmitter.d.ts +14 -0
- package/dist/utils/voidEmitter.js +15 -0
- package/package.json +246 -14
- package/dist/CodeBlockEditor-6488d3ea.cjs +0 -1
- package/dist/CodeBlockEditor-884743e8.js +0 -79
- package/dist/FrontmatterEditor-435d0430.js +0 -118
- package/dist/FrontmatterEditor-95b69d31.cjs +0 -1
- package/dist/ImageEditor-43997418.cjs +0 -1
- package/dist/JsxEditor-1b8aa6c6.cjs +0 -1
- package/dist/JsxEditor-b2e4afc2.js +0 -108
- package/dist/LeafDirectiveEditor-792cbb83.js +0 -59
- package/dist/LeafDirectiveEditor-c0daefa4.cjs +0 -1
- package/dist/SandpackEditor-56a51f80.js +0 -100
- package/dist/SandpackEditor-a09311db.cjs +0 -1
- package/dist/SourceEditor-1fc83319.cjs +0 -1
- package/dist/SourceEditor-32f2b4d8.js +0 -64
- package/dist/TableEditor-616848bc.cjs +0 -1
- package/dist/TableEditor-777ac58a.js +0 -426
- package/dist/index-51585eed.cjs +0 -1
- package/dist/index-d34aa66b.js +0 -4361
- package/dist/index.cjs +0 -1
- package/dist/useCodeMirrorRef-8f68c999.cjs +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { $createHeadingNode, $createQuoteNode } from "@lexical/rich-text";
|
|
2
|
+
import { $createParagraphNode } from "lexical";
|
|
3
|
+
import React__default from "react";
|
|
4
|
+
import { corePluginHooks } from "../../core/index.js";
|
|
5
|
+
import { Select } from "../primitives/select.js";
|
|
6
|
+
import { useHasPlugin } from "../../../gurx/react.js";
|
|
7
|
+
const BlockTypeSelect = () => {
|
|
8
|
+
const convertSelectionToNode = corePluginHooks.usePublisher("convertSelectionToNode");
|
|
9
|
+
const [currentBlockType] = corePluginHooks.useEmitterValues("currentBlockType");
|
|
10
|
+
const hasQuote = useHasPlugin("quote");
|
|
11
|
+
const hasHeadings = useHasPlugin("headings");
|
|
12
|
+
if (!hasQuote && !hasHeadings) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const items = [{ label: "Paragraph", value: "paragraph" }];
|
|
16
|
+
if (hasQuote) {
|
|
17
|
+
items.push({ label: "Quote", value: "quote" });
|
|
18
|
+
}
|
|
19
|
+
if (hasHeadings) {
|
|
20
|
+
items.push(...[1, 2, 3, 4, 5, 6].map((n) => ({ label: `Heading ${n}`, value: `h${n}` })));
|
|
21
|
+
}
|
|
22
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
23
|
+
Select,
|
|
24
|
+
{
|
|
25
|
+
value: currentBlockType,
|
|
26
|
+
onChange: (blockType) => {
|
|
27
|
+
switch (blockType) {
|
|
28
|
+
case "quote":
|
|
29
|
+
convertSelectionToNode(() => $createQuoteNode());
|
|
30
|
+
break;
|
|
31
|
+
case "paragraph":
|
|
32
|
+
convertSelectionToNode(() => $createParagraphNode());
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
if (blockType == "")
|
|
36
|
+
;
|
|
37
|
+
else if (blockType.startsWith("h")) {
|
|
38
|
+
convertSelectionToNode(() => $createHeadingNode(blockType));
|
|
39
|
+
} else {
|
|
40
|
+
throw new Error(`Unknown block type: ${blockType}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
triggerTitle: "Select block type",
|
|
45
|
+
placeholder: "Block type",
|
|
46
|
+
items
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
BlockTypeSelect
|
|
52
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { corePluginHooks } from "../../core/index.js";
|
|
3
|
+
import { IS_BOLD, IS_ITALIC, IS_UNDERLINE } from "../../../FormatConstants.js";
|
|
4
|
+
import { MultipleChoiceToggleGroup } from "../primitives/toolbar.js";
|
|
5
|
+
import BoldIcon from "../../../icons/format_bold.svg.js";
|
|
6
|
+
import ItalicIcon from "../../../icons/format_italic.svg.js";
|
|
7
|
+
import UnderlinedIcon from "../../../icons/format_underlined.svg.js";
|
|
8
|
+
const BoldItalicUnderlineToggles = () => {
|
|
9
|
+
const [currentFormat] = corePluginHooks.useEmitterValues("currentFormat");
|
|
10
|
+
const applyFormat = corePluginHooks.usePublisher("applyFormat");
|
|
11
|
+
const boldIsOn = (currentFormat & IS_BOLD) !== 0;
|
|
12
|
+
const italicIsOn = (currentFormat & IS_ITALIC) !== 0;
|
|
13
|
+
const underlineIsOn = (currentFormat & IS_UNDERLINE) !== 0;
|
|
14
|
+
const boldTitle = boldIsOn ? "Remove bold" : "Bold";
|
|
15
|
+
const italicTitle = italicIsOn ? "Remove italic" : "Italic";
|
|
16
|
+
const underlineTitle = underlineIsOn ? "Remove underline" : "Underline";
|
|
17
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
18
|
+
MultipleChoiceToggleGroup,
|
|
19
|
+
{
|
|
20
|
+
items: [
|
|
21
|
+
{ title: boldTitle, contents: /* @__PURE__ */ React__default.createElement(BoldIcon, null), active: boldIsOn, onChange: applyFormat.bind(null, "bold") },
|
|
22
|
+
{ title: italicTitle, contents: /* @__PURE__ */ React__default.createElement(ItalicIcon, null), active: italicIsOn, onChange: applyFormat.bind(null, "italic") },
|
|
23
|
+
{
|
|
24
|
+
title: underlineTitle,
|
|
25
|
+
contents: /* @__PURE__ */ React__default.createElement(UnderlinedIcon, { style: { transform: "translateY(2px)" } }),
|
|
26
|
+
active: underlineIsOn,
|
|
27
|
+
onChange: applyFormat.bind(null, "underline")
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
BoldItalicUnderlineToggles
|
|
35
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A component that allows the user to change the admonition type of the current selection.
|
|
4
|
+
* For this component to work, you must pass the {@link AdmonitionDirectiveDescriptor} to the `directivesPlugin` `directiveDescriptors` parameter.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ChangeAdmonitionType: () => React.JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { corePluginHooks } from "../../core/index.js";
|
|
3
|
+
import { Select } from "../primitives/select.js";
|
|
4
|
+
import { ADMONITION_TYPES } from "../../../directive-editors/AdmonitionDirectiveDescriptor.js";
|
|
5
|
+
const ChangeAdmonitionType = () => {
|
|
6
|
+
const [editorInFocus, rootEditor] = corePluginHooks.useEmitterValues("editorInFocus", "rootEditor");
|
|
7
|
+
const admonitionNode = editorInFocus.rootNode;
|
|
8
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
9
|
+
Select,
|
|
10
|
+
{
|
|
11
|
+
value: admonitionNode.getMdastNode().name,
|
|
12
|
+
onChange: (name) => {
|
|
13
|
+
rootEditor == null ? void 0 : rootEditor.update(() => {
|
|
14
|
+
admonitionNode.setMdastNode({ ...admonitionNode.getMdastNode(), name });
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
rootEditor == null ? void 0 : rootEditor.update(() => {
|
|
17
|
+
admonitionNode.getLatest().select();
|
|
18
|
+
});
|
|
19
|
+
}, 80);
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
triggerTitle: "Select admonition type",
|
|
23
|
+
placeholder: "Admonition type",
|
|
24
|
+
items: ADMONITION_TYPES.map((type) => ({ label: type, value: type }))
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
ChangeAdmonitionType
|
|
30
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A component that allows the user to change the code block language of the current selection.
|
|
4
|
+
* For this component to work, you must enable the `codeMirrorPlugin` for the editor.
|
|
5
|
+
* See {@link ConditionalContents} for an example on how to display the dropdown only when a code block is in focus.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ChangeCodeMirrorLanguage: () => React.JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { corePluginHooks } from "../../core/index.js";
|
|
3
|
+
import { Select } from "../primitives/select.js";
|
|
4
|
+
import { codeMirrorHooks } from "../../codemirror/index.js";
|
|
5
|
+
import styles from "../../../styles/ui.module.css.js";
|
|
6
|
+
const ChangeCodeMirrorLanguage = () => {
|
|
7
|
+
const [editorInFocus, theEditor] = corePluginHooks.useEmitterValues("editorInFocus", "activeEditor");
|
|
8
|
+
const codeBlockNode = editorInFocus.rootNode;
|
|
9
|
+
const [codeBlockLanguages] = codeMirrorHooks.useEmitterValues("codeBlockLanguages");
|
|
10
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: styles.selectWithLabel }, /* @__PURE__ */ React__default.createElement("label", null, "Code block language:"), /* @__PURE__ */ React__default.createElement(
|
|
11
|
+
Select,
|
|
12
|
+
{
|
|
13
|
+
value: codeBlockNode.getLanguage(),
|
|
14
|
+
onChange: (language) => {
|
|
15
|
+
theEditor == null ? void 0 : theEditor.update(() => {
|
|
16
|
+
codeBlockNode.setLanguage(language);
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
theEditor == null ? void 0 : theEditor.update(() => {
|
|
19
|
+
codeBlockNode.getLatest().select();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
triggerTitle: "Select code block language",
|
|
25
|
+
placeholder: "Code block language",
|
|
26
|
+
items: Object.entries(codeBlockLanguages).map(([value, label]) => ({ value, label }))
|
|
27
|
+
}
|
|
28
|
+
));
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
ChangeCodeMirrorLanguage
|
|
32
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { IS_CODE } from "../../../FormatConstants.js";
|
|
3
|
+
import CodeIcon from "../../../icons/code.svg.js";
|
|
4
|
+
import { corePluginHooks } from "../../core/index.js";
|
|
5
|
+
import { MultipleChoiceToggleGroup } from "../primitives/toolbar.js";
|
|
6
|
+
const CodeToggle = () => {
|
|
7
|
+
const [currentFormat] = corePluginHooks.useEmitterValues("currentFormat");
|
|
8
|
+
const applyFormat = corePluginHooks.usePublisher("applyFormat");
|
|
9
|
+
const codeIsOn = (currentFormat & IS_CODE) !== 0;
|
|
10
|
+
const title = codeIsOn ? "Remove code format" : "Inline code format";
|
|
11
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
12
|
+
MultipleChoiceToggleGroup,
|
|
13
|
+
{
|
|
14
|
+
items: [{ title, contents: /* @__PURE__ */ React__default.createElement(CodeIcon, null), active: codeIsOn, onChange: applyFormat.bind(null, "code") }]
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
CodeToggle
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { ButtonWithTooltip } from "../primitives/toolbar.js";
|
|
3
|
+
import LinkIcon from "../../../icons/link.svg.js";
|
|
4
|
+
import { linkDialogPluginHooks } from "../../link-dialog/index.js";
|
|
5
|
+
const CreateLink = () => {
|
|
6
|
+
const openLinkDialog = linkDialogPluginHooks.usePublisher("openLinkEditDialog");
|
|
7
|
+
return /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: "Create link", onClick: (_) => openLinkDialog(true) }, /* @__PURE__ */ React__default.createElement(LinkIcon, null));
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
CreateLink
|
|
11
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A wrapper element for the toolbar contents that lets the user toggle between rich text, diff and source mode.
|
|
4
|
+
* Put the rich text toolbar contents as children of this component.
|
|
5
|
+
* For this component to work, you must include the `diffSourcePlugin`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <MDXEditor markdown='Hello world'
|
|
10
|
+
* plugins={[toolbarPlugin({
|
|
11
|
+
* toolbarContents: () => ( <> <DiffSourceToggleWrapper><UndoRedo /><BoldItalicUnderlineToggles /></DiffSourceToggleWrapper></>)
|
|
12
|
+
* }), diffSourcePlugin()]}
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const DiffSourceToggleWrapper: React.FC<{
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { diffSourcePluginHooks } from "../../diff-source/index.js";
|
|
3
|
+
import { SingleChoiceToggleGroup } from "../primitives/toolbar.js";
|
|
4
|
+
import RichTextIcon from "../../../icons/rich_text.svg.js";
|
|
5
|
+
import DiffIcon from "../../../icons/difference.svg.js";
|
|
6
|
+
import SourceIcon from "../../../icons/markdown.svg.js";
|
|
7
|
+
import styles from "../../../styles/ui.module.css.js";
|
|
8
|
+
const DiffSourceToggleWrapper = ({ children }) => {
|
|
9
|
+
const [viewMode] = diffSourcePluginHooks.useEmitterValues("viewMode");
|
|
10
|
+
const changeViewMode = diffSourcePluginHooks.usePublisher("viewMode");
|
|
11
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, viewMode === "rich-text" ? children : viewMode === "diff" ? /* @__PURE__ */ React__default.createElement("span", { className: styles.toolbarTitleMode }, "Diff mode") : /* @__PURE__ */ React__default.createElement("span", { className: styles.toolbarTitleMode }, "Source mode"), /* @__PURE__ */ React__default.createElement("div", { style: { marginLeft: "auto" } }, /* @__PURE__ */ React__default.createElement(
|
|
12
|
+
SingleChoiceToggleGroup,
|
|
13
|
+
{
|
|
14
|
+
className: styles.diffSourceToggle,
|
|
15
|
+
value: viewMode,
|
|
16
|
+
items: [
|
|
17
|
+
{ title: "Rich text", contents: /* @__PURE__ */ React__default.createElement(RichTextIcon, null), value: "rich-text" },
|
|
18
|
+
{ title: "Diff mode", contents: /* @__PURE__ */ React__default.createElement(DiffIcon, null), value: "diff" },
|
|
19
|
+
{ title: "Source", contents: /* @__PURE__ */ React__default.createElement(SourceIcon, null), value: "source" }
|
|
20
|
+
],
|
|
21
|
+
onChange: (value) => changeViewMode(value || "rich-text")
|
|
22
|
+
}
|
|
23
|
+
)));
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
DiffSourceToggleWrapper
|
|
27
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar dropdown button that allows the user to insert admonitions.
|
|
4
|
+
* For this to work, you need to have the `directives` plugin enabled with the {@link AdmonitionDirectiveDescriptor} configured.
|
|
5
|
+
*/
|
|
6
|
+
export declare const InsertAdmonition: () => React.JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { ButtonOrDropdownButton } from "../primitives/toolbar.js";
|
|
3
|
+
import AdmonitionIcon from "../../../icons/emergency_home.svg.js";
|
|
4
|
+
import { directivesPluginHooks } from "../../directives/index.js";
|
|
5
|
+
import { ADMONITION_TYPES } from "../../../directive-editors/AdmonitionDirectiveDescriptor.js";
|
|
6
|
+
const InsertAdmonition = () => {
|
|
7
|
+
const insertDirective = directivesPluginHooks.usePublisher("insertDirective");
|
|
8
|
+
const items = React__default.useMemo(
|
|
9
|
+
() => ADMONITION_TYPES.map((type) => ({ value: type, label: type.replace(/^./, (l) => l.toUpperCase()) })),
|
|
10
|
+
[]
|
|
11
|
+
);
|
|
12
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
13
|
+
ButtonOrDropdownButton,
|
|
14
|
+
{
|
|
15
|
+
title: "Insert admonition",
|
|
16
|
+
onChoose: (admonitionName) => {
|
|
17
|
+
insertDirective({
|
|
18
|
+
type: "containerDirective",
|
|
19
|
+
name: admonitionName
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
items
|
|
23
|
+
},
|
|
24
|
+
/* @__PURE__ */ React__default.createElement(AdmonitionIcon, null)
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
InsertAdmonition
|
|
29
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert a fenced code block.
|
|
4
|
+
* Once the code block is focused, you can construct a special code block toolbar for it, using the {@link ConditionalContents} primitive.
|
|
5
|
+
* See the {@link ConditionalContents} documentation for an example.
|
|
6
|
+
*/
|
|
7
|
+
export declare const InsertCodeBlock: React.FC;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { ButtonWithTooltip } from "../primitives/toolbar.js";
|
|
3
|
+
import FrameSourceIcon from "../../../icons/frame_source.svg.js";
|
|
4
|
+
import { codeBlockPluginHooks } from "../../codeblock/index.js";
|
|
5
|
+
const InsertCodeBlock = () => {
|
|
6
|
+
const insertCodeBlock = codeBlockPluginHooks.usePublisher("insertCodeBlock");
|
|
7
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
8
|
+
ButtonWithTooltip,
|
|
9
|
+
{
|
|
10
|
+
title: "Insert code block",
|
|
11
|
+
onClick: () => {
|
|
12
|
+
insertCodeBlock({});
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
/* @__PURE__ */ React__default.createElement(FrameSourceIcon, null)
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
InsertCodeBlock
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert a {@link https://jekyllrb.com/docs/front-matter/ | front-matter} editor (if one is not already present).
|
|
4
|
+
* For this to work, you need to have the `frontmatterPlugin` plugin enabled.
|
|
5
|
+
*/
|
|
6
|
+
export declare const InsertFrontmatter: React.FC;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { ButtonWithTooltip } from "../primitives/toolbar.js";
|
|
3
|
+
import FrontmatterIcon from "../../../icons/frontmatter.svg.js";
|
|
4
|
+
import { frontmatterPluginHooks } from "../../frontmatter/index.js";
|
|
5
|
+
const InsertFrontmatter = () => {
|
|
6
|
+
const insertFrontmatter = frontmatterPluginHooks.usePublisher("insertFrontmatter");
|
|
7
|
+
return /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: "Insert frontmatter editor", onClick: insertFrontmatter.bind(null, true) }, /* @__PURE__ */ React__default.createElement(FrontmatterIcon, null));
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
InsertFrontmatter
|
|
11
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert an image from an URL.
|
|
4
|
+
* For the button to work, you need to have the `imagePlugin` plugin enabled.
|
|
5
|
+
*/
|
|
6
|
+
export declare const InsertImage: React.ForwardRefExoticComponent<Omit<Record<string, never>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { imagePluginHooks } from "../../image/index.js";
|
|
3
|
+
import { DialogButton } from "../primitives/DialogButton.js";
|
|
4
|
+
import AddPhotoIcon from "../../../icons/add_photo.svg.js";
|
|
5
|
+
const InsertImage = React__default.forwardRef((_, forwardedRef) => {
|
|
6
|
+
const [imageAutocompleteSuggestions] = imagePluginHooks.useEmitterValues("imageAutocompleteSuggestions");
|
|
7
|
+
const insertImage = imagePluginHooks.usePublisher("insertImage");
|
|
8
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
9
|
+
DialogButton,
|
|
10
|
+
{
|
|
11
|
+
ref: forwardedRef,
|
|
12
|
+
submitButtonTitle: "Insert Image",
|
|
13
|
+
dialogInputPlaceholder: "Paste or select image URL",
|
|
14
|
+
tooltipTitle: "Insert image",
|
|
15
|
+
onSubmit: insertImage,
|
|
16
|
+
buttonContent: /* @__PURE__ */ React__default.createElement(AddPhotoIcon, null),
|
|
17
|
+
autocompleteSuggestions: imageAutocompleteSuggestions
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
export {
|
|
22
|
+
InsertImage
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A dropdown button that allows the user to insert a live code block into the editor. The dropdown offers a list of presets that are defined in the sandpack plugin config.
|
|
4
|
+
* For this to work, you need to have the `sandpackPlugin` installed.
|
|
5
|
+
*/
|
|
6
|
+
export declare const InsertSandpack: () => React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { ButtonOrDropdownButton } from "../primitives/toolbar.js";
|
|
3
|
+
import LiveCodeIcon from "../../../icons/deployed_code.svg.js";
|
|
4
|
+
import { sandpackPluginHooks } from "../../sandpack/index.js";
|
|
5
|
+
const InsertSandpack = () => {
|
|
6
|
+
const [sandpackConfig] = sandpackPluginHooks.useEmitterValues("sandpackConfig");
|
|
7
|
+
const insertSandpack = sandpackPluginHooks.usePublisher("insertSandpack");
|
|
8
|
+
const items = React__default.useMemo(() => sandpackConfig.presets.map((preset) => ({ value: preset.name, label: preset.name })), [sandpackConfig]);
|
|
9
|
+
return /* @__PURE__ */ React__default.createElement(ButtonOrDropdownButton, { title: "Insert Sandpack", onChoose: insertSandpack, items }, /* @__PURE__ */ React__default.createElement(LiveCodeIcon, null));
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
InsertSandpack
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonWithTooltip } from "../primitives/toolbar.js";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { tablePluginHooks } from "../../table/index.js";
|
|
4
|
+
import TableIcon from "../../../icons/table.svg.js";
|
|
5
|
+
const InsertTable = () => {
|
|
6
|
+
const insertTable = tablePluginHooks.usePublisher("insertTable");
|
|
7
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
8
|
+
ButtonWithTooltip,
|
|
9
|
+
{
|
|
10
|
+
title: "Insert table",
|
|
11
|
+
onClick: () => {
|
|
12
|
+
insertTable(true);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
/* @__PURE__ */ React__default.createElement(TableIcon, null)
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
InsertTable
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert a thematic break (rendered as an HR HTML element).
|
|
4
|
+
* For this button to work, you need to have the `thematicBreakPlugin` plugin enabled.
|
|
5
|
+
*/
|
|
6
|
+
export declare const InsertThematicBreak: React.FC;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { thematicBreakPluginHooks } from "../../thematic-break/index.js";
|
|
3
|
+
import { ButtonWithTooltip } from "../primitives/toolbar.js";
|
|
4
|
+
import HorizontalRuleIcon from "../../../icons/horizontal_rule.svg.js";
|
|
5
|
+
const InsertThematicBreak = () => {
|
|
6
|
+
const insertThematicBreak = thematicBreakPluginHooks.usePublisher("insertThematicBreak");
|
|
7
|
+
return /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: "Insert thematic break", onClick: insertThematicBreak.bind(null, true) }, /* @__PURE__ */ React__default.createElement(HorizontalRuleIcon, null));
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
InsertThematicBreak
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar component that includes all toolbar components.
|
|
4
|
+
* Notice that some of the buttons will work only if you have the corresponding plugin enabled, so you should use it only for testing purposes.
|
|
5
|
+
* You'll probably want to create your own toolbar component that includes only the buttons that you need.
|
|
6
|
+
*/
|
|
7
|
+
export declare const KitchenSinkToolbar: React.FC;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { ConditionalContents, Separator } from "../primitives/toolbar.js";
|
|
3
|
+
import { BlockTypeSelect } from "./BlockTypeSelect.js";
|
|
4
|
+
import { BoldItalicUnderlineToggles } from "./BoldItalicUnderlineToggles.js";
|
|
5
|
+
import { ChangeAdmonitionType } from "./ChangeAdmonitionType.js";
|
|
6
|
+
import { ChangeCodeMirrorLanguage } from "./ChangeCodeMirrorLanguage.js";
|
|
7
|
+
import { CodeToggle } from "./CodeToggle.js";
|
|
8
|
+
import { DiffSourceToggleWrapper } from "./DiffSourceToggleWrapper.js";
|
|
9
|
+
import { InsertAdmonition } from "./InsertAdmonition.js";
|
|
10
|
+
import { InsertCodeBlock } from "./InsertCodeBlock.js";
|
|
11
|
+
import { InsertFrontmatter } from "./InsertFrontmatter.js";
|
|
12
|
+
import { InsertImage } from "./InsertImage.js";
|
|
13
|
+
import { InsertSandpack } from "./InsertSandpack.js";
|
|
14
|
+
import { InsertTable } from "./InsertTable.js";
|
|
15
|
+
import { InsertThematicBreak } from "./InsertThematicBreak.js";
|
|
16
|
+
import { ListsToggle } from "./ListsToggle.js";
|
|
17
|
+
import { ShowSandpackInfo } from "./ShowSandpackInfo.js";
|
|
18
|
+
import { UndoRedo } from "./UndoRedo.js";
|
|
19
|
+
import { CreateLink } from "./CreateLink.js";
|
|
20
|
+
function whenInAdmonition(editorInFocus) {
|
|
21
|
+
const node = editorInFocus == null ? void 0 : editorInFocus.rootNode;
|
|
22
|
+
if (!node || node.getType() !== "directive") {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return ["note", "tip", "danger", "info", "caution"].includes(node.getMdastNode().name);
|
|
26
|
+
}
|
|
27
|
+
const KitchenSinkToolbar = () => {
|
|
28
|
+
return /* @__PURE__ */ React__default.createElement(DiffSourceToggleWrapper, null, /* @__PURE__ */ React__default.createElement(
|
|
29
|
+
ConditionalContents,
|
|
30
|
+
{
|
|
31
|
+
options: [
|
|
32
|
+
{ when: (editor) => (editor == null ? void 0 : editor.editorType) === "codeblock", contents: () => /* @__PURE__ */ React__default.createElement(ChangeCodeMirrorLanguage, null) },
|
|
33
|
+
{ when: (editor) => (editor == null ? void 0 : editor.editorType) === "sandpack", contents: () => /* @__PURE__ */ React__default.createElement(ShowSandpackInfo, null) },
|
|
34
|
+
{
|
|
35
|
+
fallback: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(UndoRedo, null), /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(BoldItalicUnderlineToggles, null), /* @__PURE__ */ React__default.createElement(CodeToggle, null), /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(ListsToggle, null), /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(
|
|
36
|
+
ConditionalContents,
|
|
37
|
+
{
|
|
38
|
+
options: [{ when: whenInAdmonition, contents: () => /* @__PURE__ */ React__default.createElement(ChangeAdmonitionType, null) }, { fallback: () => /* @__PURE__ */ React__default.createElement(BlockTypeSelect, null) }]
|
|
39
|
+
}
|
|
40
|
+
), /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(CreateLink, null), /* @__PURE__ */ React__default.createElement(InsertImage, null), /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(InsertTable, null), /* @__PURE__ */ React__default.createElement(InsertThematicBreak, null), /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(InsertCodeBlock, null), /* @__PURE__ */ React__default.createElement(InsertSandpack, null), /* @__PURE__ */ React__default.createElement(
|
|
41
|
+
ConditionalContents,
|
|
42
|
+
{
|
|
43
|
+
options: [
|
|
44
|
+
{
|
|
45
|
+
when: (editorInFocus) => !whenInAdmonition(editorInFocus),
|
|
46
|
+
contents: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(InsertAdmonition, null))
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
), /* @__PURE__ */ React__default.createElement(Separator, null), /* @__PURE__ */ React__default.createElement(InsertFrontmatter, null))
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
));
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
KitchenSinkToolbar
|
|
58
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar toggle that allows the user to toggle between bulleted and numbered lists.
|
|
4
|
+
* Pressing the selected button will convert the current list to the other type. Pressing it again will remove the list.
|
|
5
|
+
* For this button to work, you need to have the `listsPlugin` plugin enabled.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ListsToggle: React.FC;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import BulletedListIcon from "../../../icons/format_list_bulleted.svg.js";
|
|
3
|
+
import NumberedListIcon from "../../../icons/format_list_numbered.svg.js";
|
|
4
|
+
import { listsPluginHooks } from "../../lists/index.js";
|
|
5
|
+
import { SingleChoiceToggleGroup } from "../primitives/toolbar.js";
|
|
6
|
+
const ListsToggle = () => {
|
|
7
|
+
const [currentListType] = listsPluginHooks.useEmitterValues("currentListType");
|
|
8
|
+
const applyListType = listsPluginHooks.usePublisher("applyListType");
|
|
9
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
10
|
+
SingleChoiceToggleGroup,
|
|
11
|
+
{
|
|
12
|
+
value: currentListType || "",
|
|
13
|
+
items: [
|
|
14
|
+
{ title: "Bulleted list", contents: /* @__PURE__ */ React__default.createElement(BulletedListIcon, null), value: "bullet" },
|
|
15
|
+
{ title: "Numbered list", contents: /* @__PURE__ */ React__default.createElement(NumberedListIcon, null), value: "number" }
|
|
16
|
+
],
|
|
17
|
+
onChange: applyListType
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
ListsToggle
|
|
23
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A component that displays the focused live code block's name.
|
|
4
|
+
* For this component to work, you must enable the `sandpackPlugin` for the editor.
|
|
5
|
+
* See {@link ConditionalContents} for an example on how to display the dropdown only when a sandpack editor is in focus.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ShowSandpackInfo: () => React.JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { corePluginHooks } from "../../core/index.js";
|
|
3
|
+
import styles from "../../../styles/ui.module.css.js";
|
|
4
|
+
import { sandpackPluginHooks } from "../../sandpack/index.js";
|
|
5
|
+
import { ButtonWithTooltip } from "../primitives/toolbar.js";
|
|
6
|
+
import DeleteIcon from "../../../icons/delete.svg.js";
|
|
7
|
+
const ShowSandpackInfo = () => {
|
|
8
|
+
const [editorInFocus, theEditor] = corePluginHooks.useEmitterValues("editorInFocus", "activeEditor");
|
|
9
|
+
const sandpackNode = editorInFocus.rootNode;
|
|
10
|
+
const [sandpackConfig] = sandpackPluginHooks.useEmitterValues("sandpackConfig");
|
|
11
|
+
const preset = sandpackConfig.presets.find((preset2) => preset2.meta === sandpackNode.getMeta());
|
|
12
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: styles.selectWithLabel }, /* @__PURE__ */ React__default.createElement(
|
|
13
|
+
ButtonWithTooltip,
|
|
14
|
+
{
|
|
15
|
+
title: "Delete this code block",
|
|
16
|
+
onClick: () => {
|
|
17
|
+
theEditor == null ? void 0 : theEditor.update(() => {
|
|
18
|
+
if (sandpackNode.getNextSibling()) {
|
|
19
|
+
sandpackNode.selectNext();
|
|
20
|
+
} else {
|
|
21
|
+
sandpackNode.selectPrevious();
|
|
22
|
+
}
|
|
23
|
+
sandpackNode.remove();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
/* @__PURE__ */ React__default.createElement(DeleteIcon, null)
|
|
28
|
+
), /* @__PURE__ */ React__default.createElement("label", null, "Sandpack preset: ", preset.name));
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
ShowSandpackInfo
|
|
32
|
+
};
|