This commit is contained in:
the-djmaze 2023-02-15 11:57:01 +01:00
parent 8058c8d2f6
commit 7a762e50c7

View file

@ -113,12 +113,13 @@ const
* Given css array, parses it and then for every selector, * Given css array, parses it and then for every selector,
* prepends namespace to prevent css collision issues * prepends namespace to prevent css collision issues
*/ */
css.applyNamespace = (namespace, prefix) => css.forEach(obj => { css.applyNamespace = namespace => css.forEach(obj => {
if (obj.type === 'media') { if (obj.type === 'media') {
obj.subStyles.applyNamespace(namespace, prefix); obj.subStyles.applyNamespace(namespace);
} else { } else {
obj.selector = obj.selector.split(',').map(selector => obj.selector = obj.selector.split(',').map(selector =>
namespace + ' ' + selector.replace('.', '.'+prefix) (namespace + ' .mail-body ' + selector.replace(/\./g, '.msg-'))
.replace(/\sbody/gi, '')
).join(','); ).join(',');
} }
}); });
@ -146,10 +147,7 @@ const
// Never have more than a single line break in a row // Never have more than a single line break in a row
.replace(/\n+/, "\n") .replace(/\n+/, "\n")
// Remove :root and html // Remove :root and html
.split(/\s+/g).map(item => item .split(/\s+/g).map(item => item.replace(/^(:root|html)$/, '')).join(' ').trim();
.replace(/^body$/, '.mail-body')
.replace(/^(:root|html)$/, '')
).join(' ').trim();
// determine the type // determine the type
if (selector.includes('@media')) { if (selector.includes('@media')) {
@ -292,8 +290,8 @@ export const
if ('STYLE' === name) { if ('STYLE' === name) {
let css = msgId ? parseCSS(oElement.textContent) : []; let css = msgId ? parseCSS(oElement.textContent) : [];
if (css.length) { if (css.length) {
css.applyNamespace(msgId, 'msg-'); css.applyNamespace(msgId);
css = css.toString().replace('.msg-mail-body', '.mail-body'); css = css.toString();
if (SettingsUserStore.removeColors()) { if (SettingsUserStore.removeColors()) {
css = css.replace(/(background-)?color:[^};]+;?/g, ''); css = css.replace(/(background-)?color:[^};]+;?/g, '');
} }