DocumentNode
Class defined in model/DocumentNode.js#28 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.schema = {
  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

Get the root node.

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

Returns
DocumentNode

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

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 inline node (e.g. Citation)

isBlock
Property defined in model/DocumentNode.js#211

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#218

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

isPropertyAnnotation
Property defined in model/DocumentNode.js#225

Declares a node to be treated as model/PropertyAnnotation.

isContainerAnnotation
Property defined in model/DocumentNode.js#232

Declares a node to be treated as model/ContainerAnnotation.

isInline
Property defined in model/DocumentNode.js#239

Declares a node to be treated as model/InlineNode.