[BREAKING CHANGE] change the default document type to doc

This commit is contained in:
Hans Pagel
2021-01-28 11:58:10 +01:00
parent a885669929
commit 62f42a229f
10 changed files with 11 additions and 13 deletions

View File

@@ -32,7 +32,7 @@ When youll work with the provided extensions only, you dont have to care t
}
```
We register three nodes here. `document`, `paragraph` and `text`. `document` is the root node which allows one or more block nodes as children (`content: 'block+'`). Since `paragraph` is in the group of block nodes (`group: 'block'`) our document can only contain paragraphs. Our paragraphs allow zero or more inline nodes as children (`content: 'inline*'`) so there can only be `text` in it. `parseDOM` defines how a node can be parsed from pasted HTML. `toDOM` defines how it will be rendered in the DOM.
We register three nodes here. `doc`, `paragraph` and `text`. `doc` is the root node which allows one or more block nodes as children (`content: 'block+'`). Since `paragraph` is in the group of block nodes (`group: 'block'`) our document can only contain paragraphs. Our paragraphs allow zero or more inline nodes as children (`content: 'inline*'`) so there can only be `text` in it. `parseDOM` defines how a node can be parsed from pasted HTML. `toDOM` defines how it will be rendered in the DOM.
In tiptap every node, mark and extension is living in its own file. This allows us to split the logic. Under the hood the whole schema will be merged together:
@@ -41,7 +41,7 @@ In tiptap every node, mark and extension is living in its own file. This allows
import { Node } from '@tiptap/core'
const Document = Node.create({
name: 'document',
name: 'doc',
topNode: true,
content: 'block+',
})