Skip to content

Commit

Permalink
increase onChange debounce time and trigger onChange on FocusLos
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Pansch committed Mar 14, 2024
1 parent 5245d97 commit 4bf2ae6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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'/)) {
Expand Down

0 comments on commit 4bf2ae6

Please sign in to comment.