Expand all

ve.dm.NodeFactory

Extends

Constructor

new ve.dm.NodeFactory() #

DataModel node factory.

Methods

canNodeContainContent(type) → {boolean} #

Check if a node can contain content.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

The node contains content

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node can contain content.

canNodeHaveChildren(type) → {boolean} #

Check if a node can have children.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

The node can have children

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node can have children.

canNodeHaveChildrenNotContent(type) → {boolean} #

Check if a node can have children but not content nor be content.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

The node can have children but not content nor be content

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node can have children but not content nor be content.

canNodeSerializeAsContent(type) → {boolean} #

Check if a node can be serialized into a content position

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

The node is content or can be round-tripped into a content position

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node can be serialized into a content position

canNodeTakeAnnotation(type, annotation) → {boolean} #

Check if node can take an annotation.

Parameters:

Name Type Description
type string

Node type

annotation ve.dm.Annotation

Annotation to test

Source:

Returns:

Node can take annotations of this type

Type
boolean

Throws:

Unknown node type

Type
Error
Check if node can take an annotation.

createFromElement(element, […args]) → {ve.dm.Model} #

Create a new item from a model element

Parameters:

Name Type Attributes Description
element Object

Model element

args any optional
repeatable

Arguments to pass to the constructor

Inherited from:
Source:

Returns:

Model constructed from element

Type
ve.dm.Model

Throws:

Element must have a .type property

Type
Error
Create a new item from a model element

doesNodeHandleOwnChildren(type) → {boolean} #

Check if the node handles its own children.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node handles its own children

Type
boolean

Throws:

Unknown node type

Type
Error
Check if the node handles its own children.

doesNodeHaveSignificantWhitespace(type) → {boolean} #

Check if the node has significant whitespace.

Can only be true if canContainContent is also true.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

The node has significant whitespace

Type
boolean

Throws:

Unknown node type

Type
Error
Check if the node has significant whitespace.

getChildNodeTypes(type) → {Array.<string>|null} #

Get allowed child node types for a node.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

List of node types allowed as children or null if any type is allowed

Type
Array.<string> | null

Throws:

Unknown node type

Type
Error
Get allowed child node types for a node.

getDataElement(type, attributes) → {Object} #

Get a document data element.

Parameters:

Name Type Description
type string

Node type

attributes Object

Node attributes, defaults will be used where needed

Source:

Returns:

Data element

Type
Object

Throws:

Unknown node type

Type
Error
Get a document data element.

getParentNodeTypes(type) → {Array.<string>|null} #

Get allowed parent node types for a node.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

List of node types allowed as parents or null if any type is allowed

Type
Array.<string> | null

Throws:

Unknown node type

Type
Error
Get allowed parent node types for a node.

getSuggestedParentNodeTypes(type) → {Array.<string>|null} #

Get suggested parent node types for a node.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

List of node types suggested as parents or null if any type is suggested

Type
Array.<string> | null

Throws:

Unknown node type

Type
Error
Get suggested parent node types for a node.

isMetaData(type) → {boolean} #

Check if a node is a meta item element

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node is meta data

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node is a meta item element

isNodeContent(type) → {boolean} #

Check if a node is content.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

The node is content

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node is content.

isNodeDeletable(type) → {boolean} #

Check if node is deletable.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node is internal

Type
boolean

Throws:

Unknown node type

Type
Error
Check if node is deletable.

isNodeFocusable(type) → {boolean} #

Check if the node is focusable.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node is focusable

Type
boolean

Throws:

Unknown node type

Type
Error
Check if the node is focusable.

isNodeInternal(type) → {boolean} #

Check if the node is internal.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node is internal

Type
boolean

Throws:

Unknown node type

Type
Error
Check if the node is internal.

isNodeUnwrappable(type) → {boolean} #

Check if a node is unwrappable.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node is unwrappable

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node is unwrappable.

isNodeWrapped(type) → {boolean} #

Check if a node has a wrapped element in the document data.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node has a wrapping element

Type
boolean

Throws:

Unknown node type

Type
Error
Check if a node has a wrapped element in the document data.

isRemovableMetaData(type) → {boolean} #

Check if a given type of meta item is removable

Parameters:

Name Type Description
type string

Meta item type

Source:

Returns:

The type is removable

Type
boolean

Throws:

Unknown item type

Type
Error
Check if a given type of meta item is removable

shouldIgnoreChildren(type) → {boolean} #

Check if the node's children should be ignored.

Parameters:

Name Type Description
type string

Node type

Source:

Returns:

Whether the node's children should be ignored

Type
boolean

Throws:

Unknown node type

Type
Error
Check if the node's children should be ignored.