@mdxeditor/editor 0.9.0 → 0.10.0-alpha.1

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.
Files changed (289) hide show
  1. package/dist/FormatConstants.d.ts +9 -0
  2. package/dist/FormatConstants.js +10 -0
  3. package/dist/MDXEditor.d.ts +31 -0
  4. package/dist/MDXEditor.js +105 -0
  5. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +4 -0
  6. package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +29 -0
  7. package/dist/directive-editors/GenericDirectiveEditor.d.ts +3 -0
  8. package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
  9. package/dist/exportMarkdownFromLexical.d.ts +114 -0
  10. package/dist/exportMarkdownFromLexical.js +199 -0
  11. package/dist/gurx/index.d.ts +3 -0
  12. package/dist/gurx/react.d.ts +121 -0
  13. package/dist/gurx/react.js +112 -0
  14. package/dist/gurx/realm.d.ts +133 -0
  15. package/dist/gurx/realm.js +491 -0
  16. package/dist/gurx/realmFactory.d.ts +58 -0
  17. package/dist/gurx/realmFactory.js +28 -0
  18. package/dist/icons/add_column.svg.js +8 -0
  19. package/dist/icons/add_photo.svg.js +8 -0
  20. package/dist/icons/add_row.svg.js +8 -0
  21. package/dist/icons/arrow_drop_down.svg.js +8 -0
  22. package/dist/icons/arrow_right.svg.js +8 -0
  23. package/dist/icons/check.svg.js +8 -0
  24. package/dist/icons/close.svg.js +8 -0
  25. package/dist/icons/code.svg.js +8 -0
  26. package/dist/icons/content_copy.svg.js +8 -0
  27. package/dist/icons/delete.svg.js +8 -0
  28. package/dist/icons/delete_small.svg.js +8 -0
  29. package/dist/icons/deployed_code.svg.js +8 -0
  30. package/dist/icons/difference.svg.js +8 -0
  31. package/dist/icons/edit.svg.js +8 -0
  32. package/dist/icons/emergency_home.svg.js +8 -0
  33. package/dist/icons/format_align_center.svg.js +8 -0
  34. package/dist/icons/format_align_left.svg.js +8 -0
  35. package/dist/icons/format_align_right.svg.js +8 -0
  36. package/dist/icons/format_bold.svg.js +8 -0
  37. package/dist/icons/format_italic.svg.js +8 -0
  38. package/dist/icons/format_list_bulleted.svg.js +8 -0
  39. package/dist/icons/format_list_numbered.svg.js +8 -0
  40. package/dist/icons/format_underlined.svg.js +8 -0
  41. package/dist/icons/frame_source.svg.js +8 -0
  42. package/dist/icons/frontmatter.svg.js +8 -0
  43. package/dist/icons/horizontal_rule.svg.js +8 -0
  44. package/dist/icons/insert_col_left.svg.js +8 -0
  45. package/dist/icons/insert_col_right.svg.js +8 -0
  46. package/dist/icons/insert_row_above.svg.js +8 -0
  47. package/dist/icons/insert_row_below.svg.js +8 -0
  48. package/dist/icons/link.svg.js +8 -0
  49. package/dist/icons/link_off.svg.js +8 -0
  50. package/dist/icons/markdown.svg.js +8 -0
  51. package/dist/icons/more_horiz.svg.js +8 -0
  52. package/dist/icons/open_in_new.svg.js +8 -0
  53. package/dist/icons/redo.svg.js +8 -0
  54. package/dist/icons/rich_text.svg.js +8 -0
  55. package/dist/icons/settings.svg.js +8 -0
  56. package/dist/icons/table.svg.js +8 -0
  57. package/dist/icons/undo.svg.js +8 -0
  58. package/dist/importMarkdownToLexical.d.ts +84 -0
  59. package/dist/importMarkdownToLexical.js +65 -0
  60. package/dist/index.d.ts +49 -1094
  61. package/dist/index.js +133 -72
  62. package/dist/jsx-editors/GenericJsxEditor.d.ts +3 -0
  63. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  64. package/dist/node_modules/react-diff-view/style/index.css.js +4 -0
  65. package/dist/plugins/codeblock/CodeBlockNode.d.ts +99 -0
  66. package/dist/plugins/codeblock/CodeBlockNode.js +155 -0
  67. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  68. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  69. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  70. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  71. package/dist/plugins/codeblock/index.d.ts +604 -0
  72. package/dist/plugins/codeblock/index.js +73 -0
  73. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  74. package/dist/plugins/codemirror/CodeMirrorEditor.js +33 -0
  75. package/dist/plugins/codemirror/index.d.ts +786 -0
  76. package/dist/plugins/codemirror/index.js +62 -0
  77. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  78. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  79. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  80. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  81. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  82. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  83. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  84. package/dist/plugins/core/LexicalTextVisitor.js +85 -0
  85. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  86. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  87. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  88. package/dist/plugins/core/MdastInlineCodeVisitor.js +11 -0
  89. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  90. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  91. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  92. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  93. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  94. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  95. package/dist/plugins/core/NestedLexicalEditor.d.ts +69 -0
  96. package/dist/plugins/core/NestedLexicalEditor.js +181 -0
  97. package/dist/plugins/core/PropertyPopover.d.ts +8 -0
  98. package/dist/plugins/core/PropertyPopover.js +36 -0
  99. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  100. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  101. package/dist/plugins/core/index.d.ts +419 -0
  102. package/dist/plugins/core/index.js +343 -0
  103. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  104. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  105. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  106. package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
  107. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  108. package/dist/plugins/diff-source/DiffViewer.js +18 -0
  109. package/dist/plugins/diff-source/SourceEditor.d.ts +2 -0
  110. package/dist/plugins/diff-source/SourceEditor.js +25 -0
  111. package/dist/plugins/diff-source/index.d.ts +530 -0
  112. package/dist/plugins/diff-source/index.js +55 -0
  113. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  114. package/dist/plugins/directives/DirectiveNode.js +92 -0
  115. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  116. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  117. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  118. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  119. package/dist/plugins/directives/index.d.ts +591 -0
  120. package/dist/plugins/directives/index.js +53 -0
  121. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  122. package/dist/plugins/frontmatter/FrontmatterEditor.js +69 -0
  123. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  124. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  125. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  126. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  127. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  128. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  129. package/dist/plugins/frontmatter/index.d.ts +510 -0
  130. package/dist/plugins/frontmatter/index.js +53 -0
  131. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  132. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  133. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  134. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  135. package/dist/plugins/headings/index.d.ts +105 -0
  136. package/dist/plugins/headings/index.js +20 -0
  137. package/dist/plugins/image/ImageEditor.d.ts +7 -0
  138. package/dist/{ImageEditor-ad505654.js → plugins/image/ImageEditor.js} +12 -47
  139. package/dist/plugins/image/ImageNode.d.ts +53 -0
  140. package/dist/plugins/image/ImageNode.js +108 -0
  141. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  142. package/dist/plugins/image/LexicalImageVisitor.js +15 -0
  143. package/dist/plugins/image/MdastImageVisitor.d.ts +3 -0
  144. package/dist/plugins/image/MdastImageVisitor.js +16 -0
  145. package/dist/plugins/image/index.d.ts +541 -0
  146. package/dist/plugins/image/index.js +244 -0
  147. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  148. package/dist/plugins/jsx/LexicalJsxNode.js +99 -0
  149. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  150. package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
  151. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  152. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  153. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  154. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  155. package/dist/plugins/jsx/index.d.ts +461 -0
  156. package/dist/plugins/jsx/index.js +37 -0
  157. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  158. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  159. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  160. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  161. package/dist/plugins/link/index.d.ts +108 -0
  162. package/dist/plugins/link/index.js +24 -0
  163. package/dist/plugins/link-dialog/LinkDialog.d.ts +12 -0
  164. package/dist/plugins/link-dialog/LinkDialog.js +174 -0
  165. package/dist/plugins/link-dialog/index.d.ts +496 -0
  166. package/dist/plugins/link-dialog/index.js +242 -0
  167. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  168. package/dist/plugins/lists/LexicalListItemVisitor.js +22 -0
  169. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  170. package/dist/plugins/lists/LexicalListVisitor.js +14 -0
  171. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  172. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  173. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  174. package/dist/plugins/lists/MdastListVisitor.js +18 -0
  175. package/dist/plugins/lists/index.d.ts +521 -0
  176. package/dist/plugins/lists/index.js +111 -0
  177. package/dist/plugins/markdown-shortcut/index.d.ts +51 -0
  178. package/dist/plugins/markdown-shortcut/index.js +34 -0
  179. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  180. package/dist/plugins/quote/LexicalQuoteVisitor.js +14 -0
  181. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  182. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  183. package/dist/plugins/quote/index.d.ts +348 -0
  184. package/dist/plugins/quote/index.js +26 -0
  185. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  186. package/dist/plugins/sandpack/SandpackEditor.js +35 -0
  187. package/dist/plugins/sandpack/index.d.ts +826 -0
  188. package/dist/plugins/sandpack/index.js +93 -0
  189. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  190. package/dist/{useCodeMirrorRef-177e9901.js → plugins/sandpack/useCodeMirrorRef.js} +22 -10
  191. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  192. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  193. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  194. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  195. package/dist/plugins/table/TableEditor.d.ts +21 -0
  196. package/dist/{TableEditor-44bef804.js → plugins/table/TableEditor.js} +109 -161
  197. package/dist/plugins/table/TableNode.d.ts +52 -0
  198. package/dist/plugins/table/TableNode.js +147 -0
  199. package/dist/plugins/table/index.d.ts +511 -0
  200. package/dist/plugins/table/index.js +59 -0
  201. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  202. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  203. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  204. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  205. package/dist/plugins/thematic-break/index.d.ts +510 -0
  206. package/dist/plugins/thematic-break/index.js +39 -0
  207. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +2 -0
  208. package/dist/plugins/toolbar/components/BlockTypeSelect.js +52 -0
  209. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +2 -0
  210. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +35 -0
  211. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +2 -0
  212. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  213. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +2 -0
  214. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  215. package/dist/plugins/toolbar/components/CodeToggle.d.ts +2 -0
  216. package/dist/plugins/toolbar/components/CodeToggle.js +20 -0
  217. package/dist/plugins/toolbar/components/CreateLink.d.ts +2 -0
  218. package/dist/plugins/toolbar/components/CreateLink.js +11 -0
  219. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +4 -0
  220. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +27 -0
  221. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +2 -0
  222. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  223. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +2 -0
  224. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  225. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +2 -0
  226. package/dist/plugins/toolbar/components/InsertFrontmatter.js +11 -0
  227. package/dist/plugins/toolbar/components/InsertImage.d.ts +2 -0
  228. package/dist/plugins/toolbar/components/InsertImage.js +23 -0
  229. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +2 -0
  230. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  231. package/dist/plugins/toolbar/components/InsertTable.d.ts +2 -0
  232. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  233. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +2 -0
  234. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  235. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +2 -0
  236. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  237. package/dist/plugins/toolbar/components/ListsToggle.d.ts +2 -0
  238. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  239. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +2 -0
  240. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +32 -0
  241. package/dist/plugins/toolbar/components/UndoRedo.d.ts +2 -0
  242. package/dist/plugins/toolbar/components/UndoRedo.js +59 -0
  243. package/dist/plugins/toolbar/index.d.ts +416 -0
  244. package/dist/plugins/toolbar/index.js +39 -0
  245. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  246. package/dist/plugins/toolbar/primitives/DialogButton.js +115 -0
  247. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +5 -0
  248. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  249. package/dist/plugins/toolbar/primitives/select.d.ts +31 -0
  250. package/dist/plugins/toolbar/primitives/select.js +44 -0
  251. package/dist/plugins/toolbar/primitives/toolbar.d.ts +85 -0
  252. package/dist/plugins/toolbar/primitives/toolbar.js +111 -0
  253. package/dist/style.css +480 -240
  254. package/dist/styles/globals.css.js +4 -0
  255. package/dist/styles/lexical-theme.module.css.js +53 -0
  256. package/dist/styles/lexicalTheme.d.ts +2 -0
  257. package/dist/styles/lexicalTheme.js +28 -0
  258. package/dist/styles/ui.module.css.js +227 -0
  259. package/dist/utils/detectMac.d.ts +2 -0
  260. package/dist/utils/detectMac.js +6 -0
  261. package/dist/utils/fp.d.ts +47 -0
  262. package/dist/utils/fp.js +10 -0
  263. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  264. package/dist/utils/isPartOftheEditorUI.js +12 -0
  265. package/dist/utils/lexicalHelpers.d.ts +11 -0
  266. package/dist/utils/lexicalHelpers.js +49 -0
  267. package/dist/utils/uuid4.d.ts +1 -0
  268. package/dist/utils/uuid4.js +10 -0
  269. package/dist/utils/voidEmitter.d.ts +14 -0
  270. package/dist/utils/voidEmitter.js +15 -0
  271. package/package.json +184 -14
  272. package/dist/CodeBlockEditor-ce4c85ed.js +0 -79
  273. package/dist/CodeBlockEditor-ed222322.cjs +0 -1
  274. package/dist/FrontmatterEditor-914aa241.cjs +0 -1
  275. package/dist/FrontmatterEditor-e2f25a6a.js +0 -118
  276. package/dist/ImageEditor-c4e65554.cjs +0 -1
  277. package/dist/JsxEditor-6cff258d.cjs +0 -1
  278. package/dist/JsxEditor-88d55ef8.js +0 -108
  279. package/dist/LeafDirectiveEditor-0e1328e6.cjs +0 -1
  280. package/dist/LeafDirectiveEditor-34ead530.js +0 -59
  281. package/dist/SandpackEditor-a999ca47.cjs +0 -1
  282. package/dist/SandpackEditor-b1e22784.js +0 -99
  283. package/dist/SourceEditor-0c46ec47.cjs +0 -1
  284. package/dist/SourceEditor-e509d0a5.js +0 -64
  285. package/dist/TableEditor-ced03ce4.cjs +0 -1
  286. package/dist/index-21fcefae.cjs +0 -1
  287. package/dist/index-ce0832cc.js +0 -4361
  288. package/dist/index.cjs +0 -1
  289. package/dist/useCodeMirrorRef-6cb866bd.cjs +0 -1
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const BlockTypeSelect: () => React.JSX.Element | null;
@@ -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,2 @@
1
+ import React from 'react';
2
+ export declare const BoldItalicUnderlineToggles: React.FC;
@@ -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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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 admonition type",
25
+ placeholder: "Admonition type",
26
+ items: Object.entries(codeBlockLanguages).map(([value, label]) => ({ value, label }))
27
+ }
28
+ ));
29
+ };
30
+ export {
31
+ ChangeCodeMirrorLanguage
32
+ };
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const CodeToggle: React.FC;
@@ -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,2 @@
1
+ import React from 'react';
2
+ export declare const CreateLink: () => React.JSX.Element;
@@ -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,4 @@
1
+ import React from 'react';
2
+ export declare const DiffSourceToggleWrapper: React.FC<{
3
+ children: React.ReactNode;
4
+ }>;
@@ -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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ export declare const InsertTable: React.FC;
@@ -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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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,2 @@
1
+ import React from 'react';
2
+ 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
+ };
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const UndoRedo: React.FC;
@@ -0,0 +1,59 @@
1
+ import { mergeRegister } from "@lexical/utils";
2
+ import { CAN_UNDO_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_REDO_COMMAND, UNDO_COMMAND, REDO_COMMAND } from "lexical";
3
+ import React__default from "react";
4
+ import RedoIcon from "../../../icons/redo.svg.js";
5
+ import UndoIcon from "../../../icons/undo.svg.js";
6
+ import { IS_APPLE } from "../../../utils/detectMac.js";
7
+ import { corePluginHooks } from "../../core/index.js";
8
+ import { MultipleChoiceToggleGroup } from "../primitives/toolbar.js";
9
+ const UndoRedo = () => {
10
+ const [activeEditor] = corePluginHooks.useEmitterValues("activeEditor");
11
+ const [canUndo, setCanUndo] = React__default.useState(false);
12
+ const [canRedo, setCanRedo] = React__default.useState(false);
13
+ React__default.useEffect(() => {
14
+ if (activeEditor) {
15
+ return mergeRegister(
16
+ activeEditor.registerCommand(
17
+ CAN_UNDO_COMMAND,
18
+ (payload) => {
19
+ setCanUndo(payload);
20
+ return false;
21
+ },
22
+ COMMAND_PRIORITY_CRITICAL
23
+ ),
24
+ activeEditor.registerCommand(
25
+ CAN_REDO_COMMAND,
26
+ (payload) => {
27
+ setCanRedo(payload);
28
+ return false;
29
+ },
30
+ COMMAND_PRIORITY_CRITICAL
31
+ )
32
+ );
33
+ }
34
+ }, [activeEditor]);
35
+ return /* @__PURE__ */ React__default.createElement(
36
+ MultipleChoiceToggleGroup,
37
+ {
38
+ items: [
39
+ {
40
+ title: IS_APPLE ? "Undo (⌘Z)" : "Undo (Ctrl+Z)",
41
+ disabled: !canUndo,
42
+ contents: /* @__PURE__ */ React__default.createElement(UndoIcon, null),
43
+ active: false,
44
+ onChange: () => activeEditor == null ? void 0 : activeEditor.dispatchCommand(UNDO_COMMAND, void 0)
45
+ },
46
+ {
47
+ title: IS_APPLE ? "Redo (⌘Y)" : "Redo (Ctrl+Y)",
48
+ disabled: !canRedo,
49
+ contents: /* @__PURE__ */ React__default.createElement(RedoIcon, null),
50
+ active: false,
51
+ onChange: () => activeEditor == null ? void 0 : activeEditor.dispatchCommand(REDO_COMMAND, void 0)
52
+ }
53
+ ]
54
+ }
55
+ );
56
+ };
57
+ export {
58
+ UndoRedo
59
+ };