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
  • mark
  • object
  • Static Methods
  • Decoration.create
  • Decoration.createProperties
  • Decoration.fromJSON
  • Decoration.isDecoration
  • Instance Methods
  • toJSON
  • Mutating Methods
  • setMark
  1. Slate Core

Decoration

PreviousDataNextDocument

Last updated 5 years ago

import { Decoration } from 'slate'

A decoration is a range of the document that has a specific dynamically applied to it based on its content or some other external state. It is not actually reflected in the document's structure itself. This can be useful for cases like syntax highlighting, or search result highlighting.

Decorations implement the interface, but also contain a mark.

Properties

Decoration({
  anchor: Point,
  focus: Point,
  mark: Mark,
})

mark

Mark

The mark associated with the decoration.

object

String

A string with a value of 'decoration'.

Static Methods

Decoration.create

Decoration.create(properties: Object) => Decoration

Create a new Decoration instance with properties.

Decoration.createProperties

Decoration.createProperties(object: Object|Decoration) => Object

Create a new dictionary of range properties from an object.

Decoration.fromJSON

Decoration.fromJSON(object: Object) => Decoration

Create a range from a JSON object.

Decoration.isDecoration

Decoration.isDecoration(value: Any) => Boolean

Check whether a value is a Decoration.

Instance Methods

toJSON

toJSON() => Object

Return a JSON representation of the range.

Mutating Methods

setMark

setMark(mark: Mark) => Decoration

Return a new decoration with a new mark.

Mark
Range