This commit is contained in:
2026-02-01 00:29:35 +01:00
parent 7f01e4f9f1
commit 45789e8ad2
2 changed files with 31 additions and 34 deletions

View File

@@ -484,7 +484,6 @@
}
if (component && component.view && component.view.el) {
const viewEl = component.view.el;
const hasInline = /<span\b|style\s*=/i.test(htmlSource);
const inlineComputedStyles = (sourceEl) => {
try {
const docRef = sourceEl.ownerDocument || document;
@@ -532,38 +531,36 @@
return '';
}
};
if (!hasInline) {
const inlined = inlineComputedStyles(viewEl);
if (inlined) {
htmlSource = inlined;
} else {
try {
const cs = (viewEl.ownerDocument || document).defaultView.getComputedStyle(viewEl);
const styles = [];
const pushStyle = (prop, val) => {
if (val) styles.push(`${prop}:${val}`);
};
pushStyle('font-family', cs.fontFamily);
pushStyle('font-size', cs.fontSize);
pushStyle('font-weight', cs.fontWeight);
pushStyle('font-style', cs.fontStyle);
if (cs.textDecorationLine && cs.textDecorationLine !== 'none') {
pushStyle('text-decoration', cs.textDecorationLine);
}
if (cs.textAlign && cs.textAlign !== 'start') {
pushStyle('text-align', cs.textAlign);
}
if (cs.lineHeight && cs.lineHeight !== 'normal') {
pushStyle('line-height', cs.lineHeight);
}
if (cs.color) {
pushStyle('color', cs.color);
}
if (styles.length) {
htmlSource = `<span style="${styles.join(';')}">${htmlSource}</span>`;
}
} catch {}
}
const inlined = inlineComputedStyles(viewEl);
if (inlined) {
htmlSource = inlined;
} else {
try {
const cs = (viewEl.ownerDocument || document).defaultView.getComputedStyle(viewEl);
const styles = [];
const pushStyle = (prop, val) => {
if (val) styles.push(`${prop}:${val}`);
};
pushStyle('font-family', cs.fontFamily);
pushStyle('font-size', cs.fontSize);
pushStyle('font-weight', cs.fontWeight);
pushStyle('font-style', cs.fontStyle);
if (cs.textDecorationLine && cs.textDecorationLine !== 'none') {
pushStyle('text-decoration', cs.textDecorationLine);
}
if (cs.textAlign && cs.textAlign !== 'start') {
pushStyle('text-align', cs.textAlign);
}
if (cs.lineHeight && cs.lineHeight !== 'normal') {
pushStyle('line-height', cs.lineHeight);
}
if (cs.color) {
pushStyle('color', cs.color);
}
if (styles.length) {
htmlSource = `<span style="${styles.join(';')}">${htmlSource}</span>`;
}
} catch {}
}
}
const initialHtml = this.sanitizeInlineHtml(htmlSource, modelContent || '');