@mermaid-editor-sdk/ui


@mermaid-editor-sdk/ui / SourceDocument

Class: SourceDocument

Defined in: package/headless/dist/source/source-document.d.ts:30

Constructors

Constructor

new SourceDocument(source, diagramType): SourceDocument

Defined in: package/headless/dist/source/source-document.d.ts:41

Analyzes source regions for safe mutations of the specified diagram type.

Parameters

ParameterTypeDescription
sourcestringMermaid source to inspect.
diagramTypeDiagramTypeDiagram type used to classify source regions.

Returns

SourceDocument

Properties

diagramType

readonly diagramType: DiagramType

Defined in: package/headless/dist/source/source-document.d.ts:34

Diagram type used to classify source regions.


regions

readonly regions: readonly SourceRegion[]

Defined in: package/headless/dist/source/source-document.d.ts:36

Source spans, including statements, comments, metadata, and opaque text.


source

readonly source: string

Defined in: package/headless/dist/source/source-document.d.ts:32

Original Mermaid source.

Methods

findUniqueEditableStatement()

findUniqueEditableStatement(statement): SourceRegion

Defined in: package/headless/dist/source/source-document.d.ts:51

Finds an editable statement and requires exactly one match.

Parameters

ParameterTypeDescription
statementstringExact statement text to find.

Returns

SourceRegion


replaceStatement()

replaceStatement(start, end, replacement): string

Defined in: package/headless/dist/source/source-document.d.ts:47

Replaces one safe flowchart node statement at the given source offsets.

Parameters

ParameterTypeDescription
startnumberInclusive start offset of the statement.
endnumberExclusive end offset of the statement.
replacementstringReplacement statement text.

Returns

string


serializeMutation()

serializeMutation(candidate): string

Defined in: package/headless/dist/source/source-document.d.ts:55

Serializes a candidate mutation while preserving protected source regions.

Parameters

ParameterTypeDescription
candidatestringCandidate Mermaid source after a mutation.

Returns

string