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
  • object
  • nodes
  • Computed Properties
  • text
  • Static Methods
  • Document.create
  • Document.fromJSON
  • Document.isDocument
  • Node Methods
  • Instance Methods
  • toJSON
  1. Slate Core

Document

PreviousDecorationNextEditor

Last updated 5 years ago

import { Document } from 'slate'

The top-level node in Slate's document model.

Documents are made up of block nodes, inline nodes, and text nodes—just like in the DOM. Note that direct descendants of a document node have to be block nodes.

In some places, you'll see mention of "fragments", which are also Document objects, just that aren't attached to the main Value. For example, when cutting-and-pasting a selection of content, that content will be referred to as a document "fragment".

Properties

Document({
  nodes: Immutable.List<Node>,
})

data

Immutable.Map

Arbitrary data associated with the document. Defaults to an empty Map.

object

String

An immutable string value of 'document' for easily separating this node from , or nodes.

nodes

Immutable.List

A list of child nodes.

Computed Properties

text

String

Static Methods

Document.create

Document.create(properties: Object) => Document

Create a document from a plain JavaScript object of properties.

Document.fromJSON

Document.fromJSON(object: Object) => Document

Create a document from a JSON object.

Document.isDocument

Document.isDocument(maybeDocument: Any) => Boolean

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

Node Methods

Instance Methods

toJSON

toJSON() => Object

Returns a JSON representation of the document.

A concatenated string of all of the descendant nodes of this node.

Documents implement the interface. For information about all of the node methods, see the .

Block
Inline
Text
Text
Node
Node reference