asdsad
This commit is contained in:
@@ -204,7 +204,23 @@
|
|||||||
|
|
||||||
const modelContent = (component.get && component.get('content')) || '';
|
const modelContent = (component.get && component.get('content')) || '';
|
||||||
const viewHtml = (component.view && component.view.el && component.view.el.innerHTML) || '';
|
const viewHtml = (component.view && component.view.el && component.view.el.innerHTML) || '';
|
||||||
const initialHtml = sanitizeInlineHtml(viewHtml || modelContent, modelContent || '');
|
let htmlSource = viewHtml || modelContent || '';
|
||||||
|
if (!htmlSource && component && typeof component.toHTML === 'function') {
|
||||||
|
try {
|
||||||
|
const fullHtml = String(component.toHTML() || '');
|
||||||
|
if (fullHtml) {
|
||||||
|
const wrapper = document.createElement('div');
|
||||||
|
wrapper.innerHTML = fullHtml;
|
||||||
|
const first = wrapper.firstElementChild;
|
||||||
|
if (first && first.innerHTML !== undefined) {
|
||||||
|
htmlSource = first.innerHTML;
|
||||||
|
} else {
|
||||||
|
htmlSource = wrapper.innerHTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
const initialHtml = sanitizeInlineHtml(htmlSource, modelContent || '');
|
||||||
content.innerHTML = initialHtml;
|
content.innerHTML = initialHtml;
|
||||||
const existingStyle = component && component.get && component.get('style') ? component.get('style') : null;
|
const existingStyle = component && component.get && component.get('style') ? component.get('style') : null;
|
||||||
if (existingStyle && typeof existingStyle === 'object') {
|
if (existingStyle && typeof existingStyle === 'object') {
|
||||||
@@ -388,14 +404,23 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const normalizeKeys = (obj) => {
|
||||||
|
const out = {};
|
||||||
|
Object.entries(obj || {}).forEach(([key, val]) => {
|
||||||
|
if (key === 'fontFamily') out['font-family'] = val;
|
||||||
|
else if (key === 'fontSize') out['font-size'] = val;
|
||||||
|
else out[key] = val;
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
};
|
||||||
if (component && component.setStyle && component.getStyle) {
|
if (component && component.setStyle && component.getStyle) {
|
||||||
const current = component.getStyle() || {};
|
const current = component.getStyle() || {};
|
||||||
const safeCurrent = (current && typeof current === 'object' && !Array.isArray(current)) ? current : {};
|
const safeCurrent = (current && typeof current === 'object' && !Array.isArray(current)) ? current : {};
|
||||||
component.setStyle({ ...safeCurrent, ...styleObj });
|
component.setStyle({ ...safeCurrent, ...normalizeKeys(styleObj) });
|
||||||
} else if (component && component.set) {
|
} else if (component && component.set) {
|
||||||
const current = component.get && component.get('style') ? component.get('style') : {};
|
const current = component.get && component.get('style') ? component.get('style') : {};
|
||||||
const safeCurrent = (current && typeof current === 'object' && !Array.isArray(current)) ? current : {};
|
const safeCurrent = (current && typeof current === 'object' && !Array.isArray(current)) ? current : {};
|
||||||
component.set('style', { ...safeCurrent, ...styleObj });
|
component.set('style', { ...safeCurrent, ...normalizeKeys(styleObj) });
|
||||||
}
|
}
|
||||||
if (component && component.view && component.view.el) {
|
if (component && component.view && component.view.el) {
|
||||||
Object.entries(styleObj).forEach(([key, val]) => {
|
Object.entries(styleObj).forEach(([key, val]) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user