1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-20 14:11:35 +02:00

update docs

This commit is contained in:
Ian Storm Taylor
2017-10-17 20:30:11 -07:00
parent 204f491b6b
commit 68e4e090f0
3 changed files with 84 additions and 1 deletions

36
docs/concepts/schemas.md Normal file
View File

@@ -0,0 +1,36 @@
# 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:
```js
{
match: Function || Object,
render: Component || Function || Object || String,
decorate: Function,
validate: Function || Object,
change: 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:
```js
## 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
```