2929 * exported functions.
3030 */
3131function RemoteFunctions ( config = { } ) {
32- // we load this file in unit test window and dont want it to do anything unexpected in the unit test runner context
33- const isUnitTestWindow = window . Phoenix && window . Phoenix . isTestWindow ;
3432 const GLOBALS = {
3533 // given to internal elements like info box, options box, image gallery and all other phcode internal elements
3634 // to distinguish between phoenix internal vs user created elements
@@ -49,7 +47,6 @@ function RemoteFunctions(config = {}) {
4947 let _nodeInfoBox ;
5048 let _nodeMoreOptionsBox ;
5149 let _moreOptionsDropdown ;
52- let _hotCorner ;
5350 let _setup = false ;
5451 let _hoverLockTimer = null ;
5552
@@ -93,7 +90,8 @@ function RemoteFunctions(config = {}) {
9390 // interaction blocks acts as 'kill switch' to block all kinds of click handlers
9491 // this is done so that links or buttons doesn't perform their natural operation in edit mode
9592 "registerInteractionBlocker" , // to block
96- "unregisterInteractionBlocker" // to unblock
93+ "unregisterInteractionBlocker" , // to unblock
94+ "udpateHotCornerState" // to update the hot corner button when state changes
9795 ] ;
9896
9997 const _moreOptionsHandlers = new Map ( ) ;
@@ -997,75 +995,6 @@ function RemoteFunctions(config = {}) {
997995 }
998996 } ;
999997
1000- /**
1001- * hot corner class,
1002- * to switch to preview mode and back
1003- */
1004- class HotCorner {
1005- constructor ( ) {
1006- this . element = null ;
1007- this . button = null ;
1008- this . box = null ;
1009- this . wasPreviewMode = false ;
1010- this . _setup ( ) ;
1011- }
1012-
1013- _setup ( ) {
1014- const container = document . createElement ( "div" ) ;
1015- container . setAttribute ( GLOBALS . PHCODE_INTERNAL_ATTR , "true" ) ;
1016-
1017- const shadow = container . attachShadow ( { mode : "open" } ) ;
1018-
1019- const content = `
1020- <div class="phoenix-hot-corner">
1021- <button class="hot-corner-btn" title="${ strings . togglePreviewMode } ">
1022- ${ icons . playButton }
1023- </button>
1024- </div>` ;
1025-
1026- shadow . innerHTML = `<style>${ cssStyles . hotCorner } </style>${ content } ` ;
1027-
1028- this . element = container ;
1029- this . button = shadow . querySelector ( ".hot-corner-btn" ) ;
1030- this . hotCorner = shadow . querySelector ( ".phoenix-hot-corner" ) ;
1031-
1032- this . button . addEventListener ( "click" , ( ) => {
1033- window . _Brackets_MessageBroker . send ( { livePreviewEditEnabled : true , type : "hotCornerPreviewToggle" } ) ;
1034- } ) ;
1035- document . body . appendChild ( this . element ) ;
1036- }
1037-
1038- updateState ( isPreviewMode , showAnimation = false ) {
1039-
1040- if ( isPreviewMode ) {
1041- this . button . classList . add ( "selected" ) ;
1042-
1043- if ( ! this . wasPreviewMode && showAnimation && this . hotCorner ) {
1044- this . hotCorner . classList . add ( "peek-animation" ) ;
1045-
1046- setTimeout ( ( ) => {
1047- if ( this . hotCorner ) {
1048- this . hotCorner . classList . remove ( "peek-animation" ) ;
1049- }
1050- } , 1200 ) ;
1051- }
1052- } else {
1053- this . button . classList . remove ( "selected" ) ;
1054- }
1055- this . wasPreviewMode = isPreviewMode ;
1056- }
1057-
1058- remove ( ) {
1059- if ( this . element && this . element . parentNode ) {
1060- this . element . parentNode . removeChild ( this . element ) ;
1061- }
1062- this . element = null ;
1063- this . button = null ;
1064- this . hotCorner = null ;
1065- }
1066- }
1067-
1068-
1069998 function Highlight ( color , trigger ) {
1070999 this . color = color ;
10711000 this . trigger = ! ! trigger ;
@@ -2097,8 +2026,8 @@ function RemoteFunctions(config = {}) {
20972026
20982027 // Update hot corner state when mode changes
20992028 // Show animation when mode changes to help users discover the feature
2100- if ( isModeChanged && _hotCorner ) {
2101- _hotCorner . updateState ( config . mode === 'preview' , true ) ;
2029+ if ( isModeChanged && SHARED_STATE . _hotCorner ) {
2030+ SHARED_STATE . _hotCorner . updateState ( config . mode === 'preview' , true ) ;
21022031 }
21032032
21042033 // Handle configuration changes
@@ -2346,22 +2275,6 @@ function RemoteFunctions(config = {}) {
23462275 } ) ;
23472276 }
23482277
2349- // init the hot corner after the DOM is ready
2350- if ( document . readyState === 'loading' ) {
2351- document . addEventListener ( 'DOMContentLoaded' , ( ) => {
2352- if ( ! _hotCorner && ! isUnitTestWindow ) {
2353- _hotCorner = new HotCorner ( ) ;
2354- _hotCorner . updateState ( config . mode === 'preview' ) ;
2355- }
2356- } ) ;
2357- } else {
2358- // or if the DOM is already ready then init directly
2359- if ( ! _hotCorner && ! isUnitTestWindow ) {
2360- _hotCorner = new HotCorner ( ) ;
2361- _hotCorner . updateState ( config . mode === 'preview' ) ;
2362- }
2363- }
2364-
23652278 // we need to refresh the config once the load is completed
23662279 // this is important because messageBroker gets ready for use only when load fires
23672280 window . addEventListener ( 'load' , function ( ) {
0 commit comments