puck icon indicating copy to clipboard operation
puck copied to clipboard

feat: add disable hotkeys feature

Open do4Mother opened this issue 2 months ago • 4 comments

when using a wysiwyg editor to the puck, using the CTRL+Z or CTRL+R keys will trigger undo or redo simultaneously.

do4Mother avatar Oct 16 '25 05:10 do4Mother

Someone is attempting to deploy a commit to the Puck Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 16 '25 05:10 vercel[bot]

Hello @do4Mother!

Thank you very much for your contribution 🙏

For the record, you can actually avoid triggering Puck hotkeys by using an onKeyDown event listener on your RTE or WYSIWYG component and stopping propagation. We’re currently implementing a Puck RTE, and we needed to do this as well to prevent Puck from switching into interactive mode when pressing cmd + i.

You can check out the implementation here:
https://github.com/puckeditor/puck/pull/1341/commits/90f3cf5fe0f1f5c84baa2d8ca81d9ea81c55292f#diff-ae9dac1ee1543faeeb141edd12591423d6ecfa47b4cf79c5875e825f475ed95cR1-R108

In that case, we stop propagation in the capturing phase (onKeyDownCapture), but you might be better off stopping it in the bubbling phase (onKeyDown).

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 hotkeys prop on the Puck component that receives an object, with an enabled property inside it? Something like this:

<Puck
  hotkeys={{ enabled: false }}
/>

That would allow us to add more controls in the future.

Thank you again for taking the time to contribute!

FedericoBonel avatar Oct 16 '25 11:10 FedericoBonel

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!

do4Mother avatar Oct 17 '25 01:10 do4Mother

@FedericoBonel Thanks for suggestions and build cool project!

do4Mother avatar Nov 20 '25 01:11 do4Mother