Document
insertTextNode(options)⇒ object
| undefined
object
| undefined
Insert a text node in specified place of the document using an insert strategy based on the options object. The options object and all properties are optional. Return the created node only if using an existing transaction (tx).
tx: Optional TransactionDocument
mode: Insert node where: first, last, before or after
refNode: If insert mode is before or after a reference node is mandatory
text: Optional text content
type: Text style type, ie paragraph, preamble, etc
Parameters
options
Object
Required - Optional object with optional properties
Example
Example
insertBlockNode(options)⇒ object
| undefined
object
| undefined
Insert a block node in specified place of the document using an insert strategy based on the options object. The data property that defines the node is mandatory. All other properties are optional. (To insert a node the node type must be defined by a plugin and known to the Writer.) Return the created node only if using an existing transaction (tx).
data: Mandatory object describing the node, may or may not have an id
tx: Optional TransactionDocument
mode: Insert node where: first, last, before or after
refNode: If insert mode is before or after a reference node is mandatory
Parameters
options
Object
| string
Required - Optional object with optional properties
Example
Example
nodes(filter)⇒ array
array
Fetch all nodes in the document, optionally filtered by type
Parameters
filter
string
| null
null
Required - Optional filter returned nodes by type
Example
node(nodeId)⇒ Node
| null
Node
| null
Fetch single node from document by id
Parameters
nodeId
string
Example
triggerFetchResourceNode(node, info)
Triggers a fetch resource from a nodes url property. For example when node has properties that is only referenced through an external url.
Parameters
node
BlockNode
Required - The resource node
info
Object
Required - Object with information to created substance transaction
Example
getPreviousNode(nodeId)⇒ *
*
Retrieve the previous node. Uses the focused surface to get all nodes in that surface/container and then returns the previous node from the one sent in
Parameters
nodeId
string
deleteNode(name, node, options)
Deletes a node from the document. Triggers a 'document:changed' event to all document:changed listeners except the plugin making the change.
Parameters
name
string
Required - Plugin name
node
object
Required - Node to delete, must contain an id
options
object
Required - Optional options object. Set replaceWithDefaultTextNode to true to replace node with default text node
Example
getDocumentNodes()⇒ Array
Array
Deprecated
Get all nodes in the document