From d6f3b86d3f3aa5131f2bbfafc374a65b39c72c10 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 6 Feb 2023 11:36:03 +0200 Subject: [PATCH] RED-5919 - WIP on "Tooltip for first annotation action shown without hovering" --- .../services/annotation-manager.service.ts | 37 +++++++++++++++++-- .../services/webviewer-loaded.guard.ts | 2 +- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts index 9f1943edf..0e81af9da 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Core } from '@pdftron/webviewer'; +import { Core, WebViewerInstance } from '@pdftron/webviewer'; import type { List } from '@iqser/common-ui'; import { AnnotationPredicate, DeleteAnnotationsOptions } from '../utils/types'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; @@ -16,6 +16,7 @@ export class REDAnnotationManager { readonly hidden = new Set(); #manager: AnnotationManager; + #instance; get selected() { return this.#manager.getSelectedAnnotations(); @@ -27,13 +28,43 @@ export class REDAnnotationManager { get #annotationSelected$() { const onSelect$ = fromEvent<[Annotation[], string]>(this.#manager, 'annotationSelected'); - return onSelect$.pipe(tap(value => console.log('Annotation selected: ', value))); + + // this.#instance.disableElements(['tooltip']); + // this.#instance.enableElements(['tooltip']); + + // setTimeout(() => { + // this.#instance.enableElements(['tooltip']); + // }, 500); + + return onSelect$.pipe( + tap(value => { + console.log('Annotation selected: ', value); + + this.#instance.disableElements(['tooltip']); + // this.#instance.disableElements(['tooltip']); + // this.#instance.enableElements(['tooltip']); + setTimeout(() => { + this.#instance.enableElements(['tooltip']); + }, 500); + }), + ); } - init(annotationManager: AnnotationManager) { + init(annotationManager: AnnotationManager, instance: WebViewerInstance) { this.#manager = annotationManager; + this.#instance = instance; this.annotationSelected$ = this.#annotationSelected$; this.#autoSelectRectangleAfterCreation(); + + // this.#manager.addEventListener('annotationSelected', (annotations, action) => { + // console.log('action: ', action); + // if (action === 'selected') { + // this.#instance.disableElements(['tooltip']); + // setTimeout(() => { + // this.#instance.enableElements(['tooltip']); + // }, 1000); + // } + // }); } isHidden(annotationId: string) { diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/webviewer-loaded.guard.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/webviewer-loaded.guard.ts index 9ce46809e..7b0e84735 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/webviewer-loaded.guard.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/webviewer-loaded.guard.ts @@ -24,7 +24,7 @@ export class WebViewerLoadedGuard implements CanActivate { this._loadingService.start(); const instance = await this._pdf.init(document.getElementById('viewer')); - this._annotationManager.init(instance.Core.annotationManager); + this._annotationManager.init(instance.Core.annotationManager, instance); this._documentViewer.init(instance.Core.documentViewer); this._viewerHeaderService.init();