@@ -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 } ">
@@ -3469,13 +3497,6 @@ function RemoteFunctions(config = {}) {
34693497 _nodeMoreOptionsBox = null ;
34703498 }
34713499
3472- // if the selected element is an image, show the image ribbon gallery (make sure its enabled in preferences)
3473- if ( element && element . tagName . toLowerCase ( ) === 'img' && shouldShowImageRibbon ( ) ) {
3474- if ( ! _imageRibbonGallery ) {
3475- _imageRibbonGallery = new ImageRibbonGallery ( element ) ;
3476- }
3477- }
3478-
34793500 element . _originalOutline = element . style . outline ;
34803501 element . style . outline = "1px solid #4285F4" ;
34813502
@@ -4113,6 +4134,7 @@ function RemoteFunctions(config = {}) {
41134134 dismissNodeMoreOptionsBox ( ) ;
41144135 dismissAIPromptBox ( ) ;
41154136 dismissNodeInfoBox ( ) ;
4137+ dismissImageRibbonGallery ( ) ;
41164138 }
41174139
41184140 /**
@@ -4314,7 +4336,6 @@ function RemoteFunctions(config = {}) {
43144336 "finishEditing" : finishEditing ,
43154337 "hasVisibleLivePreviewBoxes" : hasVisibleLivePreviewBoxes ,
43164338 "dismissUIAndCleanupState" : dismissUIAndCleanupState ,
4317- "dismissImageRibbonGallery" : dismissImageRibbonGallery ,
43184339 "enableHoverListeners" : enableHoverListeners ,
43194340 "registerHandlers" : registerHandlers
43204341 } ;
0 commit comments