Skip to content

Commit cc9cb47

Browse files
committed
Added a keyboard shortcut for adding files
1 parent 01dca7f commit cc9cb47

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

client/components/Nav.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class Nav extends React.PureComponent {
197197
onClick={() => this.props.newFile(this.props.rootFile.id)}
198198
>
199199
{this.props.t('Nav.Sketch.AddFile')}
200+
<span className="nav__keyboard-shortcut">{'\u21E7'}+N</span>
200201
</NavMenuItem>
201202
<NavMenuItem
202203
onClick={() => this.props.newFolder(this.props.rootFile.id)}

client/components/__snapshots__/Nav.unit.test.jsx.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,11 @@ exports[`Nav renders editor version 1`] = `
373373
>
374374
<button>
375375
Add File
376+
<span
377+
class="nav__keyboard-shortcut"
378+
>
379+
⇧+N
380+
</span>
376381
</button>
377382
</li>
378383
<li

client/modules/IDE/components/KeyboardShortcutModal.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ function KeyboardShortcutModal() {
6969
<span className="keyboard-shortcut__command">{metaKeyName} + K</span>
7070
<span>{t('KeyboardShortcuts.CodeEditing.ColorPicker')}</span>
7171
</li>
72+
<li className="keyboard-shortcut-item">
73+
<span className="keyboard-shortcut__command">{'\u21E7'} + N</span>
74+
<span>{t('KeyboardShortcuts.CodeEditing.CreateNewFile')}</span>
75+
</li>
7276
</ul>
7377
<h3 className="keyboard-shortcuts__title">General</h3>
7478
<ul className="keyboard-shortcuts__list">

client/modules/IDE/pages/IDEView.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ class IDEView extends React.Component {
229229
this.props.closeNewFileModal();
230230
}
231231
}
232+
if (e.keyCode === 78 && e.shiftKey) {
233+
e.preventDefault();
234+
e.stopPropagation();
235+
this.props.newFile(
236+
this.props.files.filter((file) => file.name === 'root')[0].id
237+
);
238+
// 78 === n
239+
}
232240
}
233241

234242
handleUnsavedChanges = (nextLocation) =>

translations/locales/en-US/translations.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@
192192
"FindNextTextMatch": "Find Next Text Match",
193193
"FindPreviousTextMatch": "Find Previous Text Match",
194194
"CodeEditing": "Code Editing",
195-
"ColorPicker": "Show Inline Color Picker"
195+
"ColorPicker": "Show Inline Color Picker",
196+
"CreateNewFile": "Create New File"
196197
},
197198
"General": {
198199
"StartSketch": "Start Sketch",

0 commit comments

Comments
 (0)