From c30eb9056a5be7b58fdc41473401ce31bf549bd6 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 5 Oct 2022 22:11:03 +1300 Subject: [PATCH] Break up text generation for legibility --- shared/naturalcrit/codeEditor/codeEditor.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index aaee268b1..b075033ac 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -252,7 +252,10 @@ const CodeEditor = createClass({ const cursorPos = this.codeMirror.getCursor(); - const text = this.codeMirror.getValue().split('\n').slice(0, cursorPos.line).reverse().filter((line)=>{return line.slice(0, header.length) == header && line; })[0] || 'PART 1 | SECTION NAME'; + const cmText = this.codeMirror.getValue(); + const cmTextArray = cmText.split('\n').slice(0, cursorPos.line).reverse(); + const cmTextArrayFilter = cmTextArray.filter((line)=>{ return line.slice(0, header.length) == header; }); + const text = cmTextArrayFilter[0].slice(header.length) || 'PART 1 | SECTION NAME'; this.codeMirror.replaceSelection(`\n{{footnote ${text}}}\n{{pageNumber,auto}}\n\n\\page\n\n`, 'end'); },