mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-14 02:02:51 +00:00
fix pageCountWidgets to get elements by correct class name
This commit is contained in:
@@ -107,39 +107,36 @@ const Editor = createClass({
|
|||||||
addEditorPageNumbers : function(){
|
addEditorPageNumbers : function(){
|
||||||
if(!this.refs.codeEditor) return;
|
if(!this.refs.codeEditor) return;
|
||||||
if(this.state.view === 'text') {
|
if(this.state.view === 'text') {
|
||||||
let editorPageCount = 2; // start counting from page 2
|
|
||||||
const codeMirror = this.refs.codeEditor.codeMirror;
|
const codeMirror = this.refs.codeEditor.codeMirror;
|
||||||
|
|
||||||
const pageCountWidgets = document.getElementsByClassName('editor-page');
|
const pageCountWidgets = document.getElementsByClassName('editor-page-count');
|
||||||
|
for (let x=pageCountWidgets.length - 1;x>=0;x--) pageCountWidgets[x].remove();
|
||||||
for(let x=pageCountWidgets.length - 1;x>=0;x--) pageCountWidgets[x].remove();
|
|
||||||
|
|
||||||
|
let editorPageCount = 2; // start counting from page 2
|
||||||
console.log(editorPageCount);
|
|
||||||
|
|
||||||
const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{
|
const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{
|
||||||
if(this.props.renderer == 'legacy') {
|
if(this.props.renderer == 'legacy') {
|
||||||
if(line.includes('\\page')) {
|
if(line.includes('\\page')) {
|
||||||
const testElement = Object.assign(document.createElement('div'), {
|
const testElement = Object.assign(document.createElement('div'), {
|
||||||
className : 'editor-page-count',
|
className : 'editor-page-count',
|
||||||
textContent : editorPageCount
|
textContent : editorPageCount
|
||||||
});
|
});
|
||||||
codeMirror.addWidget({ line: lineNumber, ch: 0}, testElement);
|
codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement);
|
||||||
testElement.style.top = parseInt(testElement.style.top) - 12.5 + 'px';
|
testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`;
|
||||||
testElement.style.left = 'unset';
|
testElement.style.left = 'unset';
|
||||||
editorPageCount = editorPageCount + 1;
|
editorPageCount = editorPageCount + 1;
|
||||||
r.push(lineNumber);
|
r.push(lineNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.props.renderer == 'V3') {
|
if(this.props.renderer == 'V3') {
|
||||||
if(line.match(/^\\page$/)){
|
if(line.match(/^\\page$/)){
|
||||||
const testElement = Object.assign(document.createElement('div'), {
|
const testElement = Object.assign(document.createElement('div'), {
|
||||||
className : 'editor-page-count',
|
className : 'editor-page-count',
|
||||||
textContent : editorPageCount
|
textContent : editorPageCount
|
||||||
});
|
});
|
||||||
codeMirror.addWidget({ line: lineNumber, ch: 0}, testElement);
|
codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement);
|
||||||
testElement.style.top = parseInt(testElement.style.top) - 12.5 + 'px';
|
testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`;
|
||||||
testElement.style.left = 'unset';
|
testElement.style.left = 'unset';
|
||||||
editorPageCount = editorPageCount + 1;
|
editorPageCount = editorPageCount + 1;
|
||||||
r.push(lineNumber);
|
r.push(lineNumber);
|
||||||
|
|||||||
Reference in New Issue
Block a user