etherpad-lite/src/node/utils
John McLear ab0cff4d95
fix(7606): sync theme-color meta with client-side dark-mode switch (#7690)
* fix(7606): sync theme-color meta with client-side dark-mode switch

PR #7636 emits <meta name="theme-color"> server-side from
settings.skinVariants. That covers operators who hard-code a dark
toolbar in settings.json, but not the runtime path: pad.ts auto-flips
the toolbar to super-dark when enableDarkMode is on, the browser
reports prefers-color-scheme: dark, and no localStorage white-mode
override is set, plus the user can flip it via #options-darkmode.
Both paths run skinVariants.updateSkinVariantsClasses(), which until
now never touched the meta — so dark-mode users kept the light
#ffffff baseline and saw a white address bar above a dark toolbar
(stffen on #7606 after 2.7.3).

Push the toolbar-color lookup into updateSkinVariantsClasses so the
meta tracks every class change: the auto-switch on init, the user
toggle, and the skinVariants builder. Mirrors the CSS-source-order
table from src/node/utils/SkinColors.ts (last matching *-toolbar
token wins). When no meta is present (non-colibris skin, server
omits it) the helper is a no-op.

Adds Playwright coverage for both paths under
colorScheme: 'light' (manual toggle) and 'dark' (auto-switch on
dark-OS clients — the case stffen reported).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(theme-color): action Qodo PR review

(1) Bug — duplicated toolbar→color table: extract the CSS-source-order
mapping and the default-color constant into src/static/js/skin_toolbar_colors,
re-imported by both src/node/utils/SkinColors.ts (server, EJS template
helper) and src/static/js/skin_variants.ts (client, runtime updates). Lives
under static/js so the browser bundle can resolve it; server-side imports
of static/js modules already exist (Changeset, AttributeMap, ImportHtml,
hooks). One source of truth means a future palette change can no longer
silently desync the server-rendered baseline meta from the client updates,
which was the exact regression that brought us here.

(2) Rule violation — 4-space continuation indentation in the new
Playwright spec: re-indent the themeColor helper and the multiline
test(...) call to the repo's 2-space rule (.editorconfig).

Existing backend coverage (configuredToolbarColor unit tests + the
specialpages server-render checks for both pad and timeslider) still
passes against the refactored helper, so it's regression-locked end to
end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 10:43:29 +01:00
..
AbsolutePaths.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
anonymizeIp.ts feat(gdpr): IP/privacy audit (PR2 of #6701) (#7547) 2026-05-01 13:47:40 +01:00
checkValidRev.ts Added typescript to etherpad 2024-02-05 21:13:02 +01:00
Cleanup.ts chore: moved first files to esm (#7061) 2025-08-04 19:59:28 +02:00
Cli.ts chore: use args from cmd (#7112) 2025-09-03 21:01:20 +02:00
customError.ts Added typescript to etherpad 2024-02-05 21:13:02 +01:00
ensureAuthorTokenCookie.ts feat(gdpr): HttpOnly author-token cookie (PR3 of #6701) (#7548) 2026-05-03 05:56:56 +01:00
ExportEtherpad.ts fix(export): /export/etherpad honors the :rev URL segment (#7566) 2026-04-26 10:29:02 +02:00
ExportHelper.ts Feat/changeset ts (#6594) 2024-08-18 12:14:24 +02:00
ExportHtml.ts fix(editor): preserve U+00A0 non-breaking space (#3037) (#7585) 2026-04-23 08:57:30 +01:00
ExportTxt.ts feat!: replace Abiword with LibreOffice and add DOCX export (#7539) 2026-04-19 09:08:22 +01:00
ImportEtherpad.ts Moved to ts (#6593) 2024-08-17 20:14:36 +02:00
ImportHtml.ts Feat/changeset ts (#6594) 2024-08-18 12:14:24 +02:00
LibreOffice.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
Minify.ts chore: migrated settings to esm6 (#7062) 2025-08-04 22:42:50 +02:00
MinifyWorker.ts Feat/frontend vitest (#6469) 2024-08-16 22:55:42 +02:00
NodeVersion.ts chore: moved first files to esm (#7061) 2025-08-04 19:59:28 +02:00
padDiff.ts fix: createDiffHTML API fails with "Not a changeset: undefined" (#7445) 2026-04-04 08:25:26 +01:00
path_exists.ts Moved path_exists and promises to es6 2024-08-18 19:52:21 +02:00
promises.ts Moved path_exists and promises to es6 2024-08-18 19:52:21 +02:00
randomstring.ts chore: moved first files to esm (#7061) 2025-08-04 19:59:28 +02:00
run_cmd.ts feat(packaging): add Debian (.deb) build via nfpm with systemd unit (v2) (#7583) 2026-04-27 10:33:30 +01:00
sanitizePathname.ts Feat/frontend vitest (#6469) 2024-08-16 22:55:42 +02:00
Settings.ts feat(settings): enable Pad-wide Settings by default; fix misleading modal title (#7679) 2026-05-07 10:01:04 +01:00
SettingsTree.ts Enforce 2-space indentation across codebase (#7426) 2026-04-01 19:48:45 +01:00
SkinColors.ts fix(7606): sync theme-color meta with client-side dark-mode switch (#7690) 2026-05-07 10:43:29 +01:00
socialMeta.ts feat: Open Graph & Twitter Card metadata for pad/timeslider/home (closes #7599) (#7635) 2026-05-01 10:43:29 +01:00
Stream.ts Added typescript to etherpad 2024-02-05 21:13:02 +01:00
tar.json Changeset: New API to simplify attribute processing 2021-11-21 04:11:41 -05:00
toolbar.ts Fix ESM/CJS interop for Settings module breaking plugin compatibility (#7421) 2026-04-01 11:39:40 +01:00
UpdateCheck.ts chore: removed axios (#7685) 2026-05-06 22:06:04 +02:00