mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 06:03:22 +08:00
docs: update content
This commit is contained in:
parent
1f064b8600
commit
65b52afd5a
@ -3,11 +3,11 @@ Congratulations! You’ve found our playground with a list of experiments. Be aw
|
||||
|
||||
## New
|
||||
* [Linter](/experiments/linter)
|
||||
* [Comments](/experiments/comments)
|
||||
* [Commands](/experiments/commands)
|
||||
* [Embeds](/experiments/embeds)
|
||||
* [Multiple editors](/experiments/multiple-editors)
|
||||
* [Details](/experiments/details)
|
||||
* [@tiptap/extension-slash-command?](/experiments/commands)
|
||||
* [@tiptap/extension-iframe?](/experiments/embeds)
|
||||
* [@tiptap/extension-toggle-list?](/experiments/details)
|
||||
* [@tiptap/extension-collaboration-annotation?](/experiments/comments)
|
||||
|
||||
## Waiting for approval
|
||||
* [@tiptap/extension-placeholder](/experiments/placeholder)
|
||||
|
@ -37,8 +37,27 @@ This will do the following:
|
||||
5. make the text editable (but that’s the default anyway), and
|
||||
6. disable the loading of [the default CSS](https://github.com/ueberdosis/tiptap-next/tree/main/packages/core/src/style.ts) (which is not much anyway).
|
||||
|
||||
## Configure extensions
|
||||
A lot of the extension can be configured, too. Add an `.configure()` to the extension and pass an object to it. The following example will disable the default heading levels 4, 5 and 6:
|
||||
## Nodes, marks and extensions
|
||||
Most features are packed into [nodes](/api/nodes), [marks](/api/marks) and [extensions](/api/extensions). Import what you need and pass them as an Array to the editor and you are good to go. Here is the minimal setup with only three extensions:
|
||||
|
||||
```js
|
||||
import { Editor } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
|
||||
new Editor({
|
||||
element: document.querySelector('.element'),
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
### Configure an extensions
|
||||
Most extensions can be configured. Add a `.configure()` to pass an object to it. The following example will disable the default heading levels 4, 5 and 6:
|
||||
|
||||
```js
|
||||
import { Editor } from '@tiptap/core'
|
||||
@ -60,4 +79,57 @@ new Editor({
|
||||
})
|
||||
```
|
||||
|
||||
Have a look at the documentation of the extension you’re using to learn more about their settings.
|
||||
Have a look at the documentation of the extension you use to learn more about their settings.
|
||||
|
||||
### Default extensions
|
||||
We have put together a few of the most common extensions and provide a `defaultExtensions()` helper to load them. Here is how you to use that:
|
||||
|
||||
```js
|
||||
import { Editor, defaultExtensions } from '@tiptap/starter-kit'
|
||||
|
||||
new Editor({
|
||||
extensions: defaultExtensions(),
|
||||
})
|
||||
```
|
||||
|
||||
And you can even pass configuration for all default extensions as an object. Just prefix the configuration with the extension name:
|
||||
|
||||
```js
|
||||
import { Editor, defaultExtensions } from '@tiptap/starter-kit'
|
||||
|
||||
new Editor({
|
||||
extensions: defaultExtensions({
|
||||
heading: {
|
||||
levels: [1, 2, 3]
|
||||
},
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
The `defaultExtensions()` function returns an array, so if you want to load them and add some custom extensions you could write it like that:
|
||||
|
||||
```js
|
||||
import { Editor, defaultExtensions } from '@tiptap/starter-kit'
|
||||
import Strike from '@tiptap/extension-strike'
|
||||
|
||||
new Editor({
|
||||
extensions: [
|
||||
...defaultExtensions(),
|
||||
Strike,
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
Don’t want to load a specific extension? Just filter it out:
|
||||
|
||||
```js
|
||||
import { Editor, defaultExtensions } from '@tiptap/starter-kit'
|
||||
|
||||
new Editor({
|
||||
extensions: [
|
||||
...defaultExtensions().filter(extension => extension.config.name !== 'history'),
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
You’ll probably see something like that in collaborative editing examples. The [`Collaboration`](/api/extensions/collaboration) comes with its own history extension, you need to remove the default [`History`](/api/extensions/history) extension to avoid conflicts.
|
||||
|
Loading…
Reference in New Issue
Block a user