plugin development - Is it possible to alter or replace the onChange function of an input within the InspectorControls panel?

admin2025-01-08  5

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 TextControls' onChange so I could, say, update style.myAttribute instead of the default attribute?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736266878a1156.html

最新回复(0)