From cde611eed5bebe778717d6cd6dbadf826d76ac3f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 11:50:04 +1200 Subject: [PATCH 01/44] Add ID to iFrame --- client/homebrew/brewRenderer/brewRenderer.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 2da7123cc..787423528 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -188,7 +188,7 @@ const BrewRenderer = createClass({ : null} -
Date: Tue, 3 May 2022 13:36:03 +1200 Subject: [PATCH 02/44] Add brewJump and sourceJump functions --- client/homebrew/editor/editor.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index fce116fcc..04251bd91 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -174,9 +174,16 @@ const Editor = createClass({ } }, - brewJump : function(){ - const currentPage = this.getCurrentPage(); - window.location.hash = `p${currentPage}`; + brewJump : function(page=this.getCurrentPage()){ + if(!document) return; + window.frames['BrewRenderer'].contentDocument.getElementById(`p${page}`).scrollIntoView({ behaviour: 'auto', block: 'start' }); + // const hashPage = (page != 1) ? `p${page}` : ''; + // window.location.hash = hashPage; + }, + + sourceJump : function(line=1){ + if(!this.isText || !this.isStyle) return; + this.refs.codeEditor.setCursorPosition(line, 1); }, //Called when there are changes to the editor's dimensions @@ -250,6 +257,8 @@ const Editor = createClass({ renderer={this.props.renderer} undo={this.undo} redo={this.redo} + brewJump={this.brewJump} + sourceJump={this.sourceJump} historySize={this.historySize()} /> {this.renderEditor()} From 010309b04f948e4ba4ff0d9ae5e159307cdf24d1 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 13:36:27 +1200 Subject: [PATCH 03/44] Add `toTop` button to SnippetBar --- client/homebrew/editor/snippetbar/snippetbar.jsx | 9 +++++++++ client/homebrew/editor/snippetbar/snippetbar.less | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index 0c6b5cc38..2be9e4775 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -60,10 +60,19 @@ const Snippetbar = createClass({ }); }, + toTop : function(){ + this.props.brewJump(1); + this.props.sourceJump(1); + }, + renderEditorButtons : function(){ if(!this.props.showEditButtons) return; return
+
+ +
diff --git a/client/homebrew/editor/snippetbar/snippetbar.less b/client/homebrew/editor/snippetbar/snippetbar.less index 371f51fda..fe374f594 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.less +++ b/client/homebrew/editor/snippetbar/snippetbar.less @@ -46,6 +46,14 @@ color : black; } } + &.toTop{ + .tooltipLeft('Back to Top'); + font-size : 0.75em; + color : grey; + &.active{ + color : black; + } + } &.divider { background: linear-gradient(#000, #000) no-repeat center/1px 100%; width: 5px; From f202e45e49f0f3a92bc6157a4dcff05e01c88725 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 13:48:19 +1200 Subject: [PATCH 04/44] Shift to `[].includes` --- client/homebrew/editor/snippetbar/snippetbar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index 2be9e4775..f16ebbbb4 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -69,7 +69,7 @@ const Snippetbar = createClass({ if(!this.props.showEditButtons) return; return
-
From 451f06ca7408deccaebeeb4decfbe5888b8806a9 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 17:24:37 +1200 Subject: [PATCH 05/44] Fix `getCurrentPage` --- client/homebrew/editor/editor.jsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 04251bd91..c8d3339f4 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -96,7 +96,7 @@ const Editor = createClass({ }, getCurrentPage : function(){ - const lines = this.props.brew.text.split('\n').slice(0, this.cursorPosition.line + 1); + const lines = this.props.brew.text.split('\n').slice(0, this.refs.codeEditor.getCursorPosition().line + 1); return _.reduce(lines, (r, line)=>{ if(line.indexOf('\\page') !== -1) r++; return r; @@ -174,16 +174,17 @@ const Editor = createClass({ } }, - brewJump : function(page=this.getCurrentPage()){ - if(!document) return; - window.frames['BrewRenderer'].contentDocument.getElementById(`p${page}`).scrollIntoView({ behaviour: 'auto', block: 'start' }); + brewJump : function(targetPage=this.getCurrentPage()){ + if(!window || this.isMeta()) return; + window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behaviour: 'auto', block: 'start' }); // const hashPage = (page != 1) ? `p${page}` : ''; // window.location.hash = hashPage; }, - sourceJump : function(line=1){ - if(!this.isText || !this.isStyle) return; - this.refs.codeEditor.setCursorPosition(line, 1); + sourceJump : function(targetLine=1){ + if(this.isText() || this.isStyle()) { + this.refs.codeEditor.setCursorPosition(targetLine, 0); + } }, //Called when there are changes to the editor's dimensions From a56601196dfd121b237e33bf1654f578e2077d00 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 17:24:58 +1200 Subject: [PATCH 06/44] Add divider buttons --- shared/naturalcrit/splitPane/splitPane.jsx | 24 +++++++++++++++------ shared/naturalcrit/splitPane/splitPane.less | 23 +++++++++++++++++++- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index 4d138e30b..691cf058f 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -85,13 +85,25 @@ const SplitPane = createClass({ }, */ renderDivider : function(){ - return
-
- - - + return <> +
console.log('left')} > +
-
; +
console.log('right')} > + +
+
+
+ + + +
+
+ ; }, render : function(){ diff --git a/shared/naturalcrit/splitPane/splitPane.less b/shared/naturalcrit/splitPane/splitPane.less index 0e9095193..7e3f819aa 100644 --- a/shared/naturalcrit/splitPane/splitPane.less +++ b/shared/naturalcrit/splitPane/splitPane.less @@ -13,7 +13,7 @@ .divider{ display : table; height : 100%; - width : 12px; + width : 15px; cursor : ew-resize; background-color : #bbb; text-align : center; @@ -32,4 +32,25 @@ background-color: #999; } } + .arrow{ + position : absolute; + width : 25px; + height : 25px; + border : 2px solid black; + border-radius : 15px; + text-align : center; + font-size : 1.2em; + cursor : pointer; + background-color : #bbb; + z-index : 999; + &.left{ + top : 30px; + } + &.right{ + top : 60px; + } + &:hover{ + background-color: #666; + } + } } From 7034f1d2d53e3d2cdfc527d71f5fab333cd2c079 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 22:32:30 +1200 Subject: [PATCH 07/44] Add sourceJump function --- client/homebrew/editor/editor.jsx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index c8d3339f4..ab264437b 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -181,8 +181,30 @@ const Editor = createClass({ // window.location.hash = hashPage; }, - sourceJump : function(targetLine=1){ + sourceJump : function(targetLine=null){ if(this.isText() || this.isStyle()) { + if(targetLine == null) { + const brewPosition = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).scrollTop; + const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page'); + + let currentPage = 0; + let currentPagePosition = 0; + while (currentPagePosition < brewPosition && currentPage < pageCollection.length) { + currentPagePosition = currentPagePosition + pageCollection[currentPage].scrollHeight; + currentPage++; + }; + + const textArray = this.props.brew.text.split('\n'); + let lineCount = 0; + let linePosition = 0; + while (linePosition < currentPage-1 && lineCount < textArray.length) { + // console.log(`${lineCount}: ${textArray[lineCount].toString()}`); + if(textArray[lineCount].toString().includes('\\page')) { linePosition++; } + lineCount++; + } + targetLine = lineCount; + } + // Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length); this.refs.codeEditor.setCursorPosition(targetLine, 0); } }, From af3a403971b343f5e9cbccbf97c38754d9476b3d Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 3 May 2022 22:33:05 +1200 Subject: [PATCH 08/44] Add moveBrew and moveSource function calls --- .../homebrew/editor/snippetbar/snippetbar.jsx | 18 +++++++++++++++++- .../homebrew/editor/snippetbar/snippetbar.less | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index f16ebbbb4..849a9c642 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -61,18 +61,34 @@ const Snippetbar = createClass({ }, toTop : function(){ + this.props.sourceJump(0); this.props.brewJump(1); - this.props.sourceJump(1); + }, + + moveBrew : function(){ + this.props.brewJump(); + }, + + moveSource : function(){ + this.props.sourceJump(); }, renderEditorButtons : function(){ if(!this.props.showEditButtons) return; return
+
+ +
+
+ +
diff --git a/client/homebrew/editor/snippetbar/snippetbar.less b/client/homebrew/editor/snippetbar/snippetbar.less index fe374f594..923568e28 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.less +++ b/client/homebrew/editor/snippetbar/snippetbar.less @@ -10,7 +10,7 @@ top : 0px; right : 0px; height : @menuHeight; - width : 125px; + width : 175px; justify-content : space-between; &>div{ height : @menuHeight; @@ -54,6 +54,22 @@ color : black; } } + &.toBrew{ + .tooltipLeft('Match Brew to Source'); + font-size : 0.75em; + color : grey; + &.active{ + color : black; + } + } + &.fromBrew{ + .tooltipLeft('Match Source to Brew'); + font-size : 0.75em; + color : grey; + &.active{ + color : black; + } + } &.divider { background: linear-gradient(#000, #000) no-repeat center/1px 100%; width: 5px; From e84f68aa150fa42bc2a6f876652da9058f236de0 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 4 May 2022 07:54:15 +1200 Subject: [PATCH 09/44] Minor styling adjustments --- shared/naturalcrit/splitPane/splitPane.less | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/splitPane/splitPane.less b/shared/naturalcrit/splitPane/splitPane.less index 7e3f819aa..5c15db5df 100644 --- a/shared/naturalcrit/splitPane/splitPane.less +++ b/shared/naturalcrit/splitPane/splitPane.less @@ -41,8 +41,9 @@ text-align : center; font-size : 1.2em; cursor : pointer; - background-color : #bbb; + background-color : #ddd; z-index : 999; + box-shadow : 0 4px 5px #0000007f; &.left{ top : 30px; } From 3d9704a392f1bdeb6cdcec83f9fbd5661056a5ac Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 9 May 2022 19:47:04 +1200 Subject: [PATCH 10/44] Fix typo 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 ab264437b..462122670 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -176,7 +176,7 @@ const Editor = createClass({ brewJump : function(targetPage=this.getCurrentPage()){ if(!window || this.isMeta()) return; - window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behaviour: 'auto', block: 'start' }); + window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behavior: 'auto', block: 'start' }); // const hashPage = (page != 1) ? `p${page}` : ''; // window.location.hash = hashPage; }, From 3c36b7f32816411aeffae507158cde72c7d002e9 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 9 May 2022 20:23:39 +1200 Subject: [PATCH 11/44] Limit Style tab source jumping --- 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 462122670..968a967de 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -182,7 +182,7 @@ const Editor = createClass({ }, sourceJump : function(targetLine=null){ - if(this.isText() || this.isStyle()) { + if(this.isText() || (this.isStyle() && targetLine == 0)) { if(targetLine == null) { const brewPosition = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).scrollTop; const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page'); From be0b1abe41e6d410a90a06ff269f4abd4f797f0c Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 9 May 2022 20:57:43 +1200 Subject: [PATCH 12/44] Adjust \page check for renderer --- client/homebrew/editor/editor.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 968a967de..826ea6da3 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -98,7 +98,11 @@ const Editor = createClass({ getCurrentPage : function(){ const lines = this.props.brew.text.split('\n').slice(0, this.refs.codeEditor.getCursorPosition().line + 1); return _.reduce(lines, (r, line)=>{ - if(line.indexOf('\\page') !== -1) r++; + if( + (this.props.renderer == 'legacy' && line.indexOf('\\page') !== -1) + || + (this.props.renderer == 'V3' && line.match(/^\\page$/)) + ) r++; return r; }, 1); }, From b26ff9eb00f9442eb4a2ff1ab0547db78513400d Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 9 May 2022 22:20:35 +1200 Subject: [PATCH 13/44] Shift to getBoundingClientRect().height --- 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 826ea6da3..a6ceb5094 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -194,7 +194,7 @@ const Editor = createClass({ let currentPage = 0; let currentPagePosition = 0; while (currentPagePosition < brewPosition && currentPage < pageCollection.length) { - currentPagePosition = currentPagePosition + pageCollection[currentPage].scrollHeight; + currentPagePosition = currentPagePosition + pageCollection[currentPage].getBoundingClientRect().height; currentPage++; }; From 02c8bf72921e3496bce8320fc7edcb15f934c32e Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 9 May 2022 22:21:00 +1200 Subject: [PATCH 14/44] Change to smooth scrolling from auto --- 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 a6ceb5094..cdfa96f31 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -180,7 +180,7 @@ const Editor = createClass({ brewJump : function(targetPage=this.getCurrentPage()){ if(!window || this.isMeta()) return; - window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behavior: 'auto', block: 'start' }); + window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behavior: 'smooth', block: 'start' }); // const hashPage = (page != 1) ? `p${page}` : ''; // window.location.hash = hashPage; }, From 7c0e702ead3c328596487cade33e7f3b05cedd4e Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 9 May 2022 23:20:16 +1200 Subject: [PATCH 15/44] Remove a loop from sourceJump --- client/homebrew/editor/editor.jsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index cdfa96f31..9ecacb48f 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -180,6 +180,7 @@ const Editor = createClass({ brewJump : function(targetPage=this.getCurrentPage()){ if(!window || this.isMeta()) return; + // console.log(`Scroll to: p${targetPage}`); window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behavior: 'smooth', block: 'start' }); // const hashPage = (page != 1) ? `p${page}` : ''; // window.location.hash = hashPage; @@ -198,15 +199,15 @@ const Editor = createClass({ currentPage++; }; - const textArray = this.props.brew.text.split('\n'); - let lineCount = 0; - let linePosition = 0; - while (linePosition < currentPage-1 && lineCount < textArray.length) { - // console.log(`${lineCount}: ${textArray[lineCount].toString()}`); - if(textArray[lineCount].toString().includes('\\page')) { linePosition++; } - lineCount++; + targetLine = 0; + + if(currentPage > 1){ + const textString = this.props.brew.text.split('\\page').slice(0, currentPage-1).join('\\page'); + const textPosition = textString.length; + const lineCount = textString.slice(0, textPosition).split('\n').length; + + targetLine = lineCount; } - targetLine = lineCount; } // Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length); this.refs.codeEditor.setCursorPosition(targetLine, 0); From 412ac5f331a5c5a1841d2266765ff89015f7f0ac Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 9 May 2022 23:39:04 +1200 Subject: [PATCH 16/44] Change to getBoundingClientRect().bottom --- 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 9ecacb48f..d557d40b4 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -195,7 +195,7 @@ const Editor = createClass({ let currentPage = 0; let currentPagePosition = 0; while (currentPagePosition < brewPosition && currentPage < pageCollection.length) { - currentPagePosition = currentPagePosition + pageCollection[currentPage].getBoundingClientRect().height; + currentPagePosition = currentPagePosition + pageCollection[currentPage].getBoundingClientRect().bottom; currentPage++; }; From 9f7ee39b0961143e443ef126a4ad0d1685ae2155 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 11 May 2022 10:46:49 +1200 Subject: [PATCH 17/44] Use BoundingRect.bottom to determine page --- client/homebrew/editor/editor.jsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index d557d40b4..d15714bae 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -189,18 +189,20 @@ const Editor = createClass({ sourceJump : function(targetLine=null){ if(this.isText() || (this.isStyle() && targetLine == 0)) { if(targetLine == null) { - const brewPosition = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).scrollTop; - const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page'); - - let currentPage = 0; - let currentPagePosition = 0; - while (currentPagePosition < brewPosition && currentPage < pageCollection.length) { - currentPagePosition = currentPagePosition + pageCollection[currentPage].getBoundingClientRect().bottom; - currentPage++; - }; - targetLine = 0; + const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page'); + const brewRendererHeight = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).getBoundingClientRect().height; + + let currentPage = 1; + for (const page of pageCollection) { + if(page.getBoundingClientRect().bottom > (brewRendererHeight / 2)) { + const pageId = page.id; + currentPage = parseInt(pageId.slice(1, pageId.length)) || 1; + break; + } + } + if(currentPage > 1){ const textString = this.props.brew.text.split('\\page').slice(0, currentPage-1).join('\\page'); const textPosition = textString.length; From 80fa48e5927f436c906e2562de8a3a6142be0d07 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 11 May 2022 15:48:03 +1200 Subject: [PATCH 18/44] Remove redundant variable Co-authored-by: Trevor Buckner --- client/homebrew/editor/editor.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index d15714bae..73c4d3a21 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -197,8 +197,7 @@ const Editor = createClass({ let currentPage = 1; for (const page of pageCollection) { if(page.getBoundingClientRect().bottom > (brewRendererHeight / 2)) { - const pageId = page.id; - currentPage = parseInt(pageId.slice(1, pageId.length)) || 1; + currentPage = parseInt(page.id.slice(1)) || 1; break; } } From 160cfcce4dd830235b9437aee117c9cf120daab7 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 13:48:36 +1200 Subject: [PATCH 19/44] Change for line consistency when moving to page 1 --- client/homebrew/editor/editor.jsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 73c4d3a21..3caf229fc 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -202,15 +202,14 @@ const Editor = createClass({ } } - if(currentPage > 1){ - const textString = this.props.brew.text.split('\\page').slice(0, currentPage-1).join('\\page'); - const textPosition = textString.length; - const lineCount = textString.slice(0, textPosition).split('\n').length; + const textSplit = this.props.renderer == 'V3' ? '\n\\page\n' : '\\page'; + const textString = this.props.brew.text.split(textSplit).slice(0, currentPage-1).join(textSplit); + const textPosition = textString.length; + const lineCount = textString.match('\n') ? textString.slice(0, textPosition).split('\n').length : 0; - targetLine = lineCount; - } + targetLine = lineCount; } - // Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length); + this.refs.codeEditor.setCursorPosition(targetLine, 0); } }, From db5e4fc36cdb9cdecadef5f4d65f8223c06f2547 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 13:49:08 +1200 Subject: [PATCH 20/44] Fix button position with default divider position --- shared/naturalcrit/splitPane/splitPane.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index 691cf058f..bc7e73905 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -29,6 +29,10 @@ const SplitPane = createClass({ userSetDividerPos : dividerPos, windowWidth : window.innerWidth }); + } else { + this.setState({ + currentDividerPos : window.innerWidth / 2 + }); } window.addEventListener('resize', this.handleWindowResize); }, @@ -83,7 +87,8 @@ const SplitPane = createClass({ window.getSelection().removeAllRanges(); } }, -*/ + */ + renderDivider : function(){ return <>
Date: Sun, 29 May 2022 15:18:35 +1200 Subject: [PATCH 21/44] Initial pass at split pane button functionality --- client/homebrew/editor/editor.jsx | 8 +++++++- shared/naturalcrit/splitPane/splitPane.jsx | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 3caf229fc..a40c656c7 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -61,8 +61,14 @@ const Editor = createClass({ window.removeEventListener('resize', this.updateEditorSize); }, - componentDidUpdate : function() { + componentDidUpdate : function(prevProps, prevState, snapshot) { this.highlightCustomMarkdown(); + if(prevProps.moveBrew !== this.props.moveBrew) { + this.brewJump(); + }; + if(prevProps.moveSource !== this.props.moveSource) { + this.sourceJump(); + }; }, updateEditorSize : function() { diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index bc7e73905..c19ffe3ac 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -17,7 +17,9 @@ const SplitPane = createClass({ return { currentDividerPos : null, windowWidth : 0, - isDragging : false + isDragging : false, + moveSource : false, + moveBrew : false }; }, @@ -93,12 +95,12 @@ const SplitPane = createClass({ return <>
console.log('left')} > + onClick={()=>this.setState({ moveSource: !this.state.moveSource })} >
console.log('right')} > + onClick={()=>this.setState({ moveBrew: !this.state.moveBrew })} >
@@ -113,7 +115,15 @@ const SplitPane = createClass({ render : function(){ return
- {this.props.children[0]} + + {React.cloneElement(this.props.children[0], { + moveBrew : this.state.moveBrew, + moveSource : this.state.moveSource + })} + {this.renderDivider()} {this.props.children[1]}
; From 4e5daf583a17e63e7805796f55cc21613a402e63 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 15:24:02 +1200 Subject: [PATCH 22/44] Remove from snippet bar --- client/homebrew/editor/editor.jsx | 2 -- .../homebrew/editor/snippetbar/snippetbar.jsx | 20 ------------------- .../editor/snippetbar/snippetbar.less | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index a40c656c7..42fd6c970 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -291,8 +291,6 @@ const Editor = createClass({ renderer={this.props.renderer} undo={this.undo} redo={this.redo} - brewJump={this.brewJump} - sourceJump={this.sourceJump} historySize={this.historySize()} /> {this.renderEditor()} diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index 849a9c642..28a55ec20 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -65,30 +65,10 @@ const Snippetbar = createClass({ this.props.brewJump(1); }, - moveBrew : function(){ - this.props.brewJump(); - }, - - moveSource : function(){ - this.props.sourceJump(); - }, - renderEditorButtons : function(){ if(!this.props.showEditButtons) return; return
-
- -
-
- -
-
- -
diff --git a/client/homebrew/editor/snippetbar/snippetbar.less b/client/homebrew/editor/snippetbar/snippetbar.less index 923568e28..7703c6ab7 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.less +++ b/client/homebrew/editor/snippetbar/snippetbar.less @@ -10,7 +10,7 @@ top : 0px; right : 0px; height : @menuHeight; - width : 175px; + width : 125px; justify-content : space-between; &>div{ height : @menuHeight; From 03bcbee1fce2ff4ec24f0915c769032c295d622e Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 15:27:02 +1200 Subject: [PATCH 23/44] Apply suggested regex 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 42fd6c970..8296478dd 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -208,7 +208,7 @@ const Editor = createClass({ } } - const textSplit = this.props.renderer == 'V3' ? '\n\\page\n' : '\\page'; + const textSplit = this.props.renderer == 'V3' ? `/^\\page$/gm` : '\\page'; const textString = this.props.brew.text.split(textSplit).slice(0, currentPage-1).join(textSplit); const textPosition = textString.length; const lineCount = textString.match('\n') ? textString.slice(0, textPosition).split('\n').length : 0; From 7b2486e4113015335e1b5419e863bf33d1983806 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 15:31:57 +1200 Subject: [PATCH 24/44] Use RegEx for text.split --- 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 8296478dd..8ddf4d6b8 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -208,7 +208,7 @@ const Editor = createClass({ } } - const textSplit = this.props.renderer == 'V3' ? `/^\\page$/gm` : '\\page'; + const textSplit = this.props.renderer == 'V3' ? /^\\page$/gm : /\\page/; const textString = this.props.brew.text.split(textSplit).slice(0, currentPage-1).join(textSplit); const textPosition = textString.length; const lineCount = textString.match('\n') ? textString.slice(0, textPosition).split('\n').length : 0; From 08db2e84920b6aca8f0a19c8562aa7618e949566 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 15:49:37 +1200 Subject: [PATCH 25/44] Hide divider arrows when not required --- client/homebrew/editor/editor.jsx | 3 ++ shared/naturalcrit/splitPane/splitPane.jsx | 44 +++++++++++++++------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 8ddf4d6b8..cab7eea12 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -232,6 +232,7 @@ const Editor = createClass({ renderEditor : function(){ if(this.isText()){ + this.props.setMoveArrows(true); return <> ; } if(this.isStyle()){ + this.props.setMoveArrows(false); return <> ; } if(this.isMeta()){ + this.props.setMoveArrows(false); return <> +
this.setState({ moveSource: !this.state.moveSource })} > + +
+
this.setState({ moveBrew: !this.state.moveBrew })} > + +
+ ; + } + }, + renderDivider : function(){ return <> -
this.setState({ moveSource: !this.state.moveSource })} > - -
-
this.setState({ moveBrew: !this.state.moveBrew })} > - -
+ {this.renderMoveArrows()}
@@ -120,8 +137,9 @@ const SplitPane = createClass({ width={this.state.currentDividerPos} > {React.cloneElement(this.props.children[0], { - moveBrew : this.state.moveBrew, - moveSource : this.state.moveSource + moveBrew : this.state.moveBrew, + moveSource : this.state.moveSource, + setMoveArrows : this.setMoveArrows })} {this.renderDivider()} From 4cc3dd93e2b3d8ab7de96d24728c05de3d3b9a8e Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 16:16:48 +1200 Subject: [PATCH 26/44] Move state change to `handleViewChange` --- client/homebrew/editor/editor.jsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index cab7eea12..1304df5db 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -96,6 +96,7 @@ const Editor = createClass({ }, handleViewChange : function(newView){ + this.props.setMoveArrows(newView === 'text'); this.setState({ view : newView }, this.updateEditorSize); //TODO: not sure if updateeditorsize needed @@ -232,7 +233,6 @@ const Editor = createClass({ renderEditor : function(){ if(this.isText()){ - this.props.setMoveArrows(true); return <> ; } if(this.isStyle()){ - this.props.setMoveArrows(false); return <> ; } if(this.isMeta()){ - this.props.setMoveArrows(false); return <> Date: Sun, 29 May 2022 16:19:58 +1200 Subject: [PATCH 27/44] Fall back to current divider position on resizing --- shared/naturalcrit/splitPane/splitPane.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index 5dc8d6e31..d6acedc6f 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -47,7 +47,7 @@ const SplitPane = createClass({ handleWindowResize : function() { // Allow divider to increase in size to last user-set position // Limit current position to between 10% and 90% of visible space - const newLoc = this.limitPosition(this.state.userSetDividerPos, 0.1*(window.innerWidth-13), 0.9*(window.innerWidth-13)); + const newLoc = this.limitPosition(this.state.userSetDividerPos || this.state.currentDividerPos, 0.1*(window.innerWidth-13), 0.9*(window.innerWidth-13)); this.setState({ currentDividerPos : newLoc, From bb1fba27c2e9503e316c1cdb77a9e97b762b4b7c Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 29 May 2022 16:26:30 +1200 Subject: [PATCH 28/44] Set a default userSetDividerPos --- shared/naturalcrit/splitPane/splitPane.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index d6acedc6f..f7ad4bed4 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -34,7 +34,8 @@ const SplitPane = createClass({ }); } else { this.setState({ - currentDividerPos : window.innerWidth / 2 + currentDividerPos : window.innerWidth / 2, + userSetDividerPos : window.innerWidth / 2 }); } window.addEventListener('resize', this.handleWindowResize); @@ -47,7 +48,7 @@ const SplitPane = createClass({ handleWindowResize : function() { // Allow divider to increase in size to last user-set position // Limit current position to between 10% and 90% of visible space - const newLoc = this.limitPosition(this.state.userSetDividerPos || this.state.currentDividerPos, 0.1*(window.innerWidth-13), 0.9*(window.innerWidth-13)); + const newLoc = this.limitPosition(this.state.userSetDividerPos, 0.1*(window.innerWidth-13), 0.9*(window.innerWidth-13)); this.setState({ currentDividerPos : newLoc, From 0c0d817cc272fdcab713036916157765fdf4fe21 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 2 Jun 2022 13:49:27 +1200 Subject: [PATCH 29/44] Add scrollPastEnd to CodeMirror --- 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 42076ed76..e09ea34a9 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -30,6 +30,8 @@ if(typeof navigator !== 'undefined'){ // require('codemirror/addon/edit/trailingspace.js'); //Active line highlighting // require('codemirror/addon/selection/active-line.js'); + //Scroll past last line + require('codemirror/addon/scroll/scrollpastend.js'); //Auto-closing //XML code folding is a requirement of the auto-closing tag feature and is not enabled require('codemirror/addon/fold/xml-fold.js'); @@ -98,7 +100,10 @@ const CodeEditor = createClass({ indentWithTabs : true, tabSize : 2, historyEventDelay : 250, + scrollPastEnd : true, extraKeys : { + // 'Alt-Left' : this.moveSource, + // 'Alt-Right' : this.moveBrew, 'Ctrl-B' : this.makeBold, 'Cmd-B' : this.makeBold, 'Ctrl-I' : this.makeItalic, From e9adc4de8225e9d13da9bff40ea307d0395173b7 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 2 Jun 2022 13:50:37 +1200 Subject: [PATCH 30/44] Highlight target line during moveSource --- client/homebrew/editor/editor.jsx | 7 ++++++- shared/naturalcrit/codeEditor/codeEditor.less | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 1304df5db..77c520431 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -19,6 +19,8 @@ const DEFAULT_STYLE_TEXT = dedent` color: black; }`; +const sourceMoveHighlightClass = 'sourceMoveFlash'; + const splice = function(str, index, inject){ return str.slice(0, index) + inject + str.slice(index); }; @@ -131,6 +133,7 @@ const Editor = createClass({ //reset custom line styles codeMirror.removeLineClass(lineNumber, 'background', 'pageLine'); codeMirror.removeLineClass(lineNumber, 'text'); + codeMirror.removeLineClass(lineNumber, 'wrap', sourceMoveHighlightClass); // Styling for \page breaks if((this.props.renderer == 'legacy' && line.includes('\\page')) || @@ -217,7 +220,9 @@ const Editor = createClass({ targetLine = lineCount; } - this.refs.codeEditor.setCursorPosition(targetLine, 0); + // this.refs.codeEditor.codeMirror.scrollIntoView({ line: targetLine, ch: 0 }, 30); + this.refs.codeEditor.setCursorPosition({ line: targetLine, ch: 0 }); + this.refs.codeEditor.codeMirror.addLineClass(targetLine, 'wrap', sourceMoveHighlightClass); } }, diff --git a/shared/naturalcrit/codeEditor/codeEditor.less b/shared/naturalcrit/codeEditor/codeEditor.less index bf36293ed..9f437e90b 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.less +++ b/shared/naturalcrit/codeEditor/codeEditor.less @@ -10,6 +10,11 @@ font-weight: 600; } + .flash .CodeMirror-line{ + background-color: #0000fc; + color: #ffffff; + } + //.cm-tab { // background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAQAAACOs/baAAAARUlEQVR4nGJgIAG8JkXxUAcCtDWemcGR1lY4MvgzCEKY7jSBjgxBDAG09UEQzAe0AMwMHrSOAwEGRtpaMIwAAAAA//8DAG4ID9EKs6YqAAAAAElFTkSuQmCC) no-repeat right; //} From 0dbe84a91a0f24992ccc2c890a0c6b19366441bb Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 2 Jun 2022 14:09:41 +1200 Subject: [PATCH 31/44] Update style --- shared/naturalcrit/codeEditor/codeEditor.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.less b/shared/naturalcrit/codeEditor/codeEditor.less index 9f437e90b..53be7e5f5 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.less +++ b/shared/naturalcrit/codeEditor/codeEditor.less @@ -10,7 +10,7 @@ font-weight: 600; } - .flash .CodeMirror-line{ + .sourceMoveFlash .CodeMirror-line{ background-color: #0000fc; color: #ffffff; } From bd681dffaed25c0af828efcabbe5a7288099ac85 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 2 Jun 2022 23:24:41 -0400 Subject: [PATCH 32/44] Fix scrollpastend not working Since the `require('codemirror/addon/scroll/scrollpastend.js');` line is inside of an `if()` block, it doesn't get compiled in the same way. We have to specify it in the `libs` array of our build script so our bundler can allow it to be loaded dynamically. --- scripts/project.json | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/project.json b/scripts/project.json index 07acdda48..5a0289ad0 100644 --- a/scripts/project.json +++ b/scripts/project.json @@ -15,6 +15,7 @@ "codemirror/addon/fold/foldcode.js", "codemirror/addon/fold/foldgutter.js", "codemirror/addon/fold/xml-fold.js", + "codemirror/addon/scroll/scrollpastend.js", "codemirror/addon/search/search.js", "codemirror/addon/search/searchcursor.js", "codemirror/addon/search/jump-to-line.js", From df41b584410d1368fa28f1bd1d65e233100b29ca Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 3 Jun 2022 13:32:04 -0400 Subject: [PATCH 33/44] Smooth scroll editor Panel, and flash target line --- client/homebrew/editor/editor.jsx | 31 ++++++++++++++----- shared/naturalcrit/codeEditor/codeEditor.less | 11 +++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 77c520431..77c655163 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -19,8 +19,6 @@ const DEFAULT_STYLE_TEXT = dedent` color: black; }`; -const sourceMoveHighlightClass = 'sourceMoveFlash'; - const splice = function(str, index, inject){ return str.slice(0, index) + inject + str.slice(index); }; @@ -133,7 +131,7 @@ const Editor = createClass({ //reset custom line styles codeMirror.removeLineClass(lineNumber, 'background', 'pageLine'); codeMirror.removeLineClass(lineNumber, 'text'); - codeMirror.removeLineClass(lineNumber, 'wrap', sourceMoveHighlightClass); + codeMirror.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash'); // Styling for \page breaks if((this.props.renderer == 'legacy' && line.includes('\\page')) || @@ -217,12 +215,29 @@ const Editor = createClass({ const textPosition = textString.length; const lineCount = textString.match('\n') ? textString.slice(0, textPosition).split('\n').length : 0; - targetLine = lineCount; - } + targetLine = lineCount - 1; //Scroll to `\page`, which is one line back. - // this.refs.codeEditor.codeMirror.scrollIntoView({ line: targetLine, ch: 0 }, 30); - this.refs.codeEditor.setCursorPosition({ line: targetLine, ch: 0 }); - this.refs.codeEditor.codeMirror.addLineClass(targetLine, 'wrap', sourceMoveHighlightClass); + let currentY = this.refs.codeEditor.codeMirror.getScrollInfo().top; + let targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true); + + //Scroll 1/10 of the way every 10ms until 1px off. + const incrementalScroll = setInterval(()=>{ + currentY += (targetY - currentY) / 10; + this.refs.codeEditor.codeMirror.scrollTo(null, currentY); + + // Update target: target height is not accurate until within +-10 lines of the visible window + if(Math.abs(targetY - currentY > 100)) + targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true); + + // End when close enough + if(Math.abs(targetY - currentY) < 1) { + this.refs.codeEditor.codeMirror.scrollTo(null, targetY); // Scroll any remaining difference + this.refs.codeEditor.setCursorPosition({ line: targetLine + 1, ch: 0 }); + this.refs.codeEditor.codeMirror.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash'); + clearInterval(incrementalScroll); + } + }, 10); + } } }, diff --git a/shared/naturalcrit/codeEditor/codeEditor.less b/shared/naturalcrit/codeEditor/codeEditor.less index 53be7e5f5..c929e0d21 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.less +++ b/shared/naturalcrit/codeEditor/codeEditor.less @@ -3,6 +3,11 @@ @import (less) 'codemirror/addon/search/matchesonscrollbar.css'; @import (less) 'codemirror/addon/dialog/dialog.css'; +@keyframes sourceMoveAnimation { + 50% {background-color: red; color: white;} + 100% {background-color: unset; color: unset;} +} + .codeEditor{ .CodeMirror-foldmarker { font-family: inherit; @@ -11,8 +16,8 @@ } .sourceMoveFlash .CodeMirror-line{ - background-color: #0000fc; - color: #ffffff; + animation-name: sourceMoveAnimation; + animation-duration: 0.4s; } //.cm-tab { @@ -24,4 +29,4 @@ // background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAQAgMAAABW5NbuAAAACVBMVEVHcEwAAAAAAAAWawmTAAAAA3RSTlMAPBJ6PMxpAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAFUlEQVQI12NgwACcCQysASAEZGAAACMuAX06aCQUAAAAAElFTkSuQmCC) no-repeat right; // } //} -} \ No newline at end of file +} From c9a182f1e2558fe64e29dbae12cf052a6ffce226 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 3 Jun 2022 15:38:26 -0400 Subject: [PATCH 34/44] Add Tooltips to arrow buttons --- shared/naturalcrit/splitPane/splitPane.less | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/splitPane/splitPane.less b/shared/naturalcrit/splitPane/splitPane.less index 5c15db5df..470d9abbc 100644 --- a/shared/naturalcrit/splitPane/splitPane.less +++ b/shared/naturalcrit/splitPane/splitPane.less @@ -36,7 +36,7 @@ position : absolute; width : 25px; height : 25px; - border : 2px solid black; + border : 2px solid #bbb; border-radius : 15px; text-align : center; font-size : 1.2em; @@ -45,9 +45,11 @@ z-index : 999; box-shadow : 0 4px 5px #0000007f; &.left{ + .tooltipLeft('Jump to locaton in Editor'); top : 30px; } &.right{ + .tooltipRight('Jump to location in Preview'); top : 60px; } &:hover{ From 4e8cbf621b9d2437e62d4ef832b9b465c29dddc0 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 4 Jun 2022 16:38:32 +1200 Subject: [PATCH 35/44] Add brew bounce animation --- client/homebrew/editor/editor.jsx | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 77c655163..470220379 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -43,7 +43,8 @@ const Editor = createClass({ }, getInitialState : function() { return { - view : 'text' //'text', 'style', 'meta' + view : 'text', //'text', 'style', 'meta' + isBrewScrolling : false }; }, @@ -189,7 +190,28 @@ const Editor = createClass({ brewJump : function(targetPage=this.getCurrentPage()){ if(!window || this.isMeta()) return; // console.log(`Scroll to: p${targetPage}`); - window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behavior: 'smooth', block: 'start' }); + const currentPos = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0].scrollTop; + const targetPos = window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).getBoundingClientRect().top; + const interimPos = targetPos >= 0 ? -30 : 30; + + const bounceDelay = 100; + const scrollDelay = 500; + + if(!this.state.isBrewScrolling) { + this.setState({ + isBrewScrolling : true + }); + window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0].scrollTo({ top: currentPos + interimPos, behavior: 'smooth' }); + setTimeout(()=>{ + window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0].scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' }); + }, bounceDelay); + setTimeout(()=>{ + this.setState({ + isBrewScrolling : false + }); + }, scrollDelay); + } + // const hashPage = (page != 1) ? `p${page}` : ''; // window.location.hash = hashPage; }, From 1d0cceda044fc2e89d4ea966a407edcfbb5c2600 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 4 Jun 2022 17:09:25 +1200 Subject: [PATCH 36/44] Eliminate unnecessary `window.frames` calls --- client/homebrew/editor/editor.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 470220379..9b0a0d594 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -190,7 +190,8 @@ const Editor = createClass({ brewJump : function(targetPage=this.getCurrentPage()){ if(!window || this.isMeta()) return; // console.log(`Scroll to: p${targetPage}`); - const currentPos = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0].scrollTop; + const brewRenderer = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0]; + const currentPos = brewRenderer.scrollTop; const targetPos = window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).getBoundingClientRect().top; const interimPos = targetPos >= 0 ? -30 : 30; @@ -201,9 +202,9 @@ const Editor = createClass({ this.setState({ isBrewScrolling : true }); - window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0].scrollTo({ top: currentPos + interimPos, behavior: 'smooth' }); + brewRenderer.scrollTo({ top: currentPos + interimPos, behavior: 'smooth' }); setTimeout(()=>{ - window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0].scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' }); + brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' }); }, bounceDelay); setTimeout(()=>{ this.setState({ From ff2268871d5d2d560caf1c1cccddefc3fdc5a07f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 4 Jun 2022 17:54:35 +1200 Subject: [PATCH 37/44] Throttle brew move function --- client/homebrew/editor/editor.jsx | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 9b0a0d594..81fcba9e6 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -43,8 +43,7 @@ const Editor = createClass({ }, getInitialState : function() { return { - view : 'text', //'text', 'style', 'meta' - isBrewScrolling : false + view : 'text' //'text', 'style', 'meta' }; }, @@ -198,20 +197,15 @@ const Editor = createClass({ const bounceDelay = 100; const scrollDelay = 500; - if(!this.state.isBrewScrolling) { - this.setState({ - isBrewScrolling : true - }); - brewRenderer.scrollTo({ top: currentPos + interimPos, behavior: 'smooth' }); - setTimeout(()=>{ - brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' }); - }, bounceDelay); - setTimeout(()=>{ - this.setState({ - isBrewScrolling : false - }); - }, scrollDelay); - } + if(!this.throttleBrewMove) { + this.throttleBrewMove = _.throttle((currentPos, interimPos, targetPos)=>{ + brewRenderer.scrollTo({ top: currentPos + interimPos, behavior: 'smooth' }); + setTimeout(()=>{ + brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' }); + }, bounceDelay); + }, scrollDelay, { leading: true }); + }; + this.throttleBrewMove(currentPos, interimPos, targetPos); // const hashPage = (page != 1) ? `p${page}` : ''; // window.location.hash = hashPage; From ee3c52109485a19f70871fd4e2e11171683f3d37 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 4 Jun 2022 18:35:22 +1200 Subject: [PATCH 38/44] Change throttle options --- 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 81fcba9e6..06d9f6b59 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -203,7 +203,7 @@ const Editor = createClass({ setTimeout(()=>{ brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' }); }, bounceDelay); - }, scrollDelay, { leading: true }); + }, scrollDelay, { leading: true, trailing: false }); }; this.throttleBrewMove(currentPos, interimPos, targetPos); From ae6ad1eaffdcaa6dc7b8102c06be946859e1a7a4 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 4 Jun 2022 18:40:05 +1200 Subject: [PATCH 39/44] Prune unnecessary styles --- .../editor/snippetbar/snippetbar.less | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippetbar.less b/client/homebrew/editor/snippetbar/snippetbar.less index 7703c6ab7..371f51fda 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.less +++ b/client/homebrew/editor/snippetbar/snippetbar.less @@ -46,30 +46,6 @@ color : black; } } - &.toTop{ - .tooltipLeft('Back to Top'); - font-size : 0.75em; - color : grey; - &.active{ - color : black; - } - } - &.toBrew{ - .tooltipLeft('Match Brew to Source'); - font-size : 0.75em; - color : grey; - &.active{ - color : black; - } - } - &.fromBrew{ - .tooltipLeft('Match Source to Brew'); - font-size : 0.75em; - color : grey; - &.active{ - color : black; - } - } &.divider { background: linear-gradient(#000, #000) no-repeat center/1px 100%; width: 5px; From 6c8cdffd8fd924caa9f120549a0c43e3024e8322 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 4 Jun 2022 19:52:41 +1200 Subject: [PATCH 40/44] Fix typo --- shared/naturalcrit/splitPane/splitPane.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/splitPane/splitPane.less b/shared/naturalcrit/splitPane/splitPane.less index 470d9abbc..700d383d5 100644 --- a/shared/naturalcrit/splitPane/splitPane.less +++ b/shared/naturalcrit/splitPane/splitPane.less @@ -45,7 +45,7 @@ z-index : 999; box-shadow : 0 4px 5px #0000007f; &.left{ - .tooltipLeft('Jump to locaton in Editor'); + .tooltipLeft('Jump to location in Editor'); top : 30px; } &.right{ From 6bc5edd33fbbff3c278811e0ad9c15d90da5f920 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 5 Jun 2022 10:03:03 +1200 Subject: [PATCH 41/44] Remove unnecessary isMeta check --- 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 06d9f6b59..6366d0520 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -187,7 +187,7 @@ const Editor = createClass({ }, brewJump : function(targetPage=this.getCurrentPage()){ - if(!window || this.isMeta()) return; + if(!window) return; // console.log(`Scroll to: p${targetPage}`); const brewRenderer = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0]; const currentPos = brewRenderer.scrollTop; From d04df9aeb004735646efc64e9aaacfb42b7cb05f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 5 Jun 2022 10:10:59 +1200 Subject: [PATCH 42/44] Remove redundant isStyle check --- 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 6366d0520..fd9f850d3 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -212,7 +212,7 @@ const Editor = createClass({ }, sourceJump : function(targetLine=null){ - if(this.isText() || (this.isStyle() && targetLine == 0)) { + if(this.isText()) { if(targetLine == null) { targetLine = 0; From 2ac9c190a9965a217177fe24de481ee9b4652b20 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 5 Jun 2022 11:11:58 +1200 Subject: [PATCH 43/44] Remove commented out shortcut keys --- shared/naturalcrit/codeEditor/codeEditor.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index e09ea34a9..6340a58fe 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -102,8 +102,6 @@ const CodeEditor = createClass({ historyEventDelay : 250, scrollPastEnd : true, extraKeys : { - // 'Alt-Left' : this.moveSource, - // 'Alt-Right' : this.moveBrew, 'Ctrl-B' : this.makeBold, 'Cmd-B' : this.makeBold, 'Ctrl-I' : this.makeItalic, From 4f69b1e7e0e6bda6893f9ea24c8ef36cddc5b1ac Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 5 Jun 2022 11:13:35 +1200 Subject: [PATCH 44/44] Remove unused toTop function --- client/homebrew/editor/snippetbar/snippetbar.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index 28a55ec20..0c6b5cc38 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -60,11 +60,6 @@ const Snippetbar = createClass({ }); }, - toTop : function(){ - this.props.sourceJump(0); - this.props.brewJump(1); - }, - renderEditorButtons : function(){ if(!this.props.showEditButtons) return;