This commit is contained in:
2026-01-28 01:05:41 +01:00
parent 639f803eb7
commit 67cf3bbd27
3 changed files with 26 additions and 2 deletions

View File

@@ -480,6 +480,25 @@
try {
const modelType = model && model.get ? model.get('type') : undefined;
const selectedEl = model && model.view && model.view.el;
const normalizeViewHtmlForModel = (html) => {
return String(html || '')
.replace(/<br\b[^>]*>/gi, '<br>')
.replace(/\sdata-gjs-type="[^"]*"/gi, '')
.replace(/\sdraggable="[^"]*"/gi, '')
.replace(/\scontenteditable="[^"]*"/gi, '')
.trim();
};
if (label === 'DESELECT' && modelType === 'text' && selectedEl) {
try {
const viewHtml = normalizeViewHtmlForModel(selectedEl.innerHTML || '');
if (viewHtml && model && model.set) {
if (model.components) {
try { model.components(viewHtml); } catch {}
}
model.set('content', viewHtml);
}
} catch {}
}
const viewOuter = selectedEl ? String(selectedEl.outerHTML || '') : '';
const modelContent = model && model.get ? String(model.get('content') || '') : '';
const editorHtml = editor && typeof editor.getHtml === 'function' ? String(editor.getHtml() || '') : '';