0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 12:52:38 +00:00

Control s and p now save and print on editor pages

This commit is contained in:
Scott Tolksdorf
2016-11-14 22:40:37 -05:00
parent 8b3f9ac76a
commit 2f2a1c5146
3 changed files with 34 additions and 7 deletions

View File

@@ -16,7 +16,6 @@ var SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
var Editor = require('../../editor/editor.jsx');
var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
var HijackPrint = require('../hijackPrint.js');
var Markdown = require('naturalcrit/markdown.js');
@@ -65,11 +64,22 @@ var EditPage = React.createClass({
htmlErrors : Markdown.validate(this.state.text)
})
document.onkeydown = HijackPrint(this.props.brew.shareId);
document.addEventListener('keydown', this.handleControlKeys);
},
componentWillUnmount: function() {
window.onbeforeunload = function(){};
document.onkeydown = function(){};
document.removeEventListener('keydown', this.handleControlKeys);
},
handleControlKeys : function(e){
if(!(e.ctrlKey || e.metaKey)) return;
e.stopPropagation();
e.preventDefault();
const S_KEY = 83;
const P_KEY = 80;
if(e.keyCode == S_KEY) this.save();
if(e.keyCode == P_KEY) window.open(`/print/${this.props.brew.shareId}?dialog=true`, '_blank').focus();
},
handleSplitMove : function(){