diff --git a/lib/letter-avatars.js b/lib/letter-avatars.js index 5f489248..235baf8b 100644 --- a/lib/letter-avatars.js +++ b/lib/letter-avatars.js @@ -8,6 +8,7 @@ const config = require('./config') exports.generateAvatar = function (name) { // use darker colors for better contrast const color = new Chance(name).color({ + format: 'hex', max_red: 150, max_green: 150, max_blue: 150 diff --git a/lib/realtime.js b/lib/realtime.js index 9a28b8e5..ac727180 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -710,7 +710,7 @@ function connection (socket) { // initialize user data // random color - let color = chance.color() + let color = chance.color({ format: 'hex' }) // make sure color not duplicated or reach max random count if (notes[noteId]) { let randomcount = 0 @@ -723,7 +723,7 @@ function connection (socket) { } }) if (found) { - color = chance.color() + color = chance.color({ format: 'hex' }) randomcount++ } } while (found && randomcount < maxrandomcount) diff --git a/public/docs/release-notes.md b/public/docs/release-notes.md index 87b87cf5..ec231601 100644 --- a/public/docs/release-notes.md +++ b/public/docs/release-notes.md @@ -1,5 +1,10 @@ # Release Notes +## Unreleased + +### Bugfixes +- Random colors for user's cursors and selections are now always in hex format to avoid conversion errors + ## 1.10.6 2026-02-04 ### Security fixes diff --git a/public/js/index.js b/public/js/index.js index 22f7ab9d..9e37e1fd 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -427,7 +427,7 @@ const supportExtraTags = [ text: '[random color tag]', search: '[]', command: function () { - const color = chance().color() + const color = chance().color({ format: 'hex' }) return '[color=' + color + ']' } }