1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 17:23:07 +01:00
slate/docs/guides/schemas.md
2016-08-14 15:51:07 -07:00

1.1 KiB

Schemas

Every Slate editor has a "schema" associated with it, which contains information about the structure of its content. It lets you specify how to render each different type of node. And for more advanced use cases it lets you enforce rules about what the content of the editor can and cannot be.

Rules

Slate schemas are built up of a set of rules. Every rule has a few properties:

{
  match: Function || Object,
  render: Component || Function || Object || String,
  decorate: Function,
  validate: Function || Object,
  transform: Function
}

Each of the properties will add certain functionality to the schema. For example,

Matches

For any schema rule to be applied, it has to match a node in the editor's content. The most basic way to do this is to match by kind and type. For example:




## Components

The most basic use of a schema is to define which React components should be rendered for each node in the editor. For example, you might want to