Quick start
Rows become a chart. The first line may name its type:
bar
Month | Online | Retail
Jan | 42 | 30
Feb | 48 | 28Mermaid becomes a diagram:
flowchart LR
idea[Idea] --> draft[Draft]Press Escape, or Enter on an empty last line, to draw it.
What the text becomes
| Text in the box | Becomes | Read as |
|---|---|---|
Rows, with an optional type line such as bar | A chart | Writing a chart |
A Mermaid chart, such as pie or sankey | A chart | Mermaid, with its type and title from its header |
| Any other Mermaid diagram | A diagram | Writing a diagram |
| draw.io XML or BPMN XML, pasted | A diagram | Its source |
pieabove rows, such asDogs, 3, is a type line, not Mermaid.- The Node of the box is
diagramInput. The Commands below drive it from a toolbar of your own.
Writing a chart
A chart is written in the chart syntax: rows, and a first line that may name the type.
bar
Month | Online | Retail
Jan | 42 | 30- The first row is the header when it holds no number outside the first column.
- Without a type line, the chart takes
chart.defaultType. - Delimiters, numbers and quotes are on Chart syntax.
Writing a diagram
A diagram is written in its own language, kept as it is typed:
- Mermaid, such as
flowchart LRwith a lineA --> B. Its first line names the kind of diagram, as a type line does for a chart. See Diagrams. - draw.io XML or BPMN XML, pasted. They are drawn, not typed; see draw.io and BPMN.
Back into text
A chart or a Mermaid diagram opens in the box again with editChartAsText or
editDiagramAsText. Change its first line, and a chart becomes another type or a diagram.
Open a chart as text, then write flowchart LR and a line such as A --> B:
Keys in the box
| Key | In the Quick Input |
|---|---|
| Enter | A new line. On an empty last line, draws the chart or the diagram |
| Shift-Enter | A new line, also on an empty last line |
| Mod-Enter, Escape | Draws the chart or the diagram |
| Mod-Shift-A | Selects everything typed into the box |
| Mod-A | Still selects the whole document |
| Backspace | In an empty box, removes it |
| Enter after a type name | pie, bar … alone on the first line sets the chart type and stays as that line |
- Below a lone type line, the box shows example rows for that type until a row is typed.
When the box closes
- Moving the selection out of the box draws it as well.
- An empty box becomes an empty paragraph.
- Text that cannot be read keeps the box open, and
confirmDiagramInputreturnsfalse.
Commands
confirmDiagramInput
Turns the open Quick Input, or a table used as an input, into a chart or a diagram.
editor.commands.confirmDiagramInput()| Option | Type | Description |
|---|---|---|
pos | number | A position inside the input. Defaults to the selection |
- Mermaid diagram source, draw.io or BPMN XML becomes a diagram, when the
flowDiagramNode is in the Schema. detectDiagramInputdecides which.
Returns false when the text cannot be read.
setDiagramInputType
Sets the chart type the open input becomes. A first line that already names a type is rewritten to the new one, so the text and the box agree.
editor.commands.setDiagramInputType('bar')| Parameter | Type | Description |
|---|---|---|
type | ChartType | A built-in chart type or one registered with chartTypes |
setDiagramInputView
Switches the open input between the text box and a table, keeping what was typed.
editor.commands.setDiagramInputView('table')| Parameter | Type | Description |
|---|---|---|
view | 'chart-syntax' | 'table' | 'chart-syntax' for the text box, 'table' for a table |
The table view needs table Nodes in the Schema.
setDiagramInputDelimiter
Makes the open Quick Input split its text at one configured delimiter, instead of the first one it finds.
editor.commands.setDiagramInputDelimiter(';')| Parameter | Type | Description |
|---|---|---|
delimiter | string | null | One of the configured delimiters. null goes back to finding it |
- The choice lasts while the box is open.
- The chart it becomes remembers the delimiter it was split with.
Returns false without an open box or for a delimiter not configured.
editChartAsText
Turns a chart into a Quick Input with its data in the chart syntax.
editor.commands.editChartAsText()| Option | Type | Description |
|---|---|---|
pos | number | The chart's position. Defaults to the selected chart |
The chart's spec, Renderer and source come back when the box is confirmed.
Returns false for a chart whose linked source is read-only.
editDiagramAsText
Turns a Mermaid diagram into a Quick Input holding its source.
editor.commands.editDiagramAsText()| Option | Type | Description |
|---|---|---|
pos | number | The diagram's position. Defaults to the selected diagram |
- Confirming the box reads it as any text: Mermaid stays a diagram, rows after a type line
such as
barmake it a chart. - Title, description, view and node positions come back when it stays a diagram of the same kind, such as a flowchart.
Returns false for draw.io and BPMN, and for a diagram drawn from a table.
editChartAsTable
Turns a chart into a table of its data.
editor.commands.editChartAsTable()| Option | Type | Description |
|---|---|---|
pos | number | The chart's position. Defaults to the selected chart |
Moving the selection out of the table makes it a chart again.
Returns false for a read-only chart or without a table in the Schema.