add transaction event

This commit is contained in:
Philipp Kühn
2019-05-31 12:00:45 +02:00
parent b54a341dec
commit 2c86db883b
2 changed files with 10 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ export default class Collaboration extends Extension {
}
}, this.options.debounce)
this.editor.on('update', ({ state }) => {
this.editor.on('transaction', ({ state }) => {
this.getSendableSteps(state)
})
}

View File

@@ -40,6 +40,7 @@ export default class Editor extends Emitter {
dropCursor: {},
parseOptions: {},
onInit: () => {},
onTransaction: () => {},
onUpdate: () => {},
onFocus: () => {},
onBlur: () => {},
@@ -49,6 +50,7 @@ export default class Editor extends Emitter {
this.events = [
'init',
'transaction',
'update',
'focus',
'blur',
@@ -311,6 +313,13 @@ export default class Editor extends Emitter {
this.view.updateState(newState)
this.setActiveNodesAndMarks()
this.emit('transaction', {
getHTML: this.getHTML.bind(this),
getJSON: this.getJSON.bind(this),
state: this.state,
transaction,
})
if (!transaction.docChanged) {
return
}