add focus and blur event

This commit is contained in:
Philipp Kühn
2018-11-12 23:15:18 +01:00
parent 9755dd3cc1
commit 5f69ac2416

View File

@@ -1,4 +1,3 @@
import Vue from 'vue'
import { EditorState, Plugin } from 'prosemirror-state' import { EditorState, Plugin } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view' import { EditorView } from 'prosemirror-view'
import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model' import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model'
@@ -30,6 +29,8 @@ export default class Editor {
content: '', content: '',
onInit: () => {}, onInit: () => {},
onUpdate: () => {}, onUpdate: () => {},
onFocus: () => {},
onBlur: () => {},
} }
this.options = { this.options = {
@@ -155,6 +156,16 @@ export default class Editor {
view.dom.style.whiteSpace = 'pre-wrap' view.dom.style.whiteSpace = 'pre-wrap'
view.dom.addEventListener('focus', () => this.options.onFocus({
state: this.state,
view: this.view,
}))
view.dom.addEventListener('blur', () => this.options.onBlur({
state: this.state,
view: this.view,
}))
return view return view
} }