mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
fix: iframes not changing to light mode correctly in some cases
This commit is contained in:
+7
-6
@@ -484,7 +484,7 @@ async function updateIframesWithDarkMode(): Promise<void> {
|
|||||||
}, (element) => {
|
}, (element) => {
|
||||||
const iframe = element as HTMLIFrameElement;
|
const iframe = element as HTMLIFrameElement;
|
||||||
try {
|
try {
|
||||||
applyDarkModeToIframe(iframe, cssLink, settingsState.DarkMode);
|
applyDarkModeToIframe(iframe, cssLink);
|
||||||
|
|
||||||
if (element.classList.contains('cke_wysiwyg_frame')) {
|
if (element.classList.contains('cke_wysiwyg_frame')) {
|
||||||
(async () => {
|
(async () => {
|
||||||
@@ -498,18 +498,20 @@ async function updateIframesWithDarkMode(): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyDarkModeToIframe(iframe: HTMLIFrameElement, cssLink: HTMLStyleElement, DarkMode: boolean): void {
|
function applyDarkModeToIframe(iframe: HTMLIFrameElement, cssLink: HTMLStyleElement): void {
|
||||||
const iframeDocument = iframe.contentDocument;
|
const iframeDocument = iframe.contentDocument;
|
||||||
if (!iframeDocument) return;
|
if (!iframeDocument) return;
|
||||||
|
|
||||||
if (iframeDocument.readyState !== 'complete') {
|
if (iframeDocument.readyState !== 'complete') {
|
||||||
iframe.onload = () => {
|
iframe.onload = () => {
|
||||||
applyDarkModeToIframe(iframe, cssLink, DarkMode);
|
applyDarkModeToIframe(iframe, cssLink);
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DarkMode) iframeDocument.documentElement.classList.add('dark');
|
if (settingsState.DarkMode) {
|
||||||
|
iframeDocument.documentElement.classList.add('dark')
|
||||||
|
}
|
||||||
|
|
||||||
const head = iframeDocument.head;
|
const head = iframeDocument.head;
|
||||||
if (head && !head.innerHTML.includes('iframecss')) {
|
if (head && !head.innerHTML.includes('iframecss')) {
|
||||||
@@ -2280,8 +2282,7 @@ function processNotices(responseText: any, labelArray: any) {
|
|||||||
let colour = notice.colour;
|
let colour = notice.colour;
|
||||||
if (typeof colour === 'string') {
|
if (typeof colour === 'string') {
|
||||||
const rgb = GetThresholdOfColor(colour);
|
const rgb = GetThresholdOfColor(colour);
|
||||||
const DarkModeResult = settingsState.DarkMode;
|
if (rgb < 100 && settingsState.DarkMode) {
|
||||||
if (rgb < 100 && DarkModeResult) {
|
|
||||||
colour = undefined;
|
colour = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,9 +64,10 @@ export function updateAllColors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settingsState.DarkMode) {
|
if (settingsState.DarkMode) {
|
||||||
element.contentDocument?.body.classList.add('dark');
|
console.log('dark')
|
||||||
|
element.contentDocument?.documentElement.classList.add('dark');
|
||||||
} else {
|
} else {
|
||||||
element.contentDocument?.body.classList.remove('dark');
|
element.contentDocument?.documentElement.classList.remove('dark');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user