Skip to content

Commit

Permalink
Register srgb color space if not registered
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmeister committed Jun 4, 2024
1 parent 563ef8b commit 909f2d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frontend/src/components/form/base/EColorField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default {
},
emits: ['input'],
setup() {
ColorSpace.register(sRGB)
if (!('srgb' in ColorSpace.registry)) {
ColorSpace.register(sRGB)
}
},
methods: {
format(value) {
Expand All @@ -56,7 +58,11 @@ export default {
}
return !value
? ''
: serialize(value, { format: 'hex', collapse: false }).toUpperCase()
: serialize(value, {
space: 'srgb',
format: 'hex',
collapse: false,
}).toUpperCase()
},
/**
* @param {string} value
Expand All @@ -66,7 +72,7 @@ export default {
return null
}
try {
const color = parse(value, { space: 'srgb' })
const color = parse(value)
color.alpha = 1
return reactive(color)
} catch (e) {
Expand Down

0 comments on commit 909f2d7

Please sign in to comment.