Slate
ExamplesGitHubSlack
v0.47
v0.47
  • Introduction
  • Walkthroughs
    • Installing Slate
    • Adding Event Handlers
    • Defining Custom Block Nodes
    • Applying Custom Formatting
    • Using Plugins
    • Saving to a Database
    • Saving and Loading HTML Content
  • Guides
    • Commands & Queries
    • Data Model
    • Plugins
    • Rendering
    • Schemas
  • General
    • Plugins
    • Resources
    • Contributing
    • Changelog
    • FAQ
    • Glossary
  • Slate Core
    • Block
    • Commands
    • Data
    • Decoration
    • Document
    • Editor
    • Inline
    • Mark
    • Node
    • Operation
    • Plugins
    • Point
    • Range
    • Schema
    • Selection
    • Text
    • Utils
    • Value
  • Slate React
    • Editor
    • Plugins
    • Rendering
    • Utils
  • Other Packages
    • slate-html-serializer
    • slate-hyperscript
    • slate-plain-serializer
    • slate-prop-types
Powered by GitBook
On this page
  • Properties
  • data
  • decorations
  • document
  • object
  • selection
  • Computed Properties
  • {edge}Text
  • {edge}Block
  • marks
  • activeMarks
  • blocks
  • fragment
  • inlines
  • texts
  • Static Methods
  • Value.create
  • Value.fromJSON
  • Value.isValue
  • Instance Methods
  • toJSON
  1. Slate Core

Value

PreviousUtilsNextEditor

Last updated 5 years ago

import { Value } from 'slate'

A Value is the top-level representation of data in Slate, containing both a and a . It's what you need to pass into the Slate to render something onto the page.

Properties

Value({
  document: Document,
  selection: Selection,
  data: Data,
  decorations: List<Decoration>,
})

data

Data

An object containing arbitrary data for the value.

decorations

List<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

Document

The current document of the value.

object

String

A string with a value of 'value'.

selection

Selection

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

Text

{edge}Block

Block

marks

Set

activeMarks

Set

blocks

List

fragment

Document

inlines

List

texts

List

Static Methods

Value.create

Value.create(properties: Object) => Value

Create a new Value instance with properties.

Value.fromJSON

Value.fromJSON(object: Object) => Value

Create a value from a JSON object.

Value.isValue

Value.isValue(any: Any) => Boolean

Returns a boolean if the passed in argument is a Value.

Instance Methods

toJSON

toJSON() => Object

Returns a JSON representation of the value.

Get the leaf node at {edge}. Where {edge} is one of: anchor, focus, start or end.

Get the leaf node at {edge}. Where {edge} is one of: anchor, focus, start or end.

Get a set of the in the current selection.

Get a subset of the 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.

Get a list of the lowest-depth nodes in the current selection.

Get a fragment of the current selection.

Get a list of the lowest-depth nodes in the current selection.

Get a list of the nodes in the current selection.

Document
Selection
<Editor>
Text
Block
Marks
Marks
Block
Document
Inline
Text