This commit is contained in:
2026-01-26 21:12:34 +01:00
parent 9791cb0772
commit 665e8d4b5a

View File

@@ -44,24 +44,20 @@
try {
const wrapper = editor.getWrapper && editor.getWrapper();
if (wrapper && wrapper.find) {
const doc = new DOMParser().parseFromString(html, 'text/html');
const candidates = wrapper.find('[data-gjs-type=\"text\"], [data-gjs-type=\"link\"], [data-gjs-type=\"button\"]');
candidates.forEach((model) => {
const content = model && model.get ? String(model.get('content') || '') : '';
const id = model && (model.getId ? model.getId() : model.get && model.get('id'));
const viewEl = model && model.view && model.view.el ? model.view.el : null;
const tag = (model && model.get && (model.get('tagName') || model.get('tag')))
|| (viewEl && viewEl.tagName)
|| 'div';
if (!content || !id) return;
const tagName = String(tag).toLowerCase();
if (tagName && tagName !== 'div') {
const rx = new RegExp(`<${tagName}([^>]*\\\\bid=[\"']${id}[\"'][^>]*)>([\\\\s\\\\S]*?)<\\\\/${tagName}>`, 'i');
html = html.replace(rx, `<${tagName}$1>${content}</${tagName}>`);
} else {
const rxAny = new RegExp(`<([a-z0-9-]+)([^>]*\\\\bid=[\"']${id}[\"'][^>]*)>([\\\\s\\\\S]*?)<\\\\/\\1>`, 'i');
html = html.replace(rxAny, `<$1$2>${content}</$1>`);
const el = doc.getElementById(id);
if (el) {
el.innerHTML = content;
}
});
if (doc.body && doc.body.innerHTML !== undefined) {
html = `<body>${doc.body.innerHTML}</body>`;
}
}
} catch {}
return html;
@@ -174,23 +170,14 @@
const isText = (component.is && component.is('text'))
|| (component.get && component.get('type') === 'text');
if (isText && component.components) {
const comps = component.components();
if (comps && typeof comps.reset === 'function') {
comps.reset([], { silent: true });
}
try {
component.components(content);
} catch {}
}
if (component.set) component.set('content', content);
} catch {}
if (component.view && component.view.el) {
component.view.el.innerHTML = content;
}
if (component.view && typeof component.view.render === 'function') {
component.view.render();
try {
if (component.view && component.view.el) {
component.view.el.innerHTML = content;
}
} catch {}
}
if (component.trigger) {
component.trigger('change:content');