From bdbde99fa75a9eba4e3f706f4c7183d3a8fe8c64 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Fri, 8 Apr 2022 12:56:49 +0700 Subject: [PATCH] Remove alpha channel from highlight color when inserting a note Fixes #2499 --- chrome/content/zotero/xpcom/data/notes.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/chrome/content/zotero/xpcom/data/notes.js b/chrome/content/zotero/xpcom/data/notes.js index 5780602b85..57646e6a3f 100644 --- a/chrome/content/zotero/xpcom/data/notes.js +++ b/chrome/content/zotero/xpcom/data/notes.js @@ -189,6 +189,19 @@ Zotero.Notes = new function() { Zotero.logError(e); } } + + nodes = doc.querySelectorAll('span[style]'); + for (let node of nodes) { + // Browser converts #RRGGBBAA hex color to rgba function, and we convert it to rgb function, + // because word processors don't understand colors with alpha channel + if (node.style.backgroundColor && node.style.backgroundColor.startsWith('rgba')) { + node.style.backgroundColor = node.style.backgroundColor + .replace('rgba', 'rgb') + .split(',') + .slice(0, 3) + .join(',') + ')'; + } + } } return doc.body.innerHTML; };