dark iframe fallback

This commit is contained in:
Yuri Kuznetsov
2022-02-21 11:22:19 +02:00
parent 444245d2e1
commit c105af939f
5 changed files with 34 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
{
"stylesheet": "client/css/espo/dark.css",
"stylesheetIframe": "client/css/espo/dark-iframe.css",
"stylesheetIframeFallback": "client/css/espo/hazyblue-iframe.css",
"dashboardCellHeight": 155,
"dashboardCellMargin": 19,
"navbarHeight": 43,

View File

@@ -1,6 +1,7 @@
{
"stylesheet": "client/css/espo/dark-vertical.css",
"stylesheetIframe": "client/css/espo/dark-vertical-iframe.css",
"stylesheetIframeFallback": "client/css/espo/hazyblue-iframe.css",
"navbarIsVertical": true,
"recordTopButtonsStickTop": 61,
"recordTopButtonsBlockHeight": 21,

View File

@@ -95,6 +95,17 @@ define('theme-manager', [], function () {
return link;
},
getIframeFallbackStylesheet: function () {
let link = this.metadata.get(['themes', this.getName(), 'stylesheetIframeFallback']) ||
'client/css/espo/espo-iframe.css';
if (this.config.get('cacheTimestamp')) {
link += '?r=' + this.config.get('cacheTimestamp').toString();
}
return link;
},
getParam: function (name) {
return this.metadata.get(['themes', this.getName(), name]) || this.defaultParams[name] || null;
},

View File

@@ -289,11 +289,17 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function
var body = this.sanitizeHtml(this.model.get(this.name) || '');
let useFallbackStylesheet = this.getThemeManager().getParam('isDark') && this.htmlHasColors(body);
var linkElement = iframeElement.contentWindow.document.createElement('link');
linkElement.type = 'text/css';
linkElement.rel = 'stylesheet';
linkElement.href = this.getBasePath() + this.getThemeManager().getIframeStylesheet();
linkElement.href = this.getBasePath() + (
useFallbackStylesheet ?
this.getThemeManager().getIframeFallbackStylesheet() :
this.getThemeManager().getIframeStylesheet()
);
body = linkElement.outerHTML + body;
@@ -987,5 +993,17 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function
});
},
htmlHasColors: function (string) {
if (~string.indexOf('background-color:')) {
return true;
}
if (~string.indexOf('color:')) {
return true;
}
return false;
},
});
});

View File

@@ -13,6 +13,8 @@ body {
> blockquote:last-child {
margin-bottom: 0;
}
background-color: var(--panel-bg);
}
body {