I could solve it with the function getColorObjectByColorValue (take a look at the gutenberg files).
If you have something like
const backgroundColors = [
{
name: 'Light Green',
slug: 'light-green',
color: '#E6F0F0'
},
{
name: 'Light Gray',
slug: 'light-gray',
color: '#F7F7F7'
}
];
then you can get the color name by
const test = getColorObjectByColorValue(backgroundColors, backgroundColor);
console.log(test.name);
Should also work with the default palette.
Related Posts:
- check if Gutenberg is currently in use
- How to use PanelColorSettings in custom Gutenberg block?
- Custom action button in Gutenberg editor (post_submitbox_misc_actions – equivalent)
- How to save block attributes when the output doesn’t change
- How to remove unwanted panels inside InspectorControls from core blocks in Gutenberg
- Gutenberg ServerSideRender is deprecated, how to work with new wp.serverSideRender component?
- Create Element From Dynamic HTML String [closed]
- creating elements/innerblocks via rangecontrol
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- Looking for callback function after Gutenberg is rendered?
- How to Parse an Array of Elements in Gutenberg Block
- Using the component outside the editor. select(‘core’) is null
- Gutenberg is there a way to know if the current block is reusable?
- How to allow core Gutenberg blocks selection only when you are inside a custom inner block
- Is there a better way to implement responsive images than what WordPress uses by default?
- Gutenberg registerFormatType with Multiple Classes
- Saving data from block editor to the database
- Gutenberg Block add element in the Editor inside InnerBlocks after div – editor-block-list
- Gutenberg – What is the best way to save/update post meta?
- How do you render_callback for register_block_type to a method in another class?
- How to create multiple Gutenberg blocks in one plugin
- Gutenberg Block showing invalid content on edit
- WordPress Block Development – trouble importing from @wordpress/icons
- Is there an additional block.json property to set to get an InnerBlocks child to respect the “supports” property?
- How to setAttributes in Gutenberg block?
- How to access noticeOperations from withNotices
- How to prevent UNDO on guternberg block editor
- How to insert text at the current cursor position in Gutenberg?
- How to override gutenberg paragraph block edit property
- Do I have to worry about useState causing a re-render?
- What’s the right way to instantiate new blocks and/or the plugin itself in toto when using wppb architecture?
- Creating a custom Gutenberg block with columns
- How to get boolean value from register_meta properly?
- How can I get the selected string when using a toolbar button in Gutenberg?
- jQuery selectors for editor elements safe to use?
- There is a problem in the gutenberg block I developed. Problem is with withInstanceId
- Gutenberg table block with Bootstrap .table class
- How to control an elements classes from multiple Gutenberg sidebar controls?
- How to add a gradient component to a custom block
- How to only load css for used blocks on frontend
- Additional classes `undefined` after saving post in Gutenberg
- How do you submit a Gutenberg plugin?
- Invalid hook call on save, not edit when using swiper slider
- How to add template colors to custom block options in WordPress Gutenberg editor sidebar?
- How to save post meta as an array in Gutenberg?
- How to properly package a block plugin
- Developing the save function in Gutenberg blocks
- WordPress Gutenberg InnerBlocks renderAppender not showing with template
- Modify custom block plugin without losing content
- Console errors in 6.0-RC1 Widget screen
- How to override supports of innerBlocks?
- How to use attributes in competent of Gutenberg
- When setting styles to an extended block that was saved as a pattern, it doesn’t remove the style that was there
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- extraprops override existing props
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- WPGut – Updating failed and shortcode?
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- Gutenberg – Call google map render function in save after DOM has been rendered
- Gutenberg block breaks when showing new data
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- Is “document loaded” different on admin side than public side?
- How to re-render inspector controls?
- How to use setAttributes outside of the edit function return
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Where do I hook to have the server do something in PHP on block attribute change?
- Where to save Gutenberg plugin data?
- Gutenberg component in a plugin admin
- How to integrate plugins into block editor
- Add custom html classes to gutenberg wrapper
- How to get access the ID of all posts of custom post type in Gutenberg editor
- How to create save function for custom Gutenberg style block?
- Gutenberg and custom blocks messed up pagespeed score. What did I wrong?
- Gutenberg text field validation
- Undo operation not working in Rich text [Gutenberg]
- How can i add insertion point between inner blocks in my custom block like core blocks
- Render raw html in Gutenberg block
- Build a dynamic block using the default attributes
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- REST API error in block editor for custom templates
- Reinitiate Gutenburg’s blocks using javascript
- Remove Gutenberg Buttons Block
- Set srcset on a block image
- Insert text programmatically in WordPress Gutenberg Editor
- Javascript function defined in view.js not reachable from save.js
- WordPress 6.6.1 – Trying to make a block but receive error, “! Cannot read property ‘then’ of undefined”
- Event when Modal is opened/visible
- Template locked block does not show appender
- Access DOM Element in Gutenberg Block on WP Admin Post Edit Screen
- Custom Gutenberg Block ‘Stylized List’ – Incorrect Rendering and Looping of List Items
- How to detect when the user clicks the publish/update button in Gutenberg Editor
- Gutenberg Static blocks: viewScript doesn’t import css for frontend?
- Custom Gutenberg block with nested InnerBlocks renderAppender not displaying add button
- Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?
- Can we write custom DOM manipulation inside edit.js file while developing custom Gutenberg block?
- User set default settings for a Block in Site Editor
- Attributes array not saving values
- how to include an image in the build of a multi block plugin
- Insert Button in to the Block Editor (Header) Toolbar