diff --git a/CHANGELOG.md b/CHANGELOG.md index 8266bb154d..a65206e263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,22 +2,27 @@ ## UNRELEASED -### Adds - -* When validating an `area` field, warn the developer if `widgets` is not nested in `options`. - ### Fixes * Focus properly Widget Editor modals when opened. Keep the previous active focus on the modal when closing the widget editor. * a11y improvements for context menus. * Fixes broken widget preview URL when the image is overridden (module improve) and external build module is registered. +* Fixes ability to change color hue by clicking the color hue bar rather than dragging the indicator +* Prevents the rich text control bar from closing while using certain UI within the color picker ### Adds +* When validating an `area` field, warn the developer if `widgets` is not nested in `options`. +* Ability to disable the color spectrum UI of a color picker * Adds support for supplying CSS variable names to a color field's `presetColors` array as selectable values. * Adds support for dynamic focus trap in Context menus (prop `dynamicFocus`). When set to `true`, the focusable elements are recalculated on each cycle step. * Adds option to disable `tabindex` on `AposToggle` component. A new prop `disableFocus` can be set to `false` to disable the focus on the toggle button. It's enabled by default. +### Changes + +* The `pickerOptions` sub property of a color field's configuration has been merged with it's parent `options` object. + + ## 4.10.0 (2024-11-20) ### Fixes diff --git a/modules/@apostrophecms/color-field/index.js b/modules/@apostrophecms/color-field/index.js index bee8cbc929..95f149819d 100644 --- a/modules/@apostrophecms/color-field/index.js +++ b/modules/@apostrophecms/color-field/index.js @@ -10,6 +10,17 @@ module.exports = { self.name = self.options.name; self.addFieldType(); self.enableBrowserData(); + self.defaultOptions = { + format: 'hex8', + disableAlpha: false, + disableFields: false, + disableSpectrum: false, + presetColors: [ + '#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', + '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', + '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF' + ] + }; }, methods(self) { return { @@ -36,7 +47,8 @@ module.exports = { getBrowserData(req) { return { name: self.name, - action: self.action + action: self.action, + defaultOptions: self.defaultOptions }; } }; diff --git a/modules/@apostrophecms/color-field/ui/apos/components/AposColor.vue b/modules/@apostrophecms/color-field/ui/apos/components/AposColor.vue index 4d532bddd2..0ec8f75ccf 100644 --- a/modules/@apostrophecms/color-field/ui/apos/components/AposColor.vue +++ b/modules/@apostrophecms/color-field/ui/apos/components/AposColor.vue @@ -3,14 +3,22 @@ role="application" aria-label="Color picker" class="apos-color" - :class="[disableAlpha ? 'apos-color--disable-alpha' : '']" + :class="[ + disableAlpha ? 'apos-color--disable-alpha' : null, + disableSpectrum ? 'apos-color--disable-spectrum' : null, + disableFields ? 'apos-color--disable-fields' : null, + !presetColors ? 'apos-color--disable-presets' : null + ]" > -
+
-
+
-
+
@@ -68,6 +76,7 @@
diff --git a/modules/@apostrophecms/color-field/ui/apos/lib/AposColorHue.vue b/modules/@apostrophecms/color-field/ui/apos/lib/AposColorHue.vue index eb3245aac6..e992b66135 100644 --- a/modules/@apostrophecms/color-field/ui/apos/lib/AposColorHue.vue +++ b/modules/@apostrophecms/color-field/ui/apos/lib/AposColorHue.vue @@ -2,7 +2,7 @@
{ return window.apos.modules['@apostrophecms/rich-text-widget']; }); @@ -113,33 +99,11 @@ export default defineComponent({ const areaOptions = props.options || {}; const userOptions = computed(() => { - return { + const options = { ...projectOptions.value, ...areaOptions }; - }); - - const mergedOptions = computed(() => { - return { - ...defaultOptions, - ...userOptions.value.color - }; - }); - - const pickerOptions = computed(() => { - const { - presetColors, disableAlpha, disableFields - } = mergedOptions.value; - - return { - presetColors, - disableAlpha, - disableFields - }; - }); - - const format = computed(() => { - return mergedOptions.value.format; + return options.color; }); const pickerValue = ref(next.value || ''); @@ -177,16 +141,8 @@ export default defineComponent({ }; const update = (value) => { - let color; - if (value._cssVariable) { - next.value = value._cssVariable; - color = `var(${next.value})`; - } else { - tinyColorObj.value = new TinyColor(value.hsl); - next.value = tinyColorObj.value.toString(format.value); - color = next.value; - } - props.editor.chain().focus().setColor(color).run(); + next.value = value; + props.editor.chain().focus().setColor(value).run(); indicatorColor.value = next.value; }; @@ -201,7 +157,11 @@ export default defineComponent({ const handleMouseDown = (event) => { const target = event.target; - if (target.closest('.apos-color__saturation-wrap') || target.closest('.apos-color__presets')) { + if ( + target.closest('.apos-color__saturation-wrap') || + target.closest('.apos-color__presets') || + target.closest('.apos-color__controls') + ) { event.preventDefault(); } else { props.editor.view.dom.focus(); @@ -211,10 +171,9 @@ export default defineComponent({ return { active, indicatorColor, - pickerOptions, + userOptions, pickerValue, hasSelection, - startsNull, open, close, update,