@mdxeditor/editor 1.14.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/MDXEditor.js +19 -25
  2. package/dist/RealmWithPlugins.js +38 -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 +433 -384
  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 +12 -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/LexicalListItemVisitor.js +2 -1
  38. package/dist/plugins/lists/index.js +50 -65
  39. package/dist/plugins/markdown-shortcut/index.js +12 -15
  40. package/dist/plugins/quote/index.js +11 -19
  41. package/dist/plugins/sandpack/SandpackEditor.js +3 -2
  42. package/dist/plugins/sandpack/index.js +34 -50
  43. package/dist/plugins/sandpack/useCodeMirrorRef.js +7 -6
  44. package/dist/plugins/table/TableEditor.js +20 -13
  45. package/dist/plugins/table/TableNode.js +28 -0
  46. package/dist/plugins/table/index.js +32 -39
  47. package/dist/plugins/thematic-break/index.js +19 -32
  48. package/dist/plugins/toolbar/components/BlockTypeSelect.js +9 -8
  49. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +4 -4
  50. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +3 -2
  51. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +5 -5
  52. package/dist/plugins/toolbar/components/CodeToggle.js +4 -3
  53. package/dist/plugins/toolbar/components/CreateLink.js +6 -4
  54. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +5 -5
  55. package/dist/plugins/toolbar/components/InsertAdmonition.js +5 -3
  56. package/dist/plugins/toolbar/components/InsertCodeBlock.js +5 -3
  57. package/dist/plugins/toolbar/components/InsertFrontmatter.js +6 -5
  58. package/dist/plugins/toolbar/components/InsertImage.js +6 -5
  59. package/dist/plugins/toolbar/components/InsertSandpack.js +5 -4
  60. package/dist/plugins/toolbar/components/InsertTable.js +5 -3
  61. package/dist/plugins/toolbar/components/InsertThematicBreak.js +6 -4
  62. package/dist/plugins/toolbar/components/ListsToggle.js +5 -4
  63. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +9 -4
  64. package/dist/plugins/toolbar/components/UndoRedo.js +3 -3
  65. package/dist/plugins/toolbar/index.js +15 -31
  66. package/dist/plugins/toolbar/primitives/DialogButton.js +23 -24
  67. package/dist/plugins/toolbar/primitives/TooltipWrap.js +3 -2
  68. package/dist/plugins/toolbar/primitives/select.js +5 -4
  69. package/dist/plugins/toolbar/primitives/toolbar.js +10 -4
  70. package/dist/style.css +935 -571
  71. package/dist/styles/globals.css.js +1 -4
  72. package/dist/styles/lexical-theme.module.css.js +25 -19
  73. package/dist/styles/ui.module.css.js +103 -103
  74. package/package.json +65 -317
  75. package/dist/FormatConstants.d.ts +0 -9
  76. package/dist/MDXEditor.d.ts +0 -103
  77. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +0 -17
  78. package/dist/directive-editors/GenericDirectiveEditor.d.ts +0 -8
  79. package/dist/exportMarkdownFromLexical.d.ts +0 -138
  80. package/dist/gurx/index.d.ts +0 -3
  81. package/dist/gurx/react.d.ts +0 -152
  82. package/dist/gurx/react.js +0 -206
  83. package/dist/gurx/realm.d.ts +0 -148
  84. package/dist/gurx/realm.js +0 -489
  85. package/dist/gurx/realmFactory.d.ts +0 -79
  86. package/dist/gurx/realmFactory.js +0 -32
  87. package/dist/importMarkdownToLexical.d.ts +0 -101
  88. package/dist/jsx-editors/GenericJsxEditor.d.ts +0 -8
  89. package/dist/plugins/codeblock/CodeBlockNode.d.ts +0 -100
  90. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +0 -4
  91. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +0 -3
  92. package/dist/plugins/codeblock/index.d.ts +0 -787
  93. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +0 -3
  94. package/dist/plugins/codemirror/index.d.ts +0 -1038
  95. package/dist/plugins/core/GenericHTMLNode.d.ts +0 -38
  96. package/dist/plugins/core/Icon.d.ts +0 -6
  97. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +0 -4
  98. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +0 -4
  99. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +0 -4
  100. package/dist/plugins/core/LexicalRootVisitor.d.ts +0 -4
  101. package/dist/plugins/core/LexicalTextVisitor.d.ts +0 -5
  102. package/dist/plugins/core/MdastBreakVisitor.d.ts +0 -3
  103. package/dist/plugins/core/MdastFormattingVisitor.d.ts +0 -4
  104. package/dist/plugins/core/MdastHTMLNode.d.ts +0 -13
  105. package/dist/plugins/core/MdastHTMLVisitor.d.ts +0 -3
  106. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +0 -3
  107. package/dist/plugins/core/MdastParagraphVisitor.d.ts +0 -3
  108. package/dist/plugins/core/MdastRootVisitor.d.ts +0 -3
  109. package/dist/plugins/core/MdastTextVisitor.d.ts +0 -3
  110. package/dist/plugins/core/NestedLexicalEditor.d.ts +0 -92
  111. package/dist/plugins/core/PropertyPopover.d.ts +0 -23
  112. package/dist/plugins/core/SharedHistoryPlugin.d.ts +0 -2
  113. package/dist/plugins/core/index.d.ts +0 -583
  114. package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +0 -15
  115. package/dist/plugins/core/ui/PopoverUtils.d.ts +0 -4
  116. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +0 -4
  117. package/dist/plugins/diff-source/DiffViewer.d.ts +0 -2
  118. package/dist/plugins/diff-source/SourceEditor.d.ts +0 -4
  119. package/dist/plugins/diff-source/index.d.ts +0 -725
  120. package/dist/plugins/directives/DirectiveNode.d.ts +0 -51
  121. package/dist/plugins/directives/DirectiveVisitor.d.ts +0 -4
  122. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +0 -3
  123. package/dist/plugins/directives/index.d.ts +0 -773
  124. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +0 -6
  125. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +0 -35
  126. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +0 -4
  127. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +0 -3
  128. package/dist/plugins/frontmatter/index.d.ts +0 -717
  129. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +0 -4
  130. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +0 -3
  131. package/dist/plugins/headings/index.d.ts +0 -707
  132. package/dist/plugins/image/ImageDialog.d.ts +0 -2
  133. package/dist/plugins/image/ImageEditor.d.ts +0 -10
  134. package/dist/plugins/image/ImageNode.d.ts +0 -65
  135. package/dist/plugins/image/ImageResizer.d.ts +0 -18
  136. package/dist/plugins/image/LexicalImageVisitor.d.ts +0 -4
  137. package/dist/plugins/image/MdastImageVisitor.d.ts +0 -6
  138. package/dist/plugins/image/index.d.ts +0 -804
  139. package/dist/plugins/jsx/LexicalJsxNode.d.ts +0 -54
  140. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +0 -4
  141. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +0 -3
  142. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +0 -3
  143. package/dist/plugins/jsx/index.d.ts +0 -779
  144. package/dist/plugins/link/AutoLinkPlugin.d.ts +0 -9
  145. package/dist/plugins/link/LexicalLinkVisitor.d.ts +0 -4
  146. package/dist/plugins/link/MdastLinkVisitor.d.ts +0 -3
  147. package/dist/plugins/link/index.d.ts +0 -101
  148. package/dist/plugins/link-dialog/LinkDialog.d.ts +0 -16
  149. package/dist/plugins/link-dialog/index.d.ts +0 -670
  150. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +0 -4
  151. package/dist/plugins/lists/LexicalListVisitor.d.ts +0 -4
  152. package/dist/plugins/lists/MdastListItemVisitor.d.ts +0 -3
  153. package/dist/plugins/lists/MdastListVisitor.d.ts +0 -3
  154. package/dist/plugins/lists/index.d.ts +0 -703
  155. package/dist/plugins/markdown-shortcut/index.d.ts +0 -80
  156. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +0 -4
  157. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +0 -3
  158. package/dist/plugins/quote/index.d.ts +0 -480
  159. package/dist/plugins/sandpack/SandpackEditor.d.ts +0 -7
  160. package/dist/plugins/sandpack/index.d.ts +0 -1077
  161. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +0 -4
  162. package/dist/plugins/table/LexicalTableVisitor.d.ts +0 -4
  163. package/dist/plugins/table/MdastTableVisitor.d.ts +0 -3
  164. package/dist/plugins/table/TableEditor.d.ts +0 -21
  165. package/dist/plugins/table/TableNode.d.ts +0 -52
  166. package/dist/plugins/table/index.d.ts +0 -704
  167. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +0 -4
  168. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +0 -3
  169. package/dist/plugins/thematic-break/index.d.ts +0 -693
  170. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +0 -6
  171. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +0 -5
  172. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +0 -6
  173. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +0 -7
  174. package/dist/plugins/toolbar/components/CodeToggle.d.ts +0 -6
  175. package/dist/plugins/toolbar/components/CreateLink.d.ts +0 -6
  176. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +0 -18
  177. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +0 -6
  178. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +0 -7
  179. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +0 -6
  180. package/dist/plugins/toolbar/components/InsertImage.d.ts +0 -6
  181. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +0 -6
  182. package/dist/plugins/toolbar/components/InsertTable.d.ts +0 -6
  183. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +0 -6
  184. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +0 -7
  185. package/dist/plugins/toolbar/components/ListsToggle.d.ts +0 -7
  186. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +0 -7
  187. package/dist/plugins/toolbar/components/UndoRedo.d.ts +0 -5
  188. package/dist/plugins/toolbar/index.d.ts +0 -564
  189. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +0 -40
  190. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +0 -8
  191. package/dist/plugins/toolbar/primitives/select.d.ts +0 -50
  192. package/dist/plugins/toolbar/primitives/toolbar.d.ts +0 -163
  193. package/dist/styles/lexicalTheme.d.ts +0 -2
  194. package/dist/utils/detectMac.d.ts +0 -3
  195. package/dist/utils/fp.d.ts +0 -47
  196. package/dist/utils/isPartOftheEditorUI.d.ts +0 -1
  197. package/dist/utils/lexicalHelpers.d.ts +0 -11
  198. package/dist/utils/makeHslTransparent.d.ts +0 -1
  199. package/dist/utils/mergeStyleAttributes.d.ts +0 -1
  200. package/dist/utils/uuid4.d.ts +0 -1
  201. package/dist/utils/voidEmitter.d.ts +0 -14
  202. package/dist/utils/whitespaceConversion.d.ts +0 -2
  203. package/dist/utils/whitespaceConversion.js +0 -9
@@ -1,26 +1,18 @@
1
- import { coreSystem } from "../core/index.js";
2
1
  import { QuoteNode } from "@lexical/rich-text";
3
2
  import { MdastBlockQuoteVisitor } from "./MdastBlockQuoteVisitor.js";
4
3
  import { LexicalQuoteVisitor } from "./LexicalQuoteVisitor.js";
5
- import { realmPlugin } from "../../gurx/react.js";
6
- import { system } from "../../gurx/realmFactory.js";
7
- const [
8
- /** @internal */
9
- quotePlugin,
10
- /** @internal */
11
- quotePluginHooks
12
- ] = realmPlugin({
13
- id: "quote",
14
- systemSpec: system(() => {
15
- return {};
16
- }, [coreSystem]),
17
- init: (realm) => {
18
- realm.pubKey("addImportVisitor", MdastBlockQuoteVisitor);
19
- realm.pubKey("addLexicalNode", QuoteNode);
20
- realm.pubKey("addExportVisitor", LexicalQuoteVisitor);
4
+ import { realmPlugin } from "../../RealmWithPlugins.js";
5
+ import { addActivePlugin$, addImportVisitor$, addLexicalNode$, addExportVisitor$ } from "../core/index.js";
6
+ const quotePlugin = realmPlugin({
7
+ init(realm) {
8
+ realm.pubIn({
9
+ [addActivePlugin$]: "quote",
10
+ [addImportVisitor$]: MdastBlockQuoteVisitor,
11
+ [addLexicalNode$]: QuoteNode,
12
+ [addExportVisitor$]: LexicalQuoteVisitor
13
+ });
21
14
  }
22
15
  });
23
16
  export {
24
- quotePlugin,
25
- quotePluginHooks
17
+ quotePlugin
26
18
  };
@@ -2,7 +2,8 @@ import React__default from "react";
2
2
  import { useCodeMirrorRef } from "./useCodeMirrorRef.js";
3
3
  import { SandpackProvider, SandpackLayout, SandpackCodeEditor, SandpackPreview, useSandpack } from "@codesandbox/sandpack-react";
4
4
  import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
5
- import { corePluginHooks } from "../core/index.js";
5
+ import { readOnly$ } from "../core/index.js";
6
+ import { useCellValue } from "@mdxeditor/gurx";
6
7
  const CodeUpdateEmitter = ({ onChange, snippetFileName }) => {
7
8
  const { sandpack } = useSandpack();
8
9
  onChange(sandpack.files[snippetFileName].code);
@@ -10,7 +11,7 @@ const CodeUpdateEmitter = ({ onChange, snippetFileName }) => {
10
11
  };
11
12
  const SandpackEditor = ({ nodeKey, code, focusEmitter, preset }) => {
12
13
  const codeMirrorRef = useCodeMirrorRef(nodeKey, "sandpack", "jsx", focusEmitter);
13
- const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
14
+ const readOnly = useCellValue(readOnly$);
14
15
  const { setCode } = useCodeBlockEditorContext();
15
16
  return /* @__PURE__ */ React__default.createElement(
16
17
  SandpackProvider,
@@ -1,9 +1,8 @@
1
1
  import React__default from "react";
2
- import { coreSystem } from "../core/index.js";
3
- import { codeBlockSystem } from "../codeblock/index.js";
2
+ import { insertCodeBlock$, appendCodeBlockEditorDescriptor$ } from "../codeblock/index.js";
4
3
  import { SandpackEditor } from "./SandpackEditor.js";
5
- import { system } from "../../gurx/realmFactory.js";
6
- import { realmPlugin } from "../../gurx/react.js";
4
+ import { Cell, Signal, withLatestFrom, map, useCellValue } from "@mdxeditor/gurx";
5
+ import { realmPlugin } from "../../RealmWithPlugins.js";
7
6
  const defaultSnippetContent = `
8
7
  export default function App() {
9
8
  return (
@@ -29,54 +28,36 @@ const defaultSandpackConfig = {
29
28
  }
30
29
  ]
31
30
  };
32
- const sandpackSystem = system(
33
- (r, [, { insertCodeBlock }]) => {
34
- const sandpackConfig = r.node(defaultSandpackConfig);
35
- const insertSandpack = r.node();
36
- r.link(
37
- r.pipe(
38
- insertSandpack,
39
- r.o.withLatestFrom(sandpackConfig),
40
- r.o.map(([presetName, sandpackConfig2]) => {
41
- const preset = presetName ? sandpackConfig2.presets.find((preset2) => preset2.name === presetName) : sandpackConfig2.presets.find((preset2) => preset2.name == sandpackConfig2.defaultPreset);
42
- if (!preset) {
43
- throw new Error(`No sandpack preset found with name ${presetName}`);
44
- }
45
- return {
46
- code: preset.initialSnippetContent || "",
47
- language: preset.snippetLanguage || "jsx",
48
- meta: preset.meta
49
- };
50
- })
51
- ),
52
- insertCodeBlock
53
- );
54
- return {
55
- insertSandpack,
56
- sandpackConfig
57
- };
58
- },
59
- [coreSystem, codeBlockSystem]
60
- );
61
- const [
62
- /** @internal */
63
- sandpackPlugin,
64
- /** @internal */
65
- sandpackPluginHooks
66
- ] = realmPlugin({
67
- id: "sandpack",
68
- systemSpec: sandpackSystem,
69
- applyParamsToSystem(r, params) {
70
- r.pubKey("sandpackConfig", params.sandpackConfig);
71
- },
72
- init(r) {
73
- r.pubKey("appendCodeBlockEditorDescriptor", {
31
+ const sandpackConfig$ = Cell(defaultSandpackConfig);
32
+ const insertSandpack$ = Signal((r) => {
33
+ r.link(
34
+ r.pipe(
35
+ insertSandpack$,
36
+ withLatestFrom(sandpackConfig$),
37
+ map(([presetName, sandpackConfig]) => {
38
+ const preset = presetName ? sandpackConfig.presets.find((preset2) => preset2.name === presetName) : sandpackConfig.presets.find((preset2) => preset2.name == sandpackConfig.defaultPreset);
39
+ if (!preset) {
40
+ throw new Error(`No sandpack preset found with name ${presetName}`);
41
+ }
42
+ return {
43
+ code: preset.initialSnippetContent || "",
44
+ language: preset.snippetLanguage || "jsx",
45
+ meta: preset.meta
46
+ };
47
+ })
48
+ ),
49
+ insertCodeBlock$
50
+ );
51
+ });
52
+ const sandpackPlugin = realmPlugin({
53
+ init(realm) {
54
+ realm.pub(appendCodeBlockEditorDescriptor$, {
74
55
  match(_language, meta) {
75
56
  return meta == null ? void 0 : meta.startsWith("live");
76
57
  },
77
58
  priority: 1,
78
59
  Editor(props) {
79
- const [config] = sandpackPluginHooks.useEmitterValues("sandpackConfig");
60
+ const config = useCellValue(sandpackConfig$);
80
61
  const preset = config.presets.find((preset2) => preset2.meta === props.meta);
81
62
  if (!preset) {
82
63
  throw new Error(`No sandpack preset found with ${props.meta}`);
@@ -84,10 +65,13 @@ const [
84
65
  return /* @__PURE__ */ React__default.createElement(SandpackEditor, { ...props, preset });
85
66
  }
86
67
  });
68
+ },
69
+ update(realm, params) {
70
+ realm.pub(sandpackConfig$, params == null ? void 0 : params.sandpackConfig);
87
71
  }
88
72
  });
89
73
  export {
90
- sandpackPlugin,
91
- sandpackPluginHooks,
92
- sandpackSystem
74
+ insertSandpack$,
75
+ sandpackConfig$,
76
+ sandpackPlugin
93
77
  };
@@ -1,10 +1,11 @@
1
1
  import { $getNodeByKey, $createParagraphNode } from "lexical";
2
2
  import React__default from "react";
3
3
  import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
4
- import { corePluginHooks } from "../core/index.js";
4
+ import { activeEditor$, editorInFocus$ } from "../core/index.js";
5
+ import { useCellValue, usePublisher } from "@mdxeditor/gurx";
5
6
  function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
6
- const [theEditor] = corePluginHooks.useEmitterValues("activeEditor");
7
- const setEditorInFocus = corePluginHooks.usePublisher("editorInFocus");
7
+ const activeEditor = useCellValue(activeEditor$);
8
+ const setEditorInFocus = usePublisher(editorInFocus$);
8
9
  const codeMirrorRef = React__default.useRef(null);
9
10
  const { lexicalNode } = useCodeBlockEditorContext();
10
11
  const atBottom = React__default.useRef(false);
@@ -27,7 +28,7 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
27
28
  if (!atBottom.current) {
28
29
  atBottom.current = true;
29
30
  } else {
30
- theEditor == null ? void 0 : theEditor.update(() => {
31
+ activeEditor == null ? void 0 : activeEditor.update(() => {
31
32
  var _a2, _b2;
32
33
  const node = $getNodeByKey(nodeKey);
33
34
  const nextSibling = node.getNextSibling();
@@ -50,7 +51,7 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
50
51
  if (!atTop.current) {
51
52
  atTop.current = true;
52
53
  } else {
53
- theEditor == null ? void 0 : theEditor.update(() => {
54
+ activeEditor == null ? void 0 : activeEditor.update(() => {
54
55
  var _a2, _b2;
55
56
  const node = $getNodeByKey(nodeKey);
56
57
  const previousSibling = node.getPreviousSibling();
@@ -67,7 +68,7 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
67
68
  e.stopPropagation();
68
69
  }
69
70
  },
70
- [theEditor, nodeKey]
71
+ [activeEditor, nodeKey]
71
72
  );
72
73
  React__default.useEffect(() => {
73
74
  const codeMirror = codeMirrorRef.current;
@@ -15,7 +15,8 @@ import classNames from "classnames";
15
15
  import styles from "../../styles/ui.module.css.js";
16
16
  import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
17
17
  import { uuidv4 } from "../../utils/uuid4.js";
18
- import { corePluginHooks } from "../core/index.js";
18
+ import { iconComponentFor$, readOnly$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, jsxIsAvailable$, rootEditor$, NESTED_EDITOR_UPDATED_COMMAND, editorRootElementRef$ } from "../core/index.js";
19
+ import { useCellValues } from "@mdxeditor/gurx";
19
20
  const AlignToTailwindClassMap = {
20
21
  center: styles.centeredCell,
21
22
  left: styles.leftAlignedCell,
@@ -23,7 +24,7 @@ const AlignToTailwindClassMap = {
23
24
  };
24
25
  const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
25
26
  const [activeCell, setActiveCell] = React__default.useState(null);
26
- const [iconComponentFor, readOnly] = corePluginHooks.useEmitterValues("iconComponentFor", "readOnly");
27
+ const [iconComponentFor, readOnly] = useCellValues(iconComponentFor$, readOnly$);
27
28
  const getCellKey = React__default.useMemo(() => {
28
29
  return (cell) => {
29
30
  if (!cell.__cacheKey) {
@@ -187,13 +188,13 @@ const Cell = ({ align, ...props }) => {
187
188
  );
188
189
  };
189
190
  const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents, colIndex, rowIndex }) => {
190
- const [importVisitors, exportVisitors, usedLexicalNodes, jsxComponentDescriptors, jsxIsAvailable, rootEditor] = corePluginHooks.useEmitterValues(
191
- "importVisitors",
192
- "exportVisitors",
193
- "usedLexicalNodes",
194
- "jsxComponentDescriptors",
195
- "jsxIsAvailable",
196
- "rootEditor"
191
+ const [importVisitors, exportVisitors, usedLexicalNodes, jsxComponentDescriptors, jsxIsAvailable, rootEditor] = useCellValues(
192
+ importVisitors$,
193
+ exportVisitors$,
194
+ usedLexicalNodes$,
195
+ jsxComponentDescriptors$,
196
+ jsxIsAvailable$,
197
+ rootEditor$
197
198
  );
198
199
  const [editor] = React__default.useState(() => {
199
200
  const editor2 = createEditor({
@@ -267,6 +268,14 @@ const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents
267
268
  return true;
268
269
  },
269
270
  COMMAND_PRIORITY_CRITICAL
271
+ ),
272
+ editor.registerCommand(
273
+ NESTED_EDITOR_UPDATED_COMMAND,
274
+ () => {
275
+ saveAndFocus(null);
276
+ return true;
277
+ },
278
+ COMMAND_PRIORITY_CRITICAL
270
279
  )
271
280
  );
272
281
  }, [colIndex, editor, rootEditor, rowIndex, saveAndFocus, setActiveCell]);
@@ -283,8 +292,7 @@ const ColumnEditor = ({
283
292
  colIndex,
284
293
  setActiveCellWithBoundaries
285
294
  }) => {
286
- const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
287
- const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
295
+ const [editorRootElementRef, iconComponentFor] = useCellValues(editorRootElementRef$, iconComponentFor$);
288
296
  const insertColumnAt = React__default.useCallback(
289
297
  (colIndex2) => {
290
298
  parentEditor.update(() => {
@@ -351,8 +359,7 @@ const RowEditor = ({
351
359
  rowIndex,
352
360
  setActiveCellWithBoundaries
353
361
  }) => {
354
- const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
355
- const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
362
+ const [editorRootElementRef, iconComponentFor] = useCellValues(editorRootElementRef$, iconComponentFor$);
356
363
  const insertRowAt = React__default.useCallback(
357
364
  (rowIndex2) => {
358
365
  parentEditor.update(() => {
@@ -21,21 +21,31 @@ function coordinatesEmitter() {
21
21
  };
22
22
  }
23
23
  class TableNode extends DecoratorNode {
24
+ /**
25
+ * Constructs a new {@link TableNode} with the specified MDAST table node as the object to edit.
26
+ * See {@link https://github.com/micromark/micromark-extension-gfm-table | micromark/micromark-extension-gfm-table} for more information on the MDAST table node.
27
+ */
24
28
  constructor(mdastNode, key) {
25
29
  super(key);
30
+ /** @internal */
26
31
  __publicField(this, "__mdastNode");
32
+ /** @internal */
27
33
  __publicField(this, "focusEmitter", coordinatesEmitter());
28
34
  this.__mdastNode = mdastNode || { type: "table", children: [] };
29
35
  }
36
+ /** @internal */
30
37
  static getType() {
31
38
  return "table";
32
39
  }
40
+ /** @internal */
33
41
  static clone(node) {
34
42
  return new TableNode(structuredClone(node.__mdastNode), node.__key);
35
43
  }
44
+ /** @internal */
36
45
  static importJSON(serializedNode) {
37
46
  return $createTableNode(serializedNode.mdastNode);
38
47
  }
48
+ /** @internal */
39
49
  exportJSON() {
40
50
  return {
41
51
  mdastNode: structuredClone(this.__mdastNode),
@@ -43,22 +53,34 @@ class TableNode extends DecoratorNode {
43
53
  version: 1
44
54
  };
45
55
  }
56
+ /**
57
+ * Returns the mdast node that this node is constructed from.
58
+ */
46
59
  getMdastNode() {
47
60
  return this.__mdastNode;
48
61
  }
62
+ /**
63
+ * Returns the number of rows in the table.
64
+ */
49
65
  getRowCount() {
50
66
  return this.__mdastNode.children.length;
51
67
  }
68
+ /**
69
+ * Returns the number of columns in the table.
70
+ */
52
71
  getColCount() {
53
72
  var _a;
54
73
  return ((_a = this.__mdastNode.children[0]) == null ? void 0 : _a.children.length) || 0;
55
74
  }
75
+ /** @internal */
56
76
  createDOM() {
57
77
  return document.createElement("div");
58
78
  }
79
+ /** @internal */
59
80
  updateDOM() {
60
81
  return false;
61
82
  }
83
+ /** @internal */
62
84
  updateCellContents(colIndex, rowIndex, children) {
63
85
  const self = this.getWritable();
64
86
  const table = self.__mdastNode;
@@ -129,12 +151,18 @@ class TableNode extends DecoratorNode {
129
151
  }
130
152
  table.align[colIndex] = align;
131
153
  }
154
+ /** @internal */
132
155
  decorate(parentEditor) {
133
156
  return /* @__PURE__ */ React__default.createElement(TableEditor, { lexicalTable: this, mdastNode: this.__mdastNode, parentEditor });
134
157
  }
158
+ /**
159
+ * Focuses the table cell at the specified coordinates.
160
+ * Pass `undefined` to remove the focus.
161
+ */
135
162
  select(coords) {
136
163
  this.focusEmitter.publish(coords || [0, 0]);
137
164
  }
165
+ /** @internal */
138
166
  isInline() {
139
167
  return false;
140
168
  }
@@ -1,11 +1,12 @@
1
+ import { realmPlugin } from "../../RealmWithPlugins.js";
2
+ import { Signal, map } from "@mdxeditor/gurx";
1
3
  import { gfmTableFromMarkdown, gfmTableToMarkdown } from "mdast-util-gfm-table";
2
4
  import { gfmTable } from "micromark-extension-gfm-table";
3
- import { coreSystem } from "../core/index.js";
5
+ import { insertDecoratorNode$, addMdastExtension$, addSyntaxExtension$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addToMarkdownExtension$ } from "../core/index.js";
4
6
  import { LexicalTableVisitor } from "./LexicalTableVisitor.js";
5
7
  import { MdastTableVisitor } from "./MdastTableVisitor.js";
6
8
  import { $createTableNode, TableNode } from "./TableNode.js";
7
- import { system } from "../../gurx/realmFactory.js";
8
- import { realmPlugin } from "../../gurx/react.js";
9
+ import { $isTableNode } from "./TableNode.js";
9
10
  function seedTable(rows = 1, columns = 1) {
10
11
  const table = {
11
12
  type: "table",
@@ -27,43 +28,35 @@ function seedTable(rows = 1, columns = 1) {
27
28
  }
28
29
  return table;
29
30
  }
30
- const tableSystem = system(
31
- (r, [{ insertDecoratorNode }]) => {
32
- const insertTable = r.node();
33
- r.link(
34
- r.pipe(
35
- insertTable,
36
- r.o.map(({ rows, columns }) => {
37
- return () => $createTableNode(seedTable(rows, columns));
38
- })
39
- ),
40
- insertDecoratorNode
41
- );
42
- return {
43
- insertTable
44
- };
45
- },
46
- [coreSystem]
47
- );
48
- const [
49
- /** @internal */
50
- tablePlugin,
51
- /** @internal */
52
- tablePluginHooks
53
- ] = realmPlugin({
54
- id: "table",
55
- systemSpec: tableSystem,
56
- init: (realm) => {
57
- realm.pubKey("addMdastExtension", gfmTableFromMarkdown);
58
- realm.pubKey("addSyntaxExtension", gfmTable);
59
- realm.pubKey("addImportVisitor", MdastTableVisitor);
60
- realm.pubKey("addLexicalNode", TableNode);
61
- realm.pubKey("addExportVisitor", LexicalTableVisitor);
62
- realm.pubKey("addToMarkdownExtension", gfmTableToMarkdown({ tableCellPadding: true, tablePipeAlign: true }));
31
+ const insertTable$ = Signal((r) => {
32
+ r.link(
33
+ r.pipe(
34
+ insertTable$,
35
+ map(({ rows, columns }) => {
36
+ return () => $createTableNode(seedTable(rows, columns));
37
+ })
38
+ ),
39
+ insertDecoratorNode$
40
+ );
41
+ });
42
+ const tablePlugin = realmPlugin({
43
+ init(realm) {
44
+ realm.pubIn({
45
+ // import
46
+ [addMdastExtension$]: gfmTableFromMarkdown(),
47
+ [addSyntaxExtension$]: gfmTable(),
48
+ [addImportVisitor$]: MdastTableVisitor,
49
+ // export
50
+ [addLexicalNode$]: TableNode,
51
+ [addExportVisitor$]: LexicalTableVisitor,
52
+ [addToMarkdownExtension$]: gfmTableToMarkdown({ tableCellPadding: true, tablePipeAlign: true })
53
+ });
63
54
  }
64
55
  });
65
56
  export {
66
- tablePlugin,
67
- tablePluginHooks,
68
- tableSystem
57
+ $createTableNode,
58
+ $isTableNode,
59
+ TableNode,
60
+ insertTable$,
61
+ tablePlugin
69
62
  };
@@ -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")