Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override core block InspectorControls panel #27752

Closed
jkva opened this issue Dec 16, 2020 · 3 comments
Closed

Override core block InspectorControls panel #27752

jkva opened this issue Dec 16, 2020 · 3 comments
Labels
[Feature] Inspector Controls The interface showing block settings and the controls available for each block Needs Technical Feedback Needs testing from a developer perspective.

Comments

@jkva
Copy link

jkva commented Dec 16, 2020

I'm working on a WordPress plugin which allows image alternative text to be managed through the Coyote Service.

To ideally integrate, I would like to be able to hook into the core/image block and override the default rendering of the alt text input field in the block's InspectorControls, to:

  1. set it to readonly
  2. replace the value with the externally defined alt text for the image
  3. add clarifying link to the panel, e.g. Manage image description at Coyote service

Thus the plugin acts purely as a content filter and it not needing to modify the actual post content.

From what I can tell it's currently not possible to hook into core block InspectorControls rendering. I am able to add panels, but not able to change or redefine native core block panels.

Potential related issues I've found:

Thank you.

@talldan
Copy link
Contributor

talldan commented Dec 17, 2020

You won't be able to override the textarea element using any of the extensibility provided, but it is possible to control the value of the alt attribute of the block and as you mention add additional UI.

Some links to the documentation:

As far as I know, there's no roadmap to provide the kind of functionality you're after and I don't fully understand the use case. Wouldn't making it readonly be frustrating for users? What happens if multiple plugins want to extend this in different ways?

@jkva
Copy link
Author

jkva commented Dec 17, 2020

Hi @talldan, thanks for your response.

it is possible to control the value of the alt attribute of the block and as you mention add additional UI.

Those slotfills look useful, thank you. I don't see a way of hooking into the InspectorControls for core/image but perhaps I could use something that comes close to it - unless I misunderstand the documentation.

I don't fully understand the use case. Wouldn't making it readonly be frustrating for users?

The point of the plugin is to show the "Coyote managed alt text" for the image in the editor and showing where this alt text is to be managed, without modifying the post content itself. Specifically, not to have this alt text be injected into the post content and hence be stored when the post is saved. The plugin should function purely as a content filter so that when it is uninstalled, post content remains unaffected.

Hence the goal would be to only modify the value of the alt text input field, setting it to readonly, and adding a management link to clarify why this is the case.

What happens if multiple plugins want to extend this in different ways?

That might be a tricky use case. I wouldn't have a clear cut answer on how to reconcile that.

@annezazu annezazu added [Feature] Inspector Controls The interface showing block settings and the controls available for each block Needs Technical Feedback Needs testing from a developer perspective. labels Dec 29, 2020
@jordesign
Copy link
Contributor

With no additional activity on this specific issue in 2+ years - I'm going to close it in favour of #6023 which covers the extension and modification of InspectorControls more broadly.

@jordesign jordesign closed this as not planned Won't fix, can't repro, duplicate, stale Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inspector Controls The interface showing block settings and the controls available for each block Needs Technical Feedback Needs testing from a developer perspective.
Projects
None yet
Development

No branches or pull requests

4 participants