From 4bf2ae617b04f473392160cefc3ed74037b54715 Mon Sep 17 00:00:00 2001 From: Christian Pansch Date: Thu, 14 Mar 2024 12:54:06 +0100 Subject: [PATCH] increase onChange debounce time and trigger onChange on FocusLos --- .../neos-ui-ckeditor5-bindings/src/ckEditorApi.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js index fa7f56352a..d9099e0d86 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js +++ b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js @@ -57,12 +57,16 @@ export const createEditor = store => async options => { return NeosEditor .create(propertyDomNode, ckEditorConfig) .then(editor => { + console.log('editor.ui', editor.ui); editor.ui.focusTracker.on('change:isFocused', event => { - if (event.source.isFocused) { - currentEditor = editor; - editorConfig.setCurrentlyEditedPropertyName(propertyName); - handleUserInteractionCallback(); + if (!event.source.isFocused) { + onChange(cleanupContentBeforeCommit(editor.getData())) + return } + + currentEditor = editor; + editorConfig.setCurrentlyEditedPropertyName(propertyName); + handleUserInteractionCallback(); }); editor.keystrokes.set('Ctrl+K', (_, cancel) => { @@ -71,7 +75,7 @@ export const createEditor = store => async options => { }); editor.model.document.on('change', () => handleUserInteractionCallback()); - editor.model.document.on('change:data', debounce(() => onChange(cleanupContentBeforeCommit(editor.getData())), 500, {maxWait: 5000})); + editor.model.document.on('change:data', debounce(() => onChange(cleanupContentBeforeCommit(editor.getData())), 1500, {maxWait: 5000})); return editor; }).catch(e => { if (e instanceof TypeError && e.message.match(/Class constructor .* cannot be invoked without 'new'/)) {