I am writing a plugin and attempting to alter what attribute gets updated when changing the value of an input in the editor sidepanel. I am filtering a function through editor.BlockEdit
using wppose.createHigherOrderComponent
. I am able to do something like below to add to the 'dimensions' (margin and padding) panel:
return (
<Fragment>
<BlockEdit {...props} />
{isSelected && props.name === "core/paragraph" && (
<InspectorControls group="dimensions">
<TextControl
label="Custom input"
value={value}
onChange={value => setAttribute('myAttribute', value)}
/>
</InspectorControls>
)}
</Fragment>
);
In theory this will update my custom attribute 'myAttribute' when the TextControl
changes. Within the dimensions panel there's existing TextControl
inputs which update the style.spacing
attributes. Am I able to filter/hook into/alter in any way the functionality of the existing TextControl
s' onChange
so I could, say, update style.myAttribute
instead of the default attribute?