MOBILE-4470 format-text: Fix image viewer
This commit is contained in:
		
							parent
							
								
									345fdffdb8
								
							
						
					
					
						commit
						26d950cbb4
					
				| @ -243,9 +243,9 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Add magnifying glass icons to view adapted images at full size. |      * Add image viewer button to view adapted images at full size. | ||||||
|      */ |      */ | ||||||
|     async addMagnifyingGlasses(): Promise<void> { |     protected async addImageViewerButton(): Promise<void> { | ||||||
|         const imgs = Array.from(this.element.querySelectorAll('.core-adapted-img-container > img')); |         const imgs = Array.from(this.element.querySelectorAll('.core-adapted-img-container > img')); | ||||||
|         if (!imgs.length) { |         if (!imgs.length) { | ||||||
|             return; |             return; | ||||||
| @ -270,7 +270,6 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec | |||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             const imgSrc = CoreTextUtils.escapeHTML(img.getAttribute('data-original-src') || img.getAttribute('src')); |  | ||||||
|             const label = Translate.instant('core.openfullimage'); |             const label = Translate.instant('core.openfullimage'); | ||||||
|             const button = document.createElement('button'); |             const button = document.createElement('button'); | ||||||
| 
 | 
 | ||||||
| @ -283,6 +282,8 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec | |||||||
|             button.innerHTML = `<ion-icon name="fas-${iconName}" aria-hidden="true" src="${src}"></ion-icon>`; |             button.innerHTML = `<ion-icon name="fas-${iconName}" aria-hidden="true" src="${src}"></ion-icon>`; | ||||||
| 
 | 
 | ||||||
|             button.addEventListener('click', (e: Event) => { |             button.addEventListener('click', (e: Event) => { | ||||||
|  |                 const imgSrc = CoreTextUtils.escapeHTML(img.getAttribute('data-original-src') || img.getAttribute('src')); | ||||||
|  | 
 | ||||||
|                 e.preventDefault(); |                 e.preventDefault(); | ||||||
|                 e.stopPropagation(); |                 e.stopPropagation(); | ||||||
|                 CoreDomUtils.viewImage(imgSrc, img.getAttribute('alt'), this.component, this.componentId); |                 CoreDomUtils.viewImage(imgSrc, img.getAttribute('alt'), this.component, this.componentId); | ||||||
| @ -371,7 +372,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec | |||||||
|         await CoreUtils.nextTick(); |         await CoreUtils.nextTick(); | ||||||
| 
 | 
 | ||||||
|         // Add magnifying glasses to images.
 |         // Add magnifying glasses to images.
 | ||||||
|         this.addMagnifyingGlasses(); |         this.addImageViewerButton(); | ||||||
| 
 | 
 | ||||||
|         if (result.options.filter) { |         if (result.options.filter) { | ||||||
|             // Let filters handle HTML. We do it here because we don't want them to block the render of the text.
 |             // Let filters handle HTML. We do it here because we don't want them to block the render of the text.
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user