Skip to content

Draft: Adding undo and redo functionalities

Sebastian Bernd Mohr requested to merge undo_and_redo into main

Implement Undo and Redo Functionality

Description

This pull request adds undo and redo which allows users to easily reverse or reapply changes made in the editor.

Core Functionality:

We keep track of changes by hooking into the editing events send to our websocket server. We do this for every connected client instead of user to allow for multiple devices of the same user to have distinctive editing stacks.

Each database update, insert and delete is considered as a state change and can be reverted or redone.

Changes and todos:

  1. Undo/Redo State Management:
    • Implemented a circular buffer that keeps track of the changes applied to each document by a user.
    • Configuration option for the number of allowed undo and redos
  2. UI/UX Integration:
    • Added Undo and Redo buttons to the eraser tool
      • Needs a bit of work and enhancements to align with the ui design choices
    • Allow top trigger undo and redo with keybinding
  3. Testing:
    • Unit tests for the redo/undo circular buffer
    • Integration tests for the websocket server
  4. Open questions
    • Should the undo history be persistent for each user instead of a per connection basis?
      • Might be a bit strange if a user edits multiple books or pages at the same time
    • Which keyboard shortcut should be used? Should there be a way to trigger the undo or redo with the pen?

Merge request reports

Loading