Value
import { Value } from 'slate'A Value is the top-level representation of data in Slate, containing both a Document and a Selection. It's what you need to pass into the Slate <Editor> to render something onto the page.
Properties
Value({
document: Document,
selection: Selection,
data: Data,
decorations: List<Decoration>,
})data
dataData
An object containing arbitrary data for the value.
decorations
decorationsList<Decoration>
A list of ranges in the document with marks that aren't part of the content itself—like matches for the current search string.
document
documentDocument
The current document of the value.
object
objectString
A string with a value of 'value'.
selection
selectionSelection
The current selection of the value.
Computed Properties
These properties aren't supplied when creating a Value, but are instead computed based on the current document and selection.
{edge}Text
{edge}TextText
Get the leaf Text node at {edge}. Where {edge} is one of: anchor, focus, start or end.
{edge}Block
{edge}BlockBlock
Get the leaf Block node at {edge}. Where {edge} is one of: anchor, focus, start or end.
marks
marksSet
Get a set of the Marks in the current selection.
activeMarks
activeMarksSet
Get a subset of the Marks that are present in all the characters in the current selection. It can be used to determine the active/inactive state of toolbar buttons corresponding to marks, based on the usual rich text editing conventions.
blocks
blocksList
Get a list of the lowest-depth Block nodes in the current selection.
fragment
fragmentDocument
Get a Document fragment of the current selection.
inlines
inlinesList
Get a list of the lowest-depth Inline nodes in the current selection.
texts
textsList
Get a list of the Text nodes in the current selection.
Static Methods
Value.create
Value.createValue.create(properties: Object) => Value
Create a new Value instance with properties.
Value.fromJSON
Value.fromJSONValue.fromJSON(object: Object) => Value
Create a value from a JSON object.
Value.isValue
Value.isValueValue.isValue(any: Any) => Boolean
Returns a boolean if the passed in argument is a Value.
Instance Methods
toJSON
toJSONtoJSON() => Object
Returns a JSON representation of the value.
Last updated