Fixhancement: restore search highlighting and add for built-in viewer (#8885)

This commit is contained in:
shamoon
2025-01-23 15:00:46 -08:00
committed by GitHub
parent 6c34e37838
commit 18c4e6029f
6 changed files with 90 additions and 44 deletions

View File

@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http'
import { Component, Input, OnDestroy, ViewChild } from '@angular/core'
import { NgbPopover, NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'
import { PdfViewerModule } from 'ng2-pdf-viewer'
import { PdfViewerComponent, PdfViewerModule } from 'ng2-pdf-viewer'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { first, Subject, takeUntil } from 'rxjs'
import { Document } from 'src/app/data/document'
@@ -57,6 +57,8 @@ export class PreviewPopupComponent implements OnDestroy {
@ViewChild('popover') popover: NgbPopover
@ViewChild('pdfViewer') pdfViewer: PdfViewerComponent
mouseOnPreview: boolean = false
popoverClass: string = 'shadow popover-preview'
@@ -114,6 +116,18 @@ export class PreviewPopupComponent implements OnDestroy {
}
}
onPageRendered() {
// Only triggered by the pngx pdf viewer
if (this.documentService.searchQuery) {
this.pdfViewer.eventBus.dispatch('find', {
query: this.documentService.searchQuery,
caseSensitive: false,
highlightAll: true,
phraseSearch: true,
})
}
}
get previewUrl() {
return this.documentService.getPreviewUrl(this.document.id)
}