diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 407d9c242..594682278 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -66,6 +66,18 @@ const Editor = React.createClass({ }) }, + getCurrentPage : function(){ + const lines = this.props.value.split('\n').slice(0, this.cursorPosition.line + 1); + return _.reduce(lines, (r, line) => { + if(line.indexOf('\\page') !== -1) r++; + return r; + }, 1); + }, + brewJump : function(){ + const currentPage = this.getCurrentPage(); + window.location.hash = 'p' + currentPage; + }, + //Called when there are changes to the editor's dimensions update : function(){ this.refs.codeEditor.updateSize(); @@ -95,6 +107,10 @@ const Editor = React.createClass({ value={this.props.value} onChange={this.handleTextChange} onCursorActivity={this.handleCursorActivty} /> + +