Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Wysiwyg/Trumbowyg editor colors when dark theme enabled #16356

Merged
merged 16 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ else
</text>
}
}

document.addEventListener('DOMContentLoaded', function() {
function setTheme() {
var theme = document.documentElement.dataset.bsTheme;
var isDark = theme === 'dark' || (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
mdameer marked this conversation as resolved.
Show resolved Hide resolved
document.querySelector('#@Html.IdFor(x => x.Html)_FieldWrapper').classList.toggle('trumbowyg-dark', isDark);
}
const mutationObserver = new MutationObserver(setTheme);
mdameer marked this conversation as resolved.
Show resolved Hide resolved
mutationObserver.observe(document.documentElement, { attributes: true });

setTheme();
});

$(function () {
@if (!string.IsNullOrEmpty(trumbowygSettings.Options))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
</div>

<script at="Foot">
document.addEventListener('DOMContentLoaded', function() {
function setTheme() {
var theme = document.documentElement.dataset.bsTheme;
var isDark = theme === 'dark' || (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
mdameer marked this conversation as resolved.
Show resolved Hide resolved
document.querySelector('#@Html.IdFor(x => x.Html)_FieldWrapper').classList.toggle('trumbowyg-dark', isDark);
}
const mutationObserver = new MutationObserver(setTheme);
mdameer marked this conversation as resolved.
Show resolved Hide resolved
mutationObserver.observe(document.documentElement, { attributes: true });

setTheme();
});

$(function () {
@* set dir while keeping trumbowg translations dictionary intact *@
@if (culture.GetLanguageDirection() == LanguageDirection.RTL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,43 @@
font-size: 16px;
}

[dir] .trumbowyg-box {
[dir] .trumbowyg-box,
[dir] .trumbowyg-dark .trumbowyg-box {
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
border-radius: var(--bs-border-radius);
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

[dir] trumbowyg-editor-box {
[dir] .trumbowyg-editor-box,
[dir] .trumbowyg-dark .trumbowyg-editor-box {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

[dir] .trumbowyg-button-pane {
[dir] .trumbowyg-button-pane,
[dir] .trumbowyg-dark .trumbowyg-button-pane {
border-bottom: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
background-color: var(--bs-border-color);
padding: 0;
}

.trumbowyg-box svg, .trumbowyg-modal svg {
color: var(--bs-body-color);
fill: var(--bs-body-color);
}

[dir] .trumbowyg-button-pane button {
margin-bottom: 0 !important;
[dir] .trumbowyg-button-pane .trumbowyg-button-group:not(:empty),
[dir] .trumbowyg-dark .trumbowyg-button-pane .trumbowyg-button-group:not(:empty) {
&::after {
background: var(--bs-border-color);
}
}

[dir] .trumbowyg-dropdown {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
[dir] .trumbowyg-dropdown,
[dir] .trumbowyg-dark .trumbowyg-dropdown {
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
}

[dir] .trumbowyg-dropdown button:hover, [dir] .trumbowyg-dropdown button:focus {
background-color: var(--bs-body-color) !important;
color: var(--bs-body-bg) !important;
}

[dir] .trumbowyg-button-pane .trumbowyg-open-dropdown::after {
border-top-color: var(--bs-body-color);
}

[dir] .trumbowyg-dropdown button {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

.trumbowyg-fullscreen {
z-index: var(--oc-editor-fullscreen);
}

[dir] .trumbowyg-fullscreen.trumbowyg-box, [dir] .trumbowyg-fullscreen .trumbowyg-editor-box {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

.trumbowyg-fullscreen .trumbowyg-button-group .trumbowyg-fullscreen-button svg {
color: var(--bs-body-color);
fill: var(--bs-body-color);
}

[dir] .trumbowyg-box .trumbowyg-editor th, [dir] .trumbowyg-box .trumbowyg-editor td {
[dir] .trumbowyg-box .trumbowyg-editor th,
[dir] .trumbowyg-box .trumbowyg-editor td {
border-width: var(--bs-border-width, 1px);
border-style: var(--bs-border-style, solid);
border-color: var(--bs-border-color, #dee2e6);
Expand Down
53 changes: 13 additions & 40 deletions src/OrchardCore.Themes/TheAdmin/wwwroot/css/TheAdmin.css
Original file line number Diff line number Diff line change
Expand Up @@ -8589,68 +8589,41 @@ ul.ui-sortable:not(:has(> li)) {
font-size: 16px;
}

[dir] .trumbowyg-box {
[dir] .trumbowyg-box,
[dir] .trumbowyg-dark .trumbowyg-box {
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
border-radius: var(--bs-border-radius);
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

[dir] trumbowyg-editor-box {
[dir] .trumbowyg-editor-box,
[dir] .trumbowyg-dark .trumbowyg-editor-box {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

[dir] .trumbowyg-button-pane {
[dir] .trumbowyg-button-pane,
[dir] .trumbowyg-dark .trumbowyg-button-pane {
border-bottom: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
background-color: var(--bs-border-color);
padding: 0;
}

.trumbowyg-box svg, .trumbowyg-modal svg {
color: var(--bs-body-color);
fill: var(--bs-body-color);
}

[dir] .trumbowyg-button-pane button {
margin-bottom: 0 !important;
[dir] .trumbowyg-button-pane .trumbowyg-button-group:not(:empty)::after,
[dir] .trumbowyg-dark .trumbowyg-button-pane .trumbowyg-button-group:not(:empty)::after {
background: var(--bs-border-color);
}

[dir] .trumbowyg-dropdown {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
[dir] .trumbowyg-dropdown,
[dir] .trumbowyg-dark .trumbowyg-dropdown {
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
}

[dir] .trumbowyg-dropdown button:hover, [dir] .trumbowyg-dropdown button:focus {
background-color: var(--bs-body-color) !important;
color: var(--bs-body-bg) !important;
}

[dir] .trumbowyg-button-pane .trumbowyg-open-dropdown::after {
border-top-color: var(--bs-body-color);
}

[dir] .trumbowyg-dropdown button {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

.trumbowyg-fullscreen {
z-index: var(--oc-editor-fullscreen);
}

[dir] .trumbowyg-fullscreen.trumbowyg-box, [dir] .trumbowyg-fullscreen .trumbowyg-editor-box {
background-color: var(--bs-body-bg);
color: var(--bs-body-color);
}

.trumbowyg-fullscreen .trumbowyg-button-group .trumbowyg-fullscreen-button svg {
color: var(--bs-body-color);
fill: var(--bs-body-color);
}

[dir] .trumbowyg-box .trumbowyg-editor th, [dir] .trumbowyg-box .trumbowyg-editor td {
[dir] .trumbowyg-box .trumbowyg-editor th,
[dir] .trumbowyg-box .trumbowyg-editor td {
border-width: var(--bs-border-width, 1px);
border-style: var(--bs-border-style, solid);
border-color: var(--bs-border-color, #dee2e6);
Expand Down

Large diffs are not rendered by default.