From eb6b64f4b1f5c8931565edb9f17a73cc28514e56 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 31 Jan 2020 08:03:09 +1000 Subject: [PATCH] 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. --- qt/ts/src/editor.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qt/ts/src/editor.ts b/qt/ts/src/editor.ts index 7486fccc5..e0cf8709b 100644 --- a/qt/ts/src/editor.ts +++ b/qt/ts/src/editor.ts @@ -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);