I’m trying to add box shadow to the core group block.
I’m using filters, since we are talking about extending a core block and not creating a block from scratch.
The issue is that all works correctly in the front end but I cannot make the changes display in the editor itself.
This is my getSaveContent filter function:
const ApplyBoxShadow = (extraProps, blockType, attributes) => {
const {
horizontalAxis,
verticalAxis,
blurAmount,
spreadAmount,
shadowColor,
inset
} = attributes;
//console.log('the extra props: ', blockType.name);
if (blockType.name == 'core/group') {
Object.assign( extraProps, { style: { 'box-shadow': `${horizontalAxis}px ${verticalAxis}px ${blurAmount}px ${spreadAmount}px ${shadowColor}` } } );
}
return extraProps;
}
wp.hooks.addFilter(
'blocks.getSaveContent.extraProps',
'gutrs/gutrs-box-shadow-style',
ApplyBoxShadow
);
Any idea why this is working in the front but not in the editor?
best regards