feat(ui): fixed toolbar group customization #12108
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR introduces a comprehensive customization system for toolbar groups in the Lexical Rich Text Editor. It allows developers to override not just the order, but virtually any aspect of toolbar components (such as format, align, indent) through the
FixedToolbarFeature
configuration. Customizable properties include order, icons, group type, and more.Why
Previously, toolbar group configurations were hardcoded in their respective components with no way to modify them without changing the source code. This made it difficult for developers to:
This enhancement provides full flexibility for tailoring the rich text editor interface while maintaining a clean and maintainable codebase.
How
The implementation consists of three key parts:
Enhanced the FixedToolbarFeature API:
customGroups
property toFixedToolbarFeatureProps
that accepts a record mapping group keys to partialToolbarGroup
objectsLeveraged existing deep merge utility:
deepMerge
utility to properly combine default configurations with custom overridesApplied customizations in the sanitization process:
sanitizeClientFeatures
function to identify and apply custom group configurationsUsage Example
Demo
fixed-toolbar-customization.mov