mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 22:52:40 +00:00
Add newPageWithFooter function
This commit is contained in:
@@ -142,6 +142,20 @@ const CodeEditor = createClass({
|
||||
'Shift-Cmd-Enter' : this.newColumn,
|
||||
'Ctrl-Enter' : this.newPage,
|
||||
'Cmd-Enter' : this.newPage,
|
||||
'Ctrl-Alt-Enter' : ()=>this.newPageWithFooter(),
|
||||
'Cmd-Alt-Enter' : ()=>this.newPageWithFooter(),
|
||||
'Ctrl-Alt-1' : ()=>this.newPageWithFooter(1),
|
||||
'Cmd-Alt-1' : ()=>this.newPageWithFooter(1),
|
||||
'Ctrl-Alt-2' : ()=>this.newPageWithFooter(2),
|
||||
'Cmd-Alt-2' : ()=>this.newPageWithFooter(2),
|
||||
'Ctrl-Alt-3' : ()=>this.newPageWithFooter(3),
|
||||
'Cmd-Alt-3' : ()=>this.newPageWithFooter(3),
|
||||
'Ctrl-Alt-4' : ()=>this.newPageWithFooter(4),
|
||||
'Cmd-Alt-4' : ()=>this.newPageWithFooter(4),
|
||||
'Ctrl-Alt-5' : ()=>this.newPageWithFooter(5),
|
||||
'Cmd-Alt-5' : ()=>this.newPageWithFooter(5),
|
||||
'Ctrl-Alt-6' : ()=>this.newPageWithFooter(6),
|
||||
'Cmd-Alt-6' : ()=>this.newPageWithFooter(6),
|
||||
'Ctrl-F' : 'findPersistent',
|
||||
'Cmd-F' : 'findPersistent',
|
||||
'Shift-Enter' : 'findPersistentPrevious',
|
||||
@@ -229,6 +243,20 @@ const CodeEditor = createClass({
|
||||
this.codeMirror.replaceSelection('\n\\page\n\n', 'end');
|
||||
},
|
||||
|
||||
newPageWithFooter : function(headerSize=1) {
|
||||
let header='';
|
||||
while (header.length < headerSize) {
|
||||
header = header.concat('#');
|
||||
}
|
||||
header = header.concat(' ');
|
||||
|
||||
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] || 'CHAPTER TITLE';
|
||||
|
||||
this.codeMirror.replaceSelection(`\n{{footnote ${text}}}\n{{pageNumber,auto}}\n\n\\page\n\n`, 'end');
|
||||
},
|
||||
|
||||
makeUnderline : function() {
|
||||
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '<u>' && selection.slice(-4) === '</u>';
|
||||
this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `<u>${selection}</u>`, 'around');
|
||||
|
||||
Reference in New Issue
Block a user