Skip to the content
v1.0.1-beta.17

Node types

Every block in a document is a node. Each node type is a class that extends Node, and is known in the JSON format by its identifier, such as "text" or "table".

Properties every node has

PropertyMeaning
nodeIdA unique ID. Kept when the document is saved, and used by comments, links and collaboration.
type, typeNameThe JSON identifier, and the name shown to users
editor, parentThe editor the node is in, and the container node that holds it (null at the top level)
alignmentWhere the node sits when it is narrower than its container (Alignments.automatic, leading, middle, trailing)
directionDirections.automatic, leftToRight or rightToLeft
lineHeight, lineSpacingA multiple of the font's line height, and extra pixels between lines
borderTop, borderRight, borderBottom, borderLeftEach {visible, size, color}
borderTopLeftRadius and the other three cornersCorner radii, in pixels
backgroundImageA picture drawn behind the node
width, heightAn explicit size, for nodes that can be resized; 0 follows the content
lockedLocked nodes can't be edited, moved or deleted. Not saved. After changing it, call editor.refreshLocks() to show it.
fixedPart of the document's fixed structure, saved with the node. An add-on can lock fixed nodes; on its own it changes nothing.
suggestionProviderText suggestions for this node, ahead of the editor's. Not saved.
fontOptionsFont choices and formats for this node, in place of the editor's. Not saved.

Every node also has:

  • toJSON() and fromJSON(data);
  • toHTML(), toMarkdown() and toPlainText();
  • inspectorSections(), the node's settings in the inspector;
  • actions(), the items on the node's own toolbar.

Base package

Text — TextNode, "text"

A paragraph of styled text. The other text blocks extend it.

MemberMeaning
new TextNode(text)
textThe plain text. Setting it replaces the content and its styles.
contentThe text and its character styles, as RichText
fontName, fontSize, bold, italic, underlineThe paragraph's default formatting; a size of 0 follows the document
textAlignmentThe alignment of the text inside the node. Buttons and checkboxes, only as wide as their captions, move with alignment instead.

Heading — HeadingNode, "heading"

MemberMeaning
new HeadingNode(text, level)level is HeadingLevels.heading1 to heading6; the default is 2
level
anchorThe fragment identifier used for links to the heading and in exported HTML

List — ListNode, "list"

A bulleted, numbered or checklist list. Each item is a paragraph of the node's text, with its own nesting level.

MemberMeaning
new ListNode(text, type)Items are separated by "\n"; type is ListTypes.unordered, ordered or checklist
listType
itemCount, levelAt(item)The number of items, and one item's nesting level
changeLevel(delta)Indents (1) or outdents (-1) the items being worked on

The list commands are on the toolbar, and Ctrl/Command+Shift+7, 8 and 9 make numbered, bulleted and checklist lists. Ctrl/Command+] and [ indent and outdent.

Quote — QuoteNode, "quote"

A block quote with an optional citation.

Code — CodeBlockNode, "codeblock"

Preformatted code. language names the language for exports and highlighting, and tabWidth is the width of a tab in spaces.

Table — TableNode, "table"

MemberMeaning
new TableNode(rows, columns)
rows, columns
cell(row, column)A cell's text, as RichText; a cell can also hold nodes, in its nodes list
hasHeader, hasFooterMakes the first or last row a header or footer row
insertRow(at), removeRow(row), insertColumn(at), removeColumn(column)
mergeCells(row, column, rowCount, columnCount), splitCell(index)
textAlignmentThe alignment of text in cells whose own alignment is Automatic

Image — ImageNode, "image"

A picture with an optional caption. Pictures chosen from files or dropped on the editor are embedded in the document.

MemberMeaning
sourceURL, setURL(url)A picture loaded from an address
imageDataAn embedded picture, as Base64 without a data: prefix
captionThe caption text
displayWidth, displayHeightThe size it is drawn at; 0 is its natural size
fillModeHow it fills that size: ImageFillModes.fit, fill or stretch

Divider — DividerNode, "divider"

A horizontal rule. lineThickness is its thickness in pixels, 1 by default, and lineColor its color; Colors.empty uses the theme's border color. Typing --- on an empty line inserts one.

Unknown content — UnknownNode

A node whose type isn't registered, such as one from an add-on this page doesn't load. It shows a placeholder and saves its JSON back unchanged.

Add-on node types

Add-onClasses and JSON types
calloutsAlertNode "alert", with alertType (AlertTypes.info, success, warning, danger)
blocksPageBreakNode "pagebreak" (with accessibilityLabel, what screen readers announce for the break), TableOfContentsNode "toc", DetailsNode "details" (a collapsible section that holds nodes)
columnsColumnsNode "columns", columns that each hold text and nodes
rawcontentRawContentNode "rawcontent", HTML written into exports unchanged
mediaAudioNode "audio", VideoNode "video"
linkcardsBookmarkNode "bookmark", EmbedNode "embed"
datatableDataTableNode "datatable", a read-only table loaded from a REST API; see Data table
formsFormNode "form", LabelNode "label", TextFieldNode "textfield", TextAreaNode "textarea", CheckboxNode "checkbox", RadioGroupNode "radiogroup", DropdownNode "select", DatalistNode "datalist", ButtonNode "button"
stepsStepsNode "steps", numbered steps or a timeline, each step holding text and nodes; see Steps, timelines and tabs
tabsTabsNode "tabs", tabbed panels that each hold text and nodes; see Steps, timelines and tabs
attachmentsAttachmentNode "attachment", a file with a download button; see Files, galleries, maps and embeds
galleryGalleryNode "gallery", pictures as a grid or a carousel; see Files, galleries, maps and embeds
mapMapNode "map", a map of a place with a pin; see Files, galleries, maps and embeds
chartsChartNode "chart", a chart of a table in the document; see Charts
signatureSignatureNode "signature", a signature field; see Signatures

Each add-on's classes are exported by its module:

import {AlertNode, AlertTypes} from "./dist/addons/scriviamo.callouts.js"

let alert = new AlertNode("Back up first.")
alert.alertType = AlertTypes.warning
editor.addNode(alert)

Which types an editor offers

An editor starts with the node types registered when it is created, in their registered order. editor.nodeTypes is that list for one editor, and the Insert menu, the block type menu and command search offer the types in it. A type whose static insertable is false isn't offered for insertion, but still loads from JSON.