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

Block Editor: Provide a way to customize panels in Inspector Controls #33891

Open
kanlukasz opened this issue Aug 5, 2021 · 7 comments
Open
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.

Comments

@kanlukasz
Copy link

kanlukasz commented Aug 5, 2021


What problem does this address?

(I am not sure if this is due to incomplete documentation or it is simply impossible to do. Therefore, I assume it as ticket here)

I don't know how to remove unwanted panels inside InspectorControls from core blocks.
Unfortunately, there is no such example in the documentation, so I'm not sure how to do it
I know about editor.BlockEdit filter but from what i see it's helping only if i want to make new wrapped component

What is your proposed solution?

If it is possible to remove unwanted panels inside InspectorControls from core blocks, it would be great to see such an example in the documentation or any example method here

@caseymilne
Copy link

Interesting idea. This would presumably have to be handled by a JS filter because the Inspector Controls are build from React components (without any PHP involvement). So we can't use PHP filters, but we could potentially use a JS filter on the list of Inspector Controls. From what little I know of the core build process however at this moment no such filtering exists and the build process would be a direct conversion from React defined components to the final output. This may change in the future because I believe it's also the reason we don't have an easy way to reorder the panels or inject new panels before defaults.

Worth mentioning that I do believe there is an HOC (Higher Order Component) approach that let's you tap into the entire editor build and through that it may be possible to filter out the panels. Some tutorials exist on using that approach for similar changes to the inspector.

@kanlukasz
Copy link
Author

This would presumably have to be handled by a JS filter

Yes, of course, which is why I mentioned editor.BlockEdit but i'm not sure how to do it

Worth mentioning that I do believe there is an HOC (Higher Order Component) approach that let's you tap into the entire editor build and through that it may be possible to filter out the panels. Some tutorials exist on using that approach for similar changes to the inspector.

Share these tutorials with us, please.


Many users are looking for a solution to this (including me):

Note: theme.json made it possible to remove some panels, but not all, e.g. panels cannot be removed from an image block, etc.


Potential related issues I've found:

@carolinan carolinan added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Aug 8, 2021
@gziolo gziolo added [Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Blocks Overall functionality of blocks labels Sep 3, 2021
@alpopp
Copy link

alpopp commented Oct 14, 2021

This is so needed. It would also be nice to conditionally remove panels. For example, only certain block styles could get certain panels.

@tellthemachines
Copy link
Contributor

Hi there! It is possible to remove block controls via theme.json, as shown in this comment. Sadly it's not possible to make the removal conditional on block styles (OP from the linked issue was also after that functionality).

@tellthemachines tellthemachines removed the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Nov 9, 2022
@ekesto
Copy link

ekesto commented Dec 6, 2022

Not the prettiest quickfix idea, but at least we could hide unwanted panels from core blocks?

What if there was a data-attribute in the sidebar containing the information what block is being edited, for example:
<div class="block-editor-block-inspector" data-block-type="core/button">

So we could then visually hide specific components using CSS:

[data-block-type="core/button"] > .color-block-support-panel {
    display: none;
}

@lucspe
Copy link

lucspe commented Jan 18, 2023

Hi,

I have found this as I was looking for a solution as well.

@ekesto suggestion makes sense.

Allowing to target control panels via CSS individually either via a class assigned or a data- attribute would also be useful to customize the style to control panels (for example to highlight some that we want the website editors to pay attention to).

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Sep 14, 2023
@gziolo gziolo mentioned this issue Sep 15, 2023
58 tasks
@gziolo gziolo changed the title Removing unwanted panels inside InspectorControls from core blocks Block Editor: Provide a way to customize panels in Inspector Controls Oct 4, 2023
@gziolo gziolo added [Feature] Block API API that allows to express the block paradigm. Needs Dev Ready for, and needs developer efforts and removed [Feature] Blocks Overall functionality of blocks labels Oct 4, 2023
@gziolo
Copy link
Member

gziolo commented Oct 4, 2023

This is one of the items that we plan to tackle as part of the Block Library project from Phase 3: Collaboration roadmap. In particular, this functionality was covered by @mtias in the following section:

It also means introducing more robust permission handling across the various capabilities (block registration, locking, etc) so administrators can define what blocks are available for different user roles (or even what capabilities of individual blocks are to be exposed). The fact that theme.json files are inherently composable should allow for more granular handlings of capabilities in a systematic way. For example, consider a fictional author.theme.json that sets, disables, and controls what tools and settings are available for authors over the root config file.

There is also a complementary issue #47641 for Block Toolbar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

9 participants