@mermaid-editor-sdk/ui / MermaidEditorProps
Interface: MermaidEditorProps
Defined in: package/ui/src/ui/MermaidEditor.tsx:42
Extends
Omit<MermaidVisualEditorOptions,"value">
Properties
autoFit?
readonlyoptionalautoFit?:boolean
Defined in: package/ui/src/ui/MermaidEditor.tsx:56
Fits the rendered diagram after rendering and when the canvas resizes.
Default
false
children?
readonlyoptionalchildren?:ReactNode
Defined in: package/ui/src/ui/MermaidEditor.tsx:77
Custom composition; when provided, replaces the default UI composition.
Default
the SDK's standard editor layout
className?
readonlyoptionalclassName?:string
Defined in: package/ui/src/ui/MermaidEditor.tsx:48
Class added to the default shell root.
Default
""
onChange?
optionalonChange?: (value) =>void
Defined in: package/ui/src/runtime/types.ts:19
Called when the user edits the source; programmatic source updates do not invoke it.
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
void
Inherited from
MermaidVisualEditorOptions.onChange
onChangeDiagramType?
optionalonChangeDiagramType?: (diagramType) =>void
Defined in: package/ui/src/runtime/types.ts:21
Called after a new diagram type is selected and its default source is applied.
Parameters
| Parameter | Type |
|---|---|
diagramType | EditableDiagramType |
Returns
void
Inherited from
MermaidVisualEditorOptions.onChangeDiagramType
onError?
optionalonError?: (error) =>void
Defined in: package/ui/src/runtime/types.ts:25
Receives parse, render, mutation, save, or lifecycle errors.
Parameters
| Parameter | Type |
|---|---|
error | EditorError |
Returns
void
Inherited from
MermaidVisualEditorOptions.onError
onRemove?
optionalonRemove?: (selection,nextSource) =>void|Promise<void>
Defined in: package/ui/src/runtime/types.ts:31
Called after removal with the selection and resulting source.
Parameters
| Parameter | Type |
|---|---|
selection | EditorSelection |
nextSource | string |
Returns
void | Promise<void>
Inherited from
MermaidVisualEditorOptions.onRemove
onReset?
optionalonReset?: (nextSource) =>void|Promise<void>
Defined in: package/ui/src/runtime/types.ts:29
Called after Reset with the resulting source.
Parameters
| Parameter | Type |
|---|---|
nextSource | string |
Returns
void | Promise<void>
Inherited from
MermaidVisualEditorOptions.onReset
onSave?
optionalonSave?: (currentSource) =>void|Promise<void>
Defined in: package/ui/src/runtime/types.ts:27
Called by Save with the current source.
Parameters
| Parameter | Type |
|---|---|
currentSource | string |
Returns
void | Promise<void>
Inherited from
MermaidVisualEditorOptions.onSave
onSelectionChange?
optionalonSelectionChange?: (selection) =>void
Defined in: package/ui/src/runtime/types.ts:23
Called when the selection changes or clears.
Parameters
| Parameter | Type |
|---|---|
selection | EditorSelection | null |
Returns
void
Inherited from
MermaidVisualEditorOptions.onSelectionChange
portalContainer?
readonlyoptionalportalContainer?:PortalContainer
Defined in: package/ui/src/ui/MermaidEditor.tsx:73
Parent container for editor dialogs and popovers. When used inside a host modal, provide an element within that modal. The target must be in the regular DOM and in the document that loads the SDK stylesheet; Shadow DOM targets are unsupported.
Default
document.body
Example
import { useRef } from 'react';
import { MermaidEditor } from '@mermaid-editor-sdk/ui';
import '@mermaid-editor-sdk/ui/style.css';
function DiagramDialogContent({ source, setSource }: { source: string; setSource: (value: string) => void }) {
const dialogRef = useRef<HTMLDivElement>(null);
return <div ref={dialogRef} className="host-dialog-overlay">
<MermaidEditor value={source} onChange={setSource} portalContainer={dialogRef} />
</div>;
}
title?
readonlyoptionaltitle?:string
Defined in: package/ui/src/ui/MermaidEditor.tsx:52
Default shell heading.
Default
"Diagram"
value
readonlyvalue:string
Defined in: package/ui/src/ui/MermaidEditor.tsx:44
Mermaid source controlled by the host.