@mermaid-editor-sdk/headless / SourceDocument
Class: SourceDocument
Defined in: source/source-document.ts:91
Constructors
Constructor
new SourceDocument(
source,diagramType):SourceDocument
Defined in: source/source-document.ts:103
Analyzes source regions for safe mutations of the specified diagram type.
Parameters
| Parameter | Type | Description |
|---|---|---|
source | string | Mermaid source to inspect. |
diagramType | DiagramType | Diagram type used to classify source regions. |
Returns
SourceDocument
Properties
diagramType
readonlydiagramType:DiagramType
Defined in: source/source-document.ts:95
Diagram type used to classify source regions.
regions
readonlyregions: readonlySourceRegion[]
Defined in: source/source-document.ts:97
Source spans, including statements, comments, metadata, and opaque text.
source
readonlysource:string
Defined in: source/source-document.ts:93
Original Mermaid source.
Methods
findUniqueEditableStatement()
findUniqueEditableStatement(
statement):SourceRegion
Defined in: source/source-document.ts:137
Finds an editable statement and requires exactly one match.
Parameters
| Parameter | Type | Description |
|---|---|---|
statement | string | Exact statement text to find. |
Returns
replaceStatement()
replaceStatement(
start,end,replacement):string
Defined in: source/source-document.ts:116
Replaces one safe flowchart node statement at the given source offsets.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | number | Inclusive start offset of the statement. |
end | number | Exclusive end offset of the statement. |
replacement | string | Replacement statement text. |
Returns
string
serializeMutation()
serializeMutation(
candidate):string
Defined in: source/source-document.ts:148
Serializes a candidate mutation while preserving protected source regions.
Parameters
| Parameter | Type | Description |
|---|---|---|
candidate | string | Candidate Mermaid source after a mutation. |
Returns
string