super_editor icon indicating copy to clipboard operation
super_editor copied to clipboard

[SuperTextField] - Create a controller that supports undo/redo (Resolves #189)

Open matthew-carroll opened this issue 2 years ago • 5 comments

[SuperTextField] - Create a controller that supports undo/redo.

This PR creates an EventSourcedAttributedTextEditingValue, which holds text, a selection, and a composing region, along with a history of commands that were run to produce the current value. The value can undo() and redo() those commands.

The commands are based on an interface called AttributedTextEditingValueCommand.

I ported the existing AttributedTextEditingController interface over to a new one called EventSourcedAttributedTextEditingController. I implemented the interface using the new event sourced value and a group of new commands. I also wrote tests for nearly every operation in the controller, and their ability to undo an operation.

Some things that are not addressed in this PR:

  • How do we handle composing attributions as things are undone and redone?
  • How can a developer add new pieces of information to the history, given that all commands operate on a type-safe data structure?
  • How can developers optionally batch commands in retrospect so that, e.g., similar commands in quick succession are batched and undone together.

matthew-carroll avatar Jul 16 '22 02:07 matthew-carroll