add oldstate to update event

This commit is contained in:
Philipp Kühn
2019-05-03 14:04:14 +02:00
parent 83075f28e6
commit 5b530d5d0c

View File

@@ -288,6 +288,8 @@ export default class Editor {
return return
} }
const oldState = this.state
this.state = this.state.apply(transaction) this.state = this.state.apply(transaction)
this.view.updateState(this.state) this.view.updateState(this.state)
this.setActiveNodesAndMarks() this.setActiveNodesAndMarks()
@@ -296,14 +298,15 @@ export default class Editor {
return return
} }
this.emitUpdate(transaction) this.emitUpdate(transaction, oldState)
} }
emitUpdate(transaction) { emitUpdate(transaction, oldState) {
this.options.onUpdate({ this.options.onUpdate({
getHTML: this.getHTML.bind(this), getHTML: this.getHTML.bind(this),
getJSON: this.getJSON.bind(this), getJSON: this.getJSON.bind(this),
state: this.state, state: this.state,
oldState,
transaction, transaction,
}) })
} }