Add filter to allow other formats to be placed outside the dropdown menu in RichTextToolbarButton #22663
Labels
[Feature] Rich Text
Related to the Rich Text component that allows developers to render a contenteditable
Needs Decision
Needs a decision to be actionable or relevant
[Type] Enhancement
A suggestion for improvement.
I'm creating a custom format named
background-color
to be able to highlight text. I basically replicated the code inside thetext-color
format in the formats library. The cool thing about the text color format is that when active, the button is displayed alongside the bold, italic, and link buttons with a colored line equal to the color of the text. I tried to do the same with my background color button but couldn't get it to work because inwordpress-develop/node-modules/@wordpress/block-editor/src/components/rich-text/format-toolbar/index.js
there is a hardcoded array such that only bold, link, italic, and text-color can ever be displayed outside the dropdown menu.So I hacked my code and set the
key
andname
parameters in theRichTextToolbarButton
of my background color format to saytext-color
instead ofbackground-color
.I would like to request a filter to extend the buttons that can be placed outside the dropdown menu in the RichTextToolbarButton component. I know that I could have placed my background color inside a BlockControls component, but I wanted the text color and the background color to behave identically to provide a better user experience. This is what I ended up with thanks to my "hack":
I think it works much more cohesively and provides a more intuitive user experience than having the text color inside the drop down menu, and the background color as a block control.
My request is similar to #16014, but I don't know why the highlighter part never made it to core.
The text was updated successfully, but these errors were encountered: