add original event to focus and blur event

This commit is contained in:
Philipp Kühn
2018-12-19 23:13:58 +01:00
parent 1b5b0c6903
commit 4113ac6c68
2 changed files with 6 additions and 4 deletions

View File

@@ -72,8 +72,8 @@ useBuiltInExtensions
| `extensions` | `Array` | `[]` | A list of extensions used, by the editor. This can be `Nodes`, `Marks` or `Plugins`. |
| `useBuiltInExtensions` | `Boolean` | `true` | By default tiptap adds a `Doc`, `Paragraph` and `Text` node to the Prosemirror schema. |
| `onInit` | `Function` | `undefined` | This will return an Object with the current `state` and `view` of Prosemirror on init. |
| `onFocus` | `Function` | `undefined` | This will return an Object with the current `state` and `view` of Prosemirror on focus. |
| `onBlur` | `Function` | `undefined` | This will return an Object with the current `state` and `view` of Prosemirror on blur. |
| `onFocus` | `Function` | `undefined` | This will return an Object with the `event` and current `state` and `view` of Prosemirror on focus. |
| `onBlur` | `Function` | `undefined` | This will return an Object with the `event` and current `state` and `view` of Prosemirror on blur. |
| `onUpdate` | `Function` | `undefined` | This will return an Object with the current `state` of Prosemirror, a `getJSON()` and `getHTML()` function on every change. |
## Components

View File

@@ -185,12 +185,14 @@ export default class Editor {
view.dom.style.whiteSpace = 'pre-wrap'
view.dom.addEventListener('focus', () => this.options.onFocus({
view.dom.addEventListener('focus', event => this.options.onFocus({
event,
state: this.state,
view: this.view,
}))
view.dom.addEventListener('blur', () => this.options.onBlur({
view.dom.addEventListener('blur', event => this.options.onBlur({
event,
state: this.state,
view: this.view,
}))