kommitters / editorjs-undo

Undo/Redo feature for Editor.js
https://www.npmjs.com/package/editorjs-undo
MIT License
171 stars 51 forks source link

Add shortcut for Cmd + Shift + Z to redo #176

Closed ollietreend closed 1 year ago

ollietreend commented 1 year ago

Is your feature request related to a problem? Please describe.

Ctrl/Cmd + Z is the universally accepted keyboard shortcut to undo something.

However the shortcut for redo varies between different operating systems:

Describe the solution you'd like

It'd be great if the redo feature supported both Ctrl + Y and Ctrl/Cmd + Shift + Z keyboard shortcuts. That way it'd be more discoverable and feel native to users of non-Windows operating systems.

Personally, I have a strong muscle memory for Cmd + Shift + Z which is why I've noticed this. It breaks my internal expectations of how an editor behaves on Mac. I expect the same is true for people using iOS devices with an attached keyboard.

Additional context

I haven't actually tried mapping redo to both shortcuts, so am unsure whether this is a trivial change or if it's limited to one single shortcut only.

But I thought I'd report this here as it doesn't seem to have been raised yet – although I do see that it was touched upon in #106.

karolrojas07 commented 1 year ago

Hi @ollietreend Have you tried to config the redo action command in your Undo instance?

You can read more about, how to custom the undo and redo commands here: https://github.com/kommitters/editorjs-undo#add-a-custom-shortcut-to-undo-and-redo

const config = {
  shortcuts: {
    undo: 'CMD+Z',
    redo: 'CMD+SHIFT+Z'
  }
}

const undo = new Undo({ editor, config });

However, we can review to support both default commands for the redo action:

You must use version >= 2.0, to config the redo action with CTRL/CMD + SHIFT + Z

ollietreend commented 1 year ago

Hi @karolrojas07. Thanks for looking at this.

I think the ideal situation would be for the redo command to support both shortcuts as out-the-box defaults. That will provide the most 'native' / expected experience for end users – who otherwise might not realise that 'redo' is available.

I guess this change is dependent on the ability to set two shortcuts for the same command. It sounds like only one shortcut is supported right now?

CristhianRodriguezMolina commented 1 year ago

Hi @ollietreend.

This feature is now available on version v2.0.21, you are now able to redo using both shortcuts CMD+Y and CMD+SHIFT+Z by default :+1: