Fix missing inline authorship colors

The hex2rgb function seems to previously have been available globally.
It probably got lost in the great Webpack refactoring and nobody noticed
 that.

 This copies the function into its own file (to make importing it easy)
 and adds an import in index.js.

 Fixes https://github.com/hedgedoc/hedgedoc/issues/2248

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-04-08 12:13:37 +02:00
parent 61e092e8af
commit e0021036ae
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
4 changed files with 20 additions and 2 deletions

17
public/vendor/ot/hex2rgb.js vendored Normal file
View file

@ -0,0 +1,17 @@
function hex2rgb (hex) {
if (hex[0] == '#') hex = hex.substr(1)
if (hex.length == 3) {
var temp = hex
hex = ''
temp = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp).slice(1)
for (var i = 0; i < 3; i++) hex += temp[i] + temp[i]
}
var triplets = /^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(hex).slice(1)
return {
red: parseInt(triplets[0], 16),
green: parseInt(triplets[1], 16),
blue: parseInt(triplets[2], 16)
}
}
module.exports = hex2rgb