0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Add brewJump and sourceJump functions

This commit is contained in:
G.Ambatte
2022-05-03 13:36:03 +12:00
parent cde611eed5
commit f6db66b28c

View File

@@ -174,9 +174,16 @@ const Editor = createClass({
}
},
brewJump : function(){
const currentPage = this.getCurrentPage();
window.location.hash = `p${currentPage}`;
brewJump : function(page=this.getCurrentPage()){
if(!document) return;
window.frames['BrewRenderer'].contentDocument.getElementById(`p${page}`).scrollIntoView({ behaviour: 'auto', block: 'start' });
// const hashPage = (page != 1) ? `p${page}` : '';
// window.location.hash = hashPage;
},
sourceJump : function(line=1){
if(!this.isText || !this.isStyle) return;
this.refs.codeEditor.setCursorPosition(line, 1);
},
//Called when there are changes to the editor's dimensions
@@ -250,6 +257,8 @@ const Editor = createClass({
renderer={this.props.renderer}
undo={this.undo}
redo={this.redo}
brewJump={this.brewJump}
sourceJump={this.sourceJump}
historySize={this.historySize()} />
{this.renderEditor()}