improve the documentation

This commit is contained in:
Hans Pagel
2020-09-04 12:35:31 +02:00
parent c5c5957e48
commit c36ddaf8fc
4 changed files with 69 additions and 38 deletions

View File

@@ -0,0 +1,41 @@
# Get the underlying ProseMirror schema
There are a few use cases where you need to work with the underlying schema. Youll need that if youre using the tiptap collaborative text editing features or if you want to manually render your content as HTML.
## With an Editor
If you need this on the client side and need an editor instance anyway, its available through the editor:
```js
import { Editor } from '@tiptap/core'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
const editor = new Editor({
extensions: [
new Document,
new Paragraph,
new Text,
// add more extensions here
])
})
const schema = editor.schema
```
## Without an Editor
If you just want to have the schema *without* initializing an actual editor, you can use the `getSchema` helper function. It needs an array of available extensions and conveniently generates a ProseMirror schema for you:
```js
import { getSchema } from '@tiptap/core'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
const schema = getSchema([
new Document,
new Paragraph,
new Text,
// add more extensions here
])
```