Add keyboard shortcut for text based output (#193)

* add shortcuts

* add keyboard shortcut for text based output

* remove duplicate
This commit is contained in:
Mathura MG 2016-11-08 12:39:46 -05:00 committed by Cassie Tarakajian
parent 41c1613d10
commit d082ada1fd
3 changed files with 20 additions and 2 deletions

View file

@ -16,7 +16,7 @@ class KeyboardShortcutModal extends React.Component {
<InlineSVG src={exitUrl} alt="Close Keyboard Shortcuts Overlay" />
</button>
</header>
<ul>
<ul title="keyboard shortcuts">
<li className="keyboard-shortcut-item">
<span className="keyboard-shortcut__command">Shift + Tab</span>
<span>Tidy</span>
@ -56,6 +56,18 @@ class KeyboardShortcutModal extends React.Component {
</span>
<span>Stop Sketch</span>
</li>
<li className="keyboard-shortcut-item">
<span className="keyboard-shortcut__command">
{this.isMac ? 'Command + Shift + 1' : 'Control + Shift + 1'}
</span>
<span>Turn On Text-based Canvas</span>
</li>
<li className="keyboard-shortcut-item">
<span className="keyboard-shortcut__command">
{this.isMac ? 'Command + Shift + 2' : 'Control + Shift + 2'}
</span>
<span>Turn Off Text-based Canvas</span>
</li>
</ul>
</section>
);

View file

@ -153,6 +153,12 @@ class IDEView extends React.Component {
e.preventDefault();
e.stopPropagation();
this.props.startSketchAndRefresh();
} else if (e.keyCode === 50 && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac)) && e.shiftKey) {
e.preventDefault();
this.props.setTextOutput(false);
} else if (e.keyCode === 49 && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac)) && e.shiftKey) {
e.preventDefault();
this.props.setTextOutput(true);
}
}

View file

@ -13,6 +13,6 @@ function fetchJSONFile(path, callback) {
httpRequest.send();
}
fetchJSONFile('data.min.json', function(data){
fetchJSONFile('/data.min.json', function(data){
allData = data;
});