I am looking for a way to retrieve the array of color objects you can set in the theme using add_theme_support('editor-color-palette', [...]);
Somehow I cannot find any information in the documentation on how to retrieve the theme colors inside a custom block.
<ColorPalette
onChange={ value => onChange(index, 'color', value) }
/>
I need the array of colors inside the onChange
callback to convert a hex color to the slug color name I have set inside php using the function getColorObjectByColorValue(themeColorsArray, callbackValueHexColor)
.
Just for future readers, thanks for the answer @tobiasegli
<ColorPalette
colors={wp.data.select( "core/editor" ).getEditorSettings().colors }
label={'bg color'}
value={ color }
onChange={ ( color ) => setState( { color } ) }
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With