Merge pull request #3510 from overleaf/jpa-fix-cm-listener-signature

[frontend] EditorWatchdogManager: fix signature of CM 'change' handler

GitOrigin-RevId: 9803876db052533de156087d38eb2a9486eb341f
This commit is contained in:
Jakob Ackermann 2021-01-07 09:55:45 +00:00 committed by Copybot
parent 8779e731e1
commit ae511474f2

View file

@ -177,9 +177,21 @@ export default class EditorWatchdogManager {
}
attachToEditor(editorName, editor) {
const onChange = change => {
// Ignore remote changes.
if (change.origin !== 'remote') this.onEdit()
let onChange
if (editorName === 'CM') {
// CM is passing the CM instance as first parameter, then the change.
onChange = (editor, change) => {
// Ignore remote changes.
if (change.origin === 'remote') return
this.onEdit()
}
} else {
// ACE is passing the change object as first parameter.
onChange = change => {
// Ignore remote changes.
if (change.origin === 'remote') return
this.onEdit()
}
}
this._log('attach to editor', editorName)
editor.on('change', onChange)