From 5e04e5dc995c220629fd1662bda597195ad67598 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Tue, 17 Jan 2017 23:32:34 -0500 Subject: [PATCH] Code to brew page jumping working --- client/homebrew/editor/editor.jsx | 16 ++++++++++++++++ client/homebrew/editor/editor.less | 14 ++++++++++++++ 2 files changed, 30 insertions(+) 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} /> + +
+ +
); } diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index 8678fd189..2df21868a 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -7,5 +7,19 @@ height : 100%; } + .brewJump{ + position: absolute; + background-color: @teal; + cursor: pointer; + width : 30px; + height : 30px; + display : flex; + align-items : center; + bottom : 20px; + right : 20px; + z-index: 1000000; + justify-content:center; + .tooltipLeft("Jump to brew page"); + } } \ No newline at end of file