From 4113ac6c68b9b7a7ac1c5cdfd2e8219ae3926b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Wed, 19 Dec 2018 23:13:58 +0100 Subject: [PATCH] add original event to focus and blur event --- README.md | 4 ++-- packages/tiptap/src/Editor.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 87273e41..2ba4fe28 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/packages/tiptap/src/Editor.js b/packages/tiptap/src/Editor.js index 56803263..84615c99 100644 --- a/packages/tiptap/src/Editor.js +++ b/packages/tiptap/src/Editor.js @@ -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, }))