ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
27.55k stars 2.29k forks source link

[Bug]: Caps lock interferes with History hotkeys #5789

Open vinzdef opened 2 weeks ago

vinzdef commented 2 weeks ago

Affected Packages

extension-history

Version(s)

2.9.1

Bug Description

Description

In the editor, pressing Mod-Z should trigger undo and Mod-Shift-Z should trigger redo. This works as expected unless "Caps lock" is enabled, then it stops working.

Environments

This affects all major browsers on Windows (tested). Not reproducible on Mac/Chrome.

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

Pressing Mod-Z should trigger undo and Mod-Shift-Z should trigger redo, even when "Caps lock" is on.

Additional Context (Optional)

Previous issues

This issue was reporting the same. It was marked as resolved. This is the PR that solved it.

The code introduced by that PR was then removed in this commit, I could not find an explanation as of why it was removed or if the problem was addressed elsewhere.

Dependency Updates

Nantris commented 2 weeks ago

I think it might be best to try to consolidate the discussion on this commit here instead.


OK, I didn't know about caps lock, their disappearance really breaks it

I cleaned them for 2 reasons:

Mod-Z was executed before Ctrl-Shift-z, and this is wrong, and their behavior is different, this can be solved by adding auxiliary caps lock hotkeys after the rest When we get to the end of the redo stack, and at this moment we press Ctrl-Shift-z, which is responsible for another step redo, nothing should happen in this situation, but Mod-Z is fired up, which does undo, which is incorrect, how to fix it I did not find an option


Fixing all cases of hotkey ordering and case handling has proven one of the more difficult parts of working with ProseMirror (which is not an easy project to work with in any event.)

I'm not familiar with the testing strategy for TipTap but it seems like this area should have some test cases given how brittle the configuration can be.

@webkadiz is it troublesome to create a codesandbox to demo those cases so everyone discussing can make sure we all understand the issues clearly?

webkadiz commented 2 weeks ago

ok, I'll show the second point in the video with this configuration:

      'Mod-z': () => this.editor.commands.undo(),
      'Shift-Mod-z': () => this.editor.commands.redo(),
      'Mod-y': () => this.editor.commands.redo(),
      'Mod-Z': () => this.editor.commands.undo(),
      'Mod-Y': () => this.editor.commands.redo(),
      'Shift-Mod-Z': () => this.editor.commands.redo(),

here I write the "first step", then press ctrl-shift-z (which is responsible for redo), but when the redo stack is empty, Mod-Z is executed, which does undo, then I press ctrl-shift-z again and redo is done

https://github.com/user-attachments/assets/afe75e3f-78ce-4f62-9077-121d711bb59e