In Editor, Keyboard Undo/Redo Breaks with Formatted Text and Loses History when Field Unfocused and Refocused

  1. Using Ctrl+Z to undo and Ctrl+Y to redo in an editor field does not work with formatted (rich) text, and the existence of <b>/<u> tags appears to mean the first character in them is retained on undo rather than deleting the elements.

  1. In the note editor, when I click outside of the text field then click inside it again I can no longer use Ctrl+Z to undo my changes to before I clicked outside the text field.

From my experience with frontend JavaScript, the easiest solution may be to override the Ctrl+Z and Ctrl+Y shortcuts which appear to be currently provided by the webview rather than your code, and implement undo/redo yourself. If this is impossible, removing Ctrl+Z and Ctrl+Y functionality would fix the bugs although it may be annoyingly limiting.

I understand some functionality may not be undoable, but a partial solution that does not leave behind artefacts with formatted text would be extremely helpful.

My system information
Anki:
    Version <U+2068>24.06.3 (a5c90890)<U+2069>
    Python 3.12.4 Qt 6.7.2 PyQt 6.7.0
Operating System:
    EndeavourOS Linux
    KDE Plasma Version: 6.1.2
    KDE Frameworks Version: 6.3.0
    Qt Version: 6.7.2
    Kernel Version: 6.9.7-arch1-1 (64-bit)
    Graphics Platform: Wayland

I can also reproduce the same bug on Windows 11.

This is a known limitation, but I didn’t see it listed in the issue tracker, so I’ve logged it here: Consider our own undo/redo stack for the editor · Issue #3339 · ankitects/anki · GitHub

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.