This commit is contained in:
2026-01-28 00:19:31 +01:00
parent 0850c365f5
commit a7a936fac2
2 changed files with 21 additions and 3 deletions

View File

@@ -1 +1 @@
1.1.35
1.1.36

View File

@@ -360,6 +360,24 @@
normalized: normalizeHtml(composite),
};
};
const buildTextComponentsFromHtml = (html) => {
const wrapper = document.createElement('div');
wrapper.innerHTML = String(html || '');
const newComps = [];
wrapper.childNodes.forEach((node) => {
if (node.nodeType === 3) {
newComps.push({ type: 'textnode', content: node.textContent || '' });
} else if (node.nodeType === 1) {
const tag = node.tagName ? node.tagName.toLowerCase() : '';
if (tag === 'br') {
newComps.push({ tagName: 'br', void: true });
} else {
newComps.push(node.outerHTML);
}
}
});
return newComps.length ? newComps : html;
};
const storeSnapshot = (model, snap) => {
if (!model || !snap) return;
const key = model.cid || model;
@@ -396,7 +414,7 @@
if (!stored || !stored.normalized) return;
try {
if (target.components) {
target.components(stored.html);
target.components(buildTextComponentsFromHtml(stored.html));
}
target.set('content', stored.html);
target.trigger && target.trigger('change:content');
@@ -429,7 +447,7 @@
if (viewHtml === modelHtml) return;
try {
syncing.add(target);
if (target.components) target.components(viewHtml);
if (target.components) target.components(buildTextComponentsFromHtml(viewHtml));
if (target.set) target.set('content', viewHtml);
target.trigger && target.trigger('change:content');
const reapply = () => {