@@ -26,7 +26,8 @@ function RemoteFunctions(config = {}) {
2626 const SHARED_STATE = {
2727 __description : "Use this to keep shared state for Live Preview Edit instead of window.*" ,
2828 _suppressDOMEditDismissal : false ,
29- _suppressDOMEditDismissalTimeout : null
29+ _suppressDOMEditDismissalTimeout : null ,
30+ _boxModelHighlightHidden : false
3031 } ;
3132
3233 let _hoverHighlight ;
@@ -449,15 +450,17 @@ function RemoteFunctions(config = {}) {
449450 s . backgroundColor = color ;
450451 }
451452
452- // Padding region
453- const padColor = COLORS . highlightPadding ;
453+ // Padding region. Rects stay in place when hidden, only their fill goes away,
454+ // so nothing has to be rebuilt when they come back.
455+ const boxModelHidden = SHARED_STATE . _boxModelHighlightHidden ;
456+ const padColor = boxModelHidden ? "transparent" : COLORS . highlightPadding ;
454457 setRect ( refs . padTop , paddingBox . left , paddingBox . top , paddingBox . width , pt , padColor ) ;
455458 setRect ( refs . padBottom , paddingBox . left , contentBox . top + contentBox . height , paddingBox . width , pb , padColor ) ;
456459 setRect ( refs . padLeft , paddingBox . left , contentBox . top , pl , contentBox . height , padColor ) ;
457460 setRect ( refs . padRight , contentBox . left + contentBox . width , contentBox . top , pr , contentBox . height , padColor ) ;
458461
459462 // Margin region
460- const margColor = COLORS . highlightMargin ;
463+ const margColor = boxModelHidden ? "transparent" : COLORS . highlightMargin ;
461464 setRect ( refs . marTop , marginBox . left , marginBox . top , marginBox . width , mt , margColor ) ;
462465 setRect ( refs . marBottom , marginBox . left , borderBox . top + borderBox . height , marginBox . width , mb , margColor ) ;
463466 setRect ( refs . marLeft , marginBox . left , borderBox . top , ml , borderBox . height , margColor ) ;
@@ -1506,6 +1509,9 @@ function RemoteFunctions(config = {}) {
15061509 _pendingHoverRAF = null ;
15071510 }
15081511
1512+ // the selection is gone, so a popover can no longer turn the fills back on
1513+ SHARED_STATE . _boxModelHighlightHidden = false ;
1514+
15091515 // Highlight.clear() removes all overlay divs (outline + margin/padding rects)
15101516 hideHighlight ( ) ;
15111517
@@ -1766,6 +1772,21 @@ function RemoteFunctions(config = {}) {
17661772 }
17671773 }
17681774
1775+ /**
1776+ * Hide just the margin/padding fills of the selected element highlight, keeping
1777+ * the outline and the selection itself. Used while editing paint properties like
1778+ * background color, where the fills sit on top of what the user is changing.
1779+ * @param {Boolean } hidden
1780+ */
1781+ function setBoxModelHighlightHidden ( hidden ) {
1782+ hidden = ! ! hidden ;
1783+ if ( SHARED_STATE . _boxModelHighlightHidden === hidden ) {
1784+ return ;
1785+ }
1786+ SHARED_STATE . _boxModelHighlightHidden = hidden ;
1787+ redrawHighlights ( ) ;
1788+ }
1789+
17691790 let customReturns = { } ;
17701791 // only apis that needs to be called from phoenix js layer should be customReturns. APis that are shared within
17711792 // the remote function context only should not be in customReturns and should be in
@@ -1789,6 +1810,7 @@ function RemoteFunctions(config = {}) {
17891810 "getHighlightTrackingElement" : getHighlightTrackingElement ,
17901811 "getHighlightStyle" : getHighlightStyle ,
17911812 "setHotCornerHidden" : setHotCornerHidden ,
1813+ "setBoxModelHighlightHidden" : setBoxModelHighlightHidden ,
17921814 "clearHoverState" : _clearHoverState
17931815 } ;
17941816
0 commit comments