@@ -2671,6 +2671,7 @@ function RemoteFunctions(config = {}) {
26712671 } ,
26722672
26732673 remove : function ( ) {
2674+ _imageRibbonGallery = null ;
26742675 if ( this . body && this . body . parentNode && this . body . parentNode === window . document . body ) {
26752676 window . document . body . removeChild ( this . body ) ;
26762677 this . body = null ;
@@ -3022,6 +3023,7 @@ function RemoteFunctions(config = {}) {
30223023
30233024 // helper function to check if image ribbon gallery should be shown
30243025 function shouldShowImageRibbon ( ) {
3026+ if ( _imageRibbonGallery ) { return false ; }
30253027 return config . imageRibbon !== false ;
30263028 }
30273029
@@ -3096,6 +3098,7 @@ function RemoteFunctions(config = {}) {
30963098 function _selectElement ( element ) {
30973099 // dismiss all UI boxes and cleanup previous element state when selecting a different element
30983100 dismissUIAndCleanupState ( ) ;
3101+ dismissImageRibbonGallery ( ) ;
30993102 if ( ! isElementEditable ( element ) ) {
31003103 return false ;
31013104 }
@@ -3109,6 +3112,11 @@ function RemoteFunctions(config = {}) {
31093112 _nodeMoreOptionsBox = null ;
31103113 }
31113114
3115+ // if the selected element is an image, show the image ribbon gallery (make sure its enabled in preferences)
3116+ if ( element && element . tagName . toLowerCase ( ) === 'img' && shouldShowImageRibbon ( ) ) {
3117+ _imageRibbonGallery = new ImageRibbonGallery ( element ) ;
3118+ }
3119+
31123120 element . _originalOutline = element . style . outline ;
31133121 element . style . outline = "1px solid #4285F4" ;
31143122
@@ -3638,7 +3646,9 @@ function RemoteFunctions(config = {}) {
36383646 // if user enabled the image ribbon setting and an image is selected, then we show the image ribbon
36393647 if ( imageRibbonJustEnabled && previouslyClickedElement &&
36403648 previouslyClickedElement . tagName . toLowerCase ( ) === 'img' ) {
3641- _imageRibbonGallery = new ImageRibbonGallery ( previouslyClickedElement ) ;
3649+ if ( ! _imageRibbonGallery ) {
3650+ _imageRibbonGallery = new ImageRibbonGallery ( previouslyClickedElement ) ;
3651+ }
36423652 }
36433653
36443654 _updateEventListeners ( ) ;
0 commit comments