DocumentNode
Class defined in model/DocumentNode.js#29 inherits from

Base node type for document nodes.

Example

The following example shows how a new node type is defined.

class Todo extends TextBlock {}
Todo.define({
  type: 'todo',
  content: 'text',
  done: { type: 'bool', default: false }
})

The following data types are supported:

  • string bare metal string data type
  • text a string that carries annotations
  • number numeric values
  • bool boolean values
  • id a node id referencing another node in the document

Get the Document instance.

Returns
Document

Whether this node has a parent.

parent is a built-in property for implementing nested nodes.

Returns
Boolean
Returns
DocumentNode

the parent node

Checks whether this node has children.

Returns
Boolean

default: false

Get the index of a given child.

Returns
Number

default: -1

Get a child node at a given position.

Returns
DocumentNode

default: null

Get the number of children nodes.

Returns
Number

default: 0

Get the root node.

The root node is the last ancestor returned by a sequence of getParent() calls.

Returns
DocumentNode
Returns
Boolean

true if node is a block node (e.g. Paragraph, Figure, List, Table)

Returns
Boolean

true if node is a text node (e.g. Paragraph, Codebock)

Returns
Boolean

true if node is an annotation node (e.g. Strong)

Returns
Boolean

true if node is an inline node (e.g. Citation)

Returns
Boolean

true if node is a container annotation (e.g. multiparagraph comment)

isBlock
Property defined in model/DocumentNode.js#230

Declares a node to be treated as block-type node.

BlockNodes are considers the direct descendant of Container nodes.

isText
Property defined in model/DocumentNode.js#237

Declares a node to be treated as text-ish node.

isPropertyAnnotation
Property defined in model/DocumentNode.js#244

Declares a node to be treated as model/PropertyAnnotation.

isContainerAnnotation
Property defined in model/DocumentNode.js#251

Declares a node to be treated as model/ContainerAnnotation.

isInline
Property defined in model/DocumentNode.js#258

Declares a node to be treated as model/InlineNode.