@@ -252,6 +252,18 @@ function RemoteFunctions(config = {}) {
252252 _aiPromptBox = new AIPromptBox ( element ) ; // create a new one
253253 }
254254
255+ /**
256+ * This function gets called when the image gallery button is clicked
257+ * it shows the image ribbon gallery at the bottom of the live preview
258+ * @param {Event } event
259+ * @param {DOMElement } element - the HTML DOM element that was clicked (should be an image)
260+ */
261+ function _handleImageGalleryOptionClick ( event , element ) {
262+ if ( ! _imageRibbonGallery && shouldShowImageRibbon ( ) ) {
263+ _imageRibbonGallery = new ImageRibbonGallery ( element ) ;
264+ }
265+ }
266+
255267 /**
256268 * This function gets called when the delete button is clicked
257269 * it sends a message to the editor using postMessage to delete the element from the source code
@@ -339,6 +351,8 @@ function RemoteFunctions(config = {}) {
339351 _handleDeleteOptionClick ( e , element ) ;
340352 } else if ( action === "ai" ) {
341353 _handleAIOptionClick ( e , element ) ;
354+ } else if ( action === "image-gallery" ) {
355+ _handleImageGalleryOptionClick ( e , element ) ;
342356 }
343357 }
344358
@@ -1257,6 +1271,13 @@ function RemoteFunctions(config = {}) {
12571271 <path d="M6 7V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v2h3v2h-2l-1.5 12.5a2 2 0 0
12581272 1-2 1.5H8.5a2 2 0 0 1-2-1.5L5 9H3V7h3zm2 0h8V5H8v2z"/>
12591273 </svg>
1274+ ` ,
1275+
1276+ imageGallery : `
1277+ <svg viewBox="0 0 24 24" fill="currentColor">
1278+ <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
1279+ <path d="M1 3v16h2V5h16V3H1z"/>
1280+ </svg>
12601281 `
12611282 } ;
12621283
@@ -1267,6 +1288,13 @@ function RemoteFunctions(config = {}) {
12671288 ${ ICONS . ai }
12681289 </span>` ;
12691290
1291+ // if its an image element, we show the image gallery icon
1292+ if ( this . element && this . element . tagName . toLowerCase ( ) === 'img' ) {
1293+ content += `<span data-action="image-gallery" title="${ config . strings . imageGallery } ">
1294+ ${ ICONS . imageGallery }
1295+ </span>` ;
1296+ }
1297+
12701298 // Only include select parent option if element supports it
12711299 if ( showSelectParentOption ) {
12721300 content += `<span data-action="select-parent" title="${ config . strings . selectParent } ">
@@ -3464,13 +3492,6 @@ function RemoteFunctions(config = {}) {
34643492 _nodeMoreOptionsBox = null ;
34653493 }
34663494
3467- // if the selected element is an image, show the image ribbon gallery (make sure its enabled in preferences)
3468- if ( element && element . tagName . toLowerCase ( ) === 'img' && shouldShowImageRibbon ( ) ) {
3469- if ( ! _imageRibbonGallery ) {
3470- _imageRibbonGallery = new ImageRibbonGallery ( element ) ;
3471- }
3472- }
3473-
34743495 element . _originalOutline = element . style . outline ;
34753496 element . style . outline = "1px solid #4285F4" ;
34763497
@@ -4108,6 +4129,7 @@ function RemoteFunctions(config = {}) {
41084129 dismissNodeMoreOptionsBox ( ) ;
41094130 dismissAIPromptBox ( ) ;
41104131 dismissNodeInfoBox ( ) ;
4132+ dismissImageRibbonGallery ( ) ;
41114133 }
41124134
41134135 /**
@@ -4309,7 +4331,6 @@ function RemoteFunctions(config = {}) {
43094331 "finishEditing" : finishEditing ,
43104332 "hasVisibleLivePreviewBoxes" : hasVisibleLivePreviewBoxes ,
43114333 "dismissUIAndCleanupState" : dismissUIAndCleanupState ,
4312- "dismissImageRibbonGallery" : dismissImageRibbonGallery ,
43134334 "enableHoverListeners" : enableHoverListeners ,
43144335 "registerHandlers" : registerHandlers
43154336 } ;
0 commit comments