RED-7605: fixed search for marked word.
This commit is contained in:
parent
44515e9f23
commit
1b99ce9dfa
@ -358,11 +358,12 @@ export class FilePreviewScreenComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (['Escape'].includes($event.key)) {
|
if (['Escape'].includes($event.key)) {
|
||||||
|
$event.preventDefault();
|
||||||
this.fullScreen = false;
|
this.fullScreen = false;
|
||||||
this.closeFullScreen();
|
this.closeFullScreen();
|
||||||
this.pdf.deactivateSearch();
|
this.pdf.deactivateSearch();
|
||||||
|
this.pdf.focusViewer();
|
||||||
this._changeRef.markForCheck();
|
this._changeRef.markForCheck();
|
||||||
window.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['f', 'F'].includes($event.key) && !$event.ctrlKey) {
|
if (['f', 'F'].includes($event.key) && !$event.ctrlKey) {
|
||||||
|
|||||||
@ -102,23 +102,19 @@ export class PdfViewer {
|
|||||||
return page$.pipe(map(page => this.#adjustPage(page)));
|
return page$.pipe(map(page => this.#adjustPage(page)));
|
||||||
}
|
}
|
||||||
|
|
||||||
focusSearch() {
|
|
||||||
const iframeWindow = this.#instance.UI.iframeWindow;
|
|
||||||
const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement;
|
|
||||||
if (input) {
|
|
||||||
input.focus();
|
|
||||||
input.select();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
activateSearch() {
|
activateSearch() {
|
||||||
this.#instance.UI.openElements(['searchPanel']);
|
this.#instance.UI.openElements(['searchPanel']);
|
||||||
}
|
}
|
||||||
|
|
||||||
deactivateSearch() {
|
deactivateSearch() {
|
||||||
|
this.#clearSearchResultsWhenVisibilityChanged();
|
||||||
this.#instance.UI.closeElements(['searchPanel']);
|
this.#instance.UI.closeElements(['searchPanel']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focusViewer() {
|
||||||
|
this.instance.UI.iframeWindow.focus();
|
||||||
|
}
|
||||||
|
|
||||||
resetAnnotationActions() {
|
resetAnnotationActions() {
|
||||||
if (this.#instance.UI.annotationPopup.getItems().length) {
|
if (this.#instance.UI.annotationPopup.getItems().length) {
|
||||||
this.#instance.UI.annotationPopup.update([]);
|
this.#instance.UI.annotationPopup.update([]);
|
||||||
@ -258,7 +254,8 @@ export class PdfViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#searchForSelectedText() {
|
#searchForSelectedText() {
|
||||||
this.#instance.UI.searchTextFull(this.documentViewer.getSelectedText(), SEARCH_OPTIONS);
|
const selected = [...new Set(this.documentViewer.getSelectedText().split('\n'))].join('\n');
|
||||||
|
this.#instance.UI.searchTextFull(selected, SEARCH_OPTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#clearSearchResultsWhenVisibilityChanged() {
|
#clearSearchResultsWhenVisibilityChanged() {
|
||||||
@ -281,8 +278,13 @@ export class PdfViewer {
|
|||||||
#listenForCommandF() {
|
#listenForCommandF() {
|
||||||
this.#instance.UI.hotkeys.on('command+f, ctrl+f', e => {
|
this.#instance.UI.hotkeys.on('command+f, ctrl+f', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.activateSearch();
|
if (!this.#isElementActive('searchPanel')) {
|
||||||
this.focusSearch();
|
this.activateSearch();
|
||||||
|
}
|
||||||
|
if (this.documentViewer.getSelectedText()) {
|
||||||
|
this.#searchForSelectedText();
|
||||||
|
}
|
||||||
|
setTimeout(() => this.#focusSearch(), 250);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,4 +319,22 @@ export class PdfViewer {
|
|||||||
|
|
||||||
return WebViewer(options, htmlElement);
|
return WebViewer(options, htmlElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#isElementActive(element: string): boolean {
|
||||||
|
return this.#instance.UI.isElementOpen(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
#focusSearch() {
|
||||||
|
if (this.#isElementActive('textPopup')) {
|
||||||
|
this.#instance.UI.closeElements(['textPopup']);
|
||||||
|
}
|
||||||
|
const iframeWindow = this.#instance.UI.iframeWindow;
|
||||||
|
const input = iframeWindow.document.getElementById('SearchPanel__input') as HTMLInputElement;
|
||||||
|
if (input) {
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
if (input.value.length > 0) {
|
||||||
|
input.select();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user