webwriter-app / webwriter

Authoring tool for interactive content
https://webwriter.app
Other
16 stars 1 forks source link

Widget history (undo/redo) #34

Closed salmenf closed 2 months ago

salmenf commented 1 year ago

Undoing/redoing changes is desirable for any stateful widget. It's better for UX to implement this on the editor level instead of the widget level.

To implement this on the widget level, the widget needs to interface with the editor. A simple approach would be running a MutationObserver on every element - When the element's attributes or children change, an event is triggered to change the editor state accordingly. This adds a small performance overhead, but integrates fluently with the existing implementation and doesn't need any changes on the widget level.