From f6cebcbb7a9ab50402ba8c5647f4395d7dd2ea48 Mon Sep 17 00:00:00 2001 From: TheNEwmanator15 <3686761+Thenewmanator15@users.noreply.github.com> Date: Sat, 26 Sep 2026 12:50:28 +0100 Subject: [PATCH 1/5] Conflict window: legible dark-mode annotations, scalable headings - The annotation box had a hard-coded white background and grey borders while its text followed the theme, so in dark mode it was white text on white. Use theme tokens for background, text and borders. - Column headings were fixed at 14px by zotero.css's groupbox heading rule, so they stayed small with a larger font size setting while the rest of the window scaled. Size them relative to the page (still 14px at the default size), and do the same for the annotation box's fixed sizes. Co-Authored-By: Claude Opus 5.5 --- scss/components/_annotation.scss | 17 +++-- scss/merge.scss | 6 ++ test/tests/syncLocalTest.js | 121 +++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 7 deletions(-) diff --git a/scss/components/_annotation.scss b/scss/components/_annotation.scss index 5081b72005..718b7a70a4 100644 --- a/scss/components/_annotation.scss +++ b/scss/components/_annotation.scss @@ -1,23 +1,26 @@ .AnnotationBox { + // Sizes relative to the 13px base, so they follow Zotero's font size setting .title { font-weight: 600; - font-size: 12px; + font-size: calc(12em / 13); margin: 5px; } - + + // Theme colors rather than a fixed white box, which left dark-theme text unreadable .container { display: flex; flex-direction: column; margin: 5px; - border: 1px solid #d7dad7; + border: var(--material-border-quarternary); border-radius: 5px; - background: white; - + background: var(--material-background); + color: var(--fill-primary); + .header { font-weight: 600; - font-size: 11px; + font-size: calc(11em / 13); margin-top: 4px; - border-bottom: 1px solid #d7dad7; + border-bottom: var(--material-border-quarternary); padding: 0 8px 3px; } diff --git a/scss/merge.scss b/scss/merge.scss index 3dd6c1edf7..68841bdf00 100644 --- a/scss/merge.scss +++ b/scss/merge.scss @@ -85,3 +85,9 @@ merge-group { margin-right: 1em; font-weight: 600; } + +// zotero.css fixes groupbox headings at 14px; keep that size at the default 13px base +// but scale with the font size setting +merge-pane groupbox > label > h2 { + font-size: calc(14em / 13); +} diff --git a/test/tests/syncLocalTest.js b/test/tests/syncLocalTest.js index cd7d94c893..b0d249a046 100644 --- a/test/tests/syncLocalTest.js +++ b/test/tests/syncLocalTest.js @@ -1515,6 +1515,127 @@ describe("Zotero.Sync.Data.Local", function () { describe("#showConflictResolutionWindow()", function () { + // WCAG contrast ratio between an element's text color and the first opaque + // background behind it + function getContrast(win, elem) { + var parse = s => s.match(/[\d.]+/g).map(Number); + var luminance = ([r, g, b]) => { + var [R, G, B] = [r, g, b].map((c) => { + c /= 255; + return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4; + }); + return 0.2126 * R + 0.7152 * G + 0.0722 * B; + }; + var fg = parse(win.getComputedStyle(elem).color); + var bg = null; + for (let node = elem; node && node.nodeType == Node.ELEMENT_NODE; node = node.parentNode) { + let rgba = parse(win.getComputedStyle(node).backgroundColor); + if (rgba.length < 4 || rgba[3] == 1) { + bg = rgba; + break; + } + } + assert.ok(bg, "no opaque background found"); + var [l1, l2] = [luminance(fg), luminance(bg)].sort((a, b) => b - a); + return (l1 + 0.05) / (l2 + 0.05); + } + + function annotationConflict(annotation) { + var json = annotation.toJSON(); + return { + libraryID: annotation.libraryID, + key: annotation.key, + processed: false, + conflict: true, + left: json, + right: Object.assign({}, json, { annotationComment: "Changed" }), + changes: [], + conflicts: [] + }; + } + + it("should show annotation conflicts legibly in dark mode", async function () { + // The annotation box's page label needs the CSL locales + await Zotero.Styles.init(); + var attachment = await importPDFAttachment(); + var annotation = await createAnnotation('highlight', attachment); + Services.prefs.setIntPref('browser.theme.toolbar-theme', 0); + try { + var promise = waitForWindow('chrome://zotero/content/merge.xhtml', async function (dialog) { + var doc = dialog.document; + var wizard = doc.querySelector('wizard'); + try { + assert.isTrue(dialog.matchMedia('(prefers-color-scheme: dark)').matches); + + // The annotation box renders asynchronously + var container; + for (let i = 0; i < 100; i++) { + container = doc.querySelector('#left-pane .AnnotationBox .container'); + if (container) break; + await Zotero.Promise.delay(50); + } + assert.ok(container, "annotation box not rendered"); + for (let selector of ['.header', '.text', '.comment']) { + let elem = container.querySelector(selector); + assert.isAtLeast(getContrast(dialog, elem), 4.5, selector); + } + } + finally { + wizard.getButton('finish').click(); + } + }); + + Zotero.Sync.Data.Local.showConflictResolutionWindow([annotationConflict(annotation)]); + await promise; + } + finally { + Services.prefs.clearUserPref('browser.theme.toolbar-theme'); + } + }); + + it("should scale column headings with the font size", async function () { + var item = await createDataObject('item'); + var json = item.toJSON(); + var fontSize = Zotero.Prefs.get('fontSize'); + Zotero.Prefs.set('fontSize', '1.38'); + try { + var promise = waitForWindow('chrome://zotero/content/merge.xhtml', function (dialog) { + var doc = dialog.document; + var wizard = doc.querySelector('wizard'); + try { + var page = doc.querySelector('wizardpage'); + var pageSize = parseFloat(dialog.getComputedStyle(page).fontSize); + for (let h2 of doc.querySelectorAll('merge-pane h2')) { + let size = parseFloat(dialog.getComputedStyle(h2).fontSize); + // Name the rules that set the size, if it's too small + let rules = dialog.InspectorUtils.getMatchingCSSRules(h2) + .filter(r => r.style.fontSize || r.style.font) + .map(r => `${r.parentStyleSheet?.href} ${r.selectorText} ${r.style.fontSize || r.style.font}`); + assert.isAtLeast(size, pageSize, h2.textContent + " " + JSON.stringify(rules)); + } + } + finally { + wizard.getButton('finish').click(); + } + }); + + Zotero.Sync.Data.Local.showConflictResolutionWindow([{ + libraryID: item.libraryID, + key: item.key, + processed: false, + conflict: true, + left: json, + right: Object.assign({}, json, { title: "Changed" }), + changes: [], + conflicts: [] + }]); + await promise; + } + finally { + Zotero.Prefs.set('fontSize', fontSize); + } + }); + it("should show title of note parent", async function () { var parentItem = await createDataObject('item', { title: "Parent" }); var note = new Zotero.Item('note'); From 051d2a746b8ada2b67939bc795e7444c538eb2bf Mon Sep 17 00:00:00 2001 From: TheNEwmanator15 <3686761+Thenewmanator15@users.noreply.github.com> Date: Sat, 26 Sep 2026 10:58:03 +0100 Subject: [PATCH 2/5] Modernize the conflict resolution window Show each version as a card in the Zotero 7 style instead of red, underlined headings: the chosen version gets an accent ring and heading, unselected versions get the standard hover/pressed fills, and keyboard focus uses the shared focus ring. Only existing theme tokens and mixins are used, so it follows light/dark themes and high-contrast mode. Co-Authored-By: Claude Opus 5.5 --- scss/merge.scss | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/scss/merge.scss b/scss/merge.scss index 68841bdf00..6e1c548999 100644 --- a/scss/merge.scss +++ b/scss/merge.scss @@ -1,3 +1,7 @@ +@import "abstracts/variables"; +@import "abstracts/functions"; +@import "abstracts/mixins"; + wizardpage { overflow: hidden; min-width: 780px; @@ -16,15 +20,29 @@ merge-group { max-height: 0; min-width: 250px; + // Each version is a card; the chosen one gets an accent ring and heading & groupbox { flex: 1; + margin: 0; + padding: 6px 8px; + background: var(--material-background); + border: var(--material-border-quinary); + border-radius: 5px; + @include focus-ring; + } + + h2 { + font-weight: 600; + } + + &[selected] groupbox { + border-color: var(--color-accent); + box-shadow: 0 0 0 1px var(--color-accent); } &[selected] h2, &[selected] attachment-box #title { - color: red; - font-weight: 600; - text-decoration: underline; + color: var(--color-accent); } .parent-row { @@ -39,26 +57,25 @@ merge-group { min-width: 15em; } + .choose-button { + margin-inline: 0; + margin-top: 6px; + } + collapsible-section { border-bottom: none !important; } } + // Versions you can choose by clicking the whole card (notes and files use the button) &:not([mergetype="note"]) { - #left-pane:active h2, - #right-pane:active h2, - #left-pane:active attachment-box #title, - #right-pane:active attachment-box #title { - color: red; - font-weight: 600; + :is(#left-pane, #right-pane):not([selected]) groupbox:hover { + background: var(--material-mix-quinary); } - } - #left-pane:hover:not([selected]) h2, - #left-pane groupbox:focus:not([selected]) h2, - #right-pane:hover:not([selected]) h2, - #right-pane groupbox:focus:not([selected]) h2 { - text-decoration: underline; + :is(#left-pane, #right-pane):not([selected]) groupbox:active { + background: var(--material-mix-quarternary); + } } editable-text .input:read-only { From 60bb9f99cc16f30762d3bddb84457ad80f7ea9b3 Mon Sep 17 00:00:00 2001 From: TheNEwmanator15 <3686761+Thenewmanator15@users.noreply.github.com> Date: Sat, 26 Sep 2026 11:51:33 +0100 Subject: [PATCH 3/5] Conflict window: keep rings unclipped, accent only the heading Pad the merge group so the keyboard focus ring and the selected ring aren't cut off by the scroll container, and drop the accent color on the chosen attachment's title, which read as a link; the heading already marks the chosen version. Co-Authored-By: Claude Opus 5.5 --- scss/merge.scss | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scss/merge.scss b/scss/merge.scss index 6e1c548999..aa3b8a2955 100644 --- a/scss/merge.scss +++ b/scss/merge.scss @@ -12,6 +12,8 @@ merge-group { display: flex; overflow: hidden auto; gap: 8px; + // Room for the focus ring and the selected ring, which the scrollport would clip + padding: 4px; merge-pane { flex: 1; @@ -40,8 +42,8 @@ merge-group { box-shadow: 0 0 0 1px var(--color-accent); } - &[selected] h2, - &[selected] attachment-box #title { + // Only the heading: an accent-colored attachment title would read as a link + &[selected] h2 { color: var(--color-accent); } From 9cecd661fbb97a9df019d86ff8af02a8aecc6f93 Mon Sep 17 00:00:00 2001 From: TheNEwmanator15 <3686761+Thenewmanator15@users.noreply.github.com> Date: Sat, 26 Sep 2026 11:57:14 +0100 Subject: [PATCH 4/5] Conflict window: mark the chosen version in high contrast Forced colors remove the selected ring's box-shadow and map the accent border and heading to ordinary text colors, leaving no way to tell which version is chosen. Use a Highlight border and an underlined Highlight heading there instead. Co-Authored-By: Claude Opus 5.5 --- scss/merge.scss | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scss/merge.scss b/scss/merge.scss index aa3b8a2955..8def73963b 100644 --- a/scss/merge.scss +++ b/scss/merge.scss @@ -47,6 +47,21 @@ merge-group { color: var(--color-accent); } + // Forced colors drop the ring's shadow and repaint the accent as plain text color, + // so mark the chosen version with a Highlight border and an underlined heading + @media (forced-colors: active) { + &[selected] groupbox { + border: 2px solid Highlight; + padding: 5px 7px; + } + + // Highlight is a background color and can be unreadable as text, so underline instead + &[selected] h2 { + color: CanvasText; + text-decoration: underline; + } + } + .parent-row { margin: 7px 5px; From 1d206d3f3c27d480156f5d35bcc03226024457ac Mon Sep 17 00:00:00 2001 From: TheNEwmanator15 <3686761+Thenewmanator15@users.noreply.github.com> Date: Wed, 7 Oct 2026 19:14:51 +0100 Subject: [PATCH 5/5] Conflict window: style the annotation box like the item pane's rows Match the item pane's annotation rows: the annotation type icon in the annotation's color next to the page label, and the same borders and spacing. The quoted text keeps the primary text color, since it's what the user has to read to choose a version. Co-Authored-By: Claude Opus 5.5 --- .../content/zotero/components/annotation.jsx | 12 ++--- scss/components/_annotation.scss | 48 ++++++++++++------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/chrome/content/zotero/components/annotation.jsx b/chrome/content/zotero/components/annotation.jsx index 6037551dc2..20fc5f254e 100644 --- a/chrome/content/zotero/components/annotation.jsx +++ b/chrome/content/zotero/components/annotation.jsx @@ -34,19 +34,19 @@ import cx from 'classnames'; // We'll want to replace this with a single component shared between the PDF reader and the rest // of the codebase. function AnnotationBox({ data }) { - var textStyle = { - borderLeft: "2px solid " + data.color - }; - + // Same icons as the item pane's annotation rows + var iconType = data.type == 'image' ? 'area' : data.type; + return (
{Zotero.getString('itemTypes.annotation')}
-
+
+
{Zotero.Cite.getLocatorString('page')} {data.pageLabel}
{data.text !== undefined - ?
{data.text}
+ ?
{data.text}
: ''} {data.type == 'image' // TODO: Localize diff --git a/scss/components/_annotation.scss b/scss/components/_annotation.scss index 718b7a70a4..55b8f31397 100644 --- a/scss/components/_annotation.scss +++ b/scss/components/_annotation.scss @@ -1,3 +1,4 @@ +// Styled after the item pane's annotation rows (elements/_annotationRow.scss) .AnnotationBox { // Sizes relative to the 13px base, so they follow Zotero's font size setting .title { @@ -11,35 +12,46 @@ display: flex; flex-direction: column; margin: 5px; - border: var(--material-border-quarternary); + border: 1px solid var(--fill-quinary); border-radius: 5px; background: var(--material-background); color: var(--fill-primary); .header { + display: flex; + align-items: center; + gap: 4px; font-weight: 600; - font-size: calc(11em / 13); - margin-top: 4px; - border-bottom: var(--material-border-quarternary); - padding: 0 8px 3px; + border-bottom: 1px solid var(--fill-quinary); + padding: 4px 8px; + + .icon { + width: 16px; + height: 16px; + -moz-context-properties: fill; + fill: var(--annotation-color, var(--fill-secondary)); + } } - + .text, .image-placeholder, .comment { - margin-left: 8px; - margin-right: 8px; - margin-bottom: 4px; + overflow-wrap: anywhere; } - - .text, .image-placeholder { - margin-top: 8px; - } - + + // Unlike the item pane's rows, the quote keeps the primary text color: it's what the + // user has to read to choose a version .text { - padding-left: 7px; + margin: 5px 8px; + padding-inline-start: 6px; + border-inline-start: 2px solid var(--annotation-color, var(--fill-secondary)); } - + + .image-placeholder { + margin: 5px 8px; + color: var(--fill-secondary); + } + .comment { - margin-top: 4px; + padding: 3px 8px 5px; } } -} \ No newline at end of file +}