@@ -41,9 +41,11 @@ function RemoteFunctions(config = {}) {
4141 // Expose the currently selected element globally for external access
4242 window . __current_ph_lp_selected = null ;
4343
44- const HIGHLIGHT_COLORS = {
45- padding : "rgba(147, 196, 125, 0.55)" ,
46- margin : "rgba(246, 178, 107, 0.66)"
44+ const COLORS = {
45+ highlightPadding : "rgba(147, 196, 125, 0.55)" ,
46+ highlightMargin : "rgba(246, 178, 107, 0.66)" ,
47+ outlineEditable : "#4285F4" ,
48+ outlineNonEditable : "#3C3F41"
4749 } ;
4850
4951 // the following fucntions can be in the handler and live preview will call those functions when the below
@@ -372,17 +374,22 @@ function RemoteFunctions(config = {}) {
372374 div . appendChild ( r ) ;
373375 }
374376
375- // Padding rects (non-overlapping: top/bottom full width, left/right content height)
376- makeRect ( { top : "0" , left : "0" , width : innerW + "px" , height : pt + "px" } , HIGHLIGHT_COLORS . padding ) ;
377- makeRect ( { bottom : "0" , left : "0" , width : innerW + "px" , height : pb + "px" } , HIGHLIGHT_COLORS . padding ) ;
378- makeRect ( { top : pt + "px" , left : "0" , width : pl + "px" , height : contentH + "px" } , HIGHLIGHT_COLORS . padding ) ;
379- makeRect ( { top : pt + "px" , right : "0" , width : pr + "px" , height : contentH + "px" } , HIGHLIGHT_COLORS . padding ) ;
380-
381- // Margin rects (top/bottom span element width, left/right span full height)
382- makeRect ( { top : - ( mt + bt ) + "px" , left : - bl + "px" , width : outerW + "px" , height : mt + "px" } , HIGHLIGHT_COLORS . margin ) ;
383- makeRect ( { bottom : - ( mb + bb ) + "px" , left : - bl + "px" , width : outerW + "px" , height : mb + "px" } , HIGHLIGHT_COLORS . margin ) ;
384- makeRect ( { top : - ( mt + bt ) + "px" , left : - ( ml + bl ) + "px" , width : ml + "px" , height : ( outerH + mt + mb ) + "px" } , HIGHLIGHT_COLORS . margin ) ;
385- makeRect ( { top : - ( mt + bt ) + "px" , right : - ( mr + br ) + "px" , width : mr + "px" , height : ( outerH + mt + mb ) + "px" } , HIGHLIGHT_COLORS . margin ) ;
377+ // Padding rects (top/bottom full width, left/right content height)
378+ const padColor = COLORS . highlightPadding ;
379+ makeRect ( { top : "0" , left : "0" , width : innerW + "px" , height : pt + "px" } , padColor ) ;
380+ makeRect ( { bottom : "0" , left : "0" , width : innerW + "px" , height : pb + "px" } , padColor ) ;
381+ makeRect ( { top : pt + "px" , left : "0" , width : pl + "px" , height : contentH + "px" } , padColor ) ;
382+ makeRect ( { top : pt + "px" , right : "0" , width : pr + "px" , height : contentH + "px" } , padColor ) ;
383+
384+ // Margin rects (top/bottom element width, left/right full height)
385+ const margColor = COLORS . highlightMargin ;
386+ const mTop = - ( mt + bt ) + "px" ;
387+ const mBot = - ( mb + bb ) + "px" ;
388+ const fullH = ( outerH + mt + mb ) + "px" ;
389+ makeRect ( { top : mTop , left : - bl + "px" , width : outerW + "px" , height : mt + "px" } , margColor ) ;
390+ makeRect ( { bottom : mBot , left : - bl + "px" , width : outerW + "px" , height : mb + "px" } , margColor ) ;
391+ makeRect ( { top : mTop , left : - ( ml + bl ) + "px" , width : ml + "px" , height : fullH } , margColor ) ;
392+ makeRect ( { top : mTop , right : - ( mr + br ) + "px" , width : mr + "px" , height : fullH } , margColor ) ;
386393
387394 window . document . body . appendChild ( div ) ;
388395 this . _divs . push ( div ) ;
@@ -433,9 +440,10 @@ function RemoteFunctions(config = {}) {
433440 _hoverHighlight . elements . forEach ( clearElementHoverHighlight ) ;
434441 _hoverHighlight . clear ( ) ;
435442
436- // Store original outline to restore on hover out, then apply a blue border
443+ // Store original outline to restore on hover out, then apply a border
437444 element . _originalHoverOutline = element . style . outline ;
438- const outlineColor = element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ? "#4285F4" : "#3C3F41" ;
445+ const isEditable = element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ;
446+ const outlineColor = isEditable ? COLORS . outlineEditable : COLORS . outlineNonEditable ;
439447 element . style . outline = `1px solid ${ outlineColor } ` ;
440448
441449 _hoverHighlight . add ( element ) ;
@@ -516,7 +524,8 @@ function RemoteFunctions(config = {}) {
516524 }
517525
518526 element . _originalOutline = element . style . outline ;
519- const outlineColor = element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ? "#4285F4" : "#3C3F41" ;
527+ const isEditable = element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ;
528+ const outlineColor = isEditable ? COLORS . outlineEditable : COLORS . outlineNonEditable ;
520529 element . style . outline = `1px solid ${ outlineColor } ` ;
521530
522531 if ( ! _clickHighlight ) {
@@ -1085,7 +1094,8 @@ function RemoteFunctions(config = {}) {
10851094 } else {
10861095 // Suppression is active - re-apply outline since attrChange may have wiped it
10871096 if ( previouslySelectedElement && previouslySelectedElement . isConnected ) {
1088- const outlineColor = previouslySelectedElement . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ? "#4285F4" : "#3C3F41" ;
1097+ const isEditable = previouslySelectedElement . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ;
1098+ const outlineColor = isEditable ? COLORS . outlineEditable : COLORS . outlineNonEditable ;
10891099 previouslySelectedElement . style . outline = `1px solid ${ outlineColor } ` ;
10901100 }
10911101 }
0 commit comments