mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 16:02:23 -04:00
ignore foreground/background colour in spans when night mode active
This prevents pasted text from a standard webpage appearing as black on white. It could theoretically be made smarter in the future, but handling all the situations where the background or foreground colour is not exactly #000/#fff might be tricky.
This commit is contained in:
parent
32b279f750
commit
eb6b64f4b1
1 changed files with 10 additions and 0 deletions
|
@ -464,6 +464,10 @@ const allowedStyling = {
|
|||
"text-decoration-line": true,
|
||||
};
|
||||
|
||||
let isNightMode = function(): boolean {
|
||||
return document.body.classList.contains("nightMode");
|
||||
};
|
||||
|
||||
let filterExternalSpan = function(node) {
|
||||
// filter out attributes
|
||||
let toRemove = [];
|
||||
|
@ -486,6 +490,12 @@ let filterExternalSpan = function(node) {
|
|||
// google docs adds this unnecessarily
|
||||
toRemove.push(name);
|
||||
}
|
||||
if (isNightMode()) {
|
||||
// ignore coloured text in night mode for now
|
||||
if (name === "background-color" || name == "color") {
|
||||
toRemove.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let name of toRemove) {
|
||||
node.style.removeProperty(name);
|
||||
|
|
Loading…
Reference in a new issue