feat: add disable hotkeys feature#1380
Conversation
|
Someone is attempting to deploy a commit to the Puck Team on Vercel. A member of the Team first needs to authorize it. |
|
Hello @do4Mother! Thank you very much for your contribution 🙏 For the record, you can actually avoid triggering Puck hotkeys by using an You can check out the implementation here: In that case, we stop propagation in the capturing phase ( We normally prefer having a feature request or bug report before opening PRs. This helps us understand the need and discuss the best approach before implementation. That said, having a set of props to control Puck hotkeys would definitely be beneficial, so I have a small request to better align it with what we’d expect to support: Could you update the API to work as a <Puck
hotkeys={{ enabled: false }}
/>That would allow us to add more controls in the future. Thank you again for taking the time to contribute! |
|
Sorry, I was so excited to contribute to this awesome project that I didn't read the documentation on how to contribute. Additionally, in the use case project I'm working on, 80% of the work is done using the WYSIWYG editor, so I don't disable hotkeys in the editor. And I have been updated the state. please help to check it. thanks! |
packages/core/types/AppState.tsx
Outdated
| }; | ||
|
|
||
| export type AppState<UserData extends Data = Data> = { | ||
| hotkeys: HotkeyState; |
There was a problem hiding this comment.
Can you move this to the AppStore rather than AppState?
There was a problem hiding this comment.
okay! i have done a refactor update to the appstore
| onAction, | ||
| metadata, | ||
| fieldTransforms: loadedFieldTransforms, | ||
| hotkeys: hotkeys, |
There was a problem hiding this comment.
| hotkeys: hotkeys, | |
| hotkeys, |
| onAction, | ||
| metadata, | ||
| loadedFieldTransforms, | ||
| hotkeys |
There was a problem hiding this comment.
| hotkeys | |
| hotkeys.enabled |
I don't know if we want to subscribe to the whole object here (which could be re-created through re renders), it might be better to start off with hotkeys.enabled, just in case.
| }; | ||
| initialHistory?: InitialHistory; | ||
| metadata?: Metadata; | ||
| hotkeys?: HotkeyState |
There was a problem hiding this comment.
I think we need to use a Partial here and handle that optionality (applying defaults) before passing it down to the appStore.
We might introduce more options in the future, and requiring enabled could become inconvenient, some users might only want to enable a single option.
FedericoBonel
left a comment
There was a problem hiding this comment.
Thanks again for your contribution @do4Mother!
Awesome stuff, left couple of comments above.
|
@FedericoBonel Thanks for suggestions and build cool project! |
when using a wysiwyg editor to the puck, using the CTRL+Z or CTRL+R keys will trigger undo or redo simultaneously.