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

Fix getCurrentPage

This commit is contained in:
G.Ambatte
2022-05-03 17:24:37 +12:00
parent f202e45e49
commit 451f06ca74

View File

@@ -96,7 +96,7 @@ const Editor = createClass({
},
getCurrentPage : function(){
const lines = this.props.brew.text.split('\n').slice(0, this.cursorPosition.line + 1);
const lines = this.props.brew.text.split('\n').slice(0, this.refs.codeEditor.getCursorPosition().line + 1);
return _.reduce(lines, (r, line)=>{
if(line.indexOf('\\page') !== -1) r++;
return r;
@@ -174,16 +174,17 @@ const Editor = createClass({
}
},
brewJump : function(page=this.getCurrentPage()){
if(!document) return;
window.frames['BrewRenderer'].contentDocument.getElementById(`p${page}`).scrollIntoView({ behaviour: 'auto', block: 'start' });
brewJump : function(targetPage=this.getCurrentPage()){
if(!window || this.isMeta()) return;
window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).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);
sourceJump : function(targetLine=1){
if(this.isText() || this.isStyle()) {
this.refs.codeEditor.setCursorPosition(targetLine, 0);
}
},
//Called when there are changes to the editor's dimensions