@mdxeditor/editor 1.11.0 → 1.11.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.
@@ -2,7 +2,7 @@ import { createEmptyHistoryState } from "@lexical/react/LexicalHistoryPlugin.js"
2
2
  import { $isHeadingNode } from "@lexical/rich-text";
3
3
  import { $setBlocksType } from "@lexical/selection";
4
4
  import { $findMatchingParent, $wrapNodeInElement, $insertNodeToNearestRoot } from "@lexical/utils";
5
- import { createCommand, SELECTION_CHANGE_COMMAND, $getRoot, COMMAND_PRIORITY_CRITICAL, $setSelection, BLUR_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getSelection, $isRangeSelection, $insertNodes, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
5
+ import { createCommand, SELECTION_CHANGE_COMMAND, $getRoot, COMMAND_PRIORITY_CRITICAL, $setSelection, BLUR_COMMAND, FOCUS_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getSelection, $isRangeSelection, $insertNodes, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
6
6
  import { exportMarkdownFromLexical } from "../../exportMarkdownFromLexical.js";
7
7
  import { importMarkdownToLexical } from "../../importMarkdownToLexical.js";
8
8
  import { LexicalLinebreakVisitor } from "./LexicalLinebreakVisitor.js";
@@ -148,8 +148,14 @@ const coreSystem = system((r) => {
148
148
  const addToMarkdownExtension = createAppendNodeFor(toMarkdownExtensions);
149
149
  const setMarkdown = r.node();
150
150
  r.sub(
151
- r.pipe(setMarkdown, r.o.withLatestFrom(rootEditor, importVisitors, mdastExtensions, syntaxExtensions, inFocus)),
152
- ([theNewMarkdownValue, editor, importVisitors2, mdastExtensions2, syntaxExtensions2, inFocus2]) => {
151
+ r.pipe(
152
+ setMarkdown,
153
+ r.o.withLatestFrom(markdown, rootEditor, importVisitors, mdastExtensions, syntaxExtensions, inFocus),
154
+ r.o.filter(([newMarkdown, oldMarkdown]) => {
155
+ return newMarkdown.trim() !== oldMarkdown.trim();
156
+ })
157
+ ),
158
+ ([theNewMarkdownValue, , editor, importVisitors2, mdastExtensions2, syntaxExtensions2, inFocus2]) => {
153
159
  editor == null ? void 0 : editor.update(() => {
154
160
  $getRoot().clear();
155
161
  importMarkdownToLexical({
@@ -161,6 +167,8 @@ const coreSystem = system((r) => {
161
167
  });
162
168
  if (!inFocus2) {
163
169
  $setSelection(null);
170
+ } else {
171
+ editor.focus();
164
172
  }
165
173
  });
166
174
  }
@@ -215,6 +223,16 @@ const coreSystem = system((r) => {
215
223
  COMMAND_PRIORITY_CRITICAL
216
224
  );
217
225
  });
226
+ r.pub(createRootEditorSubscription, (theEditor) => {
227
+ return theEditor.registerCommand(
228
+ FOCUS_COMMAND,
229
+ () => {
230
+ r.pub(inFocus, true);
231
+ return false;
232
+ },
233
+ COMMAND_PRIORITY_CRITICAL
234
+ );
235
+ });
218
236
  r.pub(createRootEditorSubscription, (theRootEditor) => {
219
237
  return theRootEditor.registerCommand(
220
238
  KEY_DOWN_COMMAND,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "private": false,
10
10
  "sideEffects": false,
11
11
  "type": "module",
12
- "version": "1.11.0",
12
+ "version": "1.11.1",
13
13
  "description": "React component for rich text markdown editing",
14
14
  "scripts": {
15
15
  "build": "vite build",