This commit is contained in:
2026-02-04 02:15:11 +01:00
parent c5c7b7cbe7
commit 379d7354c2
2 changed files with 31 additions and 6 deletions

View File

@@ -1 +1 @@
1.2.43
1.2.44

View File

@@ -466,13 +466,38 @@
// Sicherstellen, dass ggf. aktive Text-Edits vor dem Speichern synchronisiert werden
try {
const wrapper = editor.getWrapper && editor.getWrapper();
const resolveComponent = (el) => {
if (!el || !wrapper || !wrapper.find) return null;
const root = (el.closest && el.closest('[data-gjs-type="text"]')) || el;
const id = root && root.getAttribute ? root.getAttribute('id') : null;
if (!id) return null;
const found = wrapper.find(`#${id}`);
return found && found[0];
};
const syncElement = (el) => {
const comp = resolveComponent(el);
if (!comp || !comp.set) return;
const root = (el.closest && el.closest('[data-gjs-type="text"]')) || el;
const html = root && root.innerHTML ? root.innerHTML : '';
const current = typeof comp.get === 'function' ? (comp.get('content') || '') : '';
if (!html.trim() && current.trim()) return;
comp.set('content', html);
comp.trigger && comp.trigger('change:content');
};
const doc = editor.Canvas && editor.Canvas.getDocument ? editor.Canvas.getDocument() : null;
const active = doc && doc.activeElement;
if (active && (active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true'))) {
syncElement(active);
}
const selected = editor.getSelected && editor.getSelected();
const view = selected && selected.view;
if (view && view.el && view.el.isContentEditable) {
view.el.blur();
}
if (selected && view && view.el && typeof selected.is === 'function' && selected.is('text')) {
selected.set('content', view.el.innerHTML);
if (view && view.el && (view.el.isContentEditable || (view.el.getAttribute && view.el.getAttribute('contenteditable') === 'true'))) {
syncElement(view.el);
} else if (selected && typeof selected.is === 'function' && (selected.is('text') || selected.is('textnode')) && view && view.el) {
syncElement(view.el);
}
} catch (e) {
// kein Block, falls Sync nicht moeglich