@mdxeditor/editor 3.35.1 → 3.36.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.
@@ -52,10 +52,13 @@ function exportLexicalTreeToMdast({
52
52
  visit(lexicalChild, parentNode);
53
53
  });
54
54
  }
55
- function visit(lexicalNode, mdastParent) {
55
+ function visit(lexicalNode, mdastParent, usedVisitors = null) {
56
56
  var _a;
57
- const visitor = visitors.find((visitor2) => {
57
+ const visitor = visitors.find((visitor2, index) => {
58
58
  var _a2;
59
+ if (usedVisitors == null ? void 0 : usedVisitors.has(index)) {
60
+ return false;
61
+ }
59
62
  return (_a2 = visitor2.testLexicalNode) == null ? void 0 : _a2.call(visitor2, lexicalNode);
60
63
  });
61
64
  if (!visitor) {
@@ -81,7 +84,11 @@ function exportLexicalTreeToMdast({
81
84
  appendToParent,
82
85
  visitChildren,
83
86
  visit,
84
- registerReferredComponent
87
+ registerReferredComponent,
88
+ nextVisitor() {
89
+ visit(lexicalNode, mdastParent, (usedVisitors ?? /* @__PURE__ */ new Set()).add(visitors.indexOf(visitor)));
90
+ return;
91
+ }
85
92
  }
86
93
  });
87
94
  }
@@ -85,8 +85,11 @@ function importMdastTreeToLexical({ root, mdastRoot, visitors, ...descriptors })
85
85
  visit(child, lexicalParent, mdastNode);
86
86
  });
87
87
  }
88
- function visit(mdastNode, lexicalParent, mdastParent) {
89
- const visitor = visitors.find((visitor2) => {
88
+ function visit(mdastNode, lexicalParent, mdastParent, skipVisitors = null) {
89
+ const visitor = visitors.find((visitor2, index) => {
90
+ if (skipVisitors == null ? void 0 : skipVisitors.has(index)) {
91
+ return false;
92
+ }
90
93
  if (typeof visitor2.testNode === "string") {
91
94
  return visitor2.testNode === mdastNode.type;
92
95
  }
@@ -113,6 +116,9 @@ function importMdastTreeToLexical({ root, mdastRoot, visitors, ...descriptors })
113
116
  metaData,
114
117
  actions: {
115
118
  visitChildren,
119
+ nextVisitor() {
120
+ visit(mdastNode, lexicalParent, mdastParent, (skipVisitors ?? /* @__PURE__ */ new Set()).add(visitors.indexOf(visitor)));
121
+ },
116
122
  addAndStepInto(lexicalNode) {
117
123
  lexicalParent.append(lexicalNode);
118
124
  if (isParent(mdastNode)) {
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ import { FC } from 'react';
17
17
  import { HeadingTagType } from '@lexical/rich-text';
18
18
  import { HistoryState } from '@lexical/history';
19
19
  import { KlassConstructor } from 'lexical';
20
+ import * as lexical from 'lexical';
20
21
  import { LexicalCommand } from 'lexical';
21
22
  import { LexicalEditor } from 'lexical';
22
23
  import { LexicalNode } from 'lexical';
@@ -1794,6 +1795,8 @@ export declare const KitchenSinkToolbar: default_2.FC;
1794
1795
  */
1795
1796
  export declare type KnownHTMLTagType = (typeof htmlTags)[number];
1796
1797
 
1798
+ export { lexical }
1799
+
1797
1800
  /**
1798
1801
  * Configures how the lexical tree is converted to a mdast tree and then to markdown.
1799
1802
  * @group Markdown Processing
@@ -1867,6 +1870,10 @@ export declare interface LexicalExportVisitor<LN extends LexicalNode, UN extends
1867
1870
  * visits the specified lexical node
1868
1871
  */
1869
1872
  visit(node: LexicalNode, parent: Mdast.Parent): void;
1873
+ /**
1874
+ * Go to next visitor in the visitors chain for potential processing from a different visitor with a lower priority
1875
+ */
1876
+ nextVisitor(): void;
1870
1877
  };
1871
1878
  }): void;
1872
1879
  /**
@@ -2095,6 +2102,10 @@ export declare interface MdastImportVisitor<UN extends Mdast.Nodes> {
2095
2102
  * Access the current style context.
2096
2103
  */
2097
2104
  getParentStyle(): string;
2105
+ /**
2106
+ * Go to next visitor in the visitors chain for potential processing from a different visitor with a lower priority
2107
+ */
2108
+ nextVisitor(): void;
2098
2109
  };
2099
2110
  }): void;
2100
2111
  /**
package/dist/index.js CHANGED
@@ -62,6 +62,7 @@ import { voidEmitter } from "./utils/voidEmitter.js";
62
62
  import { RealmWithPlugins, realmPlugin } from "./RealmWithPlugins.js";
63
63
  import { DEFAULT_FORMAT, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE } from "./FormatConstants.js";
64
64
  import { lexicalTheme } from "./styles/lexicalTheme.js";
65
+ import * as lexical from "lexical";
65
66
  import { htmlTags, isMdastHTMLNode } from "./plugins/core/MdastHTMLNode.js";
66
67
  import { $createGenericHTMLNode, $isGenericHTMLNode, GenericHTMLNode, TYPE_NAME } from "./plugins/core/GenericHTMLNode.js";
67
68
  import { $convertTableElement, $createTableNode, $isTableNode, TableNode } from "./plugins/table/TableNode.js";
@@ -264,6 +265,7 @@ export {
264
265
  jsxComponentDescriptors$,
265
266
  jsxIsAvailable$,
266
267
  jsxPlugin,
268
+ lexical,
267
269
  lexicalTheme,
268
270
  lexicalTheme$,
269
271
  linkAutocompleteSuggestions$,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "*.css"
12
12
  ],
13
13
  "type": "module",
14
- "version": "3.35.1",
14
+ "version": "3.36.0",
15
15
  "description": "React component for rich text markdown editing",
16
16
  "scripts": {
17
17
  "build": "vite build",