From b08431560751855a4cc3783f3635004164dfbc1b Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 26 Jan 2023 15:10:00 +0100 Subject: fix empty detection, and only make sentence transparent if no word is highlighted --- anki-card-template/card.css | 4 ++-- anki-card-template/card.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/anki-card-template/card.css b/anki-card-template/card.css index 693db90..648fd2b 100644 --- a/anki-card-template/card.css +++ b/anki-card-template/card.css @@ -32,9 +32,9 @@ body { font-weight: 400; } -#card #sentence { color: #000b; } +#card #sentence:has(b) { color: #000b; } #card #sentence b { color: #000f; } -.night_mode #card #sentence { color: #fffb; } +.night_mode #card #sentence:has(b) { color: #fffb; } .night_mode #card #sentence b { color: #ffff; } /* body margin */ diff --git a/anki-card-template/card.js b/anki-card-template/card.js index 00ae0aa..15870fa 100644 --- a/anki-card-template/card.js +++ b/anki-card-template/card.js @@ -284,7 +284,8 @@ HTMLElement.prototype.parse = function() { var out = nodes.map(n => n.data).join(""); this.innerHTML = out; this.classList.add("parsed"); - if (out.length == 0) this.classList.add("empty"); + if (nodes.reduce((current, n) => current + (n.type == "text" ? n.data.length : 0), 0) == 0) + this.classList.add("empty"); // if innerHTML only contains empty html (no 'user' text) }; function layout() { -- cgit v1.2.3