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

Adding ShortCut Key 'Ctrl/Cmd+Alt+f' for newFolder #3379

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/common/useKeyDownHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export default function useKeyDownHandlers(keyHandlers) {
} else if (isCtrl && e.altKey && e.code === 'KeyN') {
// specifically for creating a new file
handlers.current[`ctrl-alt-n`]?.(e);
} else if (isCtrl && e.altKey && e.code === 'KeyF') {
// specifically for creating a new folder
handlers.current[`ctrl-alt-f`]?.(e);
} else if (isCtrl) {
handlers.current[`ctrl-${e.key.toLowerCase()}`]?.(e);
}
Expand Down
3 changes: 3 additions & 0 deletions client/modules/IDE/components/Header/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ const ProjectMenu = () => {
metaKey === 'Ctrl' ? `${metaKeyName}+H` : `${metaKeyName}+⌥+F`;
const newFileCommand =
metaKey === 'Ctrl' ? `${metaKeyName}+Alt+N` : `${metaKeyName}+⌥+N`;
const newFolderCommand =
metaKey === 'Ctrl' ? `${metaKeyName}+Alt+F` : `${metaKeyName}+⌥+F`;

return (
<ul className="nav__items-left" role="menubar">
Expand Down Expand Up @@ -230,6 +232,7 @@ const ProjectMenu = () => {
</MenubarItem>
<MenubarItem onClick={() => dispatch(newFolder(rootFile.id))}>
{t('Nav.Sketch.AddFolder')}
<span className="nav__keyboard-shortcut">{newFolderCommand}</span>
</MenubarItem>
<MenubarItem onClick={() => dispatch(startSketch())}>
{t('Nav.Sketch.Run')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ exports[`Nav renders editor version for desktop 1`] = `
role="menuitem"
>
Add Folder
<span
class="nav__keyboard-shortcut"
>
Ctrl+Alt+F
</span>
</button>
</li>
<li
Expand Down
8 changes: 7 additions & 1 deletion client/modules/IDE/components/IDEKeyHandlers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
showErrorModal,
startSketch,
stopSketch,
newFile
newFile,
newFolder
} from '../actions/ide';
import { setAllAccessibleOutput } from '../actions/preferences';
import { cloneProject, saveProject } from '../actions/project';
Expand Down Expand Up @@ -82,6 +83,11 @@ export const useIDEKeyHandlers = ({ getContent }) => {
e.stopPropagation();
dispatch(newFile(rootFile.id));
},
'ctrl-alt-f': (e) => {
e.preventDefault();
e.stopPropagation();
dispatch(newFolder(rootFile.id));
},
'ctrl-`': (e) => {
e.preventDefault();
dispatch(consoleIsExpanded ? collapseConsole() : expandConsole());
Expand Down
6 changes: 6 additions & 0 deletions client/modules/IDE/components/KeyboardShortcutModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function KeyboardShortcutModal() {
metaKey === 'Ctrl' ? `${metaKeyName} + H` : `${metaKeyName} + ⌥ + F`;
const newFileCommand =
metaKey === 'Ctrl' ? `${metaKeyName} + Alt + N` : `${metaKeyName} + ⌥ + N`;
const newFolderCommand =
metaKey === 'Ctrl' ? `${metaKeyName} + Alt + F` : `${metaKeyName} + ⌥ + F`;
return (
<div className="keyboard-shortcuts">
<h3 className="keyboard-shortcuts__title">
Expand Down Expand Up @@ -75,6 +77,10 @@ function KeyboardShortcutModal() {
<span className="keyboard-shortcut__command">{newFileCommand}</span>
<span>{t('KeyboardShortcuts.CodeEditing.CreateNewFile')}</span>
</li>
<li className="keyboard-shortcut-item">
<span className="keyboard-shortcut__command">{newFolderCommand}</span>
<span>{t('KeyboardShortcuts.CodeEditing.CreateNewFolder')}</span>
</li>
</ul>
<h3 className="keyboard-shortcuts__title">General</h3>
<ul className="keyboard-shortcuts__list">
Expand Down
3 changes: 2 additions & 1 deletion translations/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@
"FindPreviousTextMatch": "Find Previous Text Match",
"CodeEditing": "Code Editing",
"ColorPicker": "Show Inline Color Picker",
"CreateNewFile": "Create New File"
"CreateNewFile": "Create New File",
"CreateNewFolder": "Create New Folder"
},
"General": {
"StartSketch": "Start Sketch",
Expand Down