+
+ {"<"}
+ {props.componentName}
+ {" />"}
+
+
- {props.previewSurface}
- {props.previewState === "empty" ? (
-
- Local preview unavailable.
-
+ {props.forbidden ? (
+
Unavailable
+ ) : props.readOnly ? (
+
Read-only
) : null}
+ {props.onEditProps ? (
+
+ ) : null}
+ {props.onDelete ? (
+
+ ) : null}
+
+
+ {/* Preview surface */}
+
+ {props.previewSurface}
{props.previewState === "error" ? (
Preview failed to render.
@@ -85,32 +132,19 @@ export function MdxComponentNodeFrame(props: {
) : null}
- {props.isVoid ? (
-
- Self-closing component
-
- ) : (
-
-
- Inner content
-
-
- Edit nested markdown directly in this block.
-
+ {/* Wrapper children */}
+ {props.isVoid ? null : (
+
{props.children}
)}
-
- {props.forbidden ? (
-
- Editing is unavailable.
-
- ) : props.readOnly ? (
-
Read-only preview.
- ) : null}
);
@@ -224,6 +258,19 @@ export function MdxComponentNodeView(
serializedPreviewProps,
]);
+ const handleEditProps = () => {
+ const pos = props.getPos();
+ if (typeof pos === "number") {
+ props.editor.commands.setNodeSelection(pos);
+ }
+ };
+
+ const handleDelete = () => {
+ props.deleteNode();
+ };
+
+ const isEditable = !props.readOnly && !props.forbidden;
+
return (