Add lexical undo/redo buttons to payload-lexical & improve context sharing between lexical Toolbar and Plugin #12060
tak-amboss
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The lexical playground has a History Plugin which provides the business logic for undo and redo actions as well as the respective button states.
Payload already uses the
HistoryPlugin
for keyboard shortcuts in lexical to allow undo and redo, but doesn't offer the option to also display the respective buttons.While implementing this as a custom lexical plugin, we stumbled upon the following issue:
Undo and redo buttons in the toolbar should indicate whether they are clickable, using the
isEnabled
function ofToolbarGroupItem
. The lexicalHistoryPlugin
already firesCAN_UNDO_COMMAND
/CAN_REDO_COMMAND
which we can listen to in thePluginComponent
to know whether the respective button should be enabled.However, there does not seem to be a proper way to share a state between the
PluginComponent
and theToolbar
, so we eventually extended the editor interfacedefined an inital state
and update this state plus tigger another update cycle whenever the command gets triggered
There is already a
EditorConfigProvider
, but this doesn't allow to share custom properties currently.Beta Was this translation helpful? Give feedback.
All reactions