Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: 3839 ckeditor only save changes if (really) dirty #3846

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ export const createEditor = store => async options => {
return NeosEditor
.create(propertyDomNode, ckEditorConfig)
.then(editor => {
const debouncedOnChange = debounce(() => onChange(cleanupContentBeforeCommit(editor.getData())), 1500, {maxWait: 5000});
editor.model.document.on('change:data', debouncedOnChange);
editor.ui.focusTracker.on('change:isFocused', event => {
if (!event.source.isFocused) {
onChange(cleanupContentBeforeCommit(editor.getData()))
// when another editor is focused commit all possible pending changes
debouncedOnChange.flush();
return
}

Expand All @@ -74,7 +77,6 @@ export const createEditor = store => async options => {
});

editor.model.document.on('change', () => handleUserInteractionCallback());
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
10 changes: 1 addition & 9 deletions packages/neos-ui-guest-frame/src/initializePropertyDomNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {$get, $contains} from 'plow-js';

import {actions, selectors} from '@neos-project/neos-ui-redux-store';
import {actions} from '@neos-project/neos-ui-redux-store';
import {validateElement} from '@neos-project/neos-ui-validators';

import {getGuestFrameWindow, closestContextPathInGuestFrame} from './dom';
Expand Down Expand Up @@ -74,14 +74,6 @@ export default ({store, globalRegistry, nodeTypesRegistry, inlineEditorRegistry,
actions.Changes.persistChanges([change])
),
onChange: value => {
const node = selectors.CR.Nodes.byContextPathSelector(contextPath)(store.getState());
if (node) {
const oldValue = node.properties[propertyName];
if (oldValue === value) {
return;
}
}

const validationResult = validateElement(value, $get(['properties', propertyName], nodeType), globalRegistry.get('validators'));
// Update inline validation errors
store.dispatch(
Expand Down
Loading