From c6f71d3a95528e1faa930091ba99e7f403404abb Mon Sep 17 00:00:00 2001 From: Oleksandr Danylchenko Date: Tue, 3 Sep 2024 21:33:19 +0300 Subject: [PATCH 1/3] Re-hash --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 32b09b26..73647864 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3557,9 +3557,9 @@ } }, "node_modules/openseadragon": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/openseadragon/-/openseadragon-5.0.0.tgz", - "integrity": "sha512-S9aabSjmJg7Jfow1UItR5aXiKQLtkDWyRR5fxLeqT4vSYMvfscXUDfVS9snUN3JuIrHaSPJAlR4H2DYSn5DWRg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/openseadragon/-/openseadragon-4.1.1.tgz", + "integrity": "sha512-owU9gsasAcobLN+LM8lN58Xc2VDSDotY9mkrwS/NB6g9KX/PcusV4RZvhHng2RF/Q0pMziwldf62glwXoGnuzg==", "license": "BSD-3-Clause", "peer": true, "funding": { From 694247dd749fe7a5ec2ef44a0fb1ace5ef0c8316 Mon Sep 17 00:00:00 2001 From: Oleksandr Danylchenko Date: Tue, 3 Sep 2024 21:33:50 +0300 Subject: [PATCH 2/3] Added `pointerdown` capturing on the `document` --- packages/text-annotator/src/SelectionHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/text-annotator/src/SelectionHandler.ts b/packages/text-annotator/src/SelectionHandler.ts index 986383b0..50c7c912 100644 --- a/packages/text-annotator/src/SelectionHandler.ts +++ b/packages/text-annotator/src/SelectionHandler.ts @@ -171,7 +171,7 @@ export const SelectionHandler = ( }); } - container.addEventListener('pointerdown', onPointerDown); + document.addEventListener('pointerdown', onPointerDown); document.addEventListener('pointerup', onPointerUp); if (annotatingEnabled) { @@ -180,7 +180,7 @@ export const SelectionHandler = ( } const destroy = () => { - container.removeEventListener('pointerdown', onPointerDown); + document.removeEventListener('pointerdown', onPointerDown); document.removeEventListener('pointerup', onPointerUp); container.removeEventListener('selectstart', onSelectStart); From ed63ccd0a1d0b176250c6e8dc4706d0d5ad9cb3e Mon Sep 17 00:00:00 2001 From: Oleksandr Danylchenko Date: Tue, 3 Sep 2024 21:34:13 +0300 Subject: [PATCH 3/3] Added ignoring `pointerdown` on `not-annotatable` --- packages/text-annotator/src/SelectionHandler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/text-annotator/src/SelectionHandler.ts b/packages/text-annotator/src/SelectionHandler.ts index 50c7c912..8ae727c3 100644 --- a/packages/text-annotator/src/SelectionHandler.ts +++ b/packages/text-annotator/src/SelectionHandler.ts @@ -116,6 +116,9 @@ export const SelectionHandler = ( // Therefore, to prevent right-click selection, we need to listen // to the initial pointerdown event and remember the button const onPointerDown = (evt: PointerEvent) => { + const annotatable = !(evt.target as Node).parentElement?.closest(NOT_ANNOTATABLE_SELECTOR); + if (!annotatable) return; + // Note that the event itself can be ephemeral! const { target, timeStamp, offsetX, offsetY, type } = evt; lastPointerDown = { ...evt, target, timeStamp, offsetX, offsetY, type }; @@ -125,8 +128,7 @@ export const SelectionHandler = ( const onPointerUp = (evt: PointerEvent) => { const annotatable = !(evt.target as Node).parentElement?.closest(NOT_ANNOTATABLE_SELECTOR); - if (!annotatable || !isLeftClick) - return; + if (!annotatable || !isLeftClick) return; // Logic for selecting an existing annotation by clicking it const clickSelect = () => {