From fda2ece848d4763f0f4687a50dc3a651b97c4124 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 14 Apr 2026 12:59:21 +0100 Subject: [PATCH] Add showAuthorColors pad option to default authorship colors off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a new padOptions.showAuthorColors setting (default: true) that lets admins default authorship colors to off for new users. Users can still toggle colors on via the checkbox — their cookie preference always overrides the server default. - Settings.ts: add showAuthorColors to padOptions type and defaults - pad.ts: process showAuthorColors from padOptions, apply as default, ensure cookie preference (true or false) overrides server setting - settings.json.template + settings.json.docker: document the option - SocketIOMessage.ts: add to PadOption type Fixes #5563 Co-Authored-By: Claude Opus 4.6 (1M context) --- settings.json.docker | 1 + settings.json.template | 1 + src/node/utils/Settings.ts | 2 ++ src/static/js/pad.ts | 20 +++++++++++++++++++- src/static/js/types/SocketIOMessage.ts | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/settings.json.docker b/settings.json.docker index a265a9235..3fa749503 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -273,6 +273,7 @@ */ "padOptions": { "noColors": "${PAD_OPTIONS_NO_COLORS:false}", + "showAuthorColors": "${PAD_OPTIONS_SHOW_AUTHOR_COLORS:true}", "showControls": "${PAD_OPTIONS_SHOW_CONTROLS:true}", "showChat": "${PAD_OPTIONS_SHOW_CHAT:true}", "showLineNumbers": "${PAD_OPTIONS_SHOW_LINE_NUMBERS:true}", diff --git a/settings.json.template b/settings.json.template index 9f0bc55a0..0a655cd5a 100644 --- a/settings.json.template +++ b/settings.json.template @@ -252,6 +252,7 @@ */ "padOptions": { "noColors": false, + "showAuthorColors": true, "showControls": true, "showChat": true, "showLineNumbers": true, diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts index d25c3d4e1..f6f758d84 100644 --- a/src/node/utils/Settings.ts +++ b/src/node/utils/Settings.ts @@ -192,6 +192,7 @@ export type SettingsType = { defaultPadText: string, padOptions: { noColors: boolean, + showAuthorColors: boolean, showControls: boolean, showChat: boolean, showLineNumbers: boolean, @@ -398,6 +399,7 @@ const settings: SettingsType = { */ padOptions: { noColors: false, + showAuthorColors: true, showControls: true, showChat: true, showLineNumbers: true, diff --git a/src/static/js/pad.ts b/src/static/js/pad.ts index d9cc4e902..812fbc417 100644 --- a/src/static/js/pad.ts +++ b/src/static/js/pad.ts @@ -69,6 +69,13 @@ const getParameters = [ $('#clearAuthorship').hide(); }, }, + { + name: 'showAuthorColors', + checkVal: 'false', + callback: (val) => { + settings.showAuthorColorsDisabled = true; + }, + }, { name: 'showControls', checkVal: 'true', @@ -461,7 +468,10 @@ const pad = { chat.chatAndUsers(true); // stick it to the screen $('#options-chatandusers').prop('checked', true); // set the checkbox to on } - if (padcookie.getPref('showAuthorshipColors') === false) { + const authorColorsPref = padcookie.getPref('showAuthorshipColors'); + if (authorColorsPref === true) { + pad.changeViewOption('showAuthorColors', true); + } else if (authorColorsPref === false) { pad.changeViewOption('showAuthorColors', false); } if (padcookie.getPref('showLineNumbers') === false) { @@ -555,6 +565,13 @@ const pad = { this.changeViewOption('noColors', true); } + // If showAuthorColors is set to false in padOptions, default colors off. + // The user can still toggle them on via the checkbox; the cookie will + // override this default on subsequent visits. + if (settings.showAuthorColorsDisabled === true) { + this.changeViewOption('showAuthorColors', false); + } + // RTL override is applied in postAceInit (after padeditor.init resolves) // to avoid a race where setViewOptions(initialViewOptions) overwrites it. @@ -783,6 +800,7 @@ const init = () => pad.init(); const settings = { LineNumbersDisabled: false, noColors: false, + showAuthorColorsDisabled: false, useMonospaceFontGlobal: false, globalUserName: false, globalUserColor: false, diff --git a/src/static/js/types/SocketIOMessage.ts b/src/static/js/types/SocketIOMessage.ts index f2b8cfc14..99622b01e 100644 --- a/src/static/js/types/SocketIOMessage.ts +++ b/src/static/js/types/SocketIOMessage.ts @@ -239,6 +239,7 @@ export type PadOptionsMessage = { export type PadOption = { "noColors"?: boolean, + "showAuthorColors"?: boolean, "showControls"?: boolean, "showChat"?: boolean, "showLineNumbers"?: boolean,