Point
import { Point } from 'slate'A point in a Slate Document. Points in Slate are inspired by the DOM Range API, with terms like "offset".
Properties
Point({
key: String,
path: List,
offset: Number,
})key
keyString
The key of the text node at the point's point.
path
pathList
The path to the text node at the point's point.
object
objectString
A string with a value of 'point'.
offset
offsetNumber
The number of characters from the start of the text node at the point's point.
Computed Properties
isSet
isSetBoolean
Whether the key, path and offset of a point is not null.
isUnset
isUnsetBoolean
Whether any of the key, path or offset of a point is null.
Static Methods
Point.create
Point.createPoint.create(properties: Object|Point) => Point
Create a new Point with properties.
Point.createProperties
Point.createPropertiesPoint.createProperties(object: Object|Point) => Object
Create a new dictionary of point properties from an object.
Point.fromJSON
Point.fromJSONPoint.fromJSON(object: Object) => Point
Create a point from a JSON object.
Point.isPoint
Point.isPointPoint.isPoint(value: Any) => Boolean
Check whether a value is a Point.
Instance Methods
toJSON
toJSONtoJSON() => Object
Return a JSON representation of the point.
Checking Methods
isAfterRange
isAfterRangeisAfterRange(range: Range) => Boolean
Determine whether the point is after a range.
isAtEndOfRange
isAtEndOfRangeisAtEndOfRange(range: Range) => Boolean
Determine whether the point is at the end of a range.
isAtStartOfRange
isAtStartOfRangeisAtStartOfRange(range: Range) => Boolean
Determine whether the point is at the start of a range.
isBeforeRange
isBeforeRangeisBeforeRange(range: Range) => Boolean
Determine whether the point is before a range.
isInRange
isInRangeisInRange(range: Range) => Boolean
Determine whether the point is inside a range.
isAtEndOfNode
isAtEndOfNodeisAtEndOfNode(node: Node) => Boolean
Determine whether the point is at the end of a node.
isAtStartOfNode
isAtStartOfNodeisAtStartOfNode(node: Node) => Boolean
Determine whether the point is at the start of a node.
isInNode
isInNodeisInNode(node: Node) => Boolean
Determine whether a point is inside a node.
Mutating Methods
moveBackward
moveBackwardmoveBackward(n: Number) => Point
Return a new point with its offset moved backwards by n characters.
moveForward
moveForwardmoveForward(n: Number) => Point
Return a new point with its offset moved forwards by n characters.
moveTo
moveTomoveTo(path: List, offset: Number) => Point moveTo(key: String, offset: Number) => Point moveTo(offset: Number) => Point
Return a new point with its path, key and offset set to new values.
🤖 When using
point.moveTo, since the point isn't aware of the document, it's possible it will become "unset" if the path or key changes and need to be re-normalized relative to the document usingpoint.normalize(document).
moveToEndOfNode
moveToEndOfNodemoveToEndOfNode(node: Node) => Point
Return a new point at the end of a node.
🤖 This method may need to be followed by
point.normalize(document), likemoveTo.
moveToStartOfNode
moveToStartOfNodemoveToStartOfNode(node: Node) => Point
Return a new point at the start of a node.
🤖 This method may need to be followed by
point.normalize(document), likemoveTo.
normalize
normalizenormalize(node: Node) => Point
Normalize the point relative to a node, ensuring that its key and path are in sync, that its offset is valid, and that it references a leaf text node.
setKey
setKeysetKey(key: String|Null) => Point
Return a new point with a new key.
setOffset
setOffsetsetOffset(offset: Number|Null) => Point
Return a new point with a new offset.
setPath
setPathsetPath(path: List|Array|Null) => Point
Return a new point with a new path.
unset
unsetunset() => Point
Return a new point with the key, path, and offset all set to null.
Last updated