Node
Node is not a publicly accessible module, but instead an interface that Document, Block and Inline all implement.
Properties
key
keyString
A short-lived, unique identifier for the node.
By default, keys are not meant to be long-lived unique identifiers for nodes that you might store in a database, or elsewhere. They are meant purely to identify a node inside of a single Slate instance. For that reason, they are simply auto-incrementing strings. (eg. '0', '1', '2', ...)
If you want to make your keys uniqueness long-lived, you'll need to supply your own key generating function via the setKeyGenerator util.
nodes
nodesImmutable.List
A list of child nodes. Defaults to a list with a single text node child.
object
objectString
An immutable string value of 'document', 'block', 'inline' or 'text' for easily separating this node from Inline or Text nodes.
Computed Properties
text
textString
A concatenated string of all of the descendant Text nodes of this node.
Methods
filterDescendants
filterDescendantsfilterDescendants(iterator: Function) => List
Deeply filter the descendant nodes of a node by iterator.
findDescendant
findDescendantfindDescendant(iterator: Function) => Node|Void
Deeply find a descendant node by iterator.
getAncestors
getAncestorsgetAncestors(path: List|Array) => List|Void getAncestors(key: String) => List|Void
Get the ancestors of a descendant by path or key.
getBlocks
getBlocksgetBlocks() => List
Get all of the bottom-most Block node descendants.
getBlocksAtRange
getBlocksAtRangegetBlocksAtRange(range: Range) => List
Get all of the bottom-most Block nodes in a range.
getBlocksByType
getBlocksByTypegetBlocksByType(type: String) => List
Get all of the bottom-most Block nodes by type.
getChild
getChildgetChild(path: List|Array) => Node|Void getChild(key: String) => Node|Void
Get a child by path or key.
getClosest
getClosestgetClosest(path: List|Array, match: Function) => Node|Void getClosest(key: String, match: Function) => Node|Void
Get the closest parent node of a descendant node by path or key that matches a match function.
getClosestBlock
getClosestBlockgetClosestBlock(path: List|Array) => Node|Void getClosestBlock(key: String) => Node|Void
Get the closest Block node to a descendant node by path or key.
getClosestInline
getClosestInlinegetClosestInline(path: List|Array) => Node|Void getClosestInline(key: String) => Node|Void
Get the closest Inline node to a descendant node by path or key.
getClosestVoid
getClosestVoidgetClosestVoid(path: List|Array) => Node|Void getClosestVoid(key: String) => Node|Void
Get the closest void parent of a descendant node by path or key.
getCommonAncestor
getCommonAncestorgetCommonAncestor(path: List|Array) => Number getCommonAncestor(key: String) => Number
Get the lowest common ancestor of a descendant node by path or key.
getDepth
getDepthgetDepth(path: List|Array) => Number getDepth(key: String) => Number
Get the depth of a descendant node by path or key.
getDescendant
getDescendantgetDescendant(path: List|Array) => Node|Void getDescendant(key: String) => Node|Void
Get a descendant node by path or key.
getFirstText
getFirstTextgetFirstText() => Text|Void
Get the first child text node inside a node.
getFragmentAtRange
getFragmentAtRangegetFragmentAtRange(range: Range) => Document
Get a document fragment of the nodes in a range.
getFurthest
getFurthestgetFurthest(path: List|Array, iterator: Function) => Node|Null getFurthest(key: String, iterator: Function) => Node|Null
Get the furthest parent of a node by path or key that matches an iterator.
getFurthestAncestor
getFurthestAncestorgetFurthestAncestor(path: List|Array) => Node|Null getFurthestAncestor(key: String) => Node|Null
Get the furthest ancestor of a node by path or key.
getFurthestBlock
getFurthestBlockgetFurthestBlock(path: List|Array) => Node|Null getFurthestBlock(key: String) => Node|Null
Get the furthest block parent of a node by path or key.
getFurthestInline
getFurthestInlinegetFurthestInline(path: List|Array) => Node|Null getFurthestInline(key: String) => Node|Null
Get the furthest inline parent of a node by path or key.
getFurthestOnlyChildAncestor
getFurthestOnlyChildAncestorgetFurthestOnlyChildAncestor(path: List|Array) => Node|Null getFurthestOnlyChildAncestor(key: String) => Node|Null
Get the furthest ancestor of a node by path or key that has only one child.
getInlines
getInlinesgetInlines() => List
Get all of the top-most Inline nodes in a node.
getInlinesAtRange
getInlinesAtRangegetInlinesAtRange(range: Range) => List
Get all of the top-most Inline nodes in a range.
getInlinesByType
getInlinesByTypegetInlinesByType(type: string) => List
Get all of the top-most Inline nodes by type.
getLastText
getLastTextgetLastText() => Node|Void
Get the last child text node inside a node.
getMarks
getMarksgetMarks(range: Range) => Set
Get a set of all of the marks in a node.
getMarksAtRange
getMarksAtRangegetMarksAtRange(range: Range) => Set
Get a set of all of the marks in a range.
getMarksByType
getMarksByTypegetMarksByType(type: String) => Set
Get a set of all of the marks by type.
getNextBlock
getNextBlockgetNextBlock(path: List|Array) => Node|Void getNextBlock(key: String) => Node|Void
Get the next, bottom-most Block node after a descendant by path or key.
getNextNode
getNextNodegetNextNode(path: List|Array) => Node|Void getNextNode(key: String) => Node|Void
Get the next node in the tree of a descendant by path or key. This will not only check for siblings but instead move up the tree returning the next ancestor if no sibling is found.
getNextSibling
getNextSiblinggetNextSibling(path: List|Array) => Node|Void getNextSibling(key: String) => Node|Void
Get the next sibling of a descendant by path or key.
getNextText
getNextTextgetNextText(path: List|Array) => Node|Void getNextText(key: String) => Node|Void
Get the next Text node after a descendant by path or key.
getNode
getNodegetNode(path: List|Array) => Node|Void getNode(key: String) => Node|Void
Get a node in the tree by path or key.
getOffset
getOffsetgetOffset(path: List|Array) => Number getOffset(key: String) => Number
Get the text offset of a descendant in the tree by path or key.
getParent
getParentgetParent(path: List|Array) => Node|Void getParent(key: String) => Node|Void
Get the parent node of a descendant by path or key.
getPath
getPathgetPath(path: List|Array) => Node|Void getPath(key: String) => Node|Void
Get the path to a descendant by path or key.
getPreviousBlock
getPreviousBlockgetPreviousBlock(path: List|Array) => Node|Void getPreviousBlock(key: String) => Node|Void
Get the previous, bottom-most Block node before a descendant by path or key.
getPreviousNode
getPreviousNodegetPreviousNode(path: List|Array) => Node|Void getPreviousNode(key: String) => Node|Void
Get the previous node in the tree of a descendant by path or key. This will not only check for siblings but instead move up the tree returning the previous ancestor if no sibling is found.
getPreviousSibling
getPreviousSiblinggetPreviousSibling(path: List|Array) => Node|Void getPreviousSibling(key: String) => Node|Void
Get the previous sibling of a descendant by path or key.
getPreviousText
getPreviousTextgetPreviousText(path: List|Array) => Node|Void getPreviousText(key: String) => Node|Void
Get the previous Text node before a descendant by path or key.
getTextAtOffset
getTextAtOffsetgetTextAtOffset(offset: Number) => Text || Void
Get the Text node at an offset.
getTextDirection
getTextDirectiongetTextDirection() => String
Get the direction of the text content in the node.
getTexts
getTextsgetTexts(range: Range) => List
Get all of the Text nodes in a node.
getTextsAtRange
getTextsAtRangegetTextsAtRange(range: Range) => List
Get all of the Text nodes in a range.
hasChild
hasChildhasChild(path: List|Array) => Boolean hasChild(key: String) => Boolean
Check whether the node has a child node by path or key.
hasDescendant
hasDescendanthasDescendant(path: List|Array) => Boolean hasDescendant(key: String) => Boolean
Check whether the node has a descendant node by path or key.
hasNode
hasNodehasNode(path: List|Array) => Boolean hasNode(key: String) => Boolean
Check whether a node exists in the tree by path or key.
Last updated
Was this helpful?