onlook-dev / onlook

The open source, local-first Webflow alternative. Design directly in your live React site and publish your changes to code.
https://onlook.dev
Apache License 2.0
2.55k stars 121 forks source link

[FEAT] Hotkeys v0 #152

Closed Kitenite closed 6 days ago

Kitenite commented 4 weeks ago

Describe the feature

We need to support hotkeys in our system these hotkeys will include various functionalities such as:

  1. Undo / redo
  2. Copy / paste
  3. Zoom

For Electron, there is a choice between using React component-level hotkeys vs using global Electron hotkeys. Seems like the choice should be based on context. Certain hotkeys such as zoom, copy/paste may be component-specific while other more global ones such as save may want to be electron-specific. Needs more exploration.

Note: There will be some existing hot keys implemented such as the zoom keys for this PR. Once the unified hotkeys system is in place, this should be moved into that system. https://github.com/onlook-dev/studio/commit/883f3ba543c993739bdc6eec481bd55aeecd9386

drfarrell commented 4 weeks ago

Editing Hotkeys

Create and edit elements

Navigation

Editing text

Ideally style edits can be made within long strings of text on selected shorter sections of text

Non-style edits to text

Kitenite commented 3 weeks ago

Exploring a few options we can use. I don't think we need to use global keys from Electron. We should use React-based hotkeys setup. A few options:

  1. https://github.com/JohannesKlauss/react-hotkeys-hook
  2. https://github.com/ccampbell/mousetrap
  3. https://github.com/jaywcjlove/react-hotkeys
  4. https://github.com/jaywcjlove/hotkeys-js

react-hotkeys-hook and mousetrap seem like the best apis with react-hotkeys-hook seeming better for react and has scope support.

Kitenite commented 2 weeks ago

Keeping this open for the rest of the hotkeys as functionalities are added. We added everything that is currently supported in https://github.com/onlook-dev/onlook/pull/193

drfarrell commented 2 weeks ago

Adding another hotkey...

drfarrell commented 2 weeks ago

Seems like we're waiting on #91 for some of the smaller styling hotkeys like Bold, Italic, etc. FYI @Eejya