0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 18:42:40 +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(){ brewJump : function(page=this.getCurrentPage()){
const currentPage = this.getCurrentPage(); if(!document) return;
window.location.hash = `p${currentPage}`; 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 //Called when there are changes to the editor's dimensions
@@ -250,6 +257,8 @@ const Editor = createClass({
renderer={this.props.renderer} renderer={this.props.renderer}
undo={this.undo} undo={this.undo}
redo={this.redo} redo={this.redo}
brewJump={this.brewJump}
sourceJump={this.sourceJump}
historySize={this.historySize()} /> historySize={this.historySize()} />
{this.renderEditor()} {this.renderEditor()}