From ed6a90e51eea8fa847751f45056a756f40e5dbe1 Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 30 Nov 2020 10:37:24 +0200 Subject: [PATCH] better fullscreen icons --- .../file-preview-screen.component.html | 1 + .../file-preview-screen.component.ts | 1 + .../file/pdf-viewer/pdf-viewer.component.ts | 57 ++++++++++++++++++- .../assets/icons/general/exit-fullscreen.svg | 46 ++++++++++++++- .../src/assets/icons/general/fullscreen.svg | 48 +++++++++++++++- .../assets/icons/general/search-pdftron.svg | 7 +++ 6 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 apps/red-ui/src/assets/icons/general/search-pdftron.svg diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html index 8c0909e18..cf5ce909b 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html @@ -85,6 +85,7 @@
(); @Output() manualAnnotationRequested = new EventEmitter(); @Output() pageChanged = new EventEmitter(); - + @Output() keyUp = new EventEmitter(); @Output() viewerReady = new EventEmitter(); @ViewChild('viewer', { static: true }) viewer: ElementRef; instance: WebViewerInstance; + private readonly _allowedKeyboardShortcuts = ['+', '-', 'p', 'r', 'Escape']; + constructor( private readonly kc: KeycloakService, private readonly _appStateService: AppStateService, @@ -86,6 +88,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { ).then((instance) => { this.instance = instance; this._disableElements(); + this._disableHotkeys(); this._configureTextPopup(); this._configureAnnotationPopup(); instance.annotManager.on('annotationSelected', (annotationList, action) => { @@ -104,6 +107,22 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { instance.docViewer.on('documentLoaded', this._documentLoaded); + instance.docViewer.on('keyUp', ($event) => { + // arrows and full-screen + if ($event.key.startsWith('Arrow') || $event.key === 'f') { + this._ngZone.run(() => { + this.keyUp.emit($event); + }); + $event.preventDefault(); + $event.stopPropagation(); + } + + if (this._allowedKeyboardShortcuts.indexOf($event.key) < 0) { + $event.preventDefault(); + $event.stopPropagation(); + } + }); + this._loadDocument(); }); } @@ -188,7 +207,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { private _configureTextPopup() { this.instance.textPopup.add({ type: 'actionButton', - img: '/assets/icons/general/search.svg', + img: '/assets/icons/general/search-pdftron.svg', title: this._translateService.instant('pdf-viewer.text-popup.actions.search'), onClick: () => { const text = this.instance.docViewer.getSelectedText(); @@ -352,4 +371,38 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { instanceDisplayMode.mode = 'Single'; this.instance.docViewer.getDisplayModeManager().setDisplayMode(instanceDisplayMode); } + + private _disableHotkeys() { + this.instance.hotkeys.off('CTRL+SHIFT+EQUAL'); + this.instance.hotkeys.off('COMMAND+SHIFT+EQUAL'); + this.instance.hotkeys.off('CTRL+SHIFT+MINUS'); + this.instance.hotkeys.off('COMMAND+SHIFT+MINUS'); + + this.instance.hotkeys.off('CTRL+V'); + this.instance.hotkeys.off('COMMAND+V'); + this.instance.hotkeys.off('CTRL+Y'); + this.instance.hotkeys.off('COMMAND+Y'); + this.instance.hotkeys.off('CTRL+O'); + this.instance.hotkeys.off('COMMAND+O'); + this.instance.hotkeys.off('CTRL+P'); + this.instance.hotkeys.off('COMMAND+P'); + this.instance.hotkeys.off('SPACE'); + + this.instance.hotkeys.off('R'); + this.instance.hotkeys.off('P'); + this.instance.hotkeys.off('A'); + this.instance.hotkeys.off('C'); + this.instance.hotkeys.off('E'); + this.instance.hotkeys.off('F'); + this.instance.hotkeys.off('I'); + this.instance.hotkeys.off('L'); + this.instance.hotkeys.off('N'); + this.instance.hotkeys.off('O'); + this.instance.hotkeys.off('T'); + this.instance.hotkeys.off('S'); + this.instance.hotkeys.off('G'); + this.instance.hotkeys.off('H'); + this.instance.hotkeys.off('K'); + this.instance.hotkeys.off('U'); + } } diff --git a/apps/red-ui/src/assets/icons/general/exit-fullscreen.svg b/apps/red-ui/src/assets/icons/general/exit-fullscreen.svg index 76d9e1da8..fecc0e07d 100644 --- a/apps/red-ui/src/assets/icons/general/exit-fullscreen.svg +++ b/apps/red-ui/src/assets/icons/general/exit-fullscreen.svg @@ -1 +1,45 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/red-ui/src/assets/icons/general/fullscreen.svg b/apps/red-ui/src/assets/icons/general/fullscreen.svg index 9e60d60a9..f618aaa67 100644 --- a/apps/red-ui/src/assets/icons/general/fullscreen.svg +++ b/apps/red-ui/src/assets/icons/general/fullscreen.svg @@ -1 +1,47 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/red-ui/src/assets/icons/general/search-pdftron.svg b/apps/red-ui/src/assets/icons/general/search-pdftron.svg new file mode 100644 index 000000000..1df4c6568 --- /dev/null +++ b/apps/red-ui/src/assets/icons/general/search-pdftron.svg @@ -0,0 +1,7 @@ + + + search + + + +