0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 19:22:47 +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(){ 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)=>{ return _.reduce(lines, (r, line)=>{
if(line.indexOf('\\page') !== -1) r++; if(line.indexOf('\\page') !== -1) r++;
return r; return r;
@@ -174,16 +174,17 @@ const Editor = createClass({
} }
}, },
brewJump : function(page=this.getCurrentPage()){ brewJump : function(targetPage=this.getCurrentPage()){
if(!document) return; if(!window || this.isMeta()) return;
window.frames['BrewRenderer'].contentDocument.getElementById(`p${page}`).scrollIntoView({ behaviour: 'auto', block: 'start' }); window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behaviour: 'auto', block: 'start' });
// const hashPage = (page != 1) ? `p${page}` : ''; // const hashPage = (page != 1) ? `p${page}` : '';
// window.location.hash = hashPage; // window.location.hash = hashPage;
}, },
sourceJump : function(line=1){ sourceJump : function(targetLine=1){
if(!this.isText || !this.isStyle) return; if(this.isText() || this.isStyle()) {
this.refs.codeEditor.setCursorPosition(line, 1); this.refs.codeEditor.setCursorPosition(targetLine, 0);
}
}, },
//Called when there are changes to the editor's dimensions //Called when there are changes to the editor's dimensions