@@ -3894,6 +3894,9 @@ function RemoteFunctions(config = {}) {
38943894
38953895 function enableHoverListeners ( ) {
38963896 if ( config . isProUser && ( config . highlight || shouldShowHighlightOnHover ( ) ) ) {
3897+ window . document . removeEventListener ( "mouseover" , onElementHover ) ;
3898+ window . document . removeEventListener ( "mouseout" , onElementHoverOut ) ;
3899+
38973900 window . document . addEventListener ( "mouseover" , onElementHover ) ;
38983901 window . document . addEventListener ( "mouseout" , onElementHoverOut ) ;
38993902 }
@@ -4693,6 +4696,37 @@ function RemoteFunctions(config = {}) {
46934696 cleanupPreviousElementState ( ) ;
46944697 }
46954698
4699+ /**
4700+ * this is a hard reset function, it resets every live preview edit thing, whether it be UI boxes
4701+ * highlighting, any timers or anything
4702+ */
4703+ function resetState ( ) {
4704+ _stopAutoScroll ( ) ;
4705+
4706+ if ( _hoverHighlight ) {
4707+ _hoverHighlight . clear ( ) ;
4708+ _hoverHighlight = null ;
4709+ }
4710+ if ( _clickHighlight ) {
4711+ _clickHighlight . clear ( ) ;
4712+ _clickHighlight = null ;
4713+ }
4714+
4715+ dismissUIAndCleanupState ( ) ;
4716+
4717+ const allElements = window . document . querySelectorAll ( "[data-brackets-id]" ) ;
4718+ for ( let i = 0 ; i < allElements . length ; i ++ ) {
4719+ if ( allElements [ i ] . _originalBackgroundColor !== undefined ) {
4720+ clearElementBackground ( allElements [ i ] ) ;
4721+ }
4722+ }
4723+
4724+ if ( config . isProUser ) {
4725+ _hoverHighlight = new Highlight ( "#c8f9c5" , true ) ;
4726+ _clickHighlight = new Highlight ( "#cfc" , true ) ;
4727+ }
4728+ }
4729+
46964730
46974731 /**
46984732 * This function is responsible to move the cursor to the end of the text content when we start editing
@@ -4816,6 +4850,16 @@ function RemoteFunctions(config = {}) {
48164850 _editHandler = new DOMEditHandler ( window . document ) ;
48174851
48184852 function registerHandlers ( ) {
4853+ // clear previous highlighting
4854+ if ( _hoverHighlight ) {
4855+ _hoverHighlight . clear ( ) ;
4856+ _hoverHighlight = null ;
4857+ }
4858+ if ( _clickHighlight ) {
4859+ _clickHighlight . clear ( ) ;
4860+ _clickHighlight = null ;
4861+ }
4862+
48194863 // Always remove existing listeners first to avoid duplicates
48204864 window . document . removeEventListener ( "mouseover" , onElementHover ) ;
48214865 window . document . removeEventListener ( "mouseout" , onElementHoverOut ) ;
@@ -4862,6 +4906,7 @@ function RemoteFunctions(config = {}) {
48624906 "finishEditing" : finishEditing ,
48634907 "hasVisibleLivePreviewBoxes" : hasVisibleLivePreviewBoxes ,
48644908 "dismissUIAndCleanupState" : dismissUIAndCleanupState ,
4909+ "resetState" : resetState ,
48654910 "enableHoverListeners" : enableHoverListeners ,
48664911 "registerHandlers" : registerHandlers ,
48674912 "handleDownloadEvent" : handleDownloadEvent
0 commit comments