This commit is contained in:
Philipp Kühn
2020-04-23 15:37:19 +02:00
parent 5a1a289953
commit 26aa34cc40

View File

@@ -6,4 +6,62 @@ This schema is *very* strict. You cant use any HTML-element or attribute that
For example if you paste something like `This is <strong>important</strong>` into tiptap and dont have registered any extension that handles `strong` tags, youll only see `This is important`.
## How a schema looks like
The most simple schema for a typical *ProseMirror* editor is looking something like that.
```js
{
nodes: {
document: {
content: 'block+',
},
paragraph: {
content: 'inline*',
group: 'block',
parseDOM: [{ tag: 'p' }],
toDOM: () => ['p', 0],
},
text: {
group: 'inline',
},
},
}
```
In tiptap we split each node into its own `Extension` class instead.
```js
class Document extends Node {
name = 'document'
schema() {
return {
content: 'block+',
}
}
}
class Paragraph extends Node {
name = 'paragraph'
schema() {
return {
content: 'inline*',
group: 'block',
parseDOM: [{ tag: 'p' }],
toDOM: () => ['p', 0],
}
}
}
class Text extends Node {
name = 'text'
schema() {
return {
group: 'inline',
}
}
}
```