compose-rich-editor
compose-rich-editor copied to clipboard
Restore RichTextStyle with Undo/Redo in Compose Desktop
- Now if we use undo/redo in compose desktop the restored text doesn't have the right style
Hi, can you add functions to RichEditState for Undo/Redo?
It's on the scope, I'll try to add it before 1.0.0
Hi @MohamedRejeb is the undo functionality added now?
Hi, not yet, but it's on top of my list.
Thanks! sorry to bug you, Is there any work around for this until you introduce it? do you have anything in your mind, I can work on it.
These should be the steps needed to implement this feature.
- Two stacks for undo and redo.
- Two public methods
undo()
andredo()
inRichTextState
class. - When the state is changed, we need to add the old state to the undo stack (This is challenging because we need to ignore some changes, such as selection changes...).
- Add key event listener and call undo and redo methods when command z and command shift z are pressed.
The upcoming BasicTextField2 already has support for it: https://android-review.googlesource.com/c/platform/frameworks/support/+/2748196
For now it seems to be Android only but eventually this comes to the multiplatform implementation as well and/or you can copy the implementation.
bump, BasicTextField2 has been released to the multiplatform