MOBILE-2995 qr: Add QR button in RTE
This commit is contained in:
		
							parent
							
								
									394dd6e24d
								
							
						
					
					
						commit
						c3f39abafa
					
				| @ -71,6 +71,11 @@ | |||||||
|                 <core-icon name="fa-eraser"></core-icon> |                 <core-icon name="fa-eraser"></core-icon> | ||||||
|             </button> |             </button> | ||||||
|         </ion-slide> |         </ion-slide> | ||||||
|  |         <ion-slide *ngIf="canScanQR"> | ||||||
|  |             <button [disabled]="!rteEnabled" (click)="scanQR($event)" (mousedown)="stopBubble($event)"> | ||||||
|  |                 <core-icon name="fa-qrcode"></core-icon> | ||||||
|  |             </button> | ||||||
|  |         </ion-slide> | ||||||
|         <ion-slide> |         <ion-slide> | ||||||
|             <button [attr.aria-pressed]="!rteEnabled" (click)="toggleEditor($event)" (mousedown)="mouseDownAction($event)" [title]=" 'core.editor.toggle' | translate"> |             <button [attr.aria-pressed]="!rteEnabled" (click)="toggleEditor($event)" (mousedown)="mouseDownAction($event)" [title]=" 'core.editor.toggle' | translate"> | ||||||
|                 <core-icon name="fa-code"></core-icon> |                 <core-icon name="fa-code"></core-icon> | ||||||
|  | |||||||
| @ -95,6 +95,8 @@ export class CoreEditorRichTextEditorComponent implements AfterContentInit, OnDe | |||||||
|         ol: 'false', |         ol: 'false', | ||||||
|     }; |     }; | ||||||
|     infoMessage: string; |     infoMessage: string; | ||||||
|  |     canScanQR: boolean; | ||||||
|  | 
 | ||||||
|     protected isCurrentView = true; |     protected isCurrentView = true; | ||||||
|     protected toolbarButtonWidth = 40; |     protected toolbarButtonWidth = 40; | ||||||
|     protected toolbarArrowWidth = 28; |     protected toolbarArrowWidth = 28; | ||||||
| @ -119,6 +121,7 @@ export class CoreEditorRichTextEditorComponent implements AfterContentInit, OnDe | |||||||
|         this.contentChanged = new EventEmitter<string>(); |         this.contentChanged = new EventEmitter<string>(); | ||||||
|         this.element = elementRef.nativeElement as HTMLDivElement; |         this.element = elementRef.nativeElement as HTMLDivElement; | ||||||
|         this.pageInstance = 'app_' + Date.now(); // Generate a "unique" ID based on timestamp.
 |         this.pageInstance = 'app_' + Date.now(); // Generate a "unique" ID based on timestamp.
 | ||||||
|  |         this.canScanQR = this.utils.canScanQR(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -865,6 +868,24 @@ export class CoreEditorRichTextEditorComponent implements AfterContentInit, OnDe | |||||||
|         }, timeout); |         }, timeout); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * Scan a QR code and put its text in the editor. | ||||||
|  |      * | ||||||
|  |      * @param $event Event data | ||||||
|  |      */ | ||||||
|  |     scanQR($event: any): void { | ||||||
|  |         this.stopBubble($event); | ||||||
|  | 
 | ||||||
|  |         // Scan for a QR code.
 | ||||||
|  |         this.utils.scanQR().then((text) => { | ||||||
|  |             if (text) { | ||||||
|  |                 document.execCommand('insertText', false, text); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             this.content.resize(); // Resize content, otherwise the content height becomes 1 for some reason.
 | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * User entered the page that contains the component. |      * User entered the page that contains the component. | ||||||
|      */ |      */ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user