docs: update content
This commit is contained in:
@@ -141,4 +141,4 @@ Have a look at all of the core commands listed below. They should give you a goo
|
|||||||
## Add your own commands
|
## Add your own commands
|
||||||
All extensions can add additional commands (and most do), check out the specific [documentation for the provided nodes](/api/nodes), [marks](/api/marks), and [extensions](/api/extensions) to learn more about those.
|
All extensions can add additional commands (and most do), check out the specific [documentation for the provided nodes](/api/nodes), [marks](/api/marks), and [extensions](/api/extensions) to learn more about those.
|
||||||
|
|
||||||
Of course, you can [add your custom extensions](/guide/build-custom-extensions) with custom commands aswell.
|
Of course, you can [add your custom extensions](/guide/build-extensions) with custom commands aswell.
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ new Editor({
|
|||||||
| `null` | Disables autofocus. |
|
| `null` | Disables autofocus. |
|
||||||
|
|
||||||
### Enable input rules
|
### Enable input rules
|
||||||
By default, tiptap enables all [input rules](/guide/build-custom-extensions/#input-rules). With `enableInputRules` you can disable that.
|
By default, tiptap enables all [input rules](/guide/build-extensions/#input-rules). With `enableInputRules` you can disable that.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { Editor } from '@tiptap/core'
|
import { Editor } from '@tiptap/core'
|
||||||
@@ -115,7 +115,7 @@ new Editor({
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Enable paste rules
|
### Enable paste rules
|
||||||
By default, tiptap enables all [paste rules](/guide/build-custom-extensions/#paste-rules). With `enablePasteRules` you can disable that.
|
By default, tiptap enables all [paste rules](/guide/build-extensions/#paste-rules). With `enablePasteRules` you can disable that.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { Editor } from '@tiptap/core'
|
import { Editor } from '@tiptap/core'
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const editor = new Editor({
|
|||||||
],
|
],
|
||||||
```
|
```
|
||||||
|
|
||||||
Learn [more about custom extensions in our guide](/guide/build-custom-extensions).
|
Learn [more about custom extensions in our guide](/guide/build-extensions).
|
||||||
|
|
||||||
### ProseMirror plugins
|
### ProseMirror plugins
|
||||||
ProseMirror has a fantastic eco system with many amazing plugins. If you want to use one of them, you can register them with tiptap like that:
|
ProseMirror has a fantastic eco system with many amazing plugins. If you want to use one of them, you can register them with tiptap like that:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Build custom extensions
|
# Build extensions
|
||||||
|
|
||||||
## toc
|
## toc
|
||||||
|
|
||||||
@@ -354,6 +354,37 @@ const CustomStrike = Strike.extend({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Events
|
||||||
|
You can even move your [event listeners](/api/events) to a separate extension. Here is an example with listeners for all events:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Extension } from '@tiptap/core'
|
||||||
|
|
||||||
|
const CustomExtension = Extension.create({
|
||||||
|
onCreate() {
|
||||||
|
// The editor is ready.
|
||||||
|
},
|
||||||
|
onUpdate() {
|
||||||
|
// The content has changed.
|
||||||
|
},
|
||||||
|
onSelection() {
|
||||||
|
// The selection has changed.
|
||||||
|
},
|
||||||
|
onTransaction({ transaction }) {
|
||||||
|
// The editor state has changed.
|
||||||
|
},
|
||||||
|
onFocus({ event }) {
|
||||||
|
// The editor is focused.
|
||||||
|
},
|
||||||
|
onBlur({ event }) {
|
||||||
|
// The editor isn’t focused anymore.
|
||||||
|
},
|
||||||
|
onDestroy() {
|
||||||
|
// The editor is being destroyed.
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
### Node views (Advanced)
|
### Node views (Advanced)
|
||||||
For advanced use cases, where you need to execute JavaScript inside your nodes, for example to render a sophisticated link preview, you need to learn about node views.
|
For advanced use cases, where you need to execute JavaScript inside your nodes, for example to render a sophisticated link preview, you need to learn about node views.
|
||||||
|
|
||||||
@@ -28,7 +28,8 @@ p {
|
|||||||
## Option 2: Add custom classes
|
## Option 2: Add custom classes
|
||||||
Most extensions have a `class` option, which you can use to add a custom CSS class to the HTML tag.
|
Most extensions have a `class` option, which you can use to add a custom CSS class to the HTML tag.
|
||||||
|
|
||||||
Most extensions allow you to add attributes to the rendered HTML through the `HTMLAttributes` configuration. You can use that to add a custom class (or any other attribute):
|
### Extensions
|
||||||
|
Most extensions allow you to add attributes to the rendered HTML through the `HTMLAttributes` option. You can use that to add a custom class (or any other attribute). That’s also very helpful, when you work with [Tailwind CSS](https://tailwindcss.com/).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
new Editor({
|
new Editor({
|
||||||
@@ -58,6 +59,19 @@ The rendered HTML will look like that:
|
|||||||
|
|
||||||
If there are already classes defined by the extensions, your classes will be added.
|
If there are already classes defined by the extensions, your classes will be added.
|
||||||
|
|
||||||
|
### Editor
|
||||||
|
You can even pass classes to the element which contains the editor like that:
|
||||||
|
|
||||||
|
```js
|
||||||
|
new Editor({
|
||||||
|
editorProps: {
|
||||||
|
attributes: {
|
||||||
|
class: 'prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## Option 3: Customize the HTML
|
## Option 3: Customize the HTML
|
||||||
You can even customize the markup for every extension. This will make a custom bold extension that doesn’t render a `<strong>` tag, but a `<b>` tag:
|
You can even customize the markup for every extension. This will make a custom bold extension that doesn’t render a `<strong>` tag, but a `<b>` tag:
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ const CustomExtension = Node.create({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Read more about [all the nifty details building custom extensions](/guide/build-custom-extensions) in our guide.
|
Read more about [all the nifty details building custom extensions](/guide/build-extensions) in our guide.
|
||||||
|
|
||||||
### Renamed settings and methods
|
### Renamed settings and methods
|
||||||
[We renamed a lot of settings and methods](/api/editor). Hopefully you can migrate to the new API with search & replace. Here is a list of what changed:
|
[We renamed a lot of settings and methods](/api/editor). Hopefully you can migrate to the new API with search & replace. Here is a list of what changed:
|
||||||
|
|||||||
@@ -47,12 +47,12 @@
|
|||||||
- title: Create a toolbar
|
- title: Create a toolbar
|
||||||
link: /guide/create-a-toolbar
|
link: /guide/create-a-toolbar
|
||||||
draft: true
|
draft: true
|
||||||
- title: Add custom styling
|
- title: Custom styling
|
||||||
link: /guide/custom-styling
|
link: /guide/custom-styling
|
||||||
- title: Store content
|
- title: Store content
|
||||||
link: /guide/store-content
|
link: /guide/store-content
|
||||||
- title: Build custom extensions
|
- title: Build extensions
|
||||||
link: /guide/build-custom-extensions
|
link: /guide/build-extensions
|
||||||
- title: Define node views
|
- title: Define node views
|
||||||
link: /guide/node-views
|
link: /guide/node-views
|
||||||
draft: true
|
draft: true
|
||||||
|
|||||||
Reference in New Issue
Block a user