diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index df674c74e..b08ee9a2b 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -28,7 +28,8 @@ let liveScroll = true; const isElementCodeMirror=(element)=>{ let el = element; while( el.tagName != 'body' ) { - if( el.classList.contains('CodeMirror-code') || el.classList.contains('CodeMirror-line')) + if ( !el?.classList ) return false + if( el?.classList?.contains('CodeMirror-code') || el.classList.contains('CodeMirror-line')) return true; el = el.parentNode; } @@ -43,6 +44,7 @@ const Editor = createClass({ text : '', style : '' }, + liveScroll : true, onTextChange : ()=>{}, onStyleChange : ()=>{}, @@ -99,6 +101,9 @@ const Editor = createClass({ if(prevProps.moveSource !== this.props.moveSource) { this.sourceJump(); }; + if(prevProps.liveScroll !== this.props.liveScroll) { + liveScroll = !liveScroll; + }; }, handleControlKeys : function(e){ @@ -126,10 +131,7 @@ const Editor = createClass({ if ((e.shiftKey) && (!e.altKey) && (e.keyCode == J_KEY)) this.sourceJump(); // Toggle Live-scrolling on Shift-CTRL-ALT-J if((e.shiftKey) && (e.altKey) && (e.keyCode == J_KEY)) { - console.log('Trying to flip the property?') - console.log(liveScroll); liveScroll = !liveScroll; - console.log(liveScroll); } if( e.keyCode == J_KEY) { diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index 2101480dc..0718a97b1 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -20,6 +20,7 @@ const SplitPane = createClass({ isDragging : false, moveSource : false, moveBrew : false, + liveScroll : true, showMoveArrows : true }; }, @@ -117,6 +118,20 @@ const SplitPane = createClass({ onClick={()=>this.setState({ moveBrew: !this.state.moveBrew })} > +
{ + this.setState({ liveScroll: !this.state.liveScroll }); + if(document.getElementById('scrollToggle').classList.contains('fa-unlock')) { + document.getElementById('scrollToggle').className = 'fas fa-lock'; + document.getElementById('scrollToggleDiv').className = 'arrow lock'; + } else { + document.getElementById('scrollToggle').className = 'fas fa-unlock'; + document.getElementById('scrollToggleDiv').className = 'arrow unlock'; + } + }} > + +
; } }, @@ -143,6 +158,7 @@ const SplitPane = createClass({ {React.cloneElement(this.props.children[0], { moveBrew : this.state.moveBrew, moveSource : this.state.moveSource, + liveScroll : this.state.liveScroll, setMoveArrows : this.setMoveArrows })} diff --git a/shared/naturalcrit/splitPane/splitPane.less b/shared/naturalcrit/splitPane/splitPane.less index 831b5ce47..2000db72a 100644 --- a/shared/naturalcrit/splitPane/splitPane.less +++ b/shared/naturalcrit/splitPane/splitPane.less @@ -53,6 +53,14 @@ .tooltipRight('Jump to location in Preview'); top : 60px; } + &.lock{ + .tooltipRight('Lock cursor tracking between windows.'); + top : 90px; + } + &.unlock{ + .tooltipRight('Unlock cursor tracking between windows.'); + top : 90px; + } &:hover{ background-color: #666; }