This commit is contained in:
2026-02-05 00:32:32 +01:00
parent 7813b4401d
commit e8a4967296
3 changed files with 37 additions and 62 deletions

View File

@@ -1 +1 @@
1.2.53 1.2.54

View File

@@ -480,13 +480,14 @@
return; return;
} }
// Minimaler Sync: nur aktives Text-Element (Selection) in das Model schreiben // Kein aktives Sync mehr vor dem Speichern, nur Logging
try { try {
const doc = editor.Canvas && editor.Canvas.getDocument ? editor.Canvas.getDocument() : null; const doc = editor.Canvas && editor.Canvas.getDocument ? editor.Canvas.getDocument() : null;
const active = doc && doc.activeElement; const active = doc && doc.activeElement;
const selectionNode = doc && doc.getSelection ? (doc.getSelection().focusNode || doc.getSelection().anchorNode) : null; const selectionNode = doc && doc.getSelection ? (doc.getSelection().focusNode || doc.getSelection().anchorNode) : null;
const selectionEl = selectionNode ? (selectionNode.nodeType === 1 ? selectionNode : selectionNode.parentElement) : null; const selectionEl = selectionNode ? (selectionNode.nodeType === 1 ? selectionNode : selectionNode.parentElement) : null;
const selected = editor.getSelected && editor.getSelected(); const selected = editor.getSelected && editor.getSelected();
<<<<<<< ours
let syncResult = null; let syncResult = null;
let syncReason = 'no-editable-selection'; let syncReason = 'no-editable-selection';
@@ -509,11 +510,37 @@
return false; return false;
}; };
const win = doc && doc.defaultView; <<<<<<< ours
const lastEl = win && win.__bridgeLastEditableEl; <<<<<<< ours
const lastCompId = win && win.__bridgeLastEditableCompId; <<<<<<< ours
// 1) Selection im DOM suchen (bevorzugt) // 1) Selection im DOM suchen (bevorzugt)
=======
=======
>>>>>>> theirs
// 1) Bevorzugt: ausgewähltes Component-Element aus der View
if (selected) {
const selEl = (selected.getEl && selected.getEl()) || (selected.view && selected.view.el);
if (selEl && (selEl.isContentEditable || (selEl.getAttribute && selEl.getAttribute('contenteditable') === 'true'))) {
syncFromElement(selected, selEl, 'selected:view');
}
<<<<<<< ours
}
// 2) Fallback: Selection im DOM suchen
>>>>>>> theirs
=======
// 1) Wenn ein ContentEditable aktiv ist, Blur auslösen, damit GrapesJS den Model-Content übernimmt
if (active && (active.isContentEditable || (active.getAttribute && active.getAttribute('contenteditable') === 'true'))) {
try {
active.dispatchEvent(new Event('blur', { bubbles: true }));
syncReason = 'blur:dispatched';
} catch {}
=======
>>>>>>> theirs
}
// 2) Fallback: Selection im DOM suchen
>>>>>>> theirs
if (!syncResult && doc && selectionEl && (selectionEl.isContentEditable || (selectionEl.getAttribute && selectionEl.getAttribute('contenteditable') === 'true'))) { if (!syncResult && doc && selectionEl && (selectionEl.isContentEditable || (selectionEl.getAttribute && selectionEl.getAttribute('contenteditable') === 'true'))) {
const root = (selectionEl.closest && selectionEl.closest('[data-gjs-type="text"]')) || selectionEl; const root = (selectionEl.closest && selectionEl.closest('[data-gjs-type="text"]')) || selectionEl;
const id = root && root.getAttribute ? root.getAttribute('id') : null; const id = root && root.getAttribute ? root.getAttribute('id') : null;
@@ -521,50 +548,14 @@
if (id && wrapper && wrapper.find) { if (id && wrapper && wrapper.find) {
const found = wrapper.find(`#${id}`); const found = wrapper.find(`#${id}`);
const comp = found && found[0]; const comp = found && found[0];
const type = comp && comp.get ? comp.get('type') : null;
if (!type || type === 'text' || type === 'textnode') {
syncFromElement(comp, root, 'selection:root'); syncFromElement(comp, root, 'selection:root');
} }
} }
}
// 2) Fallback: zuletzt fokussiertes Element
if (!syncResult && lastEl && (lastEl.isContentEditable || (lastEl.getAttribute && lastEl.getAttribute('contenteditable') === 'true'))) {
const root = (lastEl.closest && lastEl.closest('[data-gjs-type="text"]')) || lastEl;
const id = root && root.getAttribute ? root.getAttribute('id') : null;
const wrapper = editor.getWrapper && editor.getWrapper();
if (id && wrapper && wrapper.find) {
const found = wrapper.find(`#${id}`);
const comp = found && found[0];
const type = comp && comp.get ? comp.get('type') : null;
if (!type || type === 'text' || type === 'textnode') {
syncFromElement(comp, root, 'last:element');
}
}
}
if (!syncResult && lastCompId) {
const wrapper = editor.getWrapper && editor.getWrapper();
if (wrapper && wrapper.find) {
const found = wrapper.find(`#${lastCompId}`);
const comp = found && found[0];
const type = comp && comp.get ? comp.get('type') : null;
const el = comp && comp.view && comp.view.el;
if (el && (!type || type === 'text' || type === 'textnode')) {
syncFromElement(comp, el, 'last:compId');
}
}
}
// 3) Fallback: ausgewähltes Component-Element aus der View
if (!syncResult && selected) {
const selEl = (selected.getEl && selected.getEl()) || (selected.view && selected.view.el);
const type = selected.get ? selected.get('type') : null;
if (selEl && (!type || type === 'text' || type === 'textnode') &&
(selEl.isContentEditable || (selEl.getAttribute && selEl.getAttribute('contenteditable') === 'true'))) {
syncFromElement(selected, selEl, 'selected:view');
}
}
=======
>>>>>>> theirs
writeDebugLog({ writeDebugLog({
event: 'save:sync:minimal', event: 'save:sync:skipped',
entityId: CURRENT_ENTITY_ID, entityId: CURRENT_ENTITY_ID,
sectionId: SECTION_ID || null, sectionId: SECTION_ID || null,
active: active ? { active: active ? {
@@ -580,8 +571,6 @@
type: selected.get ? selected.get('type') : null, type: selected.get ? selected.get('type') : null,
contentLen: selected.get ? String(selected.get('content') || '').length : 0, contentLen: selected.get ? String(selected.get('content') || '').length : 0,
} : null, } : null,
syncResult,
syncReason,
editorHtmlLen: (editor.getHtml && String(editor.getHtml() || '').length) || 0, editorHtmlLen: (editor.getHtml && String(editor.getHtml() || '').length) || 0,
editorHtmlPreview: (editor.getHtml && String(editor.getHtml() || '').slice(0, 300)) || '', editorHtmlPreview: (editor.getHtml && String(editor.getHtml() || '').slice(0, 300)) || '',
}); });

View File

@@ -772,12 +772,6 @@
if (!target) return; if (!target) return;
const isEditable = !!(target.isContentEditable || (target.getAttribute && target.getAttribute('contenteditable') === 'true')); const isEditable = !!(target.isContentEditable || (target.getAttribute && target.getAttribute('contenteditable') === 'true'));
if (!isEditable) return; if (!isEditable) return;
try {
const win = target.ownerDocument && target.ownerDocument.defaultView;
if (win) {
win.__bridgeLastEditableEl = target;
}
} catch {}
const selected = editor.getSelected && editor.getSelected(); const selected = editor.getSelected && editor.getSelected();
const selectedEl = selected && selected.view && selected.view.el; const selectedEl = selected && selected.view && selected.view.el;
let editorHtml = ''; let editorHtml = '';
@@ -798,14 +792,6 @@
const selectedEl = selected && selected.view && selected.view.el; const selectedEl = selected && selected.view && selected.view.el;
if (!selected || !selectedEl) return; if (!selected || !selectedEl) return;
if (syncing.has(selected)) return; if (syncing.has(selected)) return;
try {
const win = target.ownerDocument && target.ownerDocument.defaultView;
if (win) {
win.__bridgeLastEditableEl = target;
const id = selected.getId ? selected.getId() : (selected.get && selected.get('id'));
if (id) win.__bridgeLastEditableCompId = id;
}
} catch {}
try { try {
const viewHtml = normalizeViewHtml(selectedEl.innerHTML || ''); const viewHtml = normalizeViewHtml(selectedEl.innerHTML || '');
if (!viewHtml) return; if (!viewHtml) return;