j4k0xb / webcrack

Deobfuscate obfuscator.io, unminify and unpack bundled javascript
https://webcrack.netlify.app
MIT License
870 stars 100 forks source link

Web IDE 'File -> Save'/etc menu items suggest the wrong keybindings on macOS #90

Closed 0xdevalias closed 3 months ago

0xdevalias commented 3 months ago

Describe the bug

Was just checking out the web IDE again after the following landed:

And noticed that the 'File' menu says to use Ctrl+S to save (and other similar menu items):

image

But this doesn't work on macOS, as the keybinding is actually Cmd+S:

Expected Behaviour

It would be good if the suggested key bindings in the menu were able to update themselves based on the platform's bindings.

Code

N/A

Logs

N/A

See Also

0xdevalias commented 3 months ago

Seems the keybindings are hardcoded in the MenuButton components' shortcut prop here:

https://github.com/j4k0xb/webcrack/blob/f6df5f2c91fe5f848b9aa24dbcfa0b39b308a1e6/apps/playground/src/components/menu/Menu.tsx#L39-L64

It might be cool if they were able to read from the same constant as the keybindings themselves, to ensure they remain in sync?

https://github.com/j4k0xb/webcrack/blob/f6df5f2c91fe5f848b9aa24dbcfa0b39b308a1e6/apps/playground/src/components/MonacoEditor.tsx#L109-L127

Skimming the related docs:

It looks like you may not be able to read the keybindings 'back' from the return value of editor.addAction; so you would probably need to separate them into their own const/etc, assuming there isn't another Monaco API that allows you to read them back later.

j4k0xb commented 3 months ago

Doing it the same as vscode/monaco now: https://github.com/microsoft/vscode/blob/d40dff9ef9aacb8e5226bcf3938c71f4b9543120/src/vs/base/common/platform.ts#L109-L110

0xdevalias commented 3 months ago

Looks good, thanks! :)