var editor_changed = false;
editor.model.document.on('change:data', () => { editor_changed = true; });
editor.ui.focusTracker.on('change:isFocused', (evt, name, isFocused) => {
if(!isFocused && editor_changed) {
editor_changed = false;
console.log(editor.getData());
}
} );