Skip to content

Commit

Permalink
Update strikethrough shortcut from Google Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed Oct 17, 2017
1 parent 13b5004 commit 8e88c3b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ We support keyboard shortcuts inspired by the ones used in [Google Docs](https:/
| Italicize | `Ctrl + I` | `⌘ + I` |
| Underline | `Ctrl + U` | `⌘ + U` |
| Monospace (code) | `Ctrl + J` | `⌘ + J` |
| Strikethrough | `Alt + Shift + 5` | `Option + Shift + 5` |
| Strikethrough | `Ctrl + Shift + X` | ` + Shift + X` |
| **Paragraph formatting (if enabled)** |||
| Increase list indentation | `Tab` | `Tab` |
| Decrease list indentation | `Shift + Tab` | `Shift + Tab` |
Expand Down
6 changes: 3 additions & 3 deletions lib/api/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ export default {
return null;
case KEY_CODES.U:
return null;
case KEY_CODES[5]:
case KEY_CODES.X:
return isEnabledInline.STRIKETHROUGH &&
e.shiftKey &&
e.altKey
hasCommandModifier(e) &&
e.shiftKey
? INLINE_STYLE.STRIKETHROUGH
: null;
case KEY_CODES[7]:
Expand Down
30 changes: 0 additions & 30 deletions lib/api/behavior.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,36 +123,6 @@ describe('behavior', () => {
).toBeNull();
});

it('has overlapping shortcuts', () => {
expect(
behavior.getKeyBindingFn(
[{ type: 'header-five' }],
[{ type: 'STRIKETHROUGH' }],
[],
)({
keyCode: KEY_CODES[5],
metaKey: false,
altKey: true,
shiftKey: true,
ctrlKey: false,
}),
).toBe('STRIKETHROUGH');

expect(
behavior.getKeyBindingFn(
[{ type: 'header-five' }],
[{ type: 'STRIKETHROUGH' }],
[],
)({
keyCode: KEY_CODES[5],
metaKey: false,
altKey: true,
shiftKey: false,
ctrlKey: true,
}),
).toBe('header-five');
});

describe('styles', () => {
it('disables default style key bindings', () => {
expect(
Expand Down
5 changes: 3 additions & 2 deletions lib/api/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const KEY_CODES = {
U: 85,
J: 74,
I: 73,
X: 88,
0: 48,
1: 49,
2: 50,
Expand Down Expand Up @@ -174,8 +175,8 @@ export const KEYBOARD_SHORTCUTS = {
macOS: '⌘+U',
},
[INLINE_STYLE.STRIKETHROUGH]: {
other: 'Alt+Shift+5',
macOS: 'Option+Shift+5',
other: 'Ctrl+Shift+X',
macOS: '+Shift+X',
},

[ENTITY_TYPE.LINK]: { other: 'Ctrl+K', macOS: '⌘+K' },
Expand Down

0 comments on commit 8e88c3b

Please sign in to comment.