Skip to content

Commit

Permalink
MacOS shortcut for links in editor3
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Oct 23, 2023
1 parent 1bd7315 commit b829154
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/core/editor3/components/Editor3Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,22 @@ export class Editor3Component extends React.Component<IProps, IState> {
}
}

isMacOS() {
if (navigator.userAgent.indexOf('Mac') != -1) {
return true;
}

return false;
}

keyBindingFn(e) {
const {key, shiftKey, ctrlKey} = e;
const {key, shiftKey, ctrlKey, metaKey} = e;
const selectionState = this.props.editorState.getSelection();
const osBasedKeyRule = this.isMacOS() ? metaKey : ctrlKey;

if (
key === 'k'
&& ctrlKey
&& osBasedKeyRule
&& this.props.editorFormat.includes('link')
&& selectionState.isCollapsed() !== true
) {
Expand Down

0 comments on commit b829154

Please sign in to comment.