Skip to content

Commit

Permalink
restrict ctr-A and ctr-E key commands to Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
bantic committed Feb 4, 2016
1 parent 08da228 commit 3684551
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/js/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,9 @@ class Editor {
this.handleNewline(event);
break;
case key.isPrintable():
let { range } = this;
range = this.range;
let { isCollapsed } = range;
let nextPosition = range.head;
nextPosition = range.head;

if (this.handleExpansion(event)) {
event.preventDefault();
Expand Down
9 changes: 7 additions & 2 deletions src/js/editor/key-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MODIFIERS, SPECIAL_KEYS } from '../utils/key';
import { filter, reduce } from '../utils/array-utils';
import assert from '../utils/assert';
import Range from '../utils/cursor/range';
import Browser from '../utils/browser';

export const DEFAULT_KEY_COMMANDS = [{
str: 'META+B',
Expand Down Expand Up @@ -53,19 +54,23 @@ export const DEFAULT_KEY_COMMANDS = [{
});
}
}, {
// FIXME restrict to OS X only?
str: 'CTRL+A',
run(editor) {
if (!Browser.isMac) {
return false;
}
let range = editor.cursor.offsets;
let {head: {section}} = range;
editor.run(postEditor => {
postEditor.setRange(new Range(section.headPosition()));
});
}
}, {
// FIXME restrict to OS X only?
str: 'CTRL+E',
run(editor) {
if (!Browser.isMac) {
return false;
}
let range = editor.cursor.offsets;
let {tail: {section}} = range;
editor.run(postEditor => {
Expand Down
3 changes: 3 additions & 0 deletions src/js/utils/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
isMac: /Mac/.test(navigator.platform)
};

0 comments on commit 3684551

Please sign in to comment.