From f6db66b28ce2322e134b8dab01af674e3eea59c5 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 13:36:03 +1200 Subject: [PATCH] Add brewJump and sourceJump functions --- client/homebrew/editor/editor.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index fce116fcc..04251bd91 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -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()}