From 1c7fa23e4e3114335f2a1e1ec8391798bc1a9ce6 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 13 Nov 2024 15:47:48 -0500 Subject: [PATCH] Fix EPUB find annotation shortcuts --- src/dom/epub/find.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dom/epub/find.ts b/src/dom/epub/find.ts index a5dcfd34..8dcfb3e9 100644 --- a/src/dom/epub/find.ts +++ b/src/dom/epub/find.ts @@ -165,13 +165,17 @@ export class EPUBFindProcessor implements FindProcessor { let index = 0; let foundSelected = false; let snippets = []; + let range: PersistentRange | undefined; for (let processor of this._processors) { if (!processor) { continue; } if (this._selectedProcessor == processor) { - index += processor.position ?? 0; + let position = processor.position ?? 0; + index += position; foundSelected = true; + // TODO: Expose this in a nicer way + range = processor.getAnnotations()[position]?.range; } else if (!foundSelected) { index += processor.getResults().length; @@ -182,6 +186,7 @@ export class EPUBFindProcessor implements FindProcessor { total: this._totalResults, index, snippets, + range, }); } }