Skip to content
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

Merged
merged 8 commits into from
Oct 24, 2023

Conversation

thecalcc
Copy link
Contributor

@thecalcc thecalcc commented Oct 23, 2023

SDNTB-851

  • Don't merge before Nikola tests it on Mac.

@@ -278,13 +278,22 @@ export class Editor3Component extends React.Component<IProps, IState> {
}
}

isMacOS() {
if (navigator.userAgent.indexOf('Mac') != -1) {
Copy link
Member

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"

Copy link
Contributor Author

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;
Copy link
Member

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() {
Copy link
Member

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

@tomaskikutis
Copy link
Member

also fix CI

@thecalcc thecalcc merged commit 8dd0036 into superdesk:develop Oct 24, 2023
4 of 5 checks passed
petrjasek pushed a commit that referenced this pull request Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants