fix: keep reader selection colors owned by the active theme
Some checks failed
build / binary (push) Waiting to run
build / container (push) Waiting to run
test / test (push) Waiting to run
test / lint-openapi (push) Waiting to run
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled

Co-authored-by: chmouel <98980+chmouel@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-09-09 03:27:38 +00:00 • committed by Chmouel Boudjnah
parent b9f99793eb
commit de60837fa1
3 changed files with 7 additions and 7 deletions

View file

@ -1717,12 +1717,12 @@ function chapterCSS(s) {
const theme = THEMES[s.theme];
if (theme) {
rules.push(
`html { color-scheme: ${theme.scheme}; --selection-bg: ${theme.selectionBg}; --selection-fg: ${theme.selectionFg}; }`,
`html { color-scheme: ${theme.scheme}; --liseur-selection-bg: ${theme.selectionBg}; --liseur-selection-fg: ${theme.selectionFg}; }`,
`html, body { background: ${theme.bg} !important; color: ${theme.fg} !important; }`,
`body * { background-color: transparent !important; color: ${theme.fg} !important; }`,
`a:any-link { color: ${theme.link} !important; }`,
"body::selection, body *::selection { background: var(--selection-bg) !important; color: var(--selection-fg) !important; }",
"body::-moz-selection, body *::-moz-selection { background: var(--selection-bg) !important; color: var(--selection-fg) !important; }",
"body::selection, body *::selection { background-color: var(--liseur-selection-bg) !important; color: var(--liseur-selection-fg) !important; }",
"body::-moz-selection, body *::-moz-selection { background-color: var(--liseur-selection-bg) !important; color: var(--liseur-selection-fg) !important; }",
);
}
if (FONTS[s.font]) {

View file

@ -254,9 +254,9 @@ const probe = `(() => {
selectionBackground: body ? doc.defaultView.getComputedStyle(body, '::selection').backgroundColor : '',
selectionColour: body ? doc.defaultView.getComputedStyle(body, '::selection').color : '',
selectionTokenBackground: doc
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--selection-bg').trim() : '',
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--liseur-selection-bg').trim() : '',
selectionTokenColour: doc
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--selection-fg').trim() : '',
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--liseur-selection-fg').trim() : '',
stageBackground: document.getElementById('reader-view')
? getComputedStyle(document.getElementById('reader-view')).backgroundColor : '',
fraction: typeof loc?.fraction === 'number' ? +loc.fraction.toFixed(4) : -1,

View file

@ -183,9 +183,9 @@ const probe = `(() => {
selectionBackground: body ? doc.defaultView.getComputedStyle(body, '::selection').backgroundColor : '',
selectionColour: body ? doc.defaultView.getComputedStyle(body, '::selection').color : '',
selectionTokenBackground: doc
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--selection-bg').trim() : '',
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--liseur-selection-bg').trim() : '',
selectionTokenColour: doc
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--selection-fg').trim() : '',
? doc.defaultView.getComputedStyle(doc.documentElement).getPropertyValue('--liseur-selection-fg').trim() : '',
stageBackground: document.getElementById('reader-view')
? getComputedStyle(document.getElementById('reader-view')).backgroundColor : '',
fraction: typeof loc?.fraction === 'number' ? +loc.fraction.toFixed(4) : -1,