update docs

This commit is contained in:
Philipp Kühn 2021-03-09 21:25:30 +01:00
parent bf357dd7cb
commit b5ebf27789

View File

@ -10,22 +10,25 @@ You can define your event listeners on a new editor instance right-away:
```js ```js
const editor = new Editor({ const editor = new Editor({
onCreate() { onCreate({ editor }) {
// The editor is ready. // The editor is ready.
}, },
onUpdate() { onUpdate({ editor }) {
// The content has changed. // The content has changed.
}, },
onSelection() { onSelectionUpdate({ editor }) {
// The selection has changed. // The selection has changed.
}, },
onTransaction({ transaction }) { onViewUpdate({ editor }) {
// The view has changed.
},
onTransaction({ editor, transaction }) {
// The editor state has changed. // The editor state has changed.
}, },
onFocus({ event }) { onFocus({ editor, event }) {
// The editor is focused. // The editor is focused.
}, },
onBlur({ event }) { onBlur({ editor, event }) {
// The editor isnt focused anymore. // The editor isnt focused anymore.
}, },
onDestroy() { onDestroy() {
@ -39,31 +42,31 @@ Or you can register your event listeners on a running editor instance:
### Bind event listeners ### Bind event listeners
```js ```js
editor.on('create', () => { editor.on('create', ({ editor }) => {
// The editor is ready. // The editor is ready.
} }
editor.on('update', () => { editor.on('update', ({ editor }) => {
// The content has changed. // The content has changed.
} }
editor.on('selectionUpdate', () => { editor.on('selectionUpdate', ({ editor }) => {
// The selection has changed. // The selection has changed.
} }
editor.on('viewUpdate', () => { editor.on('viewUpdate', ({ editor }) => {
// The view has changed. // The view has changed.
} }
editor.on('transaction', ({ transaction }) => { editor.on('transaction', ({ editor, transaction }) => {
// The editor state has changed. // The editor state has changed.
} }
editor.on('focus', ({ event }) => { editor.on('focus', ({ editor, event }) => {
// The editor is focused. // The editor is focused.
} }
editor.on('blur', ({ event }) => { editor.on('blur', ({ editor, event }) => {
// The editor isnt focused anymore. // The editor isnt focused anymore.
} }
@ -94,22 +97,25 @@ Moving your event listeners to custom extensions (or nodes, or marks) is also po
import { Extension } from '@tiptap/core' import { Extension } from '@tiptap/core'
const CustomExtension = Extension.create({ const CustomExtension = Extension.create({
onCreate() { onCreate({ editor }) {
// The editor is ready. // The editor is ready.
}, },
onUpdate() { onUpdate({ editor }) {
// The content has changed. // The content has changed.
}, },
onSelection() { onSelectionUpdate({ editor }) {
// The selection has changed. // The selection has changed.
}, },
onTransaction({ transaction }) { onViewUpdate({ editor }) {
// The view has changed.
},
onTransaction({ editor, transaction }) {
// The editor state has changed. // The editor state has changed.
}, },
onFocus({ event }) { onFocus({ editor, event }) {
// The editor is focused. // The editor is focused.
}, },
onBlur({ event }) { onBlur({ editor, event }) {
// The editor isnt focused anymore. // The editor isnt focused anymore.
}, },
onDestroy() { onDestroy() {