From 5258e9f0e6d7957706286e90ae052bca1aabe267 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Thu, 12 Aug 2021 22:41:34 -0500 Subject: [PATCH 01/54] Add Hotkey Ctrl/Cmd + K to create Link --- shared/naturalcrit/codeEditor/codeEditor.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 9707bde56..b8ecda048 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -54,7 +54,9 @@ const CodeEditor = createClass({ 'Ctrl-M' : this.makeSpan, 'Cmd-M' : this.makeSpan, 'Ctrl-/' : this.makeComment, - 'Cmd-/' : this.makeComment + 'Cmd-/' : this.makeComment, + 'Ctrl-K' : this.makeLink, + 'Cmd-K' : this.makeLink } }); @@ -99,6 +101,15 @@ const CodeEditor = createClass({ } }, + makeLink : function() { + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-3) === ']()'; + this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`, 'around'); + if(selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 3 }); + } + }, + //=-- Externally used -==// setCursorPosition : function(line, char){ setTimeout(()=>{ From b89c10a298f1867c12ce72c686bbf8b4e8984481 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Thu, 12 Aug 2021 22:48:42 -0500 Subject: [PATCH 02/54] Change cursor finish position Change cursor finish position --- shared/naturalcrit/codeEditor/codeEditor.jsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index b8ecda048..2b8879f7c 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -104,10 +104,8 @@ const CodeEditor = createClass({ makeLink : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-3) === ']()'; this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`, 'around'); - if(selection.length === 0){ - const cursor = this.codeMirror.getCursor(); - this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 3 }); - } + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); }, //=-- Externally used -==// From 727a58f56d285a34bb3cf6cfb622499d34667dc3 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Fri, 13 Aug 2021 08:28:02 -0500 Subject: [PATCH 03/54] Fixed cursor finish position - tested on single words and multi word strings - tested removal of hyperlink - tested with highlighting selection from left to right, and right to left. - tested on empty strings --- shared/naturalcrit/codeEditor/codeEditor.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 2b8879f7c..7f0c315fe 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -103,9 +103,12 @@ const CodeEditor = createClass({ makeLink : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-3) === ']()'; - this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`, 'around'); - const cursor = this.codeMirror.getCursor(); - this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); + this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`); + if ((selection.slice(0, 1) !== '[' || selection.slice(-3) !== ']()') || selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + console.log('hello'); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); + } }, //=-- Externally used -==// From 8c03b453b2eeabb761829329cac6c18bc80b9e59 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Fri, 13 Aug 2021 08:31:41 -0500 Subject: [PATCH 04/54] circleCI fix --- shared/naturalcrit/codeEditor/codeEditor.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 7f0c315fe..85214b1d1 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -104,7 +104,7 @@ const CodeEditor = createClass({ makeLink : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-3) === ']()'; this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`); - if ((selection.slice(0, 1) !== '[' || selection.slice(-3) !== ']()') || selection.length === 0){ + if((selection.slice(0, 1) !== '[' || selection.slice(-3) !== ']()') || selection.length === 0){ const cursor = this.codeMirror.getCursor(); console.log('hello'); this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); From ae75eb07b70858bc98fbff1ee65f055d7d27b3b0 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sun, 5 Sep 2021 20:33:51 -0500 Subject: [PATCH 05/54] matched functionality of link hotkey in github --- shared/naturalcrit/codeEditor/codeEditor.jsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 85214b1d1..cf08de0b3 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -102,12 +102,11 @@ const CodeEditor = createClass({ }, makeLink : function() { - const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-3) === ']()'; - this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`); - if((selection.slice(0, 1) !== '[' || selection.slice(-3) !== ']()') || selection.length === 0){ + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-6) === '](url)'; + this.codeMirror.replaceSelection(t ? selection.slice(1, -6) : `[${selection}](url)`); + if((selection.slice(0, 1) !== '[' || selection.slice(-6) !== '](url)') || selection.length === 0){ const cursor = this.codeMirror.getCursor(); - console.log('hello'); - this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); + this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 }); } }, From 08c845ff006ef60ee9f8c7855f845511a525fd92 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 6 Sep 2021 20:35:55 -0500 Subject: [PATCH 06/54] add underline hotkey and change italic hotkey to * Using `*` rather than `_` characters for italics is more inline with existing snippets. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 9707bde56..f32a7e130 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -51,6 +51,8 @@ const CodeEditor = createClass({ 'Cmd-B' : this.makeBold, 'Ctrl-I' : this.makeItalic, 'Cmd-I' : this.makeItalic, + 'Ctrl-U' : this.makeUnderline, + 'Cmd-U' : this.makeUnderline, 'Ctrl-M' : this.makeSpan, 'Cmd-M' : this.makeSpan, 'Ctrl-/' : this.makeComment, @@ -73,14 +75,23 @@ const CodeEditor = createClass({ }, makeItalic : function() { - const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '_' && selection.slice(-1) === '_'; - this.codeMirror.replaceSelection(t ? selection.slice(1, -1) : `_${selection}_`, 'around'); + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '*' && selection.slice(-1) === '*'; + this.codeMirror.replaceSelection(t ? selection.slice(1, -1) : `*${selection}*`, 'around'); if(selection.length === 0){ const cursor = this.codeMirror.getCursor(); this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); } }, + makeUnderline : function() { + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '' && selection.slice(-4) === ''; + this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `${selection}`, 'around'); + if(selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 4 }); + } + }, + makeSpan : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}'; this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `{{ ${selection}}}`, 'around'); From 7dcd3356306632523c526cb4538ddfd06005dbf9 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 6 Sep 2021 21:12:48 -0500 Subject: [PATCH 07/54] add makeDiv hotkey - V3 Curly Divs Shift-Cmd/Ctrl-M makes a curly div. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 31 +++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index f32a7e130..6858d5840 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -47,16 +47,18 @@ const CodeEditor = createClass({ indentWithTabs : true, tabSize : 2, extraKeys : { - 'Ctrl-B' : this.makeBold, - 'Cmd-B' : this.makeBold, - 'Ctrl-I' : this.makeItalic, - 'Cmd-I' : this.makeItalic, - 'Ctrl-U' : this.makeUnderline, - 'Cmd-U' : this.makeUnderline, - 'Ctrl-M' : this.makeSpan, - 'Cmd-M' : this.makeSpan, - 'Ctrl-/' : this.makeComment, - 'Cmd-/' : this.makeComment + 'Ctrl-B' : this.makeBold, + 'Cmd-B' : this.makeBold, + 'Ctrl-I' : this.makeItalic, + 'Cmd-I' : this.makeItalic, + 'Ctrl-U' : this.makeUnderline, + 'Cmd-U' : this.makeUnderline, + 'Ctrl-M' : this.makeSpan, + 'Cmd-M' : this.makeSpan, + 'Shift-Ctrl-M' : this.makeDiv, + 'Shift-Cmd-M' : this.makeDiv, + 'Ctrl-/' : this.makeComment, + 'Cmd-/' : this.makeComment } }); @@ -101,6 +103,15 @@ const CodeEditor = createClass({ } }, + makeDiv : function() { + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}'; + this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `{{\n${selection}\n}}`, 'around'); + if(selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line - 1, ch: cursor.ch }); // set to -2? if wanting to enter classes etc. if so, get rid of first \n when replacing selection + } + }, + makeComment : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 4) === ''; this.codeMirror.replaceSelection(t ? selection.slice(4, -3) : ``, 'around'); From 389ad1cf1778d88141935996a436dcbe8d7a6797 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Fri, 10 Sep 2021 23:18:23 -0500 Subject: [PATCH 08/54] add hotkeys for   and empty makeNbsp, makeSpace, removeSpace --- shared/naturalcrit/codeEditor/codeEditor.jsx | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 6858d5840..6d5685cd7 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -53,6 +53,12 @@ const CodeEditor = createClass({ 'Cmd-I' : this.makeItalic, 'Ctrl-U' : this.makeUnderline, 'Cmd-U' : this.makeUnderline, + 'Ctrl-.' : this.makeNbsp, + 'Cmd-.' : this.makeNbsp, + 'Shift-Ctrl-.' : this.makeSpace, + 'Shift-Cmd-.' : this.makeSpace, + 'Shift-Ctrl-,' : this.removeSpace, + 'Shift-Cmd-,' : this.removeSpace, 'Ctrl-M' : this.makeSpan, 'Cmd-M' : this.makeSpan, 'Shift-Ctrl-M' : this.makeDiv, @@ -85,6 +91,30 @@ const CodeEditor = createClass({ } }, + makeNbsp : function() { + this.codeMirror.replaceSelection(' ', 'end'); + }, + + makeSpace : function() { + const selection = this.codeMirror.getSelection(); + const t = selection.slice(0, 8) === '{{width:' && selection.slice(0 -4) === '% }}'; + if(t){ + const percent = parseInt(selection.slice(8, -4)) + 10; + this.codeMirror.replaceSelection(percent < 90 ? `{{width:${percent}% }}` : '{{width:100% }}', 'around'); + } else { + this.codeMirror.replaceSelection(`{{width:10% }}`, 'around'); + } + }, + + removeSpace : function() { + const selection = this.codeMirror.getSelection(); + const t = selection.slice(0, 8) === '{{width:' && selection.slice(0 -4) === '% }}'; + if(t){ + const percent = parseInt(selection.slice(8, -4)) - 10; + this.codeMirror.replaceSelection(percent > 10 ? `{{width:${percent}% }}` : '', 'around'); + } + }, + makeUnderline : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '' && selection.slice(-4) === ''; this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `${selection}`, 'around'); From bec2a7c77abca010522ea920aed1e56374c07839 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sat, 11 Sep 2021 00:12:58 -0500 Subject: [PATCH 09/54] add hotkeys for new \page and \column --- shared/naturalcrit/codeEditor/codeEditor.jsx | 48 ++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 6d5685cd7..a810bee3a 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -47,24 +47,28 @@ const CodeEditor = createClass({ indentWithTabs : true, tabSize : 2, extraKeys : { - 'Ctrl-B' : this.makeBold, - 'Cmd-B' : this.makeBold, - 'Ctrl-I' : this.makeItalic, - 'Cmd-I' : this.makeItalic, - 'Ctrl-U' : this.makeUnderline, - 'Cmd-U' : this.makeUnderline, - 'Ctrl-.' : this.makeNbsp, - 'Cmd-.' : this.makeNbsp, - 'Shift-Ctrl-.' : this.makeSpace, - 'Shift-Cmd-.' : this.makeSpace, - 'Shift-Ctrl-,' : this.removeSpace, - 'Shift-Cmd-,' : this.removeSpace, - 'Ctrl-M' : this.makeSpan, - 'Cmd-M' : this.makeSpan, - 'Shift-Ctrl-M' : this.makeDiv, - 'Shift-Cmd-M' : this.makeDiv, - 'Ctrl-/' : this.makeComment, - 'Cmd-/' : this.makeComment + 'Ctrl-B' : this.makeBold, + 'Cmd-B' : this.makeBold, + 'Ctrl-I' : this.makeItalic, + 'Cmd-I' : this.makeItalic, + 'Ctrl-U' : this.makeUnderline, + 'Cmd-U' : this.makeUnderline, + 'Ctrl-.' : this.makeNbsp, + 'Cmd-.' : this.makeNbsp, + 'Shift-Ctrl-.' : this.makeSpace, + 'Shift-Cmd-.' : this.makeSpace, + 'Shift-Ctrl-,' : this.removeSpace, + 'Shift-Cmd-,' : this.removeSpace, + 'Shift-Ctrl-Enter' : this.newColumn, + 'Shift-Cmd-Enter' : this.newColumn, + 'Ctrl-Enter' : this.newPage, + 'Cmd-Enter' : this.newPage, + 'Ctrl-M' : this.makeSpan, + 'Cmd-M' : this.makeSpan, + 'Shift-Ctrl-M' : this.makeDiv, + 'Shift-Cmd-M' : this.makeDiv, + 'Ctrl-/' : this.makeComment, + 'Cmd-/' : this.makeComment } }); @@ -115,6 +119,14 @@ const CodeEditor = createClass({ } }, + newColumn : function() { + this.codeMirror.replaceSelection('\n\\column\n\n', 'end'); + }, + + newPage : function() { + this.codeMirror.replaceSelection('\n\\page\n\n', 'end'); + }, + makeUnderline : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '' && selection.slice(-4) === ''; this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `${selection}`, 'around'); From ec2c74f09300bb3741d54c61c1f83333e023e3ad Mon Sep 17 00:00:00 2001 From: Rodrigo Kuerten Date: Tue, 21 Sep 2021 17:11:07 -0300 Subject: [PATCH 10/54] Created base make header functions --- shared/naturalcrit/codeEditor/codeEditor.jsx | 28 ++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 9707bde56..368af3e9c 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -47,14 +47,20 @@ const CodeEditor = createClass({ indentWithTabs : true, tabSize : 2, extraKeys : { - 'Ctrl-B' : this.makeBold, - 'Cmd-B' : this.makeBold, - 'Ctrl-I' : this.makeItalic, - 'Cmd-I' : this.makeItalic, - 'Ctrl-M' : this.makeSpan, - 'Cmd-M' : this.makeSpan, - 'Ctrl-/' : this.makeComment, - 'Cmd-/' : this.makeComment + 'Ctrl-B' : this.makeBold, + 'Cmd-B' : this.makeBold, + 'Ctrl-I' : this.makeItalic, + 'Cmd-I' : this.makeItalic, + 'Ctrl-M' : this.makeSpan, + 'Cmd-M' : this.makeSpan, + 'Ctrl-/' : this.makeComment, + 'Cmd-/' : this.makeComment, + 'Shift-Ctrl-1' : ()=>this.makeHeader(1), + 'Shift-Ctrl-2' : ()=>this.makeHeader(2), + 'Shift-Ctrl-3' : ()=>this.makeHeader(3), + 'Shift-Ctrl-4' : ()=>this.makeHeader(4), + 'Shift-Ctrl-5' : ()=>this.makeHeader(5), + 'Shift-Ctrl-6' : ()=>this.makeHeader(6), } }); @@ -63,6 +69,12 @@ const CodeEditor = createClass({ this.updateSize(); }, + makeHeader : function (number) { + const selection = this.codeMirror.getSelection(); + const header = Array(number).fill('#').join(''); + this.codeMirror.replaceSelection(`${header} ${selection}`, 'around'); + }, + makeBold : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '**' && selection.slice(-2) === '**'; this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `**${selection}**`, 'around'); From bbad4b9e8ace3c0665adbeea209d6ddbf4b2e0c4 Mon Sep 17 00:00:00 2001 From: Rodrigo Kuerten Date: Tue, 21 Sep 2021 17:25:37 -0300 Subject: [PATCH 11/54] Removed H1 and H2 options and updated cursor after added hashtags --- shared/naturalcrit/codeEditor/codeEditor.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 368af3e9c..8b96f0d0f 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -55,8 +55,6 @@ const CodeEditor = createClass({ 'Cmd-M' : this.makeSpan, 'Ctrl-/' : this.makeComment, 'Cmd-/' : this.makeComment, - 'Shift-Ctrl-1' : ()=>this.makeHeader(1), - 'Shift-Ctrl-2' : ()=>this.makeHeader(2), 'Shift-Ctrl-3' : ()=>this.makeHeader(3), 'Shift-Ctrl-4' : ()=>this.makeHeader(4), 'Shift-Ctrl-5' : ()=>this.makeHeader(5), @@ -73,6 +71,8 @@ const CodeEditor = createClass({ const selection = this.codeMirror.getSelection(); const header = Array(number).fill('#').join(''); this.codeMirror.replaceSelection(`${header} ${selection}`, 'around'); + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch + selection.length + number + 1 }); }, makeBold : function() { From c10bdabee0d057c3aa315cec09c9008ffa5e8c2a Mon Sep 17 00:00:00 2001 From: Rodrigo Kuerten Date: Wed, 22 Sep 2021 18:21:34 -0300 Subject: [PATCH 12/54] Added h1 and h2 & cmd version --- shared/naturalcrit/codeEditor/codeEditor.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 8b96f0d0f..9c506a020 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -55,10 +55,18 @@ const CodeEditor = createClass({ 'Cmd-M' : this.makeSpan, 'Ctrl-/' : this.makeComment, 'Cmd-/' : this.makeComment, + 'Shift-Ctrl-1' : ()=>this.makeHeader(1), + 'Shift-Ctrl-2' : ()=>this.makeHeader(2), 'Shift-Ctrl-3' : ()=>this.makeHeader(3), 'Shift-Ctrl-4' : ()=>this.makeHeader(4), 'Shift-Ctrl-5' : ()=>this.makeHeader(5), 'Shift-Ctrl-6' : ()=>this.makeHeader(6), + 'Shift-Cmd-1' : ()=>this.makeHeader(1), + 'Shift-Cmd-2' : ()=>this.makeHeader(2), + 'Shift-Cmd-3' : ()=>this.makeHeader(3), + 'Shift-Cmd-4' : ()=>this.makeHeader(4), + 'Shift-Cmd-5' : ()=>this.makeHeader(5), + 'Shift-Cmd-6' : ()=>this.makeHeader(6), } }); From beb3c7ec89d10ffa2838bfc2602a018a0c032789 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Thu, 23 Sep 2021 00:22:40 -0500 Subject: [PATCH 13/54] make undo behavior work regardless of url text --- shared/naturalcrit/codeEditor/codeEditor.jsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index cf08de0b3..f49cd29b1 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -102,9 +102,16 @@ const CodeEditor = createClass({ }, makeLink : function() { - const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-6) === '](url)'; - this.codeMirror.replaceSelection(t ? selection.slice(1, -6) : `[${selection}](url)`); - if((selection.slice(0, 1) !== '[' || selection.slice(-6) !== '](url)') || selection.length === 0){ + const isLink = /^\[(.*)(\]\()(.*)\)$/g; + const selection = this.codeMirror.getSelection(); + if(isLink.test(selection) == true){ + const altText = selection.slice(1, selection.lastIndexOf('](')); + const url = selection.slice(selection.lastIndexOf('](') + 2, -1); + this.codeMirror.replaceSelection(`${altText} ${url}`); + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch }); + } else { + this.codeMirror.replaceSelection(`[${selection}](url)`); const cursor = this.codeMirror.getCursor(); this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 }); } From b3e37dd2c10612c288e4c7d87ba9ea02a886cf6b Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Thu, 23 Sep 2021 01:01:02 -0500 Subject: [PATCH 14/54] add comment about trying capture groups in future. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index f49cd29b1..c39c43da2 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -105,8 +105,8 @@ const CodeEditor = createClass({ const isLink = /^\[(.*)(\]\()(.*)\)$/g; const selection = this.codeMirror.getSelection(); if(isLink.test(selection) == true){ - const altText = selection.slice(1, selection.lastIndexOf('](')); - const url = selection.slice(selection.lastIndexOf('](') + 2, -1); + const altText = selection.slice(1, selection.lastIndexOf('](')); // could likely be done better with capture groups + const url = selection.slice(selection.lastIndexOf('](') + 2, -1); // could likely be done better with capture groups this.codeMirror.replaceSelection(`${altText} ${url}`); const cursor = this.codeMirror.getCursor(); this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch }); From ba9413eae5d20d9be288fa7e41783f33e92be54a Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 27 Sep 2021 09:31:59 -0500 Subject: [PATCH 15/54] initial commit, add hotkey definitions --- shared/naturalcrit/codeEditor/codeEditor.jsx | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 9707bde56..fe63f7565 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -47,14 +47,18 @@ const CodeEditor = createClass({ indentWithTabs : true, tabSize : 2, extraKeys : { - 'Ctrl-B' : this.makeBold, - 'Cmd-B' : this.makeBold, - 'Ctrl-I' : this.makeItalic, - 'Cmd-I' : this.makeItalic, - 'Ctrl-M' : this.makeSpan, - 'Cmd-M' : this.makeSpan, - 'Ctrl-/' : this.makeComment, - 'Cmd-/' : this.makeComment + 'Ctrl-B' : this.makeBold, + 'Cmd-B' : this.makeBold, + 'Ctrl-I' : this.makeItalic, + 'Cmd-I' : this.makeItalic, + 'Ctrl-M' : this.makeSpan, + 'Cmd-M' : this.makeSpan, + 'Ctrl-/' : this.makeComment, + 'Cmd-/' : this.makeComment, + 'Ctrl-L' : this.makeUnOrderedList, + 'Cmd-L' : this.makeUnOrderedList, + 'Shift-Ctrl-L' : this.makeOrderedList, + 'Shift-Cmd-L' : this.makeOrderedList } }); @@ -99,6 +103,10 @@ const CodeEditor = createClass({ } }, + makeUnOrderedList : function() { + const selection = this.codeMirror.getSelection() + } + //=-- Externally used -==// setCursorPosition : function(line, char){ setTimeout(()=>{ From cb0f5217fe734f11f106b3a76493d122a55ffb97 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 27 Sep 2021 21:23:05 -0500 Subject: [PATCH 16/54] get and set selection to cover entire lines --- shared/naturalcrit/codeEditor/codeEditor.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index fe63f7565..b641a403a 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -104,8 +104,20 @@ const CodeEditor = createClass({ }, makeUnOrderedList : function() { - const selection = this.codeMirror.getSelection() - } + const isList = /^-\s/gm; + const selectionStart = this.codeMirror.getCursor('from'); + const selectionEnd = this.codeMirror.getCursor('to'); + const selection = this.codeMirror.setSelection( + { line: selectionStart.line, ch: 0 }, + { line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length }); + console.log(selectionStart, selectionEnd, selection); + }, + + + // ordered list: + // selection should expand to include the full line even if selection is only part of line + // regex should match "- " at beginning of selection + // regex should match "- " at beginnign of each line or maybe "\n- " //=-- Externally used -==// setCursorPosition : function(line, char){ From 41609f90ea4ddf66c1071f4acba286b864e2dded Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 27 Sep 2021 21:34:09 -0500 Subject: [PATCH 17/54] update to detect if an unordered list or not. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index b641a403a..a91fda406 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -111,6 +111,11 @@ const CodeEditor = createClass({ { line: selectionStart.line, ch: 0 }, { line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length }); console.log(selectionStart, selectionEnd, selection); + if(isList.test(this.codeMirror.getSelection()) == true){ + console.log('is list'); + } else { + console.log('is not a list'); + } }, From 6717692187c554b12945feb3b9a95ea8ed6b91f7 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Tue, 28 Sep 2021 11:19:02 -0500 Subject: [PATCH 18/54] finish UL creation/removal function --- shared/naturalcrit/codeEditor/codeEditor.jsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index a91fda406..997143faf 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -104,17 +104,18 @@ const CodeEditor = createClass({ }, makeUnOrderedList : function() { - const isList = /^-\s/gm; const selectionStart = this.codeMirror.getCursor('from'); const selectionEnd = this.codeMirror.getCursor('to'); - const selection = this.codeMirror.setSelection( + this.codeMirror.setSelection( { line: selectionStart.line, ch: 0 }, - { line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length }); - console.log(selectionStart, selectionEnd, selection); - if(isList.test(this.codeMirror.getSelection()) == true){ - console.log('is list'); + { line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length } + ); + const isUL = /^-\s/gm; + const newSelection = this.codeMirror.getSelection(); + if(newSelection.match(isUL) == null){ + this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around'); } else { - console.log('is not a list'); + this.codeMirror.replaceSelection(newSelection.replace(isUL, ''), 'around'); } }, From 63c59a223a67be9773fcc314b5abf499e385fb11 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Tue, 28 Sep 2021 14:34:31 -0500 Subject: [PATCH 19/54] refine removal of lists regardless if UL or OL Next step after this is to get numbered lists to increase --- shared/naturalcrit/codeEditor/codeEditor.jsx | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 997143faf..1ac90a124 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -55,10 +55,10 @@ const CodeEditor = createClass({ 'Cmd-M' : this.makeSpan, 'Ctrl-/' : this.makeComment, 'Cmd-/' : this.makeComment, - 'Ctrl-L' : this.makeUnOrderedList, - 'Cmd-L' : this.makeUnOrderedList, - 'Shift-Ctrl-L' : this.makeOrderedList, - 'Shift-Cmd-L' : this.makeOrderedList + 'Ctrl-L' : ()=>this.makeList('UL'), + 'Cmd-L' : ()=>this.makeList('UL'), + 'Shift-Ctrl-L' : ()=>this.makeList('OL'), + 'Shift-Cmd-L' : ()=>this.makeList('OL') } }); @@ -103,19 +103,21 @@ const CodeEditor = createClass({ } }, - makeUnOrderedList : function() { - const selectionStart = this.codeMirror.getCursor('from'); - const selectionEnd = this.codeMirror.getCursor('to'); + makeList : function(listType) { + const selectionStart = this.codeMirror.getCursor('from'), selectionEnd = this.codeMirror.getCursor('to'); this.codeMirror.setSelection( { line: selectionStart.line, ch: 0 }, { line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length } ); - const isUL = /^-\s/gm; const newSelection = this.codeMirror.getSelection(); - if(newSelection.match(isUL) == null){ - this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around'); - } else { - this.codeMirror.replaceSelection(newSelection.replace(isUL, ''), 'around'); + + const regex = /^\d+\.\s|^-\s/gm; + console.log(regex); + if(newSelection.match(regex) != null){ // if selection IS A LIST + this.codeMirror.replaceSelection(newSelection.replace(regex, ''), 'around'); + } else { // if selection IS NOT A LIST + listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around') : + this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '1. '), 'around'); } }, From 40a75b9b278e29996948374462a7afa87c95adc2 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Tue, 28 Sep 2021 16:09:00 -0500 Subject: [PATCH 20/54] increment ordered list numbering --- shared/naturalcrit/codeEditor/codeEditor.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 1ac90a124..a48d451df 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -112,12 +112,16 @@ const CodeEditor = createClass({ const newSelection = this.codeMirror.getSelection(); const regex = /^\d+\.\s|^-\s/gm; - console.log(regex); if(newSelection.match(regex) != null){ // if selection IS A LIST this.codeMirror.replaceSelection(newSelection.replace(regex, ''), 'around'); } else { // if selection IS NOT A LIST - listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '- '), 'around') : - this.codeMirror.replaceSelection(newSelection.replace(/^/gm, '1. '), 'around'); + listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, `- `), 'around') : + this.codeMirror.replaceSelection(newSelection.replace(/^/gm, (()=>{ + let n = 1; + return ()=>{ + return `${n++}. `; + }; + })()), 'around'); } }, From 3bf5d7a2dbe44846a194ee99ae85bfcca1e29832 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Thu, 30 Sep 2021 17:59:45 -0500 Subject: [PATCH 21/54] change makeComment function to adapt to gfm or css editor --- shared/naturalcrit/codeEditor/codeEditor.jsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index a810bee3a..ee318ee1d 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -155,12 +155,24 @@ const CodeEditor = createClass({ }, makeComment : function() { - const selection = this.codeMirror.getSelection(), t = selection.slice(0, 4) === ''; - this.codeMirror.replaceSelection(t ? selection.slice(4, -3) : ``, 'around'); + let regex; + let cursorPos; + let newComment; + const selection = this.codeMirror.getSelection(); + if(this.props.language === 'gfm'){ + regex = /^\s*()\s*$/gs; + cursorPos = 4; + newComment = ``; + } else { + regex = /^\s*(\/\*\s?)(.*?)(\s?\*\/)\s*$/gs; + cursorPos = 3; + newComment = `/* ${selection} */`; + } + this.codeMirror.replaceSelection(regex.test(selection) == true ? selection.replace(regex, '$2') : newComment, 'around'); if(selection.length === 0){ const cursor = this.codeMirror.getCursor(); - this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 4 }); - } + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - cursorPos }); + }; }, //=-- Externally used -==// From 1fb63f8be3b608f301152bdc97716c78af174533 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sat, 6 Nov 2021 22:28:12 -0500 Subject: [PATCH 22/54] initial commit to add programmatic page counts in editor update element classname to be more descriptive, remove some commented code. --- client/homebrew/editor/editor.jsx | 50 ++++++++++++++++++++++++++++++ client/homebrew/editor/editor.less | 12 +++---- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 77001435d..40a58ea83 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -52,6 +52,7 @@ const Editor = createClass({ componentDidMount : function() { this.updateEditorSize(); + this.addEditorPageNumbers(); this.highlightCustomMarkdown(); window.addEventListener('resize', this.updateEditorSize); }, @@ -61,6 +62,7 @@ const Editor = createClass({ }, componentDidUpdate : function() { + this.addEditorPageNumbers(); this.highlightCustomMarkdown(); }, @@ -102,6 +104,53 @@ const Editor = createClass({ }, 1); }, + addEditorPageNumbers : function(){ + if(!this.refs.codeEditor) return; + if(this.state.view === 'text') { + let editorPageCount = 2; // start counting from page 2 + const codeMirror = this.refs.codeEditor.codeMirror; + + const pageCountWidgets = document.getElementsByClassName('editor-page'); + + for(let x=pageCountWidgets.length - 1;x>=0;x--) pageCountWidgets[x].remove(); + + + console.log(editorPageCount); + + const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{ + if(this.props.renderer == 'legacy') { + if(line.includes('\\page')) { + const testElement = Object.assign(document.createElement('div'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.addWidget({ line: lineNumber, ch: 0}, testElement); + testElement.style.top = parseInt(testElement.style.top) - 12.5 + 'px'; + testElement.style.left = 'unset'; + editorPageCount = editorPageCount + 1; + r.push(lineNumber); + } + } + + if(this.props.renderer == 'V3') { + if(line.match(/^\\page$/)){ + const testElement = Object.assign(document.createElement('div'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.addWidget({ line: lineNumber, ch: 0}, testElement); + testElement.style.top = parseInt(testElement.style.top) - 12.5 + 'px'; + testElement.style.left = 'unset'; + editorPageCount = editorPageCount + 1; + r.push(lineNumber); + } + } + return r; + }, []); + return lineNumbers; + } + }, + highlightCustomMarkdown : function(){ if(!this.refs.codeEditor) return; if(this.state.view === 'text') { @@ -111,6 +160,7 @@ const Editor = createClass({ const customHighlights = codeMirror.getAllMarks(); for (let i=0;i{ //reset custom line styles diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index 8633e4eb3..439e1f482 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -5,17 +5,13 @@ .codeEditor{ height : 100%; - counter-reset : page; - counter-increment : page; .pageLine{ background : #33333328; border-top : #339 solid 1px; - &:after{ - content : counter(page); - counter-increment : page; - float : right; - color : gray; - } + } + .editor-page-count{ + color : grey; + right : 12px; } .columnSplit{ font-style : italic; From 9141b93a6b8b02181f5d324712d7785e71528218 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sun, 7 Nov 2021 16:47:54 -0600 Subject: [PATCH 23/54] fix pageCountWidgets to get elements by correct class name --- client/homebrew/editor/editor.jsx | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 40a58ea83..006955fc2 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -107,39 +107,36 @@ const Editor = createClass({ addEditorPageNumbers : function(){ if(!this.refs.codeEditor) return; if(this.state.view === 'text') { - let editorPageCount = 2; // start counting from page 2 const codeMirror = this.refs.codeEditor.codeMirror; - const pageCountWidgets = document.getElementsByClassName('editor-page'); - - for(let x=pageCountWidgets.length - 1;x>=0;x--) pageCountWidgets[x].remove(); + const pageCountWidgets = document.getElementsByClassName('editor-page-count'); + for (let x=pageCountWidgets.length - 1;x>=0;x--) pageCountWidgets[x].remove(); - - console.log(editorPageCount); + let editorPageCount = 2; // start counting from page 2 const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{ if(this.props.renderer == 'legacy') { if(line.includes('\\page')) { const testElement = Object.assign(document.createElement('div'), { - className : 'editor-page-count', + className : 'editor-page-count', textContent : editorPageCount }); - codeMirror.addWidget({ line: lineNumber, ch: 0}, testElement); - testElement.style.top = parseInt(testElement.style.top) - 12.5 + 'px'; + codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); + testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; testElement.style.left = 'unset'; editorPageCount = editorPageCount + 1; r.push(lineNumber); } } - + if(this.props.renderer == 'V3') { if(line.match(/^\\page$/)){ const testElement = Object.assign(document.createElement('div'), { - className : 'editor-page-count', + className : 'editor-page-count', textContent : editorPageCount }); - codeMirror.addWidget({ line: lineNumber, ch: 0}, testElement); - testElement.style.top = parseInt(testElement.style.top) - 12.5 + 'px'; + codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); + testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; testElement.style.left = 'unset'; editorPageCount = editorPageCount + 1; r.push(lineNumber); From c3e24ef4c597f332b86d5470ac9e909b83aa7220 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 8 Nov 2021 08:59:30 -0600 Subject: [PATCH 24/54] replace _.reduce() with _.forEach() --- client/homebrew/editor/editor.jsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 006955fc2..96c3ce786 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -114,7 +114,7 @@ const Editor = createClass({ let editorPageCount = 2; // start counting from page 2 - const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{ + _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ if(this.props.renderer == 'legacy') { if(line.includes('\\page')) { const testElement = Object.assign(document.createElement('div'), { @@ -125,7 +125,6 @@ const Editor = createClass({ testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; testElement.style.left = 'unset'; editorPageCount = editorPageCount + 1; - r.push(lineNumber); } } @@ -139,12 +138,9 @@ const Editor = createClass({ testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; testElement.style.left = 'unset'; editorPageCount = editorPageCount + 1; - r.push(lineNumber); } } - return r; - }, []); - return lineNumbers; + }, []) } }, From 403e5050e85473229c6b7569c569f4a64d20110e Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:05:08 -0600 Subject: [PATCH 25/54] adjust position from `right` to accommodate scrollbar --- client/homebrew/editor/editor.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index 439e1f482..61f9279cb 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -11,7 +11,7 @@ } .editor-page-count{ color : grey; - right : 12px; + right : 15px; } .columnSplit{ font-style : italic; From 796bd220007e28cc7e35bec0d4172eff7f3d1d16 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:07:59 -0600 Subject: [PATCH 26/54] circleCI update --- client/homebrew/editor/editor.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 96c3ce786..73a5a0d51 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -140,7 +140,7 @@ const Editor = createClass({ editorPageCount = editorPageCount + 1; } } - }, []) + }, []); } }, From 3e54f6e6e1e0622dd1ef2061f026cb10104d6aee Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 8 Nov 2021 10:49:41 -0600 Subject: [PATCH 27/54] remove collection array from _.forEach() function Co-authored-by: Trevor Buckner --- client/homebrew/editor/editor.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 73a5a0d51..a882863d1 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -140,7 +140,7 @@ const Editor = createClass({ editorPageCount = editorPageCount + 1; } } - }, []); + }); } }, From 9f05aae876d2d7fad4495faa1f1d889c0679db72 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Wed, 10 Nov 2021 11:17:45 -0600 Subject: [PATCH 28/54] remove `left` property entirely and set height to cm.defaultTextHeight --- client/homebrew/editor/editor.jsx | 7 ++++--- client/homebrew/editor/editor.less | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index a882863d1..7879b8797 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -122,8 +122,9 @@ const Editor = createClass({ textContent : editorPageCount }); codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); - testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; - testElement.style.left = 'unset'; + // testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; + testElement.style.top = `${parseInt(testElement.style.top) - cm.defaultTextHeight()}px`; + testElement.style.left = null; editorPageCount = editorPageCount + 1; } } @@ -136,7 +137,7 @@ const Editor = createClass({ }); codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; - testElement.style.left = 'unset'; + testElement.style.left = null; editorPageCount = editorPageCount + 1; } } diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index 61f9279cb..d20cfd86e 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -11,7 +11,7 @@ } .editor-page-count{ color : grey; - right : 15px; + right : 15px; // needs to be enough to push past scrollbar. } .columnSplit{ font-style : italic; From 8b13528661fe6e74c63ec954834700416caf0e64 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Wed, 17 Nov 2021 09:47:51 -0600 Subject: [PATCH 29/54] add check for change to current viewport --- client/homebrew/editor/editor.jsx | 40 ++++++++++++-------- shared/naturalcrit/codeEditor/codeEditor.jsx | 1 + 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 7879b8797..ef96e64c8 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -114,30 +114,40 @@ const Editor = createClass({ let editorPageCount = 2; // start counting from page 2 + // get top and bottom line numbers currently in editor viewport + const viewportRect = codeMirror.getWrapperElement().getBoundingClientRect(); + const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, "window"); + const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, "window"); + _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ if(this.props.renderer == 'legacy') { if(line.includes('\\page')) { - const testElement = Object.assign(document.createElement('div'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); - // testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; - testElement.style.top = `${parseInt(testElement.style.top) - cm.defaultTextHeight()}px`; - testElement.style.left = null; + // add a check here to see if in current viewport, then create widget if true + if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ + const testElement = Object.assign(document.createElement('div'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); + testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; + testElement.style.left = null; + } + // end createWidget process editorPageCount = editorPageCount + 1; } } if(this.props.renderer == 'V3') { if(line.match(/^\\page$/)){ - const testElement = Object.assign(document.createElement('div'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); - testElement.style.top = `${parseInt(testElement.style.top) - 12.5}px`; - testElement.style.left = null; + if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ + const testElement = Object.assign(document.createElement('div'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); + testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; + testElement.style.left = null; + } editorPageCount = editorPageCount + 1; } } diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 621e24f77..8b9c372b6 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -80,6 +80,7 @@ const CodeEditor = createClass({ // Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror. Either one works. this.codeMirror.on('change', (cm)=>{this.props.onChange(cm.getValue());}); + this.codeMirror.on('viewportChange', _.debounce((cm)=>{this.props.onChange(cm.getValue());},200)); this.updateSize(); }, From f0608441fcc5736e75c84adc3b97ca7f9741ba45 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Wed, 17 Nov 2021 09:58:31 -0600 Subject: [PATCH 30/54] fix circleCI errors --- client/homebrew/editor/editor.jsx | 4 ++-- shared/naturalcrit/codeEditor/codeEditor.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index ef96e64c8..7b31ca75e 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -116,8 +116,8 @@ const Editor = createClass({ // get top and bottom line numbers currently in editor viewport const viewportRect = codeMirror.getWrapperElement().getBoundingClientRect(); - const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, "window"); - const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, "window"); + const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, 'window'); + const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, 'window'); _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ if(this.props.renderer == 'legacy') { diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 8b9c372b6..9b202cedc 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -80,7 +80,7 @@ const CodeEditor = createClass({ // Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror. Either one works. this.codeMirror.on('change', (cm)=>{this.props.onChange(cm.getValue());}); - this.codeMirror.on('viewportChange', _.debounce((cm)=>{this.props.onChange(cm.getValue());},200)); + this.codeMirror.on('viewportChange', _.debounce((cm)=>{this.props.onChange(cm.getValue());}, 200)); this.updateSize(); }, From f72d8f0ef006f8e8d2c16190e3394efd73caf51f Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Wed, 17 Nov 2021 10:47:16 -0600 Subject: [PATCH 31/54] merge pageNumber() into customHighlight() --- client/homebrew/editor/editor.jsx | 103 ++++++++++++------------------ 1 file changed, 41 insertions(+), 62 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 7b31ca75e..2ce86c3b7 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -52,7 +52,6 @@ const Editor = createClass({ componentDidMount : function() { this.updateEditorSize(); - this.addEditorPageNumbers(); this.highlightCustomMarkdown(); window.addEventListener('resize', this.updateEditorSize); }, @@ -62,7 +61,6 @@ const Editor = createClass({ }, componentDidUpdate : function() { - this.addEditorPageNumbers(); this.highlightCustomMarkdown(); }, @@ -104,57 +102,6 @@ const Editor = createClass({ }, 1); }, - addEditorPageNumbers : function(){ - if(!this.refs.codeEditor) return; - if(this.state.view === 'text') { - const codeMirror = this.refs.codeEditor.codeMirror; - - const pageCountWidgets = document.getElementsByClassName('editor-page-count'); - for (let x=pageCountWidgets.length - 1;x>=0;x--) pageCountWidgets[x].remove(); - - let editorPageCount = 2; // start counting from page 2 - - // get top and bottom line numbers currently in editor viewport - const viewportRect = codeMirror.getWrapperElement().getBoundingClientRect(); - const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, 'window'); - const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, 'window'); - - _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ - if(this.props.renderer == 'legacy') { - if(line.includes('\\page')) { - // add a check here to see if in current viewport, then create widget if true - if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ - const testElement = Object.assign(document.createElement('div'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); - testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; - testElement.style.left = null; - } - // end createWidget process - editorPageCount = editorPageCount + 1; - } - } - - if(this.props.renderer == 'V3') { - if(line.match(/^\\page$/)){ - if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ - const testElement = Object.assign(document.createElement('div'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); - testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; - testElement.style.left = null; - } - editorPageCount = editorPageCount + 1; - } - } - }); - } - }, - highlightCustomMarkdown : function(){ if(!this.refs.codeEditor) return; if(this.state.view === 'text') { @@ -164,8 +111,18 @@ const Editor = createClass({ const customHighlights = codeMirror.getAllMarks(); for (let i=0;i=0;x--) pageCountWidgets[x].remove(); - const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{ + let editorPageCount = 2; // start page count from page 2 + + // get top and bottom line numbers currently in editor viewport + const viewportRect = codeMirror.getWrapperElement().getBoundingClientRect(); + const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, 'window'); + const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, 'window'); + + _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ //reset custom line styles codeMirror.removeLineClass(lineNumber, 'background'); @@ -174,21 +131,46 @@ const Editor = createClass({ // Legacy Codemirror styling if(this.props.renderer == 'legacy') { if(line.includes('\\page')){ + // add back the original class 'background' but also add the new class '.pageline' codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - r.push(lineNumber); - } + // add a check here to see if in current viewport, then create widget if true + if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ + const testElement = Object.assign(document.createElement('div'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); + // addWidget() sets an inline style for 'top' and 'left' by default; the below overrides or removes the default values + testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; + testElement.style.left = null; + } + // end createWidget process + editorPageCount = editorPageCount + 1; + }; + } // New Codemirror styling for V3 renderer if(this.props.renderer == 'V3') { if(line.match(/^\\page$/)){ + // add back the original class 'background' but also add the new class '.pageline' codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - r.push(lineNumber); + // add a check here to see if in current viewport, then create widget if true + if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ + const testElement = Object.assign(document.createElement('div'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); + // addWidget() sets an inline style for 'top' and 'left' by default; the below overrides or removes the default values + testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; + testElement.style.left = null; + } + editorPageCount = editorPageCount + 1; } if(line.match(/^\\column$/)){ codeMirror.addLineClass(lineNumber, 'text', 'columnSplit'); - r.push(lineNumber); } // Highlight inline spans {{content}} @@ -218,10 +200,7 @@ const Editor = createClass({ codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' }); } } - - return r; - }, []); - return lineNumbers; + }); } }, From 7997698bcd5cf307b764675abe42249614174ac5 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sun, 21 Nov 2021 10:58:41 -0600 Subject: [PATCH 32/54] change conditions for google error --- client/homebrew/pages/editPage/editPage.jsx | 4 ++-- client/homebrew/pages/newPage/newPage.jsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index ee4f41f5b..b2bbac114 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -349,7 +349,7 @@ const EditPage = createClass({ ; } - if(this.state.errors.status == '403' && this.state.errors.response.body.errors[0].reason == 'insufficientPermissions'){ + if(this.state.errors.url.match(/^\/api\/.*Google.*$/m)){ return Oops!
@@ -360,7 +360,7 @@ const EditPage = createClass({
- Sign In + Go to Log In Page
diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 3f09cac4e..72b38e202 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -226,7 +226,7 @@ const NewPage = createClass({ ; } - if(this.state.errors.status == '403' && this.state.errors.response.body.errors[0].reason == 'insufficientPermissions'){ + if(this.state.errors.url.match(/^\/api\/.*Google.*$/m)){ return Oops!
@@ -237,7 +237,7 @@ const NewPage = createClass({
- Sign In + Go to Log In Page
From 372d33271de5d653aa9cc6a83bb4a1cdd6c325d7 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sun, 21 Nov 2021 15:17:23 -0600 Subject: [PATCH 33/54] Change widgets to bookmarks for page counters --- client/homebrew/editor/editor.jsx | 37 +++++++++++------------------- client/homebrew/editor/editor.less | 2 +- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 3201b8c79..f2428e906 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -105,22 +105,20 @@ const Editor = createClass({ highlightCustomMarkdown : function(){ if(!this.refs.codeEditor) return; if(this.state.view === 'text') { + console.log('change'); const codeMirror = this.refs.codeEditor.codeMirror; //reset custom text styles const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding - for (let i=0;i=0;i--) customHighlights[i].clear(); - // remove all widgets (page numbers in Editor) - const pageCountWidgets = document.getElementsByClassName('editor-page-count'); - for (let x=pageCountWidgets.length - 1;x>=0;x--) pageCountWidgets[x].remove(); let editorPageCount = 2; // start page count from page 2 // get top and bottom line numbers currently in editor viewport const viewportRect = codeMirror.getWrapperElement().getBoundingClientRect(); - const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, 'window'); - const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, 'window'); + const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, 'window') - 50; + const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, 'window') + 50; _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ @@ -131,20 +129,16 @@ const Editor = createClass({ // Legacy Codemirror styling if(this.props.renderer == 'legacy') { if(line.includes('\\page')){ - // add back the original class 'background' but also add the new class '.pageline' - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - // add a check here to see if in current viewport, then create widget if true + // add a check here to see if in current viewport if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ - const testElement = Object.assign(document.createElement('div'), { + // add back the original class 'background' but also add the new class '.pageline' + codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); + const pageCountElement = Object.assign(document.createElement('span'), { className : 'editor-page-count', textContent : editorPageCount }); - codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); - // addWidget() sets an inline style for 'top' and 'left' by default; the below overrides or removes the default values - testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; - testElement.style.left = null; + codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); } - // end createWidget process editorPageCount = editorPageCount + 1; }; @@ -153,18 +147,15 @@ const Editor = createClass({ // New Codemirror styling for V3 renderer if(this.props.renderer == 'V3') { if(line.match(/^\\page$/)){ - // add back the original class 'background' but also add the new class '.pageline' - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - // add a check here to see if in current viewport, then create widget if true + // add a check here to see if in current viewport, if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ - const testElement = Object.assign(document.createElement('div'), { + // add back the original class 'background' but also add the new class '.pageline' + codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); + const pageCountElement = Object.assign(document.createElement('span'), { className : 'editor-page-count', textContent : editorPageCount }); - codeMirror.addWidget({ line: lineNumber, ch: 0 }, testElement); - // addWidget() sets an inline style for 'top' and 'left' by default; the below overrides or removes the default values - testElement.style.top = `${parseInt(testElement.style.top) - codeMirror.defaultTextHeight()}px`; - testElement.style.left = null; + codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); } editorPageCount = editorPageCount + 1; } diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index d20cfd86e..ffdcdd856 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -11,7 +11,7 @@ } .editor-page-count{ color : grey; - right : 15px; // needs to be enough to push past scrollbar. + float: right; } .columnSplit{ font-style : italic; From 2e5d1b3b5572c95a5b2945fb2e2eb5f957c80175 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Wed, 24 Nov 2021 07:48:44 -0600 Subject: [PATCH 34/54] Update client/homebrew/pages/newPage/newPage.jsx Co-authored-by: Trevor Buckner --- client/homebrew/pages/newPage/newPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 72b38e202..380ffefea 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -226,7 +226,7 @@ const NewPage = createClass({ ; } - if(this.state.errors.url.match(/^\/api\/.*Google.*$/m)){ + if(this.state.errors.response.req.url.match(/^\/api\/.*Google.*$/m)){ return Oops!
From 9618e802d1c602bcb7919ded545d9e49cfac587c Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Wed, 24 Nov 2021 14:35:36 -0600 Subject: [PATCH 35/54] Update client/homebrew/pages/editPage/editPage.jsx Co-authored-by: Trevor Buckner --- client/homebrew/pages/editPage/editPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index b2bbac114..fff13a945 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -349,7 +349,7 @@ const EditPage = createClass({ ; } - if(this.state.errors.url.match(/^\/api\/.*Google.*$/m)){ + if(this.state.errors.response.req.url.match(/^\/api\/.*Google.*$/m)){ return Oops!
From 2586a871e1fd48e6bf34137d01b6fc936cdbeb9f Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 2 Dec 2021 11:45:10 -0500 Subject: [PATCH 36/54] Use capture groups, add default "alt text" if none selected Also allow whitespace at end and start of selection, so you don't have to be perfect. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 495166c1b..b7bb8b435 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -156,16 +156,17 @@ const CodeEditor = createClass({ }, makeLink : function() { - const isLink = /^\[(.*)(\]\()(.*)\)$/g; - const selection = this.codeMirror.getSelection(); - if(isLink.test(selection) == true){ - const altText = selection.slice(1, selection.lastIndexOf('](')); // could likely be done better with capture groups - const url = selection.slice(selection.lastIndexOf('](') + 2, -1); // could likely be done better with capture groups + const isLink = /^\[(.*)\]\((.*)\)$/; + const selection = this.codeMirror.getSelection().trim(); + let match; + if(match = isLink.exec(selection)){ + const altText = match[1]; + const url = match[2]; this.codeMirror.replaceSelection(`${altText} ${url}`); const cursor = this.codeMirror.getCursor(); this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch }); } else { - this.codeMirror.replaceSelection(`[${selection}](url)`); + this.codeMirror.replaceSelection(`[${selection || 'alt text'}](url)`); const cursor = this.codeMirror.getCursor(); this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 }); } From 9da1bfc6063563264bc5602521d7598571680f8a Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 2 Dec 2021 12:18:22 -0500 Subject: [PATCH 37/54] Finish Merge with Master --- shared/naturalcrit/codeEditor/codeEditor.jsx | 126 ++++++++++++++++--- 1 file changed, 108 insertions(+), 18 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index ee318ee1d..423e46468 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -13,6 +13,13 @@ if(typeof navigator !== 'undefined'){ require('codemirror/mode/gfm/gfm.js'); //Github flavoured markdown require('codemirror/mode/css/css.js'); require('codemirror/mode/javascript/javascript.js'); + + //Addons + require('codemirror/addon/fold/foldcode.js'); + require('codemirror/addon/fold/foldgutter.js'); + + const foldCode = require('./fold-code'); + foldCode.registerHomebreweryHelper(CodeMirror); } const CodeEditor = createClass({ @@ -25,28 +32,48 @@ const CodeEditor = createClass({ }; }, + getInitialState : function() { + return { + docs : {} + }; + }, + componentDidMount : function() { this.buildEditor(); + const newDoc = CodeMirror.Doc(this.props.value, this.props.language); + this.codeMirror.swapDoc(newDoc); }, componentDidUpdate : function(prevProps) { - if(prevProps.language !== this.props.language){ //rebuild editor when switching tabs - this.buildEditor(); - } - if(this.codeMirror && this.codeMirror.getValue() != this.props.value) { //update editor contents if brew.text is changed from outside + if(prevProps.view !== this.props.view){ //view changed; swap documents + let newDoc; + + if(!this.state.docs[this.props.view]) { + newDoc = CodeMirror.Doc(this.props.value, this.props.language); + } else { + newDoc = this.state.docs[this.props.view]; + } + + const oldDoc = { [prevProps.view]: this.codeMirror.swapDoc(newDoc) }; + + this.setState((prevState)=>({ + docs : _.merge({}, prevState.docs, oldDoc) + })); + + this.props.rerenderParent(); + } else if(this.codeMirror?.getValue() != this.props.value) { //update editor contents if brew.text is changed from outside this.codeMirror.setValue(this.props.value); } }, buildEditor : function() { this.codeMirror = CodeMirror(this.refs.editor, { - value : this.props.value, - lineNumbers : true, - lineWrapping : this.props.wrap, - mode : this.props.language, //TODO: CSS MODE DOESN'T SEEM TO LOAD PROPERLY - indentWithTabs : true, - tabSize : 2, - extraKeys : { + lineNumbers : true, + lineWrapping : this.props.wrap, + indentWithTabs : true, + tabSize : 2, + historyEventDelay : 250, + extraKeys : { 'Ctrl-B' : this.makeBold, 'Cmd-B' : this.makeBold, 'Ctrl-I' : this.makeItalic, @@ -59,17 +86,46 @@ const CodeEditor = createClass({ 'Shift-Cmd-.' : this.makeSpace, 'Shift-Ctrl-,' : this.removeSpace, 'Shift-Cmd-,' : this.removeSpace, - 'Shift-Ctrl-Enter' : this.newColumn, - 'Shift-Cmd-Enter' : this.newColumn, - 'Ctrl-Enter' : this.newPage, - 'Cmd-Enter' : this.newPage, 'Ctrl-M' : this.makeSpan, 'Cmd-M' : this.makeSpan, 'Shift-Ctrl-M' : this.makeDiv, 'Shift-Cmd-M' : this.makeDiv, 'Ctrl-/' : this.makeComment, - 'Cmd-/' : this.makeComment - } + 'Cmd-/' : this.makeComment, + 'Ctrl-K' : this.makeLink, + 'Cmd-K' : this.makeLink, + 'Shift-Ctrl-Enter' : this.newColumn, + 'Shift-Cmd-Enter' : this.newColumn, + 'Ctrl-Enter' : this.newPage, + 'Cmd-Enter' : this.newPage, + 'Ctrl-[' : this.foldAllCode, + 'Cmd-[' : this.foldAllCode, + 'Ctrl-]' : this.unfoldAllCode, + 'Cmd-]' : this.unfoldAllCode + }, + foldGutter : true, + foldOptions : { + scanUp : true, + rangeFinder : CodeMirror.fold.homebrewery, + widget : (from, to)=>{ + let text = ''; + let currentLine = from.line; + const maxLength = 50; + while (currentLine <= to.line && text.length <= maxLength) { + text += this.codeMirror.getLine(currentLine); + if(currentLine < to.line) + text += ' '; + currentLine += 1; + } + + text = text.trim(); + if(text.length > maxLength) + text = `${text.substr(0, maxLength)}...`; + + return `\u21A4 ${text} \u21A6`; + } + }, + gutters : ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'] }); // Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror. Either one works. @@ -175,6 +231,31 @@ const CodeEditor = createClass({ }; }, + makeLink : function() { + const isLink = /^\[(.*)\]\((.*)\)$/; + const selection = this.codeMirror.getSelection().trim(); + let match; + if(match = isLink.exec(selection)){ + const altText = match[1]; + const url = match[2]; + this.codeMirror.replaceSelection(`${altText} ${url}`); + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch }); + } else { + this.codeMirror.replaceSelection(`[${selection || 'alt text'}](url)`); + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 }); + } + }, + + foldAllCode : function() { + this.codeMirror.execCommand('foldAll'); + }, + + unfoldAllCode : function() { + this.codeMirror.execCommand('unfoldAll'); + }, + //=-- Externally used -==// setCursorPosition : function(line, char){ setTimeout(()=>{ @@ -188,10 +269,19 @@ const CodeEditor = createClass({ updateSize : function(){ this.codeMirror.refresh(); }, + redo : function(){ + return this.codeMirror.redo(); + }, + undo : function(){ + return this.codeMirror.undo(); + }, + historySize : function(){ + return this.codeMirror.doc.historySize(); + }, //----------------------// render : function(){ - return
; + return
; } }); From a30e150ade2df8d6564585f186c0a1295b4a9481 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 2 Dec 2021 15:47:18 -0500 Subject: [PATCH 38/54] Disable max lines to satisfy lint Eventually we should move the hotkey scripts into a separate file. They are becoming a beast of their own. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 423e46468..57e306bd3 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ require('./codeEditor.less'); const React = require('react'); const createClass = require('create-react-class'); From 1865e56b04ee49cbd330de8fe72e2602d005d1fb Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 2 Dec 2021 23:44:48 -0500 Subject: [PATCH 39/54] lint --- shared/naturalcrit/codeEditor/codeEditor.jsx | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index d21a3c256..95302b10d 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -95,18 +95,18 @@ const CodeEditor = createClass({ 'Cmd-/' : this.makeComment, 'Ctrl-K' : this.makeLink, 'Cmd-K' : this.makeLink, - 'Shift-Ctrl-1' : ()=>this.makeHeader(1), - 'Shift-Ctrl-2' : ()=>this.makeHeader(2), - 'Shift-Ctrl-3' : ()=>this.makeHeader(3), - 'Shift-Ctrl-4' : ()=>this.makeHeader(4), - 'Shift-Ctrl-5' : ()=>this.makeHeader(5), - 'Shift-Ctrl-6' : ()=>this.makeHeader(6), - 'Shift-Cmd-1' : ()=>this.makeHeader(1), - 'Shift-Cmd-2' : ()=>this.makeHeader(2), - 'Shift-Cmd-3' : ()=>this.makeHeader(3), - 'Shift-Cmd-4' : ()=>this.makeHeader(4), - 'Shift-Cmd-5' : ()=>this.makeHeader(5), - 'Shift-Cmd-6' : ()=>this.makeHeader(6), + 'Shift-Ctrl-1' : ()=>this.makeHeader(1), + 'Shift-Ctrl-2' : ()=>this.makeHeader(2), + 'Shift-Ctrl-3' : ()=>this.makeHeader(3), + 'Shift-Ctrl-4' : ()=>this.makeHeader(4), + 'Shift-Ctrl-5' : ()=>this.makeHeader(5), + 'Shift-Ctrl-6' : ()=>this.makeHeader(6), + 'Shift-Cmd-1' : ()=>this.makeHeader(1), + 'Shift-Cmd-2' : ()=>this.makeHeader(2), + 'Shift-Cmd-3' : ()=>this.makeHeader(3), + 'Shift-Cmd-4' : ()=>this.makeHeader(4), + 'Shift-Cmd-5' : ()=>this.makeHeader(5), + 'Shift-Cmd-6' : ()=>this.makeHeader(6), 'Shift-Ctrl-Enter' : this.newColumn, 'Shift-Cmd-Enter' : this.newColumn, 'Ctrl-Enter' : this.newPage, From 5cd45a1413656855fe9fb07347ecaa68e43e0516 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Fri, 3 Dec 2021 20:20:40 -0600 Subject: [PATCH 40/54] remove "in viewport" requirement for markdown highlight/pg numbers --- client/homebrew/editor/editor.jsx | 31 +++++++------------- shared/naturalcrit/codeEditor/codeEditor.jsx | 1 - 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index f2428e906..49649bf1d 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -115,11 +115,6 @@ const Editor = createClass({ let editorPageCount = 2; // start page count from page 2 - // get top and bottom line numbers currently in editor viewport - const viewportRect = codeMirror.getWrapperElement().getBoundingClientRect(); - const topVisibleLine = codeMirror.lineAtHeight(viewportRect.top, 'window') - 50; - const bottomVisibleLine = codeMirror.lineAtHeight(viewportRect.bottom, 'window') + 50; - _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ //reset custom line styles @@ -129,17 +124,15 @@ const Editor = createClass({ // Legacy Codemirror styling if(this.props.renderer == 'legacy') { if(line.includes('\\page')){ - // add a check here to see if in current viewport - if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ - // add back the original class 'background' but also add the new class '.pageline' - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - const pageCountElement = Object.assign(document.createElement('span'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); - } - editorPageCount = editorPageCount + 1; + // add back the original class 'background' but also add the new class '.pageline' + codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); + const pageCountElement = Object.assign(document.createElement('span'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); + + editorPageCount += 1; }; } @@ -147,8 +140,6 @@ const Editor = createClass({ // New Codemirror styling for V3 renderer if(this.props.renderer == 'V3') { if(line.match(/^\\page$/)){ - // add a check here to see if in current viewport, - if(lineNumber > topVisibleLine && lineNumber < bottomVisibleLine){ // add back the original class 'background' but also add the new class '.pageline' codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); const pageCountElement = Object.assign(document.createElement('span'), { @@ -156,8 +147,8 @@ const Editor = createClass({ textContent : editorPageCount }); codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); - } - editorPageCount = editorPageCount + 1; + + editorPageCount += 1; } if(line.match(/^\\column$/)){ diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index a23603908..01eca0114 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -114,7 +114,6 @@ const CodeEditor = createClass({ // Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror. Either one works. this.codeMirror.on('change', (cm)=>{this.props.onChange(cm.getValue());}); - this.codeMirror.on('viewportChange', _.debounce((cm)=>{this.props.onChange(cm.getValue());}, 200)); this.updateSize(); }, From dcf4fe10cd091f6d44f97380300d61f5276cee58 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Fri, 3 Dec 2021 20:25:04 -0600 Subject: [PATCH 41/54] lint --- client/homebrew/editor/editor.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 49649bf1d..35da6e3bb 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -131,7 +131,7 @@ const Editor = createClass({ textContent : editorPageCount }); codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); - + editorPageCount += 1; }; @@ -140,14 +140,14 @@ const Editor = createClass({ // New Codemirror styling for V3 renderer if(this.props.renderer == 'V3') { if(line.match(/^\\page$/)){ - // add back the original class 'background' but also add the new class '.pageline' - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - const pageCountElement = Object.assign(document.createElement('span'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); - + // add back the original class 'background' but also add the new class '.pageline' + codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); + const pageCountElement = Object.assign(document.createElement('span'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); + editorPageCount += 1; } From 00491379328c8966a35848d621d56655e0f49d12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Dec 2021 03:00:58 +0000 Subject: [PATCH 42/54] Bump eslint from 8.3.0 to 8.4.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.3.0 to 8.4.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.3.0...v8.4.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 106 +++++++++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/package-lock.json b/package-lock.json index bbf92c64c..65b2524e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" }, "devDependencies": { - "eslint": "^8.3.0", + "eslint": "^8.4.0", "eslint-plugin-react": "^7.27.1", "pico-check": "^2.1.3" }, @@ -1776,14 +1776,14 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.4.tgz", - "integrity": "sha512-h8Vx6MdxwWI2WM8/zREHMoqdgLNXEL4QX3MWSVMdyNJGvXVOs+6lp+m2hc3FnuMHDc4poxFNI20vCk0OmI4G0Q==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.0.0", + "espree": "^9.2.0", "globals": "^13.9.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", @@ -1796,9 +1796,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -1831,12 +1831,12 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz", + "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.0", + "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", "minimatch": "^3.0.4" }, @@ -1845,9 +1845,9 @@ } }, "node_modules/@humanwhocodes/config-array/node_modules/debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -1868,9 +1868,9 @@ "dev": true }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, "node_modules/@sindresorhus/is": { @@ -3850,13 +3850,13 @@ } }, "node_modules/eslint": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.3.0.tgz", - "integrity": "sha512-aIay56Ph6RxOTC7xyr59Kt3ewX185SaGnAr8eWukoPLeriCrvGjvAubxuvaXOfsxhtwV5g0uBOsyhAom4qJdww==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.0.tgz", + "integrity": "sha512-kv0XQcAQJL/VD9THQKhTQZVqkJKA+tIj/v2ZKNaIHRAADcJWFb+B/BAewUYuF6UVg1s2xC5qXVoDk0G8sKGeTA==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^1.0.4", - "@humanwhocodes/config-array": "^0.6.0", + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -3867,7 +3867,7 @@ "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.1.0", - "espree": "^9.1.0", + "espree": "^9.2.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -4115,9 +4115,9 @@ } }, "node_modules/espree": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.1.0.tgz", - "integrity": "sha512-ZgYLvCS1wxOczBYGcQT9DDWgicXwJ4dbocr9uYN+/eresBAUuBu+O4WzB21ufQ/JqQT8gyp7hJ3z8SHii32mTQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz", + "integrity": "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==", "dev": true, "dependencies": { "acorn": "^8.6.0", @@ -10771,14 +10771,14 @@ } }, "@eslint/eslintrc": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.4.tgz", - "integrity": "sha512-h8Vx6MdxwWI2WM8/zREHMoqdgLNXEL4QX3MWSVMdyNJGvXVOs+6lp+m2hc3FnuMHDc4poxFNI20vCk0OmI4G0Q==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.0.0", + "espree": "^9.2.0", "globals": "^13.9.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", @@ -10788,9 +10788,9 @@ }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -10811,20 +10811,20 @@ } }, "@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz", + "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.0", + "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", "minimatch": "^3.0.4" }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -10839,9 +10839,9 @@ } }, "@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, "@sindresorhus/is": { @@ -12466,13 +12466,13 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "eslint": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.3.0.tgz", - "integrity": "sha512-aIay56Ph6RxOTC7xyr59Kt3ewX185SaGnAr8eWukoPLeriCrvGjvAubxuvaXOfsxhtwV5g0uBOsyhAom4qJdww==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.0.tgz", + "integrity": "sha512-kv0XQcAQJL/VD9THQKhTQZVqkJKA+tIj/v2ZKNaIHRAADcJWFb+B/BAewUYuF6UVg1s2xC5qXVoDk0G8sKGeTA==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.0.4", - "@humanwhocodes/config-array": "^0.6.0", + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -12483,7 +12483,7 @@ "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.1.0", - "espree": "^9.1.0", + "espree": "^9.2.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -12666,9 +12666,9 @@ "dev": true }, "espree": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.1.0.tgz", - "integrity": "sha512-ZgYLvCS1wxOczBYGcQT9DDWgicXwJ4dbocr9uYN+/eresBAUuBu+O4WzB21ufQ/JqQT8gyp7hJ3z8SHii32mTQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz", + "integrity": "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==", "dev": true, "requires": { "acorn": "^8.6.0", diff --git a/package.json b/package.json index fb152d6d5..75aca3d11 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" }, "devDependencies": { - "eslint": "^8.3.0", + "eslint": "^8.4.0", "eslint-plugin-react": "^7.27.1", "pico-check": "^2.1.3" } From 8acd42fcbef632dd2fbc0cdb68983205d3e31628 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 15:36:41 -0500 Subject: [PATCH 43/54] Small cleanup. Reduce redundant code. --- client/homebrew/editor/editor.jsx | 39 +++++++++--------------------- client/homebrew/editor/editor.less | 2 +- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 35da6e3bb..3822c0b99 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -105,14 +105,12 @@ const Editor = createClass({ highlightCustomMarkdown : function(){ if(!this.refs.codeEditor) return; if(this.state.view === 'text') { - console.log('change'); const codeMirror = this.refs.codeEditor.codeMirror; //reset custom text styles const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear(); - let editorPageCount = 2; // start page count from page 2 _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ @@ -121,36 +119,23 @@ const Editor = createClass({ codeMirror.removeLineClass(lineNumber, 'background'); codeMirror.removeLineClass(lineNumber, 'text'); - // Legacy Codemirror styling - if(this.props.renderer == 'legacy') { - if(line.includes('\\page')){ - // add back the original class 'background' but also add the new class '.pageline' - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - const pageCountElement = Object.assign(document.createElement('span'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); + // Styling for \page breaks + if((this.props.renderer == 'legacy' && line.includes('\\page')) || + (this.props.renderer == 'V3' && line.match(/^\\page$/))) { - editorPageCount += 1; - }; + // add back the original class 'background' but also add the new class '.pageline' + codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); + const pageCountElement = Object.assign(document.createElement('span'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); - } + editorPageCount += 1; + }; // New Codemirror styling for V3 renderer if(this.props.renderer == 'V3') { - if(line.match(/^\\page$/)){ - // add back the original class 'background' but also add the new class '.pageline' - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - const pageCountElement = Object.assign(document.createElement('span'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); - - editorPageCount += 1; - } - if(line.match(/^\\column$/)){ codeMirror.addLineClass(lineNumber, 'text', 'columnSplit'); } diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index ffdcdd856..810ee1710 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -11,7 +11,7 @@ } .editor-page-count{ color : grey; - float: right; + float : right; } .columnSplit{ font-style : italic; From 09f64e018e29ac5d656cca213731f194f4a6c450 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 16:23:18 -0500 Subject: [PATCH 44/54] Tell CodeMirror to batch custom highlights before updating the browser --- client/homebrew/editor/editor.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 3822c0b99..ae2c3aa1d 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -107,6 +107,8 @@ const Editor = createClass({ if(this.state.view === 'text') { const codeMirror = this.refs.codeEditor.codeMirror; + codeMirror.startOperation(); + //reset custom text styles const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear(); @@ -168,6 +170,8 @@ const Editor = createClass({ } } }); + + codeMirror.endOperation(); } }, From e2b2b38e5bd3b35a7fa4222c87996560b2f756dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Dec 2021 03:00:52 +0000 Subject: [PATCH 45/54] Bump eslint from 8.4.0 to 8.4.1 Bumps [eslint](https://github.com/eslint/eslint) from 8.4.0 to 8.4.1. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.4.0...v8.4.1) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 65b2524e2..b632a497b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" }, "devDependencies": { - "eslint": "^8.4.0", + "eslint": "^8.4.1", "eslint-plugin-react": "^7.27.1", "pico-check": "^2.1.3" }, @@ -3850,9 +3850,9 @@ } }, "node_modules/eslint": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.0.tgz", - "integrity": "sha512-kv0XQcAQJL/VD9THQKhTQZVqkJKA+tIj/v2ZKNaIHRAADcJWFb+B/BAewUYuF6UVg1s2xC5qXVoDk0G8sKGeTA==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.1.tgz", + "integrity": "sha512-TxU/p7LB1KxQ6+7aztTnO7K0i+h0tDi81YRY9VzB6Id71kNz+fFYnf5HD5UOQmxkzcoa0TlVZf9dpMtUv0GpWg==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.0.5", @@ -12466,9 +12466,9 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "eslint": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.0.tgz", - "integrity": "sha512-kv0XQcAQJL/VD9THQKhTQZVqkJKA+tIj/v2ZKNaIHRAADcJWFb+B/BAewUYuF6UVg1s2xC5qXVoDk0G8sKGeTA==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.1.tgz", + "integrity": "sha512-TxU/p7LB1KxQ6+7aztTnO7K0i+h0tDi81YRY9VzB6Id71kNz+fFYnf5HD5UOQmxkzcoa0TlVZf9dpMtUv0GpWg==", "dev": true, "requires": { "@eslint/eslintrc": "^1.0.5", diff --git a/package.json b/package.json index 75aca3d11..13843ef5f 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" }, "devDependencies": { - "eslint": "^8.4.0", + "eslint": "^8.4.1", "eslint-plugin-react": "^7.27.1", "pico-check": "^2.1.3" } From da4dc9eb7e383963463da85e32ffad053ef744d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Dec 2021 03:01:19 +0000 Subject: [PATCH 46/54] Bump mongoose from 6.0.14 to 6.0.15 Bumps [mongoose](https://github.com/Automattic/mongoose) from 6.0.14 to 6.0.15. - [Release notes](https://github.com/Automattic/mongoose/releases) - [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md) - [Commits](https://github.com/Automattic/mongoose/compare/6.0.14...6.0.15) --- updated-dependencies: - dependency-name: mongoose dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 65b2524e2..cc338d2a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "marked": "3.0.8", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.29.1", - "mongoose": "^6.0.14", + "mongoose": "^6.0.15", "nanoid": "3.1.30", "nconf": "^0.11.3", "prop-types": "15.7.2", @@ -6421,9 +6421,9 @@ } }, "node_modules/mongoose": { - "version": "6.0.14", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.14.tgz", - "integrity": "sha512-SZ0kBlHrz/G70yWdVXLfM/gH4NsY85+as4MZRdtWxBTDEcmoE3rCFAz1/Ho2ycg5mJAeOBwdGZw4a5sn/WrwUA==", + "version": "6.0.15", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.15.tgz", + "integrity": "sha512-Lr53MKrJ4XNTdsMkhOYxeBJClsV7pgwr2VFf7E8TK9Xh5hs2kzFF49jJv9i4CWcshmydcF8uDfaQ9sQlqzZoYw==", "dependencies": { "bson": "^4.2.2", "kareem": "2.3.2", @@ -14430,9 +14430,9 @@ } }, "mongoose": { - "version": "6.0.14", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.14.tgz", - "integrity": "sha512-SZ0kBlHrz/G70yWdVXLfM/gH4NsY85+as4MZRdtWxBTDEcmoE3rCFAz1/Ho2ycg5mJAeOBwdGZw4a5sn/WrwUA==", + "version": "6.0.15", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.0.15.tgz", + "integrity": "sha512-Lr53MKrJ4XNTdsMkhOYxeBJClsV7pgwr2VFf7E8TK9Xh5hs2kzFF49jJv9i4CWcshmydcF8uDfaQ9sQlqzZoYw==", "requires": { "bson": "^4.2.2", "kareem": "2.3.2", diff --git a/package.json b/package.json index 75aca3d11..ad48e24be 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "marked": "3.0.8", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.29.1", - "mongoose": "^6.0.14", + "mongoose": "^6.0.15", "nanoid": "3.1.30", "nconf": "^0.11.3", "prop-types": "15.7.2", From b6e29c8a61bc77be945745ecc6dc6096f29678d2 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 22:30:58 -0500 Subject: [PATCH 47/54] Change to callback style --- client/homebrew/editor/editor.jsx | 106 +++++++++++++++--------------- 1 file changed, 52 insertions(+), 54 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index ae2c3aa1d..b9e090c39 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -107,71 +107,69 @@ const Editor = createClass({ if(this.state.view === 'text') { const codeMirror = this.refs.codeEditor.codeMirror; - codeMirror.startOperation(); + codeMirror.operation(() => { // Batch CodeMirror styling + //reset custom text styles + const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding + for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear(); - //reset custom text styles - const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding - for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear(); + let editorPageCount = 2; // start page count from page 2 - let editorPageCount = 2; // start page count from page 2 + _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ - _.forEach(this.props.brew.text.split('\n'), (line, lineNumber)=>{ + //reset custom line styles + codeMirror.removeLineClass(lineNumber, 'background'); + codeMirror.removeLineClass(lineNumber, 'text'); - //reset custom line styles - codeMirror.removeLineClass(lineNumber, 'background'); - codeMirror.removeLineClass(lineNumber, 'text'); + // Styling for \page breaks + if((this.props.renderer == 'legacy' && line.includes('\\page')) || + (this.props.renderer == 'V3' && line.match(/^\\page$/))) { - // Styling for \page breaks - if((this.props.renderer == 'legacy' && line.includes('\\page')) || - (this.props.renderer == 'V3' && line.match(/^\\page$/))) { + // add back the original class 'background' but also add the new class '.pageline' + codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); + const pageCountElement = Object.assign(document.createElement('span'), { + className : 'editor-page-count', + textContent : editorPageCount + }); + codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); - // add back the original class 'background' but also add the new class '.pageline' - codeMirror.addLineClass(lineNumber, 'background', 'pageLine'); - const pageCountElement = Object.assign(document.createElement('span'), { - className : 'editor-page-count', - textContent : editorPageCount - }); - codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement); + editorPageCount += 1; + }; - editorPageCount += 1; - }; - - // New Codemirror styling for V3 renderer - if(this.props.renderer == 'V3') { - if(line.match(/^\\column$/)){ - codeMirror.addLineClass(lineNumber, 'text', 'columnSplit'); - } - - // Highlight inline spans {{content}} - if(line.includes('{{') && line.includes('}}')){ - const regex = /{{(?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])*\s*|}}/g; - let match; - let blockCount = 0; - while ((match = regex.exec(line)) != null) { - if(match[0].startsWith('{')) { - blockCount += 1; - } else { - blockCount -= 1; - } - if(blockCount < 0) { - blockCount = 0; - continue; - } - codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'inline-block' }); + // New Codemirror styling for V3 renderer + if(this.props.renderer == 'V3') { + if(line.match(/^\\column$/)){ + codeMirror.addLineClass(lineNumber, 'text', 'columnSplit'); } - } else if(line.trimLeft().startsWith('{{') || line.trimLeft().startsWith('}}')){ - // Highlight block divs {{\n Content \n}} - let endCh = line.length+1; - const match = line.match(/^ *{{(?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])* *$|^ *}}$/); - if(match) - endCh = match.index+match[0].length; - codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' }); + // Highlight inline spans {{content}} + if(line.includes('{{') && line.includes('}}')){ + const regex = /{{(?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])*\s*|}}/g; + let match; + let blockCount = 0; + while ((match = regex.exec(line)) != null) { + if(match[0].startsWith('{')) { + blockCount += 1; + } else { + blockCount -= 1; + } + if(blockCount < 0) { + blockCount = 0; + continue; + } + codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'inline-block' }); + } + } else if(line.trimLeft().startsWith('{{') || line.trimLeft().startsWith('}}')){ + // Highlight block divs {{\n Content \n}} + let endCh = line.length+1; + + const match = line.match(/^ *{{(?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])* *$|^ *}}$/); + if(match) + endCh = match.index+match[0].length; + codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' }); + } } - } + }); }); - - codeMirror.endOperation(); } }, From 1bbacc974ba68adc13d67893ffa9db95027ae42d Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 22:31:25 -0500 Subject: [PATCH 48/54] lint --- client/homebrew/editor/editor.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index b9e090c39..6f9ce517f 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -107,7 +107,7 @@ const Editor = createClass({ if(this.state.view === 'text') { const codeMirror = this.refs.codeEditor.codeMirror; - codeMirror.operation(() => { // Batch CodeMirror styling + codeMirror.operation(()=>{ // Batch CodeMirror styling //reset custom text styles const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear(); From 53ad7ecd57ace99dfc13d4d2a670f81b0f0a5daa Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 22:37:55 -0500 Subject: [PATCH 49/54] Update editPage.jsx --- client/homebrew/pages/editPage/editPage.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index fff13a945..651847996 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -354,9 +354,9 @@ const EditPage = createClass({ Oops!
Looks like your Google credentials have - expired! Visit the log in page to sign out - and sign back in with Google - to save this to Google Drive! + expired! Visit our log in page to sign out + and sign back in with Google, + then try saving again!
From d8b7e299fdf49bb190af6c6d0232c91f06d961f5 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 22:39:12 -0500 Subject: [PATCH 50/54] Update newPage.jsx --- client/homebrew/pages/newPage/newPage.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 380ffefea..bcb29477b 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -231,9 +231,9 @@ const NewPage = createClass({ Oops!
Looks like your Google credentials have - expired! Visit the log in page to sign out - and sign back in with Google - to save this to Google Drive! + expired! Visit our log in page to sign out + and sign back in with Google, + then try saving again!
From 634a98c2cb049a9edc4454903024b6869a9ef1e4 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 22:39:48 -0500 Subject: [PATCH 51/54] Update newPage.jsx --- client/homebrew/pages/newPage/newPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index bcb29477b..0eb18a91b 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -237,7 +237,7 @@ const NewPage = createClass({
- Go to Log In Page + Sign In
From fe9998c6e47a3a659583a78c18de046837f44d17 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 22:40:42 -0500 Subject: [PATCH 52/54] Update editPage.jsx --- client/homebrew/pages/editPage/editPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 651847996..1adccbd8b 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -360,7 +360,7 @@ const EditPage = createClass({
- Go to Log In Page + Sign In
From 0a335cefbf2f5690c519ccb13d06a9ae02c1fc58 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 6 Dec 2021 22:41:11 -0500 Subject: [PATCH 53/54] Update newPage.jsx --- client/homebrew/pages/newPage/newPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 0eb18a91b..73f29853b 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -237,7 +237,7 @@ const NewPage = createClass({
- Sign In + Sign In
From 12cb457c60260435fe991fe1ab4e07a608d9ed72 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 7 Dec 2021 23:01:42 -0500 Subject: [PATCH 54/54] Up to Version 3.0.5 --- changelog.md | 33 +++++++++++++++++++++++++++++++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 1b22c7d8d..b44eae35e 100644 --- a/changelog.md +++ b/changelog.md @@ -3,11 +3,12 @@ h5 { font-size: .35cm !important; } -.taskList li { - list-style-type : none; +.page ul ul { + margin-left: 0px; } .taskList li input { + list-style-type : none; margin-left : -0.52cm; transform: translateY(.05cm); filter: brightness(1.1) drop-shadow(1px 2px 1px #222); @@ -33,6 +34,34 @@ pre { ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). +### Tuesday 07/12/2021 - v3.0.5 +{{taskList +* [x] Fixed paragraph spacing for **note** and **descriptive** boxes in V3. + + Fixes issues: [#1836](https://github.com/naturalcrit/homebrewery/issues/1836) + +* [x] Added a whole bunch of hotkeys: + + * Page Break `CTRL + ENTER` + * Column Break `CTRL + SHIFT + ENTER` + * Bulleted Lists `CTRL + L` + * Numbered Lists `CTRL + SHIFT + L` + * Headers `CTRL + SHIFT + (1-6)` + * Underline `CTRL + U` + * Link `CTRL + K` + * Non-breaking space (\ ) `CTRL + .` + * Add Horizontal Space `CTRL + SHIFT + .` + * Remove Horizontal Space `CTRL + SHIFT + ,` + * Curly Span `CTRL + M` + * Curly Div `CTRL + SHIFT + M` + +* [x] Fixed page numbers in the editor panel getting scrambled when scrolling up and down. + +* [x] Faster swapping between tabs on long brews. + +* [x] Better error messages for common issue with Google Drive credentials expiring. +}} + ### Wednesday 17/11/2021 - v3.0.4 {{taskList * [x] Fixed incorrect sorting of Google brews by page count and views on the user page. diff --git a/package-lock.json b/package-lock.json index 9536b9c4a..37a7b8347 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebrewery", - "version": "3.0.4", + "version": "3.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "homebrewery", - "version": "3.0.4", + "version": "3.0.5", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 6efdab95f..ac4494b8a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebrewery", "description": "Create authentic looking D&D homebrews using only markdown", - "version": "3.0.4", + "version": "3.0.5", "engines": { "node": "16.11.x" },