docs: use regular case for Tiptap

This commit is contained in:
Hans Pagel
2021-10-19 22:30:45 +02:00
parent 3fe97621e7
commit f45c8d0ca7
77 changed files with 203 additions and 203 deletions

View File

@@ -5,11 +5,11 @@ tableOfContents: true
# Schema
## Introduction
Unlike many other editors, tiptap is based on a [schema](https://prosemirror.net/docs/guide/#schema) that defines how your content is structured. That enables you to define the kind of nodes that may occur in the document, its attributes and the way they can be nested.
Unlike many other editors, Tiptap is based on a [schema](https://prosemirror.net/docs/guide/#schema) that defines how your content is structured. That enables you to define the kind of nodes that may occur in the document, its attributes and the way they can be nested.
This schema is *very* strict. You cant use any HTML element or attribute that is not defined in your schema.
Let me give you one example: If you paste something like `This is <strong>important</strong>` into tiptap, but dont have any extension that handles `strong` tags, youll only see `This is important` without the strong tags.
Let me give you one example: If you paste something like `This is <strong>important</strong>` into Tiptap, but dont have any extension that handles `strong` tags, youll only see `This is important` without the strong tags.
## How a schema looks like
When youll work with the provided extensions only, you dont have to care that much about the schema. If youre building your own extensions, its probably helpful to understand how the schema works. Lets look at the most simple schema for a typical ProseMirror editor:
@@ -36,10 +36,10 @@ When youll work with the provided extensions only, you dont have to care t
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:
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:
```js
// the tiptap schema API
// the Tiptap schema API
import { Node } from '@tiptap/core'
const Document = Node.create({
@@ -294,7 +294,7 @@ Mark.create({
```
## 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.
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.
### Option 1: With an Editor
If you need this on the client side and need an editor instance anyway, its available through the editor: