1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-05-11 12:55:22 +02:00

add keyboard sh0rtcuts command

This commit is contained in:
Kushagra Gour 2018-10-30 01:05:08 +05:30
parent ae85bfb474
commit 23a1df7dfd
2 changed files with 17 additions and 4 deletions

View File

@ -3,6 +3,7 @@ export const NEW_CREATION_EVENT = 'newCreationEvent';
export const OPEN_SAVED_CREATIONS_EVENT = 'openSavedCreationsEvent'; export const OPEN_SAVED_CREATIONS_EVENT = 'openSavedCreationsEvent';
export const SAVE_EVENT = 'saveEvent'; export const SAVE_EVENT = 'saveEvent';
export const OPEN_SETTINGS_EVENT = 'openSettingsEvent'; export const OPEN_SETTINGS_EVENT = 'openSettingsEvent';
export const SHOW_KEYBOARD_SHORTCUTS_EVENT = 'showKeyboardShortcutsEvent';
export const commands = [ export const commands = [
{ {
@ -24,5 +25,10 @@ export const commands = [
name: 'Open Settings', name: 'Open Settings',
event: OPEN_SETTINGS_EVENT, event: OPEN_SETTINGS_EVENT,
keyboardShortcut: '' keyboardShortcut: ''
},
{
name: 'Show Keyboard Shortcuts',
event: SHOW_KEYBOARD_SHORTCUTS_EVENT,
keyboardShortcut: ''
} }
]; ];

View File

@ -60,7 +60,8 @@ import {
OPEN_SAVED_CREATIONS_EVENT, OPEN_SAVED_CREATIONS_EVENT,
SAVE_EVENT, SAVE_EVENT,
OPEN_SETTINGS_EVENT, OPEN_SETTINGS_EVENT,
NEW_CREATION_EVENT NEW_CREATION_EVENT,
SHOW_KEYBOARD_SHORTCUTS_EVENT
} from '../commands'; } from '../commands';
import { commandPaletteService } from '../commandPaletteService'; import { commandPaletteService } from '../commandPaletteService';
@ -503,6 +504,9 @@ export default class App extends Component {
openSettings() { openSettings() {
this.setState({ isSettingsModalOpen: true }); this.setState({ isSettingsModalOpen: true });
} }
openKeyboardShortcuts() {
this.setState({ isKeyboardShortcutsModalOpen: true });
}
componentDidMount() { componentDidMount() {
function setBodySize() { function setBodySize() {
@ -584,6 +588,9 @@ export default class App extends Component {
}, },
[OPEN_SETTINGS_EVENT]: () => { [OPEN_SETTINGS_EVENT]: () => {
this.openSettings(); this.openSettings();
},
[SHOW_KEYBOARD_SHORTCUTS_EVENT]: () => {
this.openKeyboardShortcuts();
} }
}; };
for (let eventName in commandPalleteHooks) { for (let eventName in commandPalleteHooks) {
@ -1455,9 +1462,9 @@ export default class App extends Component {
)} )}
codepenBtnClickHandler={this.codepenBtnClickHandler.bind(this)} codepenBtnClickHandler={this.codepenBtnClickHandler.bind(this)}
saveHtmlBtnClickHandler={this.saveHtmlBtnClickHandler.bind(this)} saveHtmlBtnClickHandler={this.saveHtmlBtnClickHandler.bind(this)}
keyboardShortcutsBtnClickHandler={() => keyboardShortcutsBtnClickHandler={this.openKeyboardShortcuts.bind(
this.setState({ isKeyboardShortcutsModalOpen: true }) this
} )}
screenshotBtnClickHandler={this.screenshotBtnClickHandler.bind( screenshotBtnClickHandler={this.screenshotBtnClickHandler.bind(
this this
)} )}