fix(editor): always use random hex colors

chance.color() can output all valid CSS
values for colors, including rgba() syntax and predefined color
names. Due to the usage of hex2rgb and other methods, this can
break the editor. This commit ensures that all randomly generated
colors are specified in hex format.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson
2026-02-10 15:09:28 +01:00
parent 7408217b6a
commit fd4d5bfbd1
4 changed files with 9 additions and 3 deletions

View File

@@ -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)