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" /> <InlineSVG src={exitUrl} alt="Close Keyboard Shortcuts Overlay" />
</button> </button>
</header> </header>
<ul> <ul title="keyboard shortcuts">
<li className="keyboard-shortcut-item"> <li className="keyboard-shortcut-item">
<span className="keyboard-shortcut__command">Shift + Tab</span> <span className="keyboard-shortcut__command">Shift + Tab</span>
<span>Tidy</span> <span>Tidy</span>
@ -56,6 +56,18 @@ class KeyboardShortcutModal extends React.Component {
</span> </span>
<span>Stop Sketch</span> <span>Stop Sketch</span>
</li> </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> </ul>
</section> </section>
); );

View File

@ -153,6 +153,12 @@ class IDEView extends React.Component {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.props.startSketchAndRefresh(); 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(); httpRequest.send();
} }
fetchJSONFile('data.min.json', function(data){ fetchJSONFile('/data.min.json', function(data){
allData = data; allData = data;
}); });