compose-rich-editor icon indicating copy to clipboard operation
compose-rich-editor copied to clipboard

Restore RichTextStyle with Undo/Redo in Compose Desktop

Open MohamedRejeb opened this issue 1 year ago • 8 comments

  • Now if we use undo/redo in compose desktop the restored text doesn't have the right style

MohamedRejeb avatar May 01 '23 14:05 MohamedRejeb

Hi, can you add functions to RichEditState for Undo/Redo?

v1rus-dev avatar Aug 03 '23 19:08 v1rus-dev

It's on the scope, I'll try to add it before 1.0.0

MohamedRejeb avatar Aug 04 '23 08:08 MohamedRejeb

Hi @MohamedRejeb is the undo functionality added now?

kannansrepo avatar Apr 01 '24 06:04 kannansrepo

Hi, not yet, but it's on top of my list.

MohamedRejeb avatar Apr 01 '24 06:04 MohamedRejeb

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.

kannansrepo avatar Apr 01 '24 06:04 kannansrepo

These should be the steps needed to implement this feature.

  • Two stacks for undo and redo.
  • Two public methods undo() and redo() in RichTextState 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.

MohamedRejeb avatar Apr 01 '24 06:04 MohamedRejeb

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.

ln-12 avatar Apr 13 '24 12:04 ln-12

bump, BasicTextField2 has been released to the multiplatform

gogopro-dev avatar May 18 '24 14:05 gogopro-dev