@mdxeditor/editor 2.8.1 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2006,6 +2006,8 @@ export declare const MultipleChoiceToggleGroup: React_2.FC<{
2006
2006
  }[];
2007
2007
  }>;
2008
2008
 
2009
+ export declare const muteChange$: NodeRef<boolean>;
2010
+
2009
2011
  /* Excluded from this release type: NESTED_EDITOR_UPDATED_COMMAND */
2010
2012
 
2011
2013
  /* Excluded from this release type: nestedEditorChildren$ */
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export * from "@mdxeditor/gurx";
3
3
  import { MDXEditor } from "./MDXEditor.js";
4
4
  import { MarkdownParseError, UnrecognizedMarkdownConstructError, importMarkdownToLexical, importMdastTreeToLexical } from "./importMarkdownToLexical.js";
5
5
  import { exportLexicalTreeToMdast, exportMarkdownFromLexical } from "./exportMarkdownFromLexical.js";
6
- import { Appender, NESTED_EDITOR_UPDATED_COMMAND, activeEditor$, activeEditorSubscriptions$, activePlugins$, addActivePlugin$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, initialRootEditorState$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
6
+ import { Appender, NESTED_EDITOR_UPDATED_COMMAND, activeEditor$, activeEditorSubscriptions$, activePlugins$, addActivePlugin$, addComposerChild$, addEditorWrapper$, addExportVisitor$, addImportVisitor$, addLexicalNode$, addMdastExtension$, addNestedEditorChild$, addSyntaxExtension$, addToMarkdownExtension$, addTopAreaChild$, applyBlockType$, applyFormat$, autoFocus$, codeBlockEditorDescriptors$, composerChildren$, contentEditableClassName$, convertSelectionToNode$, corePlugin, createActiveEditorSubscription$, createRootEditorSubscription$, currentBlockType$, currentFormat$, currentSelection$, directiveDescriptors$, editorInFocus$, editorRootElementRef$, editorWrappers$, exportVisitors$, historyState$, iconComponentFor$, importVisitors$, inFocus$, initialMarkdown$, initialRootEditorState$, insertDecoratorNode$, insertMarkdown$, jsxComponentDescriptors$, jsxIsAvailable$, markdown$, markdownErrorSignal$, markdownProcessingError$, markdownSourceEditorValue$, mdastExtensions$, muteChange$, nestedEditorChildren$, onBlur$, placeholder$, readOnly$, rootEditor$, rootEditorSubscriptions$, setMarkdown$, syntaxExtensions$, toMarkdownExtensions$, toMarkdownOptions$, topAreaChildren$, usedLexicalNodes$, viewMode$ } from "./plugins/core/index.js";
7
7
  import { ALL_HEADING_LEVELS, allowedHeadingLevels$, headingsPlugin } from "./plugins/headings/index.js";
8
8
  import { insertThematicBreak$, thematicBreakPlugin } from "./plugins/thematic-break/index.js";
9
9
  import { applyListType$, currentListType$, listsPlugin } from "./plugins/lists/index.js";
@@ -246,6 +246,7 @@ export {
246
246
  markdownSourceEditorValue$,
247
247
  maxLengthPlugin,
248
248
  mdastExtensions$,
249
+ muteChange$,
249
250
  nestedEditorChildren$,
250
251
  noop,
251
252
  onBlur$,
@@ -3,7 +3,7 @@ import { createEmptyHistoryState } from "@lexical/react/LexicalHistoryPlugin.js"
3
3
  import { $isHeadingNode } from "@lexical/rich-text";
4
4
  import { $setBlocksType } from "@lexical/selection";
5
5
  import { $findMatchingParent, $wrapNodeInElement, $insertNodeToNearestRoot } from "@lexical/utils";
6
- import { Cell, withLatestFrom, Signal, filter, scan } from "@mdxeditor/gurx";
6
+ import { Cell, withLatestFrom, Signal, filter, map, scan } from "@mdxeditor/gurx";
7
7
  import { createCommand, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getRoot, $setSelection, $getSelection, $insertNodes, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, FOCUS_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, BLUR_COMMAND, $isRangeSelection, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
8
8
  import { mdxJsxFromMarkdown, mdxJsxToMarkdown } from "mdast-util-mdx-jsx";
9
9
  import { mdxJsx } from "micromark-extension-mdx-jsx";
@@ -83,6 +83,17 @@ const markdownSignal$ = Signal((r) => {
83
83
  r.link(markdown$, markdownSignal$);
84
84
  r.link(initialMarkdown$, markdown$);
85
85
  });
86
+ const mutableMarkdownSignal$ = Signal((r) => {
87
+ r.link(
88
+ r.pipe(
89
+ markdownSignal$,
90
+ withLatestFrom(muteChange$),
91
+ filter(([, muted]) => !muted),
92
+ map(([value]) => value)
93
+ ),
94
+ mutableMarkdownSignal$
95
+ );
96
+ });
86
97
  const importVisitors$ = Cell([]);
87
98
  const syntaxExtensions$ = Cell([]);
88
99
  const mdastExtensions$ = Cell([]);
@@ -101,6 +112,7 @@ const addSyntaxExtension$ = Appender(syntaxExtensions$);
101
112
  const addMdastExtension$ = Appender(mdastExtensions$);
102
113
  const addExportVisitor$ = Appender(exportVisitors$);
103
114
  const addToMarkdownExtension$ = Appender(toMarkdownExtensions$);
115
+ const muteChange$ = Cell(false);
104
116
  const setMarkdown$ = Signal((r) => {
105
117
  r.sub(
106
118
  r.pipe(
@@ -111,15 +123,21 @@ const setMarkdown$ = Signal((r) => {
111
123
  })
112
124
  ),
113
125
  ([theNewMarkdownValue, , editor, inFocus]) => {
114
- editor == null ? void 0 : editor.update(() => {
115
- $getRoot().clear();
116
- tryImportingMarkdown(r, $getRoot(), theNewMarkdownValue);
117
- if (!inFocus) {
118
- $setSelection(null);
119
- } else {
120
- editor.focus();
126
+ r.pub(muteChange$, true);
127
+ editor == null ? void 0 : editor.update(
128
+ () => {
129
+ $getRoot().clear();
130
+ tryImportingMarkdown(r, $getRoot(), theNewMarkdownValue);
131
+ if (!inFocus) {
132
+ $setSelection(null);
133
+ } else {
134
+ editor.focus();
135
+ }
136
+ },
137
+ {
138
+ onUpdate: () => r.pub(muteChange$, false)
121
139
  }
122
- });
140
+ );
123
141
  }
124
142
  );
125
143
  });
@@ -504,7 +522,7 @@ const corePlugin = realmPlugin({
504
522
  [placeholder$]: params == null ? void 0 : params.placeholder,
505
523
  [readOnly$]: params == null ? void 0 : params.readOnly
506
524
  });
507
- realm.singletonSub(markdownSignal$, params == null ? void 0 : params.onChange);
525
+ realm.singletonSub(mutableMarkdownSignal$, params == null ? void 0 : params.onChange);
508
526
  realm.singletonSub(onBlur$, params == null ? void 0 : params.onBlur);
509
527
  realm.singletonSub(markdownErrorSignal$, params == null ? void 0 : params.onError);
510
528
  }
@@ -563,6 +581,7 @@ export {
563
581
  markdownProcessingError$,
564
582
  markdownSourceEditorValue$,
565
583
  mdastExtensions$,
584
+ muteChange$,
566
585
  nestedEditorChildren$,
567
586
  onBlur$,
568
587
  placeholder$,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "2.8.1",
14
+ "version": "2.8.2",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",