@mdxeditor/editor 3.21.3 → 3.21.4
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
|
@@ -1782,6 +1782,10 @@ export declare interface LexicalExportVisitor<LN extends LexicalNode, UN extends
|
|
|
1782
1782
|
* @see {@link JsxComponentDescriptor}
|
|
1783
1783
|
*/
|
|
1784
1784
|
registerReferredComponent(componentName: string): void;
|
|
1785
|
+
/**
|
|
1786
|
+
* visits the specified lexical node
|
|
1787
|
+
*/
|
|
1788
|
+
visit(node: LexicalNode, parent: Mdast.Parent): void;
|
|
1785
1789
|
};
|
|
1786
1790
|
}): void;
|
|
1787
1791
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $isListItemNode, $isListNode } from "@lexical/list";
|
|
2
|
+
import { $isTextNode } from "lexical";
|
|
2
3
|
const LexicalListItemVisitor = {
|
|
3
4
|
testLexicalNode: $isListItemNode,
|
|
4
5
|
visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
|
|
@@ -19,7 +20,21 @@ const LexicalListItemVisitor = {
|
|
|
19
20
|
spread: false,
|
|
20
21
|
children: []
|
|
21
22
|
});
|
|
22
|
-
|
|
23
|
+
let surroundingParagraph = null;
|
|
24
|
+
for (const child of lexicalNode.getChildren()) {
|
|
25
|
+
if ($isTextNode(child)) {
|
|
26
|
+
if (!surroundingParagraph) {
|
|
27
|
+
surroundingParagraph = actions.appendToParent(listItem, {
|
|
28
|
+
type: "paragraph",
|
|
29
|
+
children: []
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
actions.visit(child, surroundingParagraph);
|
|
33
|
+
} else {
|
|
34
|
+
surroundingParagraph = null;
|
|
35
|
+
actions.visit(child, listItem);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
}
|
|
24
39
|
}
|
|
25
40
|
};
|