use handleDOMEvents for focus and blur events

This commit is contained in:
Philipp Kühn
2019-05-17 23:29:32 +02:00
parent 78e6b703ff
commit 5ec5168cc1

View File

@@ -205,6 +205,18 @@ export default class Editor extends Emitter {
attributes: {
tabindex: 0,
},
handleDOMEvents: {
focus: event => this.emit('focus', {
event,
state: this.state,
view: this.view,
}),
blur: event => this.emit('blur', {
event,
state: this.state,
view: this.view,
}),
},
},
}),
new Plugin({
@@ -248,18 +260,6 @@ export default class Editor extends Emitter {
view.dom.style.whiteSpace = 'pre-wrap'
view.dom.addEventListener('focus', event => this.emit('focus', {
event,
state: this.state,
view: this.view,
}))
view.dom.addEventListener('blur', event => this.emit('blur', {
event,
state: this.state,
view: this.view,
}))
return view
}