@mdxeditor/editor 1.14.3 → 2.0.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.
Files changed (202) hide show
  1. package/dist/MDXEditor.js +19 -25
  2. package/dist/RealmWithPlugins.js +36 -0
  3. package/dist/directive-editors/GenericDirectiveEditor.js +7 -4
  4. package/dist/index.d.ts +2590 -62
  5. package/dist/index.js +138 -66
  6. package/dist/jsx-editors/GenericJsxEditor.js +12 -9
  7. package/dist/plugins/codeblock/CodeBlockNode.js +5 -5
  8. package/dist/plugins/codeblock/index.js +37 -63
  9. package/dist/plugins/codemirror/CodeMirrorEditor.js +3 -2
  10. package/dist/plugins/codemirror/index.js +28 -45
  11. package/dist/plugins/core/GenericHTMLNode.js +9 -1
  12. package/dist/plugins/core/MdastHTMLNode.js +0 -1
  13. package/dist/plugins/core/NestedLexicalEditor.js +11 -10
  14. package/dist/plugins/core/PropertyPopover.js +3 -2
  15. package/dist/plugins/core/SharedHistoryPlugin.js +3 -3
  16. package/dist/plugins/core/index.js +426 -385
  17. package/dist/plugins/core/ui/DownshiftAutoComplete.js +3 -2
  18. package/dist/plugins/core/ui/PopoverUtils.js +3 -2
  19. package/dist/plugins/diff-source/DiffSourceWrapper.js +3 -4
  20. package/dist/plugins/diff-source/DiffViewer.js +7 -7
  21. package/dist/plugins/diff-source/SourceEditor.js +6 -6
  22. package/dist/plugins/diff-source/index.js +17 -52
  23. package/dist/plugins/directives/DirectiveNode.js +28 -5
  24. package/dist/plugins/directives/index.js +36 -43
  25. package/dist/plugins/frontmatter/FrontmatterEditor.js +20 -16
  26. package/dist/plugins/frontmatter/index.js +51 -62
  27. package/dist/plugins/headings/index.js +43 -49
  28. package/dist/plugins/image/ImageDialog.js +11 -7
  29. package/dist/plugins/image/ImageEditor.js +10 -7
  30. package/dist/plugins/image/ImageNode.js +27 -5
  31. package/dist/plugins/image/index.js +65 -72
  32. package/dist/plugins/jsx/LexicalJsxNode.js +3 -2
  33. package/dist/plugins/jsx/index.js +48 -60
  34. package/dist/plugins/link/index.js +15 -20
  35. package/dist/plugins/link-dialog/LinkDialog.js +17 -16
  36. package/dist/plugins/link-dialog/index.js +194 -216
  37. package/dist/plugins/lists/index.js +50 -65
  38. package/dist/plugins/markdown-shortcut/index.js +12 -15
  39. package/dist/plugins/quote/index.js +11 -19
  40. package/dist/plugins/sandpack/SandpackEditor.js +3 -2
  41. package/dist/plugins/sandpack/index.js +34 -50
  42. package/dist/plugins/sandpack/useCodeMirrorRef.js +7 -6
  43. package/dist/plugins/table/TableEditor.js +12 -13
  44. package/dist/plugins/table/TableNode.js +28 -0
  45. package/dist/plugins/table/index.js +32 -39
  46. package/dist/plugins/thematic-break/index.js +19 -32
  47. package/dist/plugins/toolbar/components/BlockTypeSelect.js +9 -8
  48. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +4 -4
  49. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +3 -2
  50. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +5 -5
  51. package/dist/plugins/toolbar/components/CodeToggle.js +4 -3
  52. package/dist/plugins/toolbar/components/CreateLink.js +6 -4
  53. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +5 -5
  54. package/dist/plugins/toolbar/components/InsertAdmonition.js +5 -3
  55. package/dist/plugins/toolbar/components/InsertCodeBlock.js +5 -3
  56. package/dist/plugins/toolbar/components/InsertFrontmatter.js +6 -5
  57. package/dist/plugins/toolbar/components/InsertImage.js +6 -5
  58. package/dist/plugins/toolbar/components/InsertSandpack.js +5 -4
  59. package/dist/plugins/toolbar/components/InsertTable.js +5 -3
  60. package/dist/plugins/toolbar/components/InsertThematicBreak.js +6 -4
  61. package/dist/plugins/toolbar/components/ListsToggle.js +5 -4
  62. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +9 -4
  63. package/dist/plugins/toolbar/components/UndoRedo.js +3 -3
  64. package/dist/plugins/toolbar/index.js +15 -31
  65. package/dist/plugins/toolbar/primitives/DialogButton.js +23 -24
  66. package/dist/plugins/toolbar/primitives/TooltipWrap.js +3 -2
  67. package/dist/plugins/toolbar/primitives/select.js +5 -4
  68. package/dist/plugins/toolbar/primitives/toolbar.js +10 -4
  69. package/dist/style.css +935 -571
  70. package/dist/styles/globals.css.js +1 -4
  71. package/dist/styles/lexical-theme.module.css.js +25 -19
  72. package/dist/styles/ui.module.css.js +103 -103
  73. package/package.json +64 -317
  74. package/dist/FormatConstants.d.ts +0 -9
  75. package/dist/MDXEditor.d.ts +0 -103
  76. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +0 -17
  77. package/dist/directive-editors/GenericDirectiveEditor.d.ts +0 -8
  78. package/dist/exportMarkdownFromLexical.d.ts +0 -138
  79. package/dist/gurx/index.d.ts +0 -3
  80. package/dist/gurx/react.d.ts +0 -152
  81. package/dist/gurx/react.js +0 -206
  82. package/dist/gurx/realm.d.ts +0 -148
  83. package/dist/gurx/realm.js +0 -489
  84. package/dist/gurx/realmFactory.d.ts +0 -79
  85. package/dist/gurx/realmFactory.js +0 -32
  86. package/dist/importMarkdownToLexical.d.ts +0 -101
  87. package/dist/jsx-editors/GenericJsxEditor.d.ts +0 -8
  88. package/dist/plugins/codeblock/CodeBlockNode.d.ts +0 -100
  89. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +0 -4
  90. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +0 -3
  91. package/dist/plugins/codeblock/index.d.ts +0 -787
  92. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +0 -3
  93. package/dist/plugins/codemirror/index.d.ts +0 -1038
  94. package/dist/plugins/core/GenericHTMLNode.d.ts +0 -38
  95. package/dist/plugins/core/Icon.d.ts +0 -6
  96. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +0 -4
  97. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +0 -4
  98. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +0 -4
  99. package/dist/plugins/core/LexicalRootVisitor.d.ts +0 -4
  100. package/dist/plugins/core/LexicalTextVisitor.d.ts +0 -5
  101. package/dist/plugins/core/MdastBreakVisitor.d.ts +0 -3
  102. package/dist/plugins/core/MdastFormattingVisitor.d.ts +0 -4
  103. package/dist/plugins/core/MdastHTMLNode.d.ts +0 -13
  104. package/dist/plugins/core/MdastHTMLVisitor.d.ts +0 -3
  105. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +0 -3
  106. package/dist/plugins/core/MdastParagraphVisitor.d.ts +0 -3
  107. package/dist/plugins/core/MdastRootVisitor.d.ts +0 -3
  108. package/dist/plugins/core/MdastTextVisitor.d.ts +0 -3
  109. package/dist/plugins/core/NestedLexicalEditor.d.ts +0 -92
  110. package/dist/plugins/core/PropertyPopover.d.ts +0 -23
  111. package/dist/plugins/core/SharedHistoryPlugin.d.ts +0 -2
  112. package/dist/plugins/core/index.d.ts +0 -583
  113. package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +0 -15
  114. package/dist/plugins/core/ui/PopoverUtils.d.ts +0 -4
  115. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +0 -4
  116. package/dist/plugins/diff-source/DiffViewer.d.ts +0 -2
  117. package/dist/plugins/diff-source/SourceEditor.d.ts +0 -4
  118. package/dist/plugins/diff-source/index.d.ts +0 -725
  119. package/dist/plugins/directives/DirectiveNode.d.ts +0 -51
  120. package/dist/plugins/directives/DirectiveVisitor.d.ts +0 -4
  121. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +0 -3
  122. package/dist/plugins/directives/index.d.ts +0 -773
  123. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +0 -6
  124. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +0 -35
  125. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +0 -4
  126. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +0 -3
  127. package/dist/plugins/frontmatter/index.d.ts +0 -717
  128. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +0 -4
  129. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +0 -3
  130. package/dist/plugins/headings/index.d.ts +0 -707
  131. package/dist/plugins/image/ImageDialog.d.ts +0 -2
  132. package/dist/plugins/image/ImageEditor.d.ts +0 -10
  133. package/dist/plugins/image/ImageNode.d.ts +0 -65
  134. package/dist/plugins/image/ImageResizer.d.ts +0 -18
  135. package/dist/plugins/image/LexicalImageVisitor.d.ts +0 -4
  136. package/dist/plugins/image/MdastImageVisitor.d.ts +0 -6
  137. package/dist/plugins/image/index.d.ts +0 -804
  138. package/dist/plugins/jsx/LexicalJsxNode.d.ts +0 -54
  139. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +0 -4
  140. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +0 -3
  141. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +0 -3
  142. package/dist/plugins/jsx/index.d.ts +0 -779
  143. package/dist/plugins/link/AutoLinkPlugin.d.ts +0 -9
  144. package/dist/plugins/link/LexicalLinkVisitor.d.ts +0 -4
  145. package/dist/plugins/link/MdastLinkVisitor.d.ts +0 -3
  146. package/dist/plugins/link/index.d.ts +0 -101
  147. package/dist/plugins/link-dialog/LinkDialog.d.ts +0 -16
  148. package/dist/plugins/link-dialog/index.d.ts +0 -670
  149. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +0 -4
  150. package/dist/plugins/lists/LexicalListVisitor.d.ts +0 -4
  151. package/dist/plugins/lists/MdastListItemVisitor.d.ts +0 -3
  152. package/dist/plugins/lists/MdastListVisitor.d.ts +0 -3
  153. package/dist/plugins/lists/index.d.ts +0 -703
  154. package/dist/plugins/markdown-shortcut/index.d.ts +0 -80
  155. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +0 -4
  156. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +0 -3
  157. package/dist/plugins/quote/index.d.ts +0 -480
  158. package/dist/plugins/sandpack/SandpackEditor.d.ts +0 -7
  159. package/dist/plugins/sandpack/index.d.ts +0 -1077
  160. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +0 -4
  161. package/dist/plugins/table/LexicalTableVisitor.d.ts +0 -4
  162. package/dist/plugins/table/MdastTableVisitor.d.ts +0 -3
  163. package/dist/plugins/table/TableEditor.d.ts +0 -21
  164. package/dist/plugins/table/TableNode.d.ts +0 -52
  165. package/dist/plugins/table/index.d.ts +0 -704
  166. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +0 -4
  167. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +0 -3
  168. package/dist/plugins/thematic-break/index.d.ts +0 -693
  169. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +0 -6
  170. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +0 -5
  171. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +0 -6
  172. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +0 -7
  173. package/dist/plugins/toolbar/components/CodeToggle.d.ts +0 -6
  174. package/dist/plugins/toolbar/components/CreateLink.d.ts +0 -6
  175. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +0 -18
  176. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +0 -6
  177. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +0 -7
  178. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +0 -6
  179. package/dist/plugins/toolbar/components/InsertImage.d.ts +0 -6
  180. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +0 -6
  181. package/dist/plugins/toolbar/components/InsertTable.d.ts +0 -6
  182. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +0 -6
  183. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +0 -7
  184. package/dist/plugins/toolbar/components/ListsToggle.d.ts +0 -7
  185. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +0 -7
  186. package/dist/plugins/toolbar/components/UndoRedo.d.ts +0 -5
  187. package/dist/plugins/toolbar/index.d.ts +0 -564
  188. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +0 -40
  189. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +0 -8
  190. package/dist/plugins/toolbar/primitives/select.d.ts +0 -50
  191. package/dist/plugins/toolbar/primitives/toolbar.d.ts +0 -163
  192. package/dist/styles/lexicalTheme.d.ts +0 -2
  193. package/dist/utils/detectMac.d.ts +0 -3
  194. package/dist/utils/fp.d.ts +0 -47
  195. package/dist/utils/isPartOftheEditorUI.d.ts +0 -1
  196. package/dist/utils/lexicalHelpers.d.ts +0 -11
  197. package/dist/utils/makeHslTransparent.d.ts +0 -1
  198. package/dist/utils/mergeStyleAttributes.d.ts +0 -1
  199. package/dist/utils/uuid4.d.ts +0 -1
  200. package/dist/utils/voidEmitter.d.ts +0 -14
  201. package/dist/utils/whitespaceConversion.d.ts +0 -2
  202. package/dist/utils/whitespaceConversion.js +0 -9
@@ -1,39 +1,26 @@
1
- import { coreSystem } from "../core/index.js";
2
- import { MdastThematicBreakVisitor } from "./MdastThematicBreakVisitor.js";
3
- import { LexicalThematicBreakVisitor } from "./LexicalThematicBreakVisitor.js";
1
+ import { realmPlugin } from "../../RealmWithPlugins.js";
4
2
  import { INSERT_HORIZONTAL_RULE_COMMAND, HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode.js";
5
3
  import { HorizontalRulePlugin } from "@lexical/react/LexicalHorizontalRulePlugin.js";
6
- import { system } from "../../gurx/realmFactory.js";
7
- import { realmPlugin } from "../../gurx/react.js";
8
- const thematicBreakSystem = system(
9
- (r, [{ activeEditor }]) => {
10
- const insertThematicBreak = r.node();
11
- r.sub(r.pipe(insertThematicBreak, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
12
- theEditor == null ? void 0 : theEditor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, void 0);
4
+ import { Action, withLatestFrom } from "@mdxeditor/gurx";
5
+ import { activeEditor$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addComposerChild$ } from "../core/index.js";
6
+ import { LexicalThematicBreakVisitor } from "./LexicalThematicBreakVisitor.js";
7
+ import { MdastThematicBreakVisitor } from "./MdastThematicBreakVisitor.js";
8
+ const insertThematicBreak$ = Action((r) => {
9
+ r.sub(r.pipe(insertThematicBreak$, withLatestFrom(activeEditor$)), ([, theEditor]) => {
10
+ theEditor == null ? void 0 : theEditor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, void 0);
11
+ });
12
+ });
13
+ const thematicBreakPlugin = realmPlugin({
14
+ init(realm) {
15
+ realm.pubIn({
16
+ [addImportVisitor$]: MdastThematicBreakVisitor,
17
+ [addLexicalNode$]: HorizontalRuleNode,
18
+ [addExportVisitor$]: LexicalThematicBreakVisitor,
19
+ [addComposerChild$]: HorizontalRulePlugin
13
20
  });
14
- return {
15
- insertThematicBreak
16
- };
17
- },
18
- [coreSystem]
19
- );
20
- const [
21
- /** @internal */
22
- thematicBreakPlugin,
23
- /** @internal */
24
- thematicBreakPluginHooks
25
- ] = realmPlugin({
26
- id: "thematic-break",
27
- systemSpec: thematicBreakSystem,
28
- init: (realm) => {
29
- realm.pubKey("addImportVisitor", MdastThematicBreakVisitor);
30
- realm.pubKey("addLexicalNode", HorizontalRuleNode);
31
- realm.pubKey("addExportVisitor", LexicalThematicBreakVisitor);
32
- realm.pubKey("addComposerChild", HorizontalRulePlugin);
33
21
  }
34
22
  });
35
23
  export {
36
- thematicBreakPlugin,
37
- thematicBreakPluginHooks,
38
- thematicBreakSystem
24
+ insertThematicBreak$,
25
+ thematicBreakPlugin
39
26
  };
@@ -1,15 +1,16 @@
1
1
  import { $createHeadingNode, $createQuoteNode } from "@lexical/rich-text";
2
+ import { usePublisher, useCellValue } from "@mdxeditor/gurx";
2
3
  import { $createParagraphNode } from "lexical";
3
4
  import React__default from "react";
4
- import { corePluginHooks } from "../../core/index.js";
5
+ import { convertSelectionToNode$, currentBlockType$, activePlugins$ } from "../../core/index.js";
6
+ import { allowedHeadingLevels$ } from "../../headings/index.js";
5
7
  import { Select } from "../primitives/select.js";
6
- import { headingsPluginHooks } from "../../headings/index.js";
7
- import { useHasPlugin } from "../../../gurx/react.js";
8
8
  const BlockTypeSelect = () => {
9
- const convertSelectionToNode = corePluginHooks.usePublisher("convertSelectionToNode");
10
- const [currentBlockType] = corePluginHooks.useEmitterValues("currentBlockType");
11
- const hasQuote = useHasPlugin("quote");
12
- const hasHeadings = useHasPlugin("headings");
9
+ const convertSelectionToNode = usePublisher(convertSelectionToNode$);
10
+ const currentBlockType = useCellValue(currentBlockType$);
11
+ const activePlugins = useCellValue(activePlugins$);
12
+ const hasQuote = activePlugins.includes("quote");
13
+ const hasHeadings = activePlugins.includes("headings");
13
14
  if (!hasQuote && !hasHeadings) {
14
15
  return null;
15
16
  }
@@ -18,7 +19,7 @@ const BlockTypeSelect = () => {
18
19
  items.push({ label: "Quote", value: "quote" });
19
20
  }
20
21
  if (hasHeadings) {
21
- const [allowedHeadingLevels] = headingsPluginHooks.useEmitterValues("allowedHeadingLevels");
22
+ const allowedHeadingLevels = useCellValue(allowedHeadingLevels$);
22
23
  items.push(...allowedHeadingLevels.map((n) => ({ label: `Heading ${n}`, value: `h${n}` })));
23
24
  }
24
25
  return /* @__PURE__ */ React__default.createElement(
@@ -1,17 +1,17 @@
1
+ import { currentFormat$, iconComponentFor$, applyFormat$ } from "../../core/index.js";
2
+ import { useCellValues, usePublisher } from "@mdxeditor/gurx";
1
3
  import React__default from "react";
2
- import { corePluginHooks } from "../../core/index.js";
3
4
  import { IS_BOLD, IS_ITALIC, IS_UNDERLINE } from "../../../FormatConstants.js";
4
5
  import { MultipleChoiceToggleGroup } from "../primitives/toolbar.js";
5
6
  const BoldItalicUnderlineToggles = () => {
6
- const [currentFormat] = corePluginHooks.useEmitterValues("currentFormat");
7
- const applyFormat = corePluginHooks.usePublisher("applyFormat");
7
+ const [currentFormat, iconComponentFor] = useCellValues(currentFormat$, iconComponentFor$);
8
+ const applyFormat = usePublisher(applyFormat$);
8
9
  const boldIsOn = (currentFormat & IS_BOLD) !== 0;
9
10
  const italicIsOn = (currentFormat & IS_ITALIC) !== 0;
10
11
  const underlineIsOn = (currentFormat & IS_UNDERLINE) !== 0;
11
12
  const boldTitle = boldIsOn ? "Remove bold" : "Bold";
12
13
  const italicTitle = italicIsOn ? "Remove italic" : "Italic";
13
14
  const underlineTitle = underlineIsOn ? "Remove underline" : "Underline";
14
- const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
15
15
  return /* @__PURE__ */ React__default.createElement(
16
16
  MultipleChoiceToggleGroup,
17
17
  {
@@ -1,9 +1,10 @@
1
1
  import React__default from "react";
2
- import { corePluginHooks } from "../../core/index.js";
2
+ import { editorInFocus$, rootEditor$ } from "../../core/index.js";
3
3
  import { Select } from "../primitives/select.js";
4
4
  import { ADMONITION_TYPES } from "../../../directive-editors/AdmonitionDirectiveDescriptor.js";
5
+ import { useCellValues } from "@mdxeditor/gurx";
5
6
  const ChangeAdmonitionType = () => {
6
- const [editorInFocus, rootEditor] = corePluginHooks.useEmitterValues("editorInFocus", "rootEditor");
7
+ const [editorInFocus, rootEditor] = useCellValues(editorInFocus$, rootEditor$);
7
8
  const admonitionNode = editorInFocus.rootNode;
8
9
  return /* @__PURE__ */ React__default.createElement(
9
10
  Select,
@@ -1,12 +1,12 @@
1
+ import { useCellValues } from "@mdxeditor/gurx";
1
2
  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
3
  import styles from "../../../styles/ui.module.css.js";
4
+ import { codeBlockLanguages$ } from "../../codemirror/index.js";
5
+ import { editorInFocus$, activeEditor$ } from "../../core/index.js";
6
+ import { Select } from "../primitives/select.js";
6
7
  const ChangeCodeMirrorLanguage = () => {
7
- const [editorInFocus, theEditor] = corePluginHooks.useEmitterValues("editorInFocus", "activeEditor");
8
+ const [editorInFocus, theEditor, codeBlockLanguages] = useCellValues(editorInFocus$, activeEditor$, codeBlockLanguages$);
8
9
  const codeBlockNode = editorInFocus.rootNode;
9
- const [codeBlockLanguages] = codeMirrorHooks.useEmitterValues("codeBlockLanguages");
10
10
  return /* @__PURE__ */ React__default.createElement("div", { className: styles.selectWithLabel }, /* @__PURE__ */ React__default.createElement("label", null, "Code block language:"), /* @__PURE__ */ React__default.createElement(
11
11
  Select,
12
12
  {
@@ -1,10 +1,11 @@
1
1
  import React__default from "react";
2
2
  import { IS_CODE } from "../../../FormatConstants.js";
3
- import { corePluginHooks } from "../../core/index.js";
3
+ import { currentFormat$, iconComponentFor$, applyFormat$ } from "../../core/index.js";
4
4
  import { MultipleChoiceToggleGroup } from "../primitives/toolbar.js";
5
+ import { useCellValues, usePublisher } from "@mdxeditor/gurx";
5
6
  const CodeToggle = () => {
6
- const [currentFormat, iconComponentFor] = corePluginHooks.useEmitterValues("currentFormat", "iconComponentFor");
7
- const applyFormat = corePluginHooks.usePublisher("applyFormat");
7
+ const [currentFormat, iconComponentFor] = useCellValues(currentFormat$, iconComponentFor$);
8
+ const applyFormat = usePublisher(applyFormat$);
8
9
  const codeIsOn = (currentFormat & IS_CODE) !== 0;
9
10
  const title = codeIsOn ? "Remove code format" : "Inline code format";
10
11
  return /* @__PURE__ */ React__default.createElement(
@@ -1,15 +1,17 @@
1
1
  import React__default from "react";
2
2
  import { ButtonWithTooltip } from "../primitives/toolbar.js";
3
- import { linkDialogPluginHooks } from "../../link-dialog/index.js";
3
+ import { openLinkEditDialog$ } from "../../link-dialog/index.js";
4
+ import { usePublisher, useCellValue } from "@mdxeditor/gurx";
5
+ import { iconComponentFor$ } from "../../core/index.js";
4
6
  const CreateLink = () => {
5
- const openLinkDialog = linkDialogPluginHooks.usePublisher("openLinkEditDialog");
6
- const [iconComponentFor] = linkDialogPluginHooks.useEmitterValues("iconComponentFor");
7
+ const openLinkDialog = usePublisher(openLinkEditDialog$);
8
+ const iconComponentFor = useCellValue(iconComponentFor$);
7
9
  return /* @__PURE__ */ React__default.createElement(
8
10
  ButtonWithTooltip,
9
11
  {
10
12
  title: "Create link",
11
13
  onClick: (_) => {
12
- openLinkDialog(true);
14
+ openLinkDialog();
13
15
  }
14
16
  },
15
17
  iconComponentFor("link")
@@ -1,11 +1,11 @@
1
+ import { viewMode$, iconComponentFor$ } from "../../core/index.js";
2
+ import { useCellValues, usePublisher } from "@mdxeditor/gurx";
1
3
  import React__default from "react";
2
- import { diffSourcePluginHooks } from "../../diff-source/index.js";
3
- import { SingleChoiceToggleGroup } from "../primitives/toolbar.js";
4
4
  import styles from "../../../styles/ui.module.css.js";
5
+ import { SingleChoiceToggleGroup } from "../primitives/toolbar.js";
5
6
  const DiffSourceToggleWrapper = ({ children }) => {
6
- const [viewMode] = diffSourcePluginHooks.useEmitterValues("viewMode");
7
- const changeViewMode = diffSourcePluginHooks.usePublisher("viewMode");
8
- const [iconComponentFor] = diffSourcePluginHooks.useEmitterValues("iconComponentFor");
7
+ const [viewMode, iconComponentFor] = useCellValues(viewMode$, iconComponentFor$);
8
+ const changeViewMode = usePublisher(viewMode$);
9
9
  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", pointerEvents: "auto", opacity: 1 } }, /* @__PURE__ */ React__default.createElement(
10
10
  SingleChoiceToggleGroup,
11
11
  {
@@ -1,10 +1,12 @@
1
1
  import React__default from "react";
2
2
  import { ButtonOrDropdownButton } from "../primitives/toolbar.js";
3
- import { directivesPluginHooks } from "../../directives/index.js";
3
+ import { insertDirective$ } from "../../directives/index.js";
4
4
  import { ADMONITION_TYPES } from "../../../directive-editors/AdmonitionDirectiveDescriptor.js";
5
+ import { usePublisher, useCellValue } from "@mdxeditor/gurx";
6
+ import { iconComponentFor$ } from "../../core/index.js";
5
7
  const InsertAdmonition = () => {
6
- const insertDirective = directivesPluginHooks.usePublisher("insertDirective");
7
- const [iconComponentFor] = directivesPluginHooks.useEmitterValues("iconComponentFor");
8
+ const insertDirective = usePublisher(insertDirective$);
9
+ const iconComponentFor = useCellValue(iconComponentFor$);
8
10
  const items = React__default.useMemo(
9
11
  () => ADMONITION_TYPES.map((type) => ({ value: type, label: type.replace(/^./, (l) => l.toUpperCase()) })),
10
12
  []
@@ -1,9 +1,11 @@
1
1
  import React__default from "react";
2
2
  import { ButtonWithTooltip } from "../primitives/toolbar.js";
3
- import { codeBlockPluginHooks } from "../../codeblock/index.js";
3
+ import { insertCodeBlock$ } from "../../codeblock/index.js";
4
+ import { usePublisher, useCellValue } from "@mdxeditor/gurx";
5
+ import { iconComponentFor$ } from "../../core/index.js";
4
6
  const InsertCodeBlock = () => {
5
- const insertCodeBlock = codeBlockPluginHooks.usePublisher("insertCodeBlock");
6
- const [iconComponentFor] = codeBlockPluginHooks.useEmitterValues("iconComponentFor");
7
+ const insertCodeBlock = usePublisher(insertCodeBlock$);
8
+ const iconComponentFor = useCellValue(iconComponentFor$);
7
9
  return /* @__PURE__ */ React__default.createElement(
8
10
  ButtonWithTooltip,
9
11
  {
@@ -1,12 +1,13 @@
1
1
  import React__default from "react";
2
2
  import { ButtonWithTooltip } from "../primitives/toolbar.js";
3
- import { frontmatterPluginHooks } from "../../frontmatter/index.js";
3
+ import { insertFrontmatter$, hasFrontmatter$ } from "../../frontmatter/index.js";
4
4
  import styles from "../../../styles/ui.module.css.js";
5
5
  import classNames from "classnames";
6
+ import { usePublisher, useCellValues } from "@mdxeditor/gurx";
7
+ import { iconComponentFor$ } from "../../core/index.js";
6
8
  const InsertFrontmatter = () => {
7
- const insertFrontmatter = frontmatterPluginHooks.usePublisher("insertFrontmatter");
8
- const [hasFrontmatter] = frontmatterPluginHooks.useEmitterValues("hasFrontmatter");
9
- const [iconComponentFor] = frontmatterPluginHooks.useEmitterValues("iconComponentFor");
9
+ const insertFrontmatter = usePublisher(insertFrontmatter$);
10
+ const [hasFrontmatter, iconComponentFor] = useCellValues(hasFrontmatter$, iconComponentFor$);
10
11
  return /* @__PURE__ */ React__default.createElement(
11
12
  ButtonWithTooltip,
12
13
  {
@@ -14,7 +15,7 @@ const InsertFrontmatter = () => {
14
15
  className: classNames({
15
16
  [styles.activeToolbarButton]: hasFrontmatter
16
17
  }),
17
- onClick: insertFrontmatter.bind(null, true)
18
+ onClick: () => insertFrontmatter()
18
19
  },
19
20
  iconComponentFor("frontmatter")
20
21
  );
@@ -1,13 +1,14 @@
1
1
  import React__default from "react";
2
- import { imagePluginHooks } from "../../image/index.js";
2
+ import { openNewImageDialog$ } from "../../image/index.js";
3
3
  import * as RadixToolbar from "@radix-ui/react-toolbar";
4
4
  import styles from "../../../styles/ui.module.css.js";
5
- import { corePluginHooks } from "../../core/index.js";
5
+ import { readOnly$, iconComponentFor$ } from "../../core/index.js";
6
6
  import { TooltipWrap } from "../primitives/TooltipWrap.js";
7
+ import { usePublisher, useCellValues } from "@mdxeditor/gurx";
7
8
  const InsertImage = React__default.forwardRef((_, forwardedRef) => {
8
- const openNewImageDialog = imagePluginHooks.usePublisher("openNewImageDialog");
9
- const [readOnly, iconComponentFor] = corePluginHooks.useEmitterValues("readOnly", "iconComponentFor");
10
- return /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ref: forwardedRef, disabled: readOnly, onClick: () => openNewImageDialog(true) }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: "Insert image" }, iconComponentFor("add_photo")));
9
+ const openNewImageDialog = usePublisher(openNewImageDialog$);
10
+ const [readOnly, iconComponentFor] = useCellValues(readOnly$, iconComponentFor$);
11
+ return /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ref: forwardedRef, disabled: readOnly, onClick: () => openNewImageDialog() }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: "Insert image" }, iconComponentFor("add_photo")));
11
12
  });
12
13
  export {
13
14
  InsertImage
@@ -1,11 +1,12 @@
1
1
  import React__default from "react";
2
2
  import { ButtonOrDropdownButton } from "../primitives/toolbar.js";
3
- import { sandpackPluginHooks } from "../../sandpack/index.js";
3
+ import { sandpackConfig$, insertSandpack$ } from "../../sandpack/index.js";
4
+ import { useCellValues, usePublisher } from "@mdxeditor/gurx";
5
+ import { iconComponentFor$ } from "../../core/index.js";
4
6
  const InsertSandpack = () => {
5
- const [sandpackConfig] = sandpackPluginHooks.useEmitterValues("sandpackConfig");
6
- const insertSandpack = sandpackPluginHooks.usePublisher("insertSandpack");
7
+ const [sandpackConfig, iconComponentFor] = useCellValues(sandpackConfig$, iconComponentFor$);
8
+ const insertSandpack = usePublisher(insertSandpack$);
7
9
  const items = React__default.useMemo(() => sandpackConfig.presets.map((preset) => ({ value: preset.name, label: preset.label })), [sandpackConfig]);
8
- const [iconComponentFor] = sandpackPluginHooks.useEmitterValues("iconComponentFor");
9
10
  return /* @__PURE__ */ React__default.createElement(ButtonOrDropdownButton, { title: "Insert Sandpack", onChoose: insertSandpack, items }, iconComponentFor("sandpack"));
10
11
  };
11
12
  export {
@@ -1,9 +1,11 @@
1
1
  import { ButtonWithTooltip } from "../primitives/toolbar.js";
2
2
  import React__default from "react";
3
- import { tablePluginHooks } from "../../table/index.js";
3
+ import { insertTable$ } from "../../table/index.js";
4
+ import { useCellValue, usePublisher } from "@mdxeditor/gurx";
5
+ import { iconComponentFor$ } from "../../core/index.js";
4
6
  const InsertTable = () => {
5
- const [iconComponentFor] = tablePluginHooks.useEmitterValues("iconComponentFor");
6
- const insertTable = tablePluginHooks.usePublisher("insertTable");
7
+ const iconComponentFor = useCellValue(iconComponentFor$);
8
+ const insertTable = usePublisher(insertTable$);
7
9
  return /* @__PURE__ */ React__default.createElement(
8
10
  ButtonWithTooltip,
9
11
  {
@@ -1,10 +1,12 @@
1
1
  import React__default from "react";
2
- import { thematicBreakPluginHooks } from "../../thematic-break/index.js";
2
+ import { insertThematicBreak$ } from "../../thematic-break/index.js";
3
3
  import { ButtonWithTooltip } from "../primitives/toolbar.js";
4
+ import { usePublisher, useCellValue } from "@mdxeditor/gurx";
5
+ import { iconComponentFor$ } from "../../core/index.js";
4
6
  const InsertThematicBreak = () => {
5
- const insertThematicBreak = thematicBreakPluginHooks.usePublisher("insertThematicBreak");
6
- const [iconComponentFor] = thematicBreakPluginHooks.useEmitterValues("iconComponentFor");
7
- return /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: "Insert thematic break", onClick: insertThematicBreak.bind(null, true) }, iconComponentFor("horizontal_rule"));
7
+ const insertThematicBreak = usePublisher(insertThematicBreak$);
8
+ const iconComponentFor = useCellValue(iconComponentFor$);
9
+ return /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: "Insert thematic break", onClick: () => insertThematicBreak() }, iconComponentFor("horizontal_rule"));
8
10
  };
9
11
  export {
10
12
  InsertThematicBreak
@@ -1,10 +1,11 @@
1
1
  import React__default from "react";
2
- import { listsPluginHooks } from "../../lists/index.js";
2
+ import { currentListType$, applyListType$ } from "../../lists/index.js";
3
3
  import { SingleChoiceToggleGroup } from "../primitives/toolbar.js";
4
+ import { useCellValues, usePublisher } from "@mdxeditor/gurx";
5
+ import { iconComponentFor$ } from "../../core/index.js";
4
6
  const ListsToggle = () => {
5
- const [currentListType] = listsPluginHooks.useEmitterValues("currentListType");
6
- const applyListType = listsPluginHooks.usePublisher("applyListType");
7
- const [iconComponentFor] = listsPluginHooks.useEmitterValues("iconComponentFor");
7
+ const [currentListType, iconComponentFor] = useCellValues(currentListType$, iconComponentFor$);
8
+ const applyListType = usePublisher(applyListType$);
8
9
  return /* @__PURE__ */ React__default.createElement(
9
10
  SingleChoiceToggleGroup,
10
11
  {
@@ -1,12 +1,17 @@
1
1
  import React__default from "react";
2
2
  import styles from "../../../styles/ui.module.css.js";
3
- import { corePluginHooks } from "../../core/index.js";
4
- import { sandpackPluginHooks } from "../../sandpack/index.js";
3
+ import { editorInFocus$, activeEditor$, iconComponentFor$ } from "../../core/index.js";
4
+ import { sandpackConfig$ } from "../../sandpack/index.js";
5
5
  import { ButtonWithTooltip } from "../primitives/toolbar.js";
6
+ import { useCellValues } from "@mdxeditor/gurx";
6
7
  const ShowSandpackInfo = () => {
7
- const [editorInFocus, theEditor, iconComponentFor] = corePluginHooks.useEmitterValues("editorInFocus", "activeEditor", "iconComponentFor");
8
+ const [editorInFocus, theEditor, iconComponentFor, sandpackConfig] = useCellValues(
9
+ editorInFocus$,
10
+ activeEditor$,
11
+ iconComponentFor$,
12
+ sandpackConfig$
13
+ );
8
14
  const sandpackNode = editorInFocus.rootNode;
9
- const [sandpackConfig] = sandpackPluginHooks.useEmitterValues("sandpackConfig");
10
15
  const preset = sandpackConfig.presets.find((preset2) => preset2.meta === sandpackNode.getMeta());
11
16
  return /* @__PURE__ */ React__default.createElement("div", { className: styles.selectWithLabel }, /* @__PURE__ */ React__default.createElement(
12
17
  ButtonWithTooltip,
@@ -1,12 +1,12 @@
1
1
  import { mergeRegister } from "@lexical/utils";
2
+ import { useCellValues } from "@mdxeditor/gurx";
2
3
  import { CAN_UNDO_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_REDO_COMMAND, UNDO_COMMAND, REDO_COMMAND } from "lexical";
3
4
  import React__default from "react";
4
5
  import { IS_APPLE } from "../../../utils/detectMac.js";
5
- import { corePluginHooks } from "../../core/index.js";
6
+ import { iconComponentFor$, activeEditor$ } from "../../core/index.js";
6
7
  import { MultipleChoiceToggleGroup } from "../primitives/toolbar.js";
7
8
  const UndoRedo = () => {
8
- const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
9
- const [activeEditor] = corePluginHooks.useEmitterValues("activeEditor");
9
+ const [iconComponentFor, activeEditor] = useCellValues(iconComponentFor$, activeEditor$);
10
10
  const [canUndo, setCanUndo] = React__default.useState(false);
11
11
  const [canRedo, setCanRedo] = React__default.useState(false);
12
12
  React__default.useEffect(() => {
@@ -1,40 +1,24 @@
1
+ import { realmPlugin } from "../../RealmWithPlugins.js";
2
+ import { Cell, useCellValues } from "@mdxeditor/gurx";
1
3
  import React__default from "react";
2
- import { coreSystem, corePluginHooks } from "../core/index.js";
4
+ import { addTopAreaChild$, readOnly$ } from "../core/index.js";
3
5
  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
- );
6
+ const toolbarContents$ = Cell(() => null);
15
7
  const DEFAULT_TOOLBAR_CONTENTS = () => {
16
8
  return "This is an empty toolbar. Pass `{toolbarContents: () => { return <>toolbar components</> }}` to the toolbarPlugin to customize it.";
17
9
  };
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);
10
+ const toolbarPlugin = realmPlugin({
11
+ init(realm, params) {
12
+ realm.pubIn({
13
+ [toolbarContents$]: (params == null ? void 0 : params.toolbarContents) ?? DEFAULT_TOOLBAR_CONTENTS,
14
+ [addTopAreaChild$]: () => {
15
+ const [toolbarContents, readOnly] = useCellValues(toolbarContents$, readOnly$);
16
+ return /* @__PURE__ */ React__default.createElement(Root, { readOnly }, toolbarContents());
17
+ }
18
+ });
29
19
  }
30
20
  });
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
21
  export {
37
- toolbarPlugin,
38
- toolbarPluginHooks,
39
- toolbarSystem
22
+ toolbarContents$,
23
+ toolbarPlugin
40
24
  };
@@ -3,35 +3,34 @@ import * as RadixToolbar from "@radix-ui/react-toolbar";
3
3
  import React__default from "react";
4
4
  import classNames from "classnames";
5
5
  import { useCombobox } from "downshift";
6
- import { corePluginHooks } from "../../core/index.js";
6
+ import { editorRootElementRef$, readOnly$, iconComponentFor$ } from "../../core/index.js";
7
7
  import styles from "../../../styles/ui.module.css.js";
8
8
  import { TooltipWrap } from "./TooltipWrap.js";
9
+ import { useCellValues, useCellValue } from "@mdxeditor/gurx";
9
10
  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
- );
11
+ const DialogButton = React__default.forwardRef(({ autocompleteSuggestions = [], submitButtonTitle, dialogInputPlaceholder, onSubmit, tooltipTitle, buttonContent }, forwardedRef) => {
12
+ const [editorRootElementRef, readOnly] = useCellValues(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
+ });
32
31
  const DialogForm = ({ autocompleteSuggestions, onSubmitCallback, dialogInputPlaceholder, submitButtonTitle }) => {
33
32
  const [items, setItems] = React__default.useState(autocompleteSuggestions.slice(0, MAX_SUGGESTIONS));
34
- const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
33
+ const iconComponentFor = useCellValue(iconComponentFor$);
35
34
  const enableAutoComplete = autocompleteSuggestions.length > 0;
36
35
  const { isOpen, getToggleButtonProps, getMenuProps, getInputProps, highlightedIndex, getItemProps, selectedItem } = useCombobox({
37
36
  initialInputValue: "",
@@ -2,9 +2,10 @@ import * as Tooltip from "@radix-ui/react-tooltip";
2
2
  import classNames from "classnames";
3
3
  import React__default from "react";
4
4
  import styles from "../../../styles/ui.module.css.js";
5
- import { corePluginHooks } from "../../core/index.js";
5
+ import { useCellValue } from "@mdxeditor/gurx";
6
+ import { editorRootElementRef$ } from "../../core/index.js";
6
7
  const TooltipWrap = React__default.forwardRef(({ title, children }, ref) => {
7
- const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
8
+ const editorRootElementRef = useCellValue(editorRootElementRef$);
8
9
  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
  });
10
11
  export {
@@ -3,14 +3,15 @@ import * as RadixSelect from "@radix-ui/react-select";
3
3
  import classNames from "classnames";
4
4
  import styles from "../../../styles/ui.module.css.js";
5
5
  import { TooltipWrap } from "./TooltipWrap.js";
6
- import { corePluginHooks } from "../../core/index.js";
6
+ import { readOnly$, iconComponentFor$, editorRootElementRef$ } from "../../core/index.js";
7
+ import { useCellValues, useCellValue } from "@mdxeditor/gurx";
7
8
  const SelectItem = React__default.forwardRef(
8
9
  ({ children, className, ...props }, forwardedRef) => {
9
10
  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
  }
11
12
  );
12
13
  const SelectTrigger = ({ title, placeholder, className }) => {
13
- const [readOnly, iconComponentFor] = corePluginHooks.useEmitterValues("readOnly", "iconComponentFor");
14
+ const [readOnly, iconComponentFor] = useCellValues(readOnly$, iconComponentFor$);
14
15
  return /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, /* @__PURE__ */ React__default.createElement(
15
16
  RadixSelect.Trigger,
16
17
  {
@@ -27,7 +28,7 @@ const SelectContent = ({
27
28
  children,
28
29
  className = styles.selectContainer
29
30
  }) => {
30
- const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
31
+ const editorRootElementRef = useCellValue(editorRootElementRef$);
31
32
  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
  };
33
34
  const SelectButtonTrigger = ({
@@ -35,7 +36,7 @@ const SelectButtonTrigger = ({
35
36
  title,
36
37
  className
37
38
  }) => {
38
- const [readOnly, iconComponentFor] = corePluginHooks.useEmitterValues("readOnly", "iconComponentFor");
39
+ const [readOnly, iconComponentFor] = useCellValues(readOnly$, iconComponentFor$);
39
40
  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
  };
41
42
  const Select = (props) => {
@@ -5,7 +5,8 @@ import React__default from "react";
5
5
  import styles from "../../../styles/ui.module.css.js";
6
6
  import { TooltipWrap } from "./TooltipWrap.js";
7
7
  import { SelectButtonTrigger, SelectContent, SelectItem } from "./select.js";
8
- import { corePluginHooks } from "../../core/index.js";
8
+ import { readOnly$, editorInFocus$ } from "../../core/index.js";
9
+ import { useCellValue } from "@mdxeditor/gurx";
9
10
  function decorateWithRef(Component, decoratedProps) {
10
11
  return React__default.forwardRef((props, ref) => {
11
12
  const className = classNames(decoratedProps.className, props.className);
@@ -63,7 +64,12 @@ const MultipleChoiceToggleGroup = ({ items }) => {
63
64
  item.contents
64
65
  )));
65
66
  };
66
- const SingleChoiceToggleGroup = ({ value, onChange, className, items }) => {
67
+ const SingleChoiceToggleGroup = ({
68
+ value,
69
+ onChange,
70
+ className,
71
+ items
72
+ }) => {
67
73
  return /* @__PURE__ */ React__default.createElement("div", { className: styles.toolbarGroupOfGroups }, /* @__PURE__ */ React__default.createElement(
68
74
  RadixToolbar.ToggleGroup,
69
75
  {
@@ -77,14 +83,14 @@ const SingleChoiceToggleGroup = ({ value, onChange, className, items }) => {
77
83
  ));
78
84
  };
79
85
  const ButtonOrDropdownButton = (props) => {
80
- const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
86
+ const readOnly = useCellValue(readOnly$);
81
87
  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
88
  };
83
89
  function isConditionalContentsOption(option) {
84
90
  return Object.hasOwn(option, "when");
85
91
  }
86
92
  const ConditionalContents = ({ options }) => {
87
- const [editorInFocus] = corePluginHooks.useEmitterValues("editorInFocus");
93
+ const editorInFocus = useCellValue(editorInFocus$);
88
94
  const contents = React__default.useMemo(() => {
89
95
  const option = options.find((option2) => {
90
96
  if (isConditionalContentsOption(option2)) {