mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-22 18:17:52 +00:00
Code to brew page jumping working
This commit is contained in:
@@ -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
|
//Called when there are changes to the editor's dimensions
|
||||||
update : function(){
|
update : function(){
|
||||||
this.refs.codeEditor.updateSize();
|
this.refs.codeEditor.updateSize();
|
||||||
@@ -95,6 +107,10 @@ const Editor = React.createClass({
|
|||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
onChange={this.handleTextChange}
|
onChange={this.handleTextChange}
|
||||||
onCursorActivity={this.handleCursorActivty} />
|
onCursorActivity={this.handleCursorActivty} />
|
||||||
|
|
||||||
|
<div className='brewJump' onClick={this.brewJump}>
|
||||||
|
<i className='fa fa-arrow-right' />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,5 +7,19 @@
|
|||||||
height : 100%;
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user