asdasd
This commit is contained in:
@@ -1 +1 @@
|
|||||||
1.1.35
|
1.1.36
|
||||||
@@ -360,6 +360,24 @@
|
|||||||
normalized: normalizeHtml(composite),
|
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) => {
|
const storeSnapshot = (model, snap) => {
|
||||||
if (!model || !snap) return;
|
if (!model || !snap) return;
|
||||||
const key = model.cid || model;
|
const key = model.cid || model;
|
||||||
@@ -396,7 +414,7 @@
|
|||||||
if (!stored || !stored.normalized) return;
|
if (!stored || !stored.normalized) return;
|
||||||
try {
|
try {
|
||||||
if (target.components) {
|
if (target.components) {
|
||||||
target.components(stored.html);
|
target.components(buildTextComponentsFromHtml(stored.html));
|
||||||
}
|
}
|
||||||
target.set('content', stored.html);
|
target.set('content', stored.html);
|
||||||
target.trigger && target.trigger('change:content');
|
target.trigger && target.trigger('change:content');
|
||||||
@@ -429,7 +447,7 @@
|
|||||||
if (viewHtml === modelHtml) return;
|
if (viewHtml === modelHtml) return;
|
||||||
try {
|
try {
|
||||||
syncing.add(target);
|
syncing.add(target);
|
||||||
if (target.components) target.components(viewHtml);
|
if (target.components) target.components(buildTextComponentsFromHtml(viewHtml));
|
||||||
if (target.set) target.set('content', viewHtml);
|
if (target.set) target.set('content', viewHtml);
|
||||||
target.trigger && target.trigger('change:content');
|
target.trigger && target.trigger('change:content');
|
||||||
const reapply = () => {
|
const reapply = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user