@mdxeditor/editor 0.0.1 → 0.0.4-development

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 (300) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +15 -75
  3. package/dist/FormatConstants.d.ts +9 -0
  4. package/dist/FormatConstants.js +10 -0
  5. package/dist/MDXEditor.d.ts +103 -0
  6. package/dist/MDXEditor.js +144 -0
  7. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
  8. package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +28 -0
  9. package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
  10. package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
  11. package/dist/exportMarkdownFromLexical.d.ts +138 -0
  12. package/dist/exportMarkdownFromLexical.js +239 -0
  13. package/dist/gurx/index.d.ts +3 -0
  14. package/dist/gurx/react.d.ts +152 -0
  15. package/dist/gurx/react.js +206 -0
  16. package/dist/gurx/realm.d.ts +148 -0
  17. package/dist/gurx/realm.js +489 -0
  18. package/dist/gurx/realmFactory.d.ts +79 -0
  19. package/dist/gurx/realmFactory.js +32 -0
  20. package/dist/icons/add_column.svg.js +5 -0
  21. package/dist/icons/add_photo.svg.js +5 -0
  22. package/dist/icons/add_row.svg.js +5 -0
  23. package/dist/icons/admonition.svg.js +5 -0
  24. package/dist/icons/arrow_drop_down.svg.js +5 -0
  25. package/dist/icons/check.svg.js +5 -0
  26. package/dist/icons/close.svg.js +5 -0
  27. package/dist/icons/code.svg.js +5 -0
  28. package/dist/icons/content_copy.svg.js +5 -0
  29. package/dist/icons/delete_big.svg.js +5 -0
  30. package/dist/icons/delete_small.svg.js +5 -0
  31. package/dist/icons/difference.svg.js +5 -0
  32. package/dist/icons/edit.svg.js +5 -0
  33. package/dist/icons/format_align_center.svg.js +5 -0
  34. package/dist/icons/format_align_left.svg.js +5 -0
  35. package/dist/icons/format_align_right.svg.js +5 -0
  36. package/dist/icons/format_bold.svg.js +5 -0
  37. package/dist/icons/format_italic.svg.js +5 -0
  38. package/dist/icons/format_list_bulleted.svg.js +5 -0
  39. package/dist/icons/format_list_checked.svg.js +5 -0
  40. package/dist/icons/format_list_numbered.svg.js +5 -0
  41. package/dist/icons/format_underlined.svg.js +5 -0
  42. package/dist/icons/frame_source.svg.js +5 -0
  43. package/dist/icons/frontmatter.svg.js +5 -0
  44. package/dist/icons/horizontal_rule.svg.js +5 -0
  45. package/dist/icons/insert_col_left.svg.js +5 -0
  46. package/dist/icons/insert_col_right.svg.js +5 -0
  47. package/dist/icons/insert_row_above.svg.js +5 -0
  48. package/dist/icons/insert_row_below.svg.js +5 -0
  49. package/dist/icons/link.svg.js +5 -0
  50. package/dist/icons/link_off.svg.js +5 -0
  51. package/dist/icons/markdown.svg.js +5 -0
  52. package/dist/icons/more_horiz.svg.js +5 -0
  53. package/dist/icons/more_vert.svg.js +5 -0
  54. package/dist/icons/open_in_new.svg.js +5 -0
  55. package/dist/icons/redo.svg.js +5 -0
  56. package/dist/icons/rich_text.svg.js +5 -0
  57. package/dist/icons/sandpack.svg.js +5 -0
  58. package/dist/icons/settings.svg.js +5 -0
  59. package/dist/icons/table.svg.js +5 -0
  60. package/dist/icons/undo.svg.js +5 -0
  61. package/dist/importMarkdownToLexical.d.ts +101 -0
  62. package/dist/importMarkdownToLexical.js +93 -0
  63. package/dist/index.d.ts +62 -726
  64. package/dist/index.js +207 -4501
  65. package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
  66. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  67. package/dist/plugins/codeblock/CodeBlockNode.d.ts +100 -0
  68. package/dist/plugins/codeblock/CodeBlockNode.js +158 -0
  69. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  70. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  71. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  72. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  73. package/dist/plugins/codeblock/index.d.ts +787 -0
  74. package/dist/plugins/codeblock/index.js +73 -0
  75. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  76. package/dist/plugins/codemirror/CodeMirrorEditor.js +42 -0
  77. package/dist/plugins/codemirror/index.d.ts +1038 -0
  78. package/dist/plugins/codemirror/index.js +62 -0
  79. package/dist/plugins/core/GenericHTMLNode.d.ts +38 -0
  80. package/dist/plugins/core/GenericHTMLNode.js +117 -0
  81. package/dist/plugins/core/Icon.d.ts +6 -0
  82. package/dist/plugins/core/Icon.js +92 -0
  83. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +4 -0
  84. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.js +15 -0
  85. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  86. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  87. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  88. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  89. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  90. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  91. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  92. package/dist/plugins/core/LexicalTextVisitor.js +102 -0
  93. package/dist/plugins/core/MdastBreakVisitor.d.ts +3 -0
  94. package/dist/plugins/core/MdastBreakVisitor.js +10 -0
  95. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  96. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  97. package/dist/plugins/core/MdastHTMLNode.d.ts +13 -0
  98. package/dist/plugins/core/MdastHTMLNode.js +122 -0
  99. package/dist/plugins/core/MdastHTMLVisitor.d.ts +3 -0
  100. package/dist/plugins/core/MdastHTMLVisitor.js +12 -0
  101. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  102. package/dist/plugins/core/MdastInlineCodeVisitor.js +27 -0
  103. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  104. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  105. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  106. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  107. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  108. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  109. package/dist/plugins/core/NestedLexicalEditor.d.ts +92 -0
  110. package/dist/plugins/core/NestedLexicalEditor.js +185 -0
  111. package/dist/plugins/core/PropertyPopover.d.ts +23 -0
  112. package/dist/plugins/core/PropertyPopover.js +39 -0
  113. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  114. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  115. package/dist/plugins/core/index.d.ts +583 -0
  116. package/dist/plugins/core/index.js +490 -0
  117. package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +15 -0
  118. package/dist/plugins/core/ui/DownshiftAutoComplete.js +83 -0
  119. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  120. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  121. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  122. package/dist/plugins/diff-source/DiffSourceWrapper.js +14 -0
  123. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  124. package/dist/plugins/diff-source/DiffViewer.js +59 -0
  125. package/dist/plugins/diff-source/SourceEditor.d.ts +4 -0
  126. package/dist/plugins/diff-source/SourceEditor.js +53 -0
  127. package/dist/plugins/diff-source/index.d.ts +725 -0
  128. package/dist/plugins/diff-source/index.js +56 -0
  129. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  130. package/dist/plugins/directives/DirectiveNode.js +92 -0
  131. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  132. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  133. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  134. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  135. package/dist/plugins/directives/index.d.ts +773 -0
  136. package/dist/plugins/directives/index.js +53 -0
  137. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  138. package/dist/plugins/frontmatter/FrontmatterEditor.js +85 -0
  139. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  140. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  141. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  142. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  143. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  144. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  145. package/dist/plugins/frontmatter/index.d.ts +717 -0
  146. package/dist/plugins/frontmatter/index.js +76 -0
  147. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  148. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  149. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  150. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  151. package/dist/plugins/headings/index.d.ts +707 -0
  152. package/dist/plugins/headings/index.js +69 -0
  153. package/dist/plugins/image/ImageDialog.d.ts +2 -0
  154. package/dist/plugins/image/ImageDialog.js +70 -0
  155. package/dist/plugins/image/ImageEditor.d.ts +10 -0
  156. package/dist/plugins/image/ImageEditor.js +227 -0
  157. package/dist/plugins/image/ImageNode.d.ts +65 -0
  158. package/dist/plugins/image/ImageNode.js +152 -0
  159. package/dist/plugins/image/ImageResizer.d.ts +18 -0
  160. package/dist/plugins/image/ImageResizer.js +214 -0
  161. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  162. package/dist/plugins/image/LexicalImageVisitor.js +35 -0
  163. package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
  164. package/dist/plugins/image/MdastImageVisitor.js +87 -0
  165. package/dist/plugins/image/index.d.ts +804 -0
  166. package/dist/plugins/image/index.js +300 -0
  167. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  168. package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
  169. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  170. package/dist/plugins/jsx/LexicalJsxVisitor.js +24 -0
  171. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  172. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  173. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  174. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  175. package/dist/plugins/jsx/index.d.ts +779 -0
  176. package/dist/plugins/jsx/index.js +82 -0
  177. package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
  178. package/dist/plugins/link/AutoLinkPlugin.js +18 -0
  179. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  180. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  181. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  182. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  183. package/dist/plugins/link/index.d.ts +101 -0
  184. package/dist/plugins/link/index.js +33 -0
  185. package/dist/plugins/link-dialog/LinkDialog.d.ts +16 -0
  186. package/dist/plugins/link-dialog/LinkDialog.js +148 -0
  187. package/dist/plugins/link-dialog/index.d.ts +669 -0
  188. package/dist/plugins/link-dialog/index.js +254 -0
  189. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  190. package/dist/plugins/lists/LexicalListItemVisitor.js +23 -0
  191. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  192. package/dist/plugins/lists/LexicalListVisitor.js +13 -0
  193. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  194. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  195. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  196. package/dist/plugins/lists/MdastListVisitor.js +20 -0
  197. package/dist/plugins/lists/index.d.ts +703 -0
  198. package/dist/plugins/lists/index.js +122 -0
  199. package/dist/plugins/markdown-shortcut/index.d.ts +80 -0
  200. package/dist/plugins/markdown-shortcut/index.js +90 -0
  201. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  202. package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
  203. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  204. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  205. package/dist/plugins/quote/index.d.ts +480 -0
  206. package/dist/plugins/quote/index.js +26 -0
  207. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  208. package/dist/plugins/sandpack/SandpackEditor.js +37 -0
  209. package/dist/plugins/sandpack/index.d.ts +1077 -0
  210. package/dist/plugins/sandpack/index.js +93 -0
  211. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  212. package/dist/plugins/sandpack/useCodeMirrorRef.js +96 -0
  213. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  214. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  215. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  216. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  217. package/dist/plugins/table/TableEditor.d.ts +21 -0
  218. package/dist/plugins/table/TableEditor.js +388 -0
  219. package/dist/plugins/table/TableNode.d.ts +52 -0
  220. package/dist/plugins/table/TableNode.js +152 -0
  221. package/dist/plugins/table/index.d.ts +704 -0
  222. package/dist/plugins/table/index.js +69 -0
  223. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  224. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  225. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  226. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  227. package/dist/plugins/thematic-break/index.d.ts +693 -0
  228. package/dist/plugins/thematic-break/index.js +39 -0
  229. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
  230. package/dist/plugins/toolbar/components/BlockTypeSelect.js +54 -0
  231. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
  232. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +33 -0
  233. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
  234. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  235. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
  236. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  237. package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
  238. package/dist/plugins/toolbar/components/CodeToggle.js +19 -0
  239. package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
  240. package/dist/plugins/toolbar/components/CreateLink.js +20 -0
  241. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
  242. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +25 -0
  243. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
  244. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  245. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
  246. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  247. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
  248. package/dist/plugins/toolbar/components/InsertFrontmatter.js +24 -0
  249. package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
  250. package/dist/plugins/toolbar/components/InsertImage.js +14 -0
  251. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
  252. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  253. package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
  254. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  255. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
  256. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  257. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
  258. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  259. package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
  260. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  261. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
  262. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +31 -0
  263. package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
  264. package/dist/plugins/toolbar/components/UndoRedo.js +58 -0
  265. package/dist/plugins/toolbar/index.d.ts +564 -0
  266. package/dist/plugins/toolbar/index.js +40 -0
  267. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  268. package/dist/plugins/toolbar/primitives/DialogButton.js +114 -0
  269. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
  270. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  271. package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
  272. package/dist/plugins/toolbar/primitives/select.js +55 -0
  273. package/dist/plugins/toolbar/primitives/toolbar.d.ts +163 -0
  274. package/dist/plugins/toolbar/primitives/toolbar.js +115 -0
  275. package/dist/style.css +1093 -288
  276. package/dist/styles/globals.css.js +4 -0
  277. package/dist/styles/lexical-theme.module.css.js +62 -0
  278. package/dist/styles/lexicalTheme.d.ts +2 -0
  279. package/dist/styles/lexicalTheme.js +31 -0
  280. package/dist/styles/ui.module.css.js +311 -0
  281. package/dist/utils/detectMac.d.ts +3 -0
  282. package/dist/utils/detectMac.js +13 -0
  283. package/dist/utils/fp.d.ts +47 -0
  284. package/dist/utils/fp.js +44 -0
  285. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  286. package/dist/utils/isPartOftheEditorUI.js +12 -0
  287. package/dist/utils/lexicalHelpers.d.ts +11 -0
  288. package/dist/utils/lexicalHelpers.js +80 -0
  289. package/dist/utils/makeHslTransparent.d.ts +1 -0
  290. package/dist/utils/makeHslTransparent.js +6 -0
  291. package/dist/utils/mergeStyleAttributes.d.ts +1 -0
  292. package/dist/utils/mergeStyleAttributes.js +22 -0
  293. package/dist/utils/uuid4.d.ts +1 -0
  294. package/dist/utils/uuid4.js +10 -0
  295. package/dist/utils/voidEmitter.d.ts +14 -0
  296. package/dist/utils/voidEmitter.js +15 -0
  297. package/dist/utils/whitespaceConversion.d.ts +2 -0
  298. package/dist/utils/whitespaceConversion.js +9 -0
  299. package/package.json +326 -39
  300. package/dist/index.cjs +0 -1
@@ -0,0 +1,40 @@
1
+ import React__default from "react";
2
+ import { coreSystem, corePluginHooks } from "../core/index.js";
3
+ import { Root } from "./primitives/toolbar.js";
4
+ import { system } from "../../gurx/realmFactory.js";
5
+ import { realmPlugin } from "../../gurx/react.js";
6
+ const toolbarSystem = system(
7
+ (r) => {
8
+ const toolbarContents = r.node(() => null);
9
+ return {
10
+ toolbarContents
11
+ };
12
+ },
13
+ [coreSystem]
14
+ );
15
+ const DEFAULT_TOOLBAR_CONTENTS = () => {
16
+ return "This is an empty toolbar. Pass `{toolbarContents: () => { return <>toolbar components</> }}` to the toolbarPlugin to customize it.";
17
+ };
18
+ const [
19
+ /** @internal */
20
+ toolbarPlugin,
21
+ /** @internal */
22
+ toolbarPluginHooks
23
+ ] = realmPlugin({
24
+ id: "toolbar",
25
+ systemSpec: toolbarSystem,
26
+ init: (realm, params) => {
27
+ realm.pubKey("toolbarContents", (params == null ? void 0 : params.toolbarContents) ?? DEFAULT_TOOLBAR_CONTENTS);
28
+ realm.pubKey("addTopAreaChild", ToolbarWrapper);
29
+ }
30
+ });
31
+ const ToolbarWrapper = () => {
32
+ const [toolbarContents] = toolbarPluginHooks.useEmitterValues("toolbarContents");
33
+ const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
34
+ return /* @__PURE__ */ React__default.createElement(Root, { readOnly }, toolbarContents());
35
+ };
36
+ export {
37
+ toolbarPlugin,
38
+ toolbarPluginHooks,
39
+ toolbarSystem
40
+ };
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ /**
3
+ * The properties of the {@link DialogButton} component.
4
+ */
5
+ export interface DialogButtonProps {
6
+ /**
7
+ * The autocomplete suggestions to show in the dialog input.
8
+ */
9
+ autocompleteSuggestions?: string[];
10
+ /**
11
+ * The callback to call when the dialog is submitted. The callback receives the value of the text input as a parameter.
12
+ */
13
+ onSubmit: (value: string) => void;
14
+ /**
15
+ * The title to show in the tooltip of the toolbar button.
16
+ */
17
+ tooltipTitle: string;
18
+ /**
19
+ * The contents of the button. Usually an icon.
20
+ * @example
21
+ * ```tsx
22
+ * <DialogButton buttonContent={<CustomIcon />} />
23
+ * ```
24
+ */
25
+ buttonContent?: React.ReactNode;
26
+ /**
27
+ * The placeholder text to show in the dialog input.
28
+ */
29
+ dialogInputPlaceholder: string;
30
+ /**
31
+ * The title of the submit button.
32
+ */
33
+ submitButtonTitle: string;
34
+ }
35
+ /**
36
+ * Use this primitive to create a toolbar button that opens a dialog with a text input, autocomplete suggestions, and a submit button.
37
+ *
38
+ * See {@link DialogButtonProps} for the properties that can be passed to this component.
39
+ */
40
+ export declare const DialogButton: React.ForwardRefExoticComponent<DialogButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,114 @@
1
+ import * as Dialog from "@radix-ui/react-dialog";
2
+ import * as RadixToolbar from "@radix-ui/react-toolbar";
3
+ import React__default from "react";
4
+ import classNames from "classnames";
5
+ import { useCombobox } from "downshift";
6
+ import { corePluginHooks } from "../../core/index.js";
7
+ import styles from "../../../styles/ui.module.css.js";
8
+ import { TooltipWrap } from "./TooltipWrap.js";
9
+ const MAX_SUGGESTIONS = 20;
10
+ const DialogButton = React__default.forwardRef(
11
+ ({ autocompleteSuggestions = [], submitButtonTitle, dialogInputPlaceholder, onSubmit, tooltipTitle, buttonContent }, forwardedRef) => {
12
+ const [editorRootElementRef, readOnly] = corePluginHooks.useEmitterValues("editorRootElementRef", "readOnly");
13
+ const [open, setOpen] = React__default.useState(false);
14
+ const onSubmitCallback = React__default.useCallback(
15
+ (value) => {
16
+ onSubmit(value);
17
+ setOpen(false);
18
+ },
19
+ [onSubmit]
20
+ );
21
+ return /* @__PURE__ */ React__default.createElement(Dialog.Root, { open, onOpenChange: setOpen }, /* @__PURE__ */ React__default.createElement(Dialog.Trigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ref: forwardedRef, disabled: readOnly }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: tooltipTitle }, buttonContent))), /* @__PURE__ */ React__default.createElement(Dialog.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Dialog.Overlay, { className: styles.dialogOverlay }), /* @__PURE__ */ React__default.createElement(Dialog.Content, { className: styles.dialogContent }, /* @__PURE__ */ React__default.createElement(
22
+ DialogForm,
23
+ {
24
+ submitButtonTitle,
25
+ autocompleteSuggestions,
26
+ onSubmitCallback,
27
+ dialogInputPlaceholder
28
+ }
29
+ ))));
30
+ }
31
+ );
32
+ const DialogForm = ({ autocompleteSuggestions, onSubmitCallback, dialogInputPlaceholder, submitButtonTitle }) => {
33
+ const [items, setItems] = React__default.useState(autocompleteSuggestions.slice(0, MAX_SUGGESTIONS));
34
+ const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
35
+ const enableAutoComplete = autocompleteSuggestions.length > 0;
36
+ const { isOpen, getToggleButtonProps, getMenuProps, getInputProps, highlightedIndex, getItemProps, selectedItem } = useCombobox({
37
+ initialInputValue: "",
38
+ onInputValueChange({ inputValue }) {
39
+ inputValue = (inputValue == null ? void 0 : inputValue.toLowerCase()) || "";
40
+ const matchingItems = [];
41
+ for (const suggestion of autocompleteSuggestions) {
42
+ if (suggestion.toLowerCase().includes(inputValue)) {
43
+ matchingItems.push(suggestion);
44
+ if (matchingItems.length >= MAX_SUGGESTIONS) {
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ setItems(matchingItems);
50
+ },
51
+ items,
52
+ itemToString(item) {
53
+ return item ?? "";
54
+ }
55
+ });
56
+ const onKeyDownEH = React__default.useCallback(
57
+ (e) => {
58
+ var _a;
59
+ if (e.key === "Escape") {
60
+ (_a = e.target.form) == null ? void 0 : _a.reset();
61
+ } else if (e.key === "Enter" && (!isOpen || items.length === 0)) {
62
+ e.preventDefault();
63
+ onSubmitCallback(e.target.value);
64
+ }
65
+ },
66
+ [isOpen, items, onSubmitCallback]
67
+ );
68
+ const downshiftInputProps = getInputProps();
69
+ const inputProps = {
70
+ ...downshiftInputProps,
71
+ onKeyDown: (e) => {
72
+ onKeyDownEH(e);
73
+ downshiftInputProps.onKeyDown(e);
74
+ }
75
+ };
76
+ const onSubmitEH = (e) => {
77
+ e.preventDefault();
78
+ e.stopPropagation();
79
+ onSubmitCallback(inputProps.value);
80
+ };
81
+ const dropdownIsVisible = isOpen && items.length > 0;
82
+ return /* @__PURE__ */ React__default.createElement("form", { onSubmit: onSubmitEH, className: classNames(styles.dialogForm) }, /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogInputContainer }, /* @__PURE__ */ React__default.createElement("div", { "data-visible-dropdown": dropdownIsVisible, className: styles.linkDialogInputWrapper }, /* @__PURE__ */ React__default.createElement(
83
+ "input",
84
+ {
85
+ placeholder: dialogInputPlaceholder,
86
+ className: styles.linkDialogInput,
87
+ ...inputProps,
88
+ autoFocus: true,
89
+ size: 30,
90
+ "data-editor-dialog": true
91
+ }
92
+ ), enableAutoComplete && /* @__PURE__ */ React__default.createElement("button", { "aria-label": "toggle menu", type: "button", ...getToggleButtonProps() }, iconComponentFor("arrow_drop_down"))), /* @__PURE__ */ React__default.createElement("div", { className: styles.downshiftAutocompleteContainer }, /* @__PURE__ */ React__default.createElement("ul", { ...getMenuProps(), "data-visible": dropdownIsVisible }, items.map((item, index) => /* @__PURE__ */ React__default.createElement(
93
+ "li",
94
+ {
95
+ "data-selected": selectedItem === item,
96
+ "data-highlighted": highlightedIndex === index,
97
+ key: `${item}${index}`,
98
+ ...getItemProps({ item, index })
99
+ },
100
+ item
101
+ ))))), /* @__PURE__ */ React__default.createElement(
102
+ "button",
103
+ {
104
+ type: "submit",
105
+ title: submitButtonTitle,
106
+ "aria-label": submitButtonTitle,
107
+ className: classNames(styles.actionButton, styles.primaryActionButton)
108
+ },
109
+ iconComponentFor("check")
110
+ ), /* @__PURE__ */ React__default.createElement(Dialog.Close, { className: styles.actionButton }, iconComponentFor("close")));
111
+ };
112
+ export {
113
+ DialogButton
114
+ };
@@ -0,0 +1,8 @@
1
+ import React, { ReactNode } from 'react';
2
+ /**
3
+ * A small styled wrapper around the radix-ui tooltip, that lets you display an instan tooltip on hover.
4
+ */
5
+ export declare const TooltipWrap: React.ForwardRefExoticComponent<{
6
+ title: string;
7
+ children: ReactNode;
8
+ } & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,12 @@
1
+ import * as Tooltip from "@radix-ui/react-tooltip";
2
+ import classNames from "classnames";
3
+ import React__default from "react";
4
+ import styles from "../../../styles/ui.module.css.js";
5
+ import { corePluginHooks } from "../../core/index.js";
6
+ const TooltipWrap = React__default.forwardRef(({ title, children }, ref) => {
7
+ const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
8
+ return /* @__PURE__ */ React__default.createElement(Tooltip.Provider, { delayDuration: 100 }, /* @__PURE__ */ React__default.createElement(Tooltip.Root, null, /* @__PURE__ */ React__default.createElement(Tooltip.Trigger, { ref, asChild: true }, /* @__PURE__ */ React__default.createElement("span", { className: styles.tooltipTrigger }, children)), /* @__PURE__ */ React__default.createElement(Tooltip.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Tooltip.Content, { className: classNames(styles.tooltipContent), sideOffset: 10 }, title))));
9
+ });
10
+ export {
11
+ TooltipWrap
12
+ };
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const SelectItem: React.ForwardRefExoticComponent<{
6
+ className?: string | undefined;
7
+ children: React.ReactNode;
8
+ value: string;
9
+ } & React.RefAttributes<HTMLDivElement | null>>;
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare const SelectTrigger: React.FC<{
14
+ title: string;
15
+ placeholder: string;
16
+ className?: string;
17
+ }>;
18
+ /**
19
+ * @internal
20
+ */
21
+ export declare const SelectContent: React.FC<{
22
+ children: React.ReactNode;
23
+ className?: string;
24
+ }>;
25
+ /**
26
+ * @internal
27
+ */
28
+ export declare const SelectButtonTrigger: React.FC<{
29
+ children: React.ReactNode;
30
+ title: string;
31
+ className?: string;
32
+ }>;
33
+ /**
34
+ * The properties of the {@link Select} React component.
35
+ */
36
+ export interface SelectProps<T extends string> {
37
+ value: T;
38
+ onChange: (value: T) => void;
39
+ triggerTitle: string;
40
+ placeholder: string;
41
+ items: ({
42
+ label: string | JSX.Element;
43
+ value: T;
44
+ } | 'separator')[];
45
+ }
46
+ /**
47
+ * A toolbar primitive you can use to build dropdowns, such as the block type select.
48
+ * See {@link SelectProps} for more details.
49
+ */
50
+ export declare const Select: <T extends string>(props: SelectProps<T>) => React.JSX.Element;
@@ -0,0 +1,55 @@
1
+ import React__default from "react";
2
+ import * as RadixSelect from "@radix-ui/react-select";
3
+ import classNames from "classnames";
4
+ import styles from "../../../styles/ui.module.css.js";
5
+ import { TooltipWrap } from "./TooltipWrap.js";
6
+ import { corePluginHooks } from "../../core/index.js";
7
+ const SelectItem = React__default.forwardRef(
8
+ ({ children, className, ...props }, forwardedRef) => {
9
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Item, { ...props, ref: forwardedRef, className: classNames(className, styles.selectItem) }, /* @__PURE__ */ React__default.createElement(RadixSelect.ItemText, null, children));
10
+ }
11
+ );
12
+ const SelectTrigger = ({ title, placeholder, className }) => {
13
+ const [readOnly, iconComponentFor] = corePluginHooks.useEmitterValues("readOnly", "iconComponentFor");
14
+ return /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, /* @__PURE__ */ React__default.createElement(
15
+ RadixSelect.Trigger,
16
+ {
17
+ "aria-label": placeholder,
18
+ className: classNames(styles.selectTrigger, className),
19
+ "data-toolbar-item": true,
20
+ disabled: readOnly
21
+ },
22
+ /* @__PURE__ */ React__default.createElement(RadixSelect.Value, { placeholder }),
23
+ /* @__PURE__ */ React__default.createElement(RadixSelect.Icon, { className: styles.selectDropdownArrow }, iconComponentFor("arrow_drop_down"))
24
+ ));
25
+ };
26
+ const SelectContent = ({
27
+ children,
28
+ className = styles.selectContainer
29
+ }) => {
30
+ const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
31
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(RadixSelect.Content, { className, onCloseAutoFocus: (e) => e.preventDefault(), position: "popper" }, /* @__PURE__ */ React__default.createElement(RadixSelect.Viewport, { "data-editor-dropdown": true }, children)));
32
+ };
33
+ const SelectButtonTrigger = ({
34
+ children,
35
+ title,
36
+ className
37
+ }) => {
38
+ const [readOnly, iconComponentFor] = corePluginHooks.useEmitterValues("readOnly", "iconComponentFor");
39
+ return /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, /* @__PURE__ */ React__default.createElement(RadixSelect.Trigger, { className: classNames(styles.toolbarButtonSelectTrigger, className), disabled: readOnly }, children, /* @__PURE__ */ React__default.createElement(RadixSelect.Icon, { className: styles.selectDropdownArrow }, iconComponentFor("arrow_drop_down"))));
40
+ };
41
+ const Select = (props) => {
42
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Root, { value: props.value || void 0, onValueChange: props.onChange }, /* @__PURE__ */ React__default.createElement(SelectTrigger, { title: props.triggerTitle, placeholder: props.placeholder }), /* @__PURE__ */ React__default.createElement(SelectContent, null, props.items.map((item, index) => {
43
+ if (item === "separator") {
44
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Separator, { key: index });
45
+ }
46
+ return /* @__PURE__ */ React__default.createElement(SelectItem, { key: index, value: item.value }, item.label);
47
+ })));
48
+ };
49
+ export {
50
+ Select,
51
+ SelectButtonTrigger,
52
+ SelectContent,
53
+ SelectItem,
54
+ SelectTrigger
55
+ };
@@ -0,0 +1,163 @@
1
+ import * as RadixToolbar from '@radix-ui/react-toolbar';
2
+ import React from 'react';
3
+ import { EditorInFocus } from '../../core';
4
+ /**
5
+ * @internal
6
+ */
7
+ export declare const Root: React.FC<{
8
+ readOnly: boolean;
9
+ children: React.ReactNode;
10
+ }>;
11
+ /**
12
+ * A toolbar button primitive.
13
+ */
14
+ export declare const Button: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object>>;
15
+ /**
16
+ * A toolbar button with a custom toolbar primitive.
17
+ */
18
+ export declare const ButtonWithTooltip: ({ title, children, ...props }: Omit<RadixToolbar.ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object> & {
19
+ title: string;
20
+ }) => React.JSX.Element;
21
+ /**
22
+ * @internal
23
+ */
24
+ export declare const ToolbarToggleItem: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object>>;
25
+ /**
26
+ * @internal
27
+ */
28
+ export declare const SingleToggleGroup: React.ForwardRefExoticComponent<(Omit<RadixToolbar.ToolbarToggleGroupSingleProps & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<RadixToolbar.ToolbarToggleGroupMultipleProps & React.RefAttributes<HTMLDivElement>, "ref">) & React.RefAttributes<object>>;
29
+ /**
30
+ * @internal
31
+ */
32
+ export declare const ToggleSingleGroupWithItem: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleGroupSingleProps, "type"> & {
33
+ on: boolean;
34
+ title: string;
35
+ disabled?: boolean | undefined;
36
+ } & React.RefAttributes<HTMLDivElement>>;
37
+ /**
38
+ * A toolbar primitive that allows you to build an UI with multiple non-exclusive toggle groups, like the bold/italic/underline toggle.
39
+ */
40
+ export declare const MultipleChoiceToggleGroup: React.FC<{
41
+ items: {
42
+ title: string;
43
+ contents: React.ReactNode;
44
+ active: boolean;
45
+ onChange: (active: boolean) => void;
46
+ disabled?: boolean;
47
+ }[];
48
+ }>;
49
+ /**
50
+ * The properties of the {@link SingleChoiceToggleGroup} React component.
51
+ */
52
+ export interface SingleChoiceToggleGroupProps<T extends string> {
53
+ items: {
54
+ title: string;
55
+ value: T;
56
+ contents: React.ReactNode;
57
+ }[];
58
+ onChange: (value: T) => void;
59
+ value: T;
60
+ className?: string;
61
+ }
62
+ /**
63
+ * A toolbar primitive that allows you to build an UI with multiple exclusive toggle groups, like the list type toggle.
64
+ */
65
+ export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChange, className, items }: SingleChoiceToggleGroupProps<T>) => React.JSX.Element;
66
+ /**
67
+ * The properties of the {@link ButtonOrDropdownButton} React component.
68
+ */
69
+ export interface ButtonOrDropdownButtonProps<T extends string> {
70
+ /**
71
+ * The contents of the button - usually an icon.
72
+ */
73
+ children: React.ReactNode;
74
+ /**
75
+ * The title used for the tooltip.
76
+ */
77
+ title: string;
78
+ /**
79
+ * The function to execute when the button is clicked or an item is chosen from the dropdown.
80
+ * If there is only one item in the dropdown, the value will be an empty string.
81
+ */
82
+ onChoose: (value: T) => void;
83
+ /**
84
+ * The items to show in the dropdown.
85
+ */
86
+ items: {
87
+ /**
88
+ * The value to pass to the `onChoose` function when this item is chosen.
89
+ */
90
+ value: T;
91
+ /**
92
+ * The label to show in the dropdown.
93
+ */
94
+ label: string | JSX.Element;
95
+ }[];
96
+ }
97
+ /**
98
+ * Use this primitive to create a toolbar button that can be either a button or a dropdown, depending on the number of items passed.
99
+ *
100
+ * @see {@link ButtonOrDropdownButtonProps} for the properties of the React component.
101
+ */
102
+ export declare const ButtonOrDropdownButton: <T extends string>(props: ButtonOrDropdownButtonProps<T>) => React.JSX.Element;
103
+ /**
104
+ * An object that describes a possible option to be displayed in the {@link ConditionalContents} component.
105
+ */
106
+ export type ConditionalContentsOption = {
107
+ /**
108
+ * A function that returns `true` if the option should be displayed for the current editor in focus.
109
+ */
110
+ when: (rootNode: EditorInFocus | null) => boolean;
111
+ /**
112
+ * The contents to display if the `when` function returns `true`.
113
+ */
114
+ contents: () => React.ReactNode;
115
+ };
116
+ /**
117
+ * A default option to be displayed in the {@link ConditionalContents} component if none of the other options match.
118
+ */
119
+ export type FallBackOption = {
120
+ /**
121
+ * The contents to display
122
+ */
123
+ fallback: () => React.ReactNode;
124
+ };
125
+ /**
126
+ * The properties of the {@link ConditionalContents} React component.
127
+ */
128
+ export interface ConditionalContentsProps {
129
+ /**
130
+ * A set of options that define the contents to show based on the editor that is in focus.
131
+ * Can be either a {@link ConditionalContentsOption} or a {@link FallBackOption}.
132
+ * See the {@link ConditionalContents} documentation for an example.
133
+ */
134
+ options: (ConditionalContentsOption | FallBackOption)[];
135
+ }
136
+ /**
137
+ * A toolbar primitive that allows you to show different contents based on the editor that is in focus.
138
+ * Useful for code editors that have different features and don't support rich text formatting.
139
+ * @example
140
+ * ```tsx
141
+ * <ConditionalContents
142
+ * options={[
143
+ * { when: (editor) => editor?.editorType === 'codeblock', contents: () => <ChangeCodeMirrorLanguage /> },
144
+ * { when: (editor) => editor?.editorType === 'sandpack', contents: () => <ShowSandpackInfo /> },
145
+ * {
146
+ * fallback: () => (
147
+ * <>
148
+ * <UndoRedo />
149
+ * <BoldItalicUnderlineToggles />
150
+ * <InsertCodeBlock />
151
+ * </>
152
+ * )
153
+ * }
154
+ * ]}
155
+ * />
156
+ * ```
157
+ */
158
+ export declare const ConditionalContents: React.FC<ConditionalContentsProps>;
159
+ /**
160
+ * A toolbar primitive that allows you to show a separator between toolbar items.
161
+ * By default, the separator is styled as vertical line.
162
+ */
163
+ export declare const Separator: React.ForwardRefExoticComponent<RadixToolbar.ToolbarSeparatorProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,115 @@
1
+ import * as RadixSelect from "@radix-ui/react-select";
2
+ import * as RadixToolbar from "@radix-ui/react-toolbar";
3
+ import classNames from "classnames";
4
+ import React__default from "react";
5
+ import styles from "../../../styles/ui.module.css.js";
6
+ import { TooltipWrap } from "./TooltipWrap.js";
7
+ import { SelectButtonTrigger, SelectContent, SelectItem } from "./select.js";
8
+ import { corePluginHooks } from "../../core/index.js";
9
+ function decorateWithRef(Component, decoratedProps) {
10
+ return React__default.forwardRef((props, ref) => {
11
+ const className = classNames(decoratedProps.className, props.className);
12
+ return /* @__PURE__ */ React__default.createElement(Component, { ...decoratedProps, ...props, className, ref });
13
+ });
14
+ }
15
+ function addTooltipToChildren(Component) {
16
+ return ({ title, children, ...props }) => {
17
+ return /* @__PURE__ */ React__default.createElement(Component, { ...props }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, children));
18
+ };
19
+ }
20
+ const Root = ({ readOnly, children }) => {
21
+ return /* @__PURE__ */ React__default.createElement(
22
+ RadixToolbar.Root,
23
+ {
24
+ className: classNames(styles.toolbarRoot, { [styles.readOnlyToolbarRoot]: readOnly }),
25
+ ...readOnly ? { tabIndex: -1 } : {}
26
+ },
27
+ children
28
+ );
29
+ };
30
+ const Button = decorateWithRef(RadixToolbar.Button, { className: styles.toolbarButton, "data-toolbar-item": true });
31
+ const ButtonWithTooltip = addTooltipToChildren(Button);
32
+ const ToolbarToggleItem = decorateWithRef(RadixToolbar.ToggleItem, {
33
+ className: styles.toolbarToggleItem,
34
+ "data-toolbar-item": true
35
+ });
36
+ const SingleToggleGroup = decorateWithRef(RadixToolbar.ToggleGroup, {
37
+ type: "single",
38
+ className: styles.toolbarToggleSingleGroup
39
+ });
40
+ const ToggleSingleGroupWithItem = React__default.forwardRef(({ on, title, children, disabled, ...props }, forwardedRef) => {
41
+ return /* @__PURE__ */ React__default.createElement(
42
+ RadixToolbar.ToggleGroup,
43
+ {
44
+ type: "single",
45
+ className: styles.toolbarToggleSingleGroup,
46
+ ...props,
47
+ value: on ? "on" : "off",
48
+ ref: forwardedRef
49
+ },
50
+ /* @__PURE__ */ React__default.createElement(ToolbarToggleItem, { title, value: "on", disabled }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, children))
51
+ );
52
+ });
53
+ const MultipleChoiceToggleGroup = ({ items }) => {
54
+ return /* @__PURE__ */ React__default.createElement("div", { className: styles.toolbarGroupOfGroups }, items.map((item, index) => /* @__PURE__ */ React__default.createElement(
55
+ ToggleSingleGroupWithItem,
56
+ {
57
+ key: index,
58
+ title: item.title,
59
+ on: item.active,
60
+ onValueChange: (v) => item.onChange(v === "on"),
61
+ disabled: item.disabled
62
+ },
63
+ item.contents
64
+ )));
65
+ };
66
+ const SingleChoiceToggleGroup = ({ value, onChange, className, items }) => {
67
+ return /* @__PURE__ */ React__default.createElement("div", { className: styles.toolbarGroupOfGroups }, /* @__PURE__ */ React__default.createElement(
68
+ RadixToolbar.ToggleGroup,
69
+ {
70
+ type: "single",
71
+ className: classNames(styles.toolbarToggleSingleGroup, className),
72
+ onValueChange: onChange,
73
+ value: value || "",
74
+ onFocus: (e) => e.preventDefault()
75
+ },
76
+ items.map((item, index) => /* @__PURE__ */ React__default.createElement(ToolbarToggleItem, { key: index, value: item.value }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: item.title }, item.contents)))
77
+ ));
78
+ };
79
+ const ButtonOrDropdownButton = (props) => {
80
+ const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
81
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, props.items.length === 1 ? /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: props.title, onClick: () => props.onChoose(""), disabled: readOnly }, props.children) : /* @__PURE__ */ React__default.createElement(RadixSelect.Root, { value: "", onValueChange: props.onChoose }, /* @__PURE__ */ React__default.createElement(SelectButtonTrigger, { title: props.title }, props.children), /* @__PURE__ */ React__default.createElement(SelectContent, { className: styles.toolbarButtonDropdownContainer }, props.items.map((item, index) => /* @__PURE__ */ React__default.createElement(SelectItem, { key: index, value: item.value }, item.label)))));
82
+ };
83
+ function isConditionalContentsOption(option) {
84
+ return Object.hasOwn(option, "when");
85
+ }
86
+ const ConditionalContents = ({ options }) => {
87
+ const [editorInFocus] = corePluginHooks.useEmitterValues("editorInFocus");
88
+ const contents = React__default.useMemo(() => {
89
+ const option = options.find((option2) => {
90
+ if (isConditionalContentsOption(option2)) {
91
+ if (option2.when(editorInFocus)) {
92
+ return true;
93
+ }
94
+ } else {
95
+ return true;
96
+ }
97
+ });
98
+ return option ? isConditionalContentsOption(option) ? option.contents() : option.fallback() : null;
99
+ }, [options, editorInFocus]);
100
+ return /* @__PURE__ */ React__default.createElement("div", { style: { display: "flex" } }, contents);
101
+ };
102
+ const Separator = RadixToolbar.Separator;
103
+ export {
104
+ Button,
105
+ ButtonOrDropdownButton,
106
+ ButtonWithTooltip,
107
+ ConditionalContents,
108
+ MultipleChoiceToggleGroup,
109
+ Root,
110
+ Separator,
111
+ SingleChoiceToggleGroup,
112
+ SingleToggleGroup,
113
+ ToggleSingleGroupWithItem,
114
+ ToolbarToggleItem
115
+ };