-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MacOS shortcut for links in editor3 #4346
MacOS shortcut for links in editor3 #4346
Conversation
@@ -278,13 +278,22 @@ export class Editor3Component extends React.Component<IProps, IState> { | |||
} | |||
} | |||
|
|||
isMacOS() { | |||
if (navigator.userAgent.indexOf('Mac') != -1) { |
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.
Mac is a very short word and could trigger a false positive when found as a part of some other string https://www.thefreedictionary.com/words-containing-mac
You have it capitalized so it's a bit protected, but I'd rather convert to lower case and check if it includes "macintosh" or "mac os"
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.
I agree on your point, but userAgent isn't limitless in regards of what words it might contain. Most answers on the internet say you should check for the string "Mac". Why should I change it if that's the case?
const selectionState = this.props.editorState.getSelection(); | ||
const osBasedKeyRule = this.isMacOS() ? metaKey : ctrlKey; |
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.
keyboardModifier, mainModifier, modifierKey or modifier would be better choices for naming
@@ -278,13 +278,22 @@ export class Editor3Component extends React.Component<IProps, IState> { | |||
} | |||
} | |||
|
|||
isMacOS() { |
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.
also you need to bind it
also fix CI |
SDNTB-851