TheSunny
doc-ios
doc-ios
  • 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
    • Changes
    • Data Model
    • Plugins
    • Rendering
    • Schemas
  • General
    • Plugins
    • Resources
    • Contributing
    • Changelog
    • FAQ
  • Slate Core
    • Block
    • Change
    • Character
    • Data
    • Document
    • Inline
    • Mark
    • Node
    • Operation
    • Range
    • Schema
    • Text
    • Value
    • setKeyGenerator
    • resetKeyGenerator
  • Slate React
    • Editor
    • Plugins
    • Custom Nodes
    • Core Plugins
    • cloneFragment
    • findDOMNode
    • findDOMRange
    • findNode
    • findRange
    • getEventRange
    • getEventTransfer
    • setEventTransfer
  • Other Packages
    • slate-html-serializer
    • slate-hyperscript
    • slate-plain-serializer
    • slate-prop-types
    • slate-schema-violations
    • slate-simulator
  • Contributing
    • iOS Development Guide
Powered by GitBook
On this page
  • Properties
  • data
  • decorations
  • document
  • history
  • object
  • schema
  • selection
  • Computed Properties
  • {edge}Text
  • {edge}Block
  • marks
  • activeMarks
  • blocks
  • fragment
  • inlines
  • texts
  • characters
  • hasUndos
  • hasRedos
  • Range-like Properties
  • {edge}Key
  • {edge}Offset
  • isBackward
  • isBlurred
  • isCollapsed
  • isExpanded
  • isFocused
  • isForward
  • isEmpty
  • Static Methods
  • Value.create
  • Value.fromJSON
  • Value.isValue
  • Instance Methods
  • change
  • toJSON
  1. Slate Core

Value

PreviousTextNextsetKeyGenerator

Last updated 7 years ago

import { Value } from 'slate'

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

All changes to the document and selection are also performed through the value object, so that they can stay in sync, and be propagated to its internal history of undo/redo value.

For convenience, in addition to changes, many of the selection and document properties are exposed as proxies on the Value object.

Properties

Value({
  document: Document,
  selection: Range,
  history: History,
  schema: Schema,
  data: Data,
  decorations: List<Ranges>|Null,
})

data

Data

An object containing arbitrary data for the value.

decorations

List<Ranges>|Null

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.

history

History

An object that stores the history of changes.

object

String

A string with a value of 'value'.

schema

Schema

An object representing the schema of the value's document.

selection

Range

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

characters

List

hasUndos

Boolean

Whether there are undoable snapshots to revert to in the history.

hasRedos

Boolean

Whether there are redoable snapshots to revert to in the history.

Range-like Properties

{edge}Key

String

Get the current key at an {edge}. Where {edge} is one of: anchor, focus, start or end.

{edge}Offset

Number

Get the current offset at an {edge}. Where {edge} is one of: anchor, focus, start or end.

isBackward

Boolean

Whether the current selection is backward.

isBlurred

Boolean

Whether the current selection is blurred.

isCollapsed

Boolean

Whether the current selection is collapsed.

isExpanded

Boolean

Whether the current selection is expanded.

isFocused

Boolean

Whether the current selection is focused.

isForward

Boolean

Whether the current selection is forward.

isEmpty

Boolean

Whether the current selection is empty.

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

change

change() => Change

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.

Get a list of the objects in the current selection.

These properties are exact proxies of the selection equivalents.

Create a new that acts on the current value.

Document
Range
<Editor>
Text
Block
Marks
Marks
Block
Document
Inline
Text
Character
Range
Change