RED-10148: fixed text selection; implemented key listener for shift.
This commit is contained in:
parent
b7c820e87c
commit
2632675cbe
@ -78,7 +78,7 @@ export class REDDocumentViewer {
|
|||||||
}
|
}
|
||||||
return ($event.target as HTMLElement)?.tagName?.toLowerCase() !== 'input';
|
return ($event.target as HTMLElement)?.tagName?.toLowerCase() !== 'input';
|
||||||
}),
|
}),
|
||||||
filter($event => $event.key.startsWith('Arrow') || ['f', 'h', 'H', 'Escape'].includes($event.key)),
|
filter($event => $event.key.startsWith('Arrow') || ['f', 'h', 'H', 'Escape', 'Shift'].includes($event.key)),
|
||||||
tap<KeyboardEvent>(stopAndPrevent),
|
tap<KeyboardEvent>(stopAndPrevent),
|
||||||
log('[PDF] Keyboard shortcut'),
|
log('[PDF] Keyboard shortcut'),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { UserPreferenceService } from '@users/user-preference.service';
|
|||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
import { combineLatest, fromEvent, Observable } from 'rxjs';
|
import { combineLatest, fromEvent, Observable } from 'rxjs';
|
||||||
import { map, startWith } from 'rxjs/operators';
|
import { map, startWith } from 'rxjs/operators';
|
||||||
import { DISABLED_HOTKEYS, DOCUMENT_LOADING_ERROR, USELESS_ELEMENTS } from '../utils/constants';
|
import { DISABLED_HOTKEYS, DOCUMENT_LOADING_ERROR, SelectionModes, USELESS_ELEMENTS } from '../utils/constants';
|
||||||
import { asList } from '../utils/functions';
|
import { asList } from '../utils/functions';
|
||||||
import { Rgb } from '../utils/types';
|
import { Rgb } from '../utils/types';
|
||||||
import { REDAnnotationManager } from './annotation-manager.service';
|
import { REDAnnotationManager } from './annotation-manager.service';
|
||||||
@ -160,12 +160,13 @@ export class PdfViewer {
|
|||||||
|
|
||||||
this.pageChanged$ = this.#pageChanged$.pipe(shareDistinctLast());
|
this.pageChanged$ = this.#pageChanged$.pipe(shareDistinctLast());
|
||||||
this.#totalPages$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(pages => this.#totalPages.set(pages));
|
this.#totalPages$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(pages => this.#totalPages.set(pages));
|
||||||
this.#setSelectionMode();
|
this.#setSelectionMode(this.#config.SELECTION_MODE);
|
||||||
this.#configureElements();
|
this.#configureElements();
|
||||||
this.#disableHotkeys();
|
this.#disableHotkeys();
|
||||||
this.#getSelectedText();
|
this.#getSelectedText();
|
||||||
this.#listenForCommandF();
|
this.#listenForCommandF();
|
||||||
this.#listenForEsc();
|
this.#listenForEsc();
|
||||||
|
this.#listenForShift();
|
||||||
this.#clearSearchResultsWhenVisibilityChanged();
|
this.#clearSearchResultsWhenVisibilityChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -258,7 +259,7 @@ 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: KeyboardEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.#isElementActive('searchPanel')) {
|
if (this.#isElementActive('searchPanel')) {
|
||||||
this.#updateSearchOptions();
|
this.#updateSearchOptions();
|
||||||
@ -274,11 +275,11 @@ export class PdfViewer {
|
|||||||
|
|
||||||
#listenForEsc() {
|
#listenForEsc() {
|
||||||
this.#instance.UI.hotkeys.on('esc', {
|
this.#instance.UI.hotkeys.on('esc', {
|
||||||
keydown: e => {
|
keydown: (e: KeyboardEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.#clickSelectToolButton();
|
this.#clickSelectToolButton();
|
||||||
},
|
},
|
||||||
keyup: e => {
|
keyup: (e: KeyboardEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.#isElementActive('searchPanel') && !this._annotationManager.resizingAnnotationId) {
|
if (this.#isElementActive('searchPanel') && !this._annotationManager.resizingAnnotationId) {
|
||||||
this.#focusViewer();
|
this.#focusViewer();
|
||||||
@ -289,6 +290,21 @@ export class PdfViewer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#listenForShift() {
|
||||||
|
this.#instance.UI.iframeWindow.addEventListener('keydown', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (e.key === 'Shift') {
|
||||||
|
this.#setSelectionMode(SelectionModes.RECTANGULAR);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.#instance.UI.iframeWindow.addEventListener('keyup', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (e.key === 'Shift') {
|
||||||
|
this.#setSelectionMode(SelectionModes.STRUCTURAL);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#getSearchOption(optionId: string): boolean {
|
#getSearchOption(optionId: string): boolean {
|
||||||
const iframeWindow = this.#instance.UI.iframeWindow;
|
const iframeWindow = this.#instance.UI.iframeWindow;
|
||||||
const checkbox = iframeWindow.document.getElementById(optionId) as HTMLInputElement;
|
const checkbox = iframeWindow.document.getElementById(optionId) as HTMLInputElement;
|
||||||
@ -350,9 +366,9 @@ export class PdfViewer {
|
|||||||
this.#instance.UI.disableElements(USELESS_ELEMENTS);
|
this.#instance.UI.disableElements(USELESS_ELEMENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#setSelectionMode(): void {
|
#setSelectionMode(selectionMode: string): void {
|
||||||
const textTool = this.#instance.Core.Tools.TextTool as unknown as TextTool;
|
const textTool = this.#instance.Core.Tools.TextTool as unknown as TextTool;
|
||||||
textTool.SELECTION_MODE = this.#config.SELECTION_MODE;
|
textTool.SELECTION_MODE = selectionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
#getInstance(htmlElement: HTMLElement) {
|
#getInstance(htmlElement: HTMLElement) {
|
||||||
|
|||||||
@ -87,3 +87,8 @@ export const DISABLED_HOTKEYS = [
|
|||||||
export const AnnotationToolNames = {
|
export const AnnotationToolNames = {
|
||||||
AnnotationCreateRectangle: 'AnnotationCreateRectangle',
|
AnnotationCreateRectangle: 'AnnotationCreateRectangle',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const SelectionModes = {
|
||||||
|
RECTANGULAR: 'rectangular',
|
||||||
|
STRUCTURAL: 'structural',
|
||||||
|
} as const;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ADMIN_CONTACT_NAME": null,
|
"ADMIN_CONTACT_NAME": null,
|
||||||
"ADMIN_CONTACT_URL": null,
|
"ADMIN_CONTACT_URL": null,
|
||||||
"API_URL": "https://maverick2.iqser.cloud",
|
"API_URL": "https://dan1.iqser.cloud",
|
||||||
"APP_NAME": "RedactManager",
|
"APP_NAME": "RedactManager",
|
||||||
"IS_DOCUMINE": false,
|
"IS_DOCUMINE": false,
|
||||||
"RULE_EDITOR_DEV_ONLY": false,
|
"RULE_EDITOR_DEV_ONLY": false,
|
||||||
@ -13,7 +13,7 @@
|
|||||||
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
||||||
"OAUTH_CLIENT_ID": "redaction",
|
"OAUTH_CLIENT_ID": "redaction",
|
||||||
"OAUTH_IDP_HINT": null,
|
"OAUTH_IDP_HINT": null,
|
||||||
"OAUTH_URL": "https://maverick2.iqser.cloud/auth",
|
"OAUTH_URL": "https://dan1.iqser.cloud/auth",
|
||||||
"RECENT_PERIOD_IN_HOURS": 24,
|
"RECENT_PERIOD_IN_HOURS": 24,
|
||||||
"SELECTION_MODE": "structural",
|
"SELECTION_MODE": "structural",
|
||||||
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
|
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user