diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 1ecdcb22b..41d3f91e4 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -59,6 +59,8 @@ const Editor = createClass({ this.updateEditorSize(); this.highlightCustomMarkdown(); window.addEventListener('resize', this.updateEditorSize); + document.getElementById('BrewRenderer').addEventListener('keydown', this.handleControlKeys); + document.addEventListener('keydown', this.handleControlKeys); const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY); if(editorTheme) { @@ -82,6 +84,20 @@ const Editor = createClass({ }; }, + handleControlKeys : function(e){ + if(!(e.ctrlKey || e.metaKey)) return; + console.log(e); + const LEFTARROW_KEY = 37; + const RIGHTARROW_KEY = 39; + if (e.shiftKey && (e.keyCode == RIGHTARROW_KEY)) this.brewJump(); + if (e.shiftKey && (e.keyCode == LEFTARROW_KEY)) this.sourceJump(); + if ((e.keyCode == LEFTARROW_KEY) || (e.keyCode == RIGHTARROW_KEY)) { + e.stopPropagation(); + e.preventDefault(); + } + }, + + updateEditorSize : function() { if(this.codeEditor.current) { let paneHeight = this.editor.current.parentNode.clientHeight; @@ -119,6 +135,7 @@ const Editor = createClass({ const codeMirror = this.codeEditor.current.codeMirror; codeMirror.operation(()=>{ // Batch CodeMirror styling + //reset custom text styles const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear();