slate-schema v0.52.6
slate-schema
Slate plugin to do schema validation, the concept is based on Prosemirror schemas.
The schema describes the kind of nodes that may occur in the document, and the way they are nested. For example, it might say that the top-level node can contain one or more blocks, and that paragraph nodes can contain any number of inline nodes, with any marks applied to them.
Install
npm install slate-schema --save
Usage
import Schema from 'slate-schema'
const plugins = [
Schema({
document: {
nodes: {
except: ['text'],
min: 1,
fillWith: { kind: 'block', type: 'paragraph', nodes: [] }
}
},
paragraph: {
nodes: { only: ['text'] }
},
code_block: {
nodes: { only: ['text'] },
marks: { only: [] }
}
})
];
Schema Format
A schema is a map of type string to a spec to describe a node. A node spec can have two properties nodes
and marks
.
nodes
describe the allowed nested nodes; and marks
describe the styling marks allowed for nested text nodes.
Examples
This repository contains multiple example that might help you get a better understanding of the schema format:
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
9 years ago
9 years ago
9 years ago