-
Notifications
You must be signed in to change notification settings - Fork 2.6k
KeyBindingUtil: add usesMacOSHeuristics method #869
KeyBindingUtil: add usesMacOSHeuristics method #869
Conversation
37b2dda
to
d5c81ea
Compare
I'm curious about the context of your needs for I would normally expect |
@hellendag I need to be able to determine which key will be used as "command modifier" before any key event takes place. In the example I posted in the OP, I check for |
I've had two use cases for access to
I was able to access it in my implementation by abusing the implementation of Edit: tested in versions 0.10.0 to 0.10.4. const isOSX = isOptionKeyCommand({ altKey: 'test' }) === 'test'; |
👋 Is there anything I can do to help get this in? As far as I can see this is still the only way to display correct keyboard shortcuts in editors. Here is another example to complement @williamboman's: It's available at https://springload.github.io/draftail/ if that helps. |
@williamboman, @thibaudcolas - I think this is fine to add in, but I want to first make sure that someone still has a need for this additional API method. Please comment here if adding this will help your project & I can then merge it in - thanks! :) |
d5c81ea
to
73530ad
Compare
73530ad
to
74216fa
Compare
Won't make much difference for me rn, I don't use draft-js much anymore. If I ever pick it up again I'm sure I'd have use for this - so it would not surprise me if more people has use for this. I've rebased on top of latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
niveditc is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Nice! I'll definitely be using this in my editor as soon as it is released. Same use case as before – displaying the right shortcut depending on the user's OS. See https://github.com/springload/draftail/blob/d7fcb93c09204467a76fbc8abe4f7073cc052bc9/lib/api/behavior.js#L23-L25. |
Summary: **Summary** Add a public method, `usesMacOSHeuristics`, to the `KeyBindingUtil` module. This makes it possible to determine how draft-js will interpret certain keyboard events and thus alter the UI accordingly, e.g.; <img width="499" alt="screenshot 2016-12-13 at 17 58 33" src="https://cloud.githubusercontent.com/assets/6705160/21150013/dee64566-c15d-11e6-9639-75a39d21d079.png"> I currently achieve this by doing (🙈); ```js const COMMAND_MODIFIER_CHAR = (navigator && navigator.userAgent.indexOf('Mac') >= 0) ? '\u2318' // Mac command key character : 'Ctrl' ``` Pull Request resolved: facebookarchive#869 Differential Revision: D9734962 fbshipit-source-id: ed3f3d0a87df51c708fd666fe85bc6acba1ecfee
Summary: **Summary** Add a public method, `usesMacOSHeuristics`, to the `KeyBindingUtil` module. This makes it possible to determine how draft-js will interpret certain keyboard events and thus alter the UI accordingly, e.g.; <img width="499" alt="screenshot 2016-12-13 at 17 58 33" src="https://cloud.githubusercontent.com/assets/6705160/21150013/dee64566-c15d-11e6-9639-75a39d21d079.png"> I currently achieve this by doing (🙈); ```js const COMMAND_MODIFIER_CHAR = (navigator && navigator.userAgent.indexOf('Mac') >= 0) ? '\u2318' // Mac command key character : 'Ctrl' ``` Pull Request resolved: facebookarchive/draft-js#869 Differential Revision: D9734962 fbshipit-source-id: ed3f3d0a87df51c708fd666fe85bc6acba1ecfee
Summary: **Summary** Add a public method, `usesMacOSHeuristics`, to the `KeyBindingUtil` module. This makes it possible to determine how draft-js will interpret certain keyboard events and thus alter the UI accordingly, e.g.; <img width="499" alt="screenshot 2016-12-13 at 17 58 33" src="https://cloud.githubusercontent.com/assets/6705160/21150013/dee64566-c15d-11e6-9639-75a39d21d079.png"> I currently achieve this by doing (🙈); ```js const COMMAND_MODIFIER_CHAR = (navigator && navigator.userAgent.indexOf('Mac') >= 0) ? '\u2318' // Mac command key character : 'Ctrl' ``` Pull Request resolved: facebookarchive/draft-js#869 Differential Revision: D9734962 fbshipit-source-id: ed3f3d0a87df51c708fd666fe85bc6acba1ecfee
Summary
Add a public method,
usesMacOSHeuristics
, to theKeyBindingUtil
module. This makes it possible to determine how draft-js will interpret certain keyboard events and thus alter the UI accordingly, e.g.;I currently achieve this by doing (🙈);