Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
chore(frontend:files): hide editor buttons from pdf viewer
johavene563e4552b14
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-pdf.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-pdf.component.tsindex 02a923ba..27f37910 100644--- a/frontend/src/app/applications/files/components/viewers/files-viewer-pdf.component.ts+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-pdf.component.ts@@ -1,4 +1,4 @@-import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core'+import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, input, ViewChild } from '@angular/core'import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'import { assetsUrl } from '../../files.constants'import { FileModel } from '../../models/file.model'@@ -6,9 +6,10 @@ import { FileModel } from '../../models/file.model'@Component({selector: 'app-files-viewer-pdf',changeDetection: ChangeDetectionStrategy.OnPush,- template: ` <iframe [src]="url()" class="app-viewer-iframe" [style.height.px]="currentHeight()"></iframe> `+ template: ` <iframe #pdfIframe [src]="url()" class="app-viewer-iframe" [style.height.px]="currentHeight()" (load)="onViewerLoaded()"></iframe> `})export class FilesViewerPdfComponent {+ @ViewChild('pdfIframe') pdfIframe: ElementRef<HTMLIFrameElement>file = input.required<FileModel>()currentHeight = input<number>()private readonly sanitizer = inject(DomSanitizer)@@ -16,4 +17,22 @@ export class FilesViewerPdfComponent {url = computed<SafeResourceUrl | null>(() =>this.file() ? this.sanitizer.bypassSecurityTrustResourceUrl(`${this.pdfjsUrl}${this.file().dataUrl}`) : null)++ onViewerLoaded(): void {+ setTimeout(() => this.hideEditorButtons(), 100)+ }++ private hideEditorButtons() {+ const doc = this.pdfIframe?.nativeElement.contentDocument+ if (!doc) return+ doc.querySelector('#downloadButton')?.classList.add('hidden')+ doc.querySelector('#editorModeButtons')?.classList.add('hidden')+ doc.querySelector('#editorModeSeparator')?.classList.add('hidden')+ const secondaryOpenFile = doc.querySelector('#secondaryOpenFile')+ secondaryOpenFile?.classList.add('hidden')+ const separator = secondaryOpenFile?.nextElementSibling?.nextElementSibling+ if (separator?.classList.contains('horizontalToolbarSeparator')) {+ separator.classList.add('hidden')+ }+ }}