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
  • Key Utils
  • KeyUtils.create
  • KeyUtils.resetGenerator
  • KeyUtils.setGenerator
  1. Slate Core

Utils

import { KeyUtils } from 'slate'

Utility functions that ship with Slate that may be useful for certain use cases.

Key Utils

KeyUtils.create

create() => String

Create a new key using the current key generator.

KeyUtils.resetGenerator

resetGenerator() => Void

Resets Slate's internal key generating function to its default state. This is useful for server-side rendering, or anywhere you want to ensure fresh, deterministic creation of keys.

KeyUtils.setGenerator

setGenerator(generator: Function) => Void

Allows you to specify your own key generating function, instead of using Slate's built-in default generator which simply uses auto-incrementing number strings. (eg. '0', '1', '2', ...)

This will act globally on all uses of the Slate dependency.

PreviousTextNextValue

Last updated 5 years ago