@@ -19,12 +19,12 @@ const getImage = (imageId) => document.querySelector(`#${CSS.escape(imageId)}`);
1919
2020const calculateImagePosition = ( el , rootRect , bodyRect ) => {
2121 const { x } = el . getBoundingClientRect ( ) ;
22- let { top, left } = rootRect
23- const { width : bodyWidth , height : bodyHeight } = bodyRect ;
22+ let { top, left } = rootRect ;
23+ const { width : bodyWidth , height : bodyHeight } = bodyRect ;
2424
25- const isSpaceRight = x + IMAGE_WIDTH <= bodyWidth
25+ const isSpaceRight = x + IMAGE_WIDTH <= bodyWidth ;
2626 if ( isSpaceRight ) {
27- left += rootRect . width + IMAGE_WIDTH
27+ left += rootRect . width + IMAGE_WIDTH ;
2828 }
2929
3030 const isSpaceBelow = rootRect . top + IMAGE_HEIGHT <= bodyHeight ;
@@ -38,11 +38,11 @@ const calculateImagePosition = (el, rootRect, bodyRect) => {
3838function showImage ( el , imageId , getRootRect ) {
3939 const img = getImage ( imageId ) ;
4040 if ( img ) {
41- const rootRect = getRootRect ( )
41+ const rootRect = getRootRect ( ) ;
4242 if ( ! rootRect ) return ;
4343
44- const bodyRect = document . body . getBoundingClientRect ( ) ;
45- if ( ! bodyRect ) return ;
44+ const bodyRect = document . body . getBoundingClientRect ( ) ;
45+ if ( ! bodyRect ) return ;
4646
4747 const { left, top } = calculateImagePosition ( el , rootRect , bodyRect ) ;
4848
@@ -127,8 +127,8 @@ app.registerExtension({
127127 // After an element is created for an item, add an image if it has one
128128 contextMenuHook [ "addItem" ] . push ( function ( el , menu , [ name , value , options ] ) {
129129 if ( el && isCustomItem ( value ) && value ?. image && ! value . submenu ) {
130- const key = `pysssss-image-combo-${ name } `
131- el . textContent += " *" ;
130+ const key = `pysssss-image-combo-${ name } ` ;
131+ el . textContent += " *" ;
132132 $el ( `div.pysssss-combo-image` , {
133133 id : key ,
134134 parent : document . body ,
@@ -138,12 +138,12 @@ app.registerExtension({
138138 } ) ;
139139
140140 const getRootRect = ( ) => menu . root ?. getBoundingClientRect ( ) ;
141- const showHandler = ( ) => showImage ( el , key , getRootRect ) ;
142- const closeHandler = ( ) => closeImage ( key ) ;
143-
144- el . addEventListener ( "mouseenter" , showHandler , { passive : true } ) ;
145- el . addEventListener ( "mouseleave" , closeHandler , { passive : true } ) ;
146- el . addEventListener ( "click" , closeHandler , { passive : true } ) ;
141+ const showHandler = ( ) => showImage ( el , key , getRootRect ) ;
142+ const closeHandler = ( ) => closeImage ( key ) ;
143+
144+ el . addEventListener ( "mouseenter" , showHandler , { passive : true } ) ;
145+ el . addEventListener ( "mouseleave" , closeHandler , { passive : true } ) ;
146+ el . addEventListener ( "click" , closeHandler , { passive : true } ) ;
147147 }
148148 } ) ;
149149
0 commit comments