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
  • key
  • object
  • nodes
  • type
  • Computed Properties
  • text
  • Static Methods
  • Block.create
  • Block.createList
  • Block.fromJSON
  • Block.isBlock
  • Node Methods
  • Instance Methods
  • toJSON
  1. Slate Core

Block

PreviousGlossaryNextCommands

Last updated 5 years ago

import { Block } from 'slate'

A block node in a Slate . Block nodes implement the interface.

Block nodes may contain nested block nodes, inline nodes, and text nodes—just like in the DOM. They always contain at least one text node child.

Properties

Block({
  data: Data,
  key: String,
  nodes: Immutable.List<Node>,
  type: String
})

data

Immutable.Map

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

key

String

A unique identifier for the node.

object

String

nodes

Immutable.List

A list of child nodes. Defaults to a list with a single text node child.

type

String

The custom type of the node (eg. blockquote or list-item).

Computed Properties

text

String

Static Methods

Block.create

Block.create(properties: Object) => Block

Create a block from a plain JavaScript object of properties.

Block.createList

Block.createList(array: Array) => List

Create a list of block nodes from a plain JavaScript array.

Block.fromJSON

Block.fromJSON(object: Object) => Block

Create a block from a JSON object.

Block.isBlock

Block.isBlock(maybeBlock: Any) => Boolean

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

Node Methods

Instance Methods

toJSON

toJSON() => Object

Returns a JSON representation of the block.

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

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

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

Document
Node
Inline
Text
Text
Node
Node reference