1+ import { i18n } from 'stackable'
2+ import DEFAULT_PRESETS from '~stackable/plugins/global-settings/preset-controls/presets.json'
13import { useSettings } from '@wordpress/block-editor'
24import { useSelect } from '@wordpress/data'
3- import DEFAULT_PRESETS from '~stackable/plugins/global-settings/preset-controls/presets.json '
5+ import { __ } from '@wordpress/i18n '
46
57const PRESET_MAPPING = {
68 fontSizes : {
@@ -21,6 +23,12 @@ const PRESET_MAPPING = {
2123 } ,
2224}
2325
26+ const nonePreset = {
27+ name : __ ( 'None' , i18n ) ,
28+ size : '0px' ,
29+ slug : 'none' ,
30+ }
31+
2432export const usePresetControls = property => {
2533 // Get the theme presets for the property
2634 const [ themePresets ] = useSettings ( PRESET_MAPPING [ property ] . settings . join ( '.' ) )
@@ -56,10 +64,12 @@ export const usePresetControls = property => {
5664
5765 // Get the merge preset marks with the CSS Variable value
5866 // Setting customOnly to true returns the preset marks for custom presets only
59- const getPresetMarks = ( { customOnly = false , additionalPresets = [ ] } = { } ) => {
67+ // Setting addNonePreset to true adds a none preset with a value of 0
68+ const getPresetMarks = ( { customOnly = false , addNonePreset = false } = { } ) => {
6069 const prefix = PRESET_MAPPING [ property ] . prefix
6170 let presets = customOnly ? allCustomPresets [ property ] ?? [ ] : getMergedPresets ( )
62- presets = [ ...additionalPresets , ...presets ]
71+ // Add the none preset
72+ presets = [ ...( addNonePreset ? [ nonePreset ] : [ ] ) , ...presets ]
6373
6474 return presets
6575 . filter ( preset => ! ( preset ?. isDiscarded ) )
0 commit comments