RED-10148: Use rectangular text selection mode when space is pressed

This commit is contained in:
Dominique Eifländer 2024-11-13 14:31:28 +01:00
parent bd66f39474
commit 2aa20085b0

View File

@ -158,13 +158,14 @@ export class PdfViewer {
this.pageChanged$ = this.#pageChanged$.pipe(shareDistinctLast());
this.#totalPages$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(pages => this.#totalPages.set(pages));
this.#setSelectionMode();
this.#setSelectionMode(this.#config.SELECTION_MODE);
this.#configureElements();
this.#disableHotkeys();
this.#getSelectedText();
this.#listenForCommandF();
this.#listenForEsc();
this.#clearSearchResultsWhenVisibilityChanged();
this.#listenForSpace();
});
return this.#instance;
@ -287,6 +288,19 @@ export class PdfViewer {
});
}
#listenForSpace() {
this.#instance.UI.hotkeys.on('space', {
keydown: e => {
e.preventDefault();
this.#setSelectionMode('rectangular');
},
keyup: e => {
e.preventDefault();
this.#setSelectionMode('structural');
},
});
}
#getSearchOption(optionId: string): boolean {
const iframeWindow = this.#instance.UI.iframeWindow;
const checkbox = iframeWindow.document.getElementById(optionId) as HTMLInputElement;
@ -348,9 +362,9 @@ export class PdfViewer {
this.#instance.UI.disableElements(USELESS_ELEMENTS);
}
#setSelectionMode(): void {
#setSelectionMode(mode: string): void {
const textTool = this.#instance.Core.Tools.TextTool as unknown as TextTool;
textTool.SELECTION_MODE = this.#config.SELECTION_MODE;
textTool.SELECTION_MODE = mode;
}
#getInstance(htmlElement: HTMLElement) {