@mdxeditor/editor 3.22.1 → 3.23.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.
package/dist/index.d.ts
CHANGED
|
@@ -1204,7 +1204,17 @@ export declare class GenericHTMLNode extends ElementNode {
|
|
|
1204
1204
|
* Use this editor for the {@link JsxComponentDescriptor} Editor option.
|
|
1205
1205
|
* @group JSX
|
|
1206
1206
|
*/
|
|
1207
|
-
export declare const GenericJsxEditor: default_2.FC<
|
|
1207
|
+
export declare const GenericJsxEditor: default_2.FC<GenericJsxEditorProps>;
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Properties for the Generic Jsx Editor
|
|
1211
|
+
*/
|
|
1212
|
+
export declare interface GenericJsxEditorProps extends JsxEditorProps {
|
|
1213
|
+
/**
|
|
1214
|
+
* A custom property editor component {@link PropertyEditorType}
|
|
1215
|
+
*/
|
|
1216
|
+
PropertyEditor?: PropertyEditorType;
|
|
1217
|
+
}
|
|
1208
1218
|
|
|
1209
1219
|
/**
|
|
1210
1220
|
* Gets the selected node from the Lexical editor.
|
|
@@ -2320,6 +2330,11 @@ export declare interface PreviewLinkDialog {
|
|
|
2320
2330
|
*/
|
|
2321
2331
|
export declare function prop<T extends Record<string, unknown>>(property: keyof T): (object: T) => T[keyof T];
|
|
2322
2332
|
|
|
2333
|
+
/**
|
|
2334
|
+
* A component capable of editing JSX properties
|
|
2335
|
+
*/
|
|
2336
|
+
declare type PropertyEditorType = typeof PropertyPopover;
|
|
2337
|
+
|
|
2323
2338
|
/**
|
|
2324
2339
|
* A React component that can be used in custom editors to edit the properties of the node.
|
|
2325
2340
|
* Displays a simple, static key/value editing UI in a popover.
|
|
@@ -15,7 +15,7 @@ const isMdxJsxAttribute = (value) => {
|
|
|
15
15
|
}
|
|
16
16
|
return false;
|
|
17
17
|
};
|
|
18
|
-
const GenericJsxEditor = ({ mdastNode, descriptor }) => {
|
|
18
|
+
const GenericJsxEditor = ({ mdastNode, descriptor, PropertyEditor }) => {
|
|
19
19
|
const updateMdastNode = useMdastNodeUpdater();
|
|
20
20
|
const properties = React__default.useMemo(
|
|
21
21
|
() => descriptor.props.reduce((acc, { name }) => {
|
|
@@ -61,8 +61,9 @@ const GenericJsxEditor = ({ mdastNode, descriptor }) => {
|
|
|
61
61
|
},
|
|
62
62
|
[mdastNode, updateMdastNode, descriptor]
|
|
63
63
|
);
|
|
64
|
+
const PropertyEditorComponent = PropertyEditor ?? PropertyPopover;
|
|
64
65
|
const shouldRenderComponentName = descriptor.props.length == 0 && descriptor.hasChildren && descriptor.kind === "flow";
|
|
65
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: descriptor.kind === "text" ? styles.inlineEditor : styles.blockEditor }, shouldRenderComponentName ? /* @__PURE__ */ React__default.createElement("span", { className: styles.genericComponentName }, mdastNode.name ?? "Fragment") : null, descriptor.props.length > 0 ? /* @__PURE__ */ React__default.createElement(
|
|
66
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: descriptor.kind === "text" ? styles.inlineEditor : styles.blockEditor }, shouldRenderComponentName ? /* @__PURE__ */ React__default.createElement("span", { className: styles.genericComponentName }, mdastNode.name ?? "Fragment") : null, descriptor.props.length > 0 ? /* @__PURE__ */ React__default.createElement(PropertyEditorComponent, { properties, title: mdastNode.name ?? "", onChange }) : null, descriptor.hasChildren ? /* @__PURE__ */ React__default.createElement(
|
|
66
67
|
NestedLexicalEditor,
|
|
67
68
|
{
|
|
68
69
|
block: descriptor.kind === "flow",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $isListItemNode, $isListNode } from "@lexical/list";
|
|
2
|
-
import { $isTextNode, $isElementNode } from "lexical";
|
|
2
|
+
import { $isTextNode, $isElementNode, $isDecoratorNode } from "lexical";
|
|
3
3
|
const LexicalListItemVisitor = {
|
|
4
4
|
testLexicalNode: $isListItemNode,
|
|
5
5
|
visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
|
|
@@ -22,7 +22,7 @@ const LexicalListItemVisitor = {
|
|
|
22
22
|
});
|
|
23
23
|
let surroundingParagraph = null;
|
|
24
24
|
for (const child of lexicalNode.getChildren()) {
|
|
25
|
-
if ($isTextNode(child) || $isElementNode(child) && child.isInline()) {
|
|
25
|
+
if ($isTextNode(child) || $isElementNode(child) && child.isInline() || $isDecoratorNode(child) && child.isInline()) {
|
|
26
26
|
if (!surroundingParagraph) {
|
|
27
27
|
surroundingParagraph = actions.appendToParent(listItem, {
|
|
28
28
|
type: "paragraph",
|