From f228509e510169b84c61cf42c6a196a57b88e326 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 4 Sep 2024 09:18:57 -0400 Subject: [PATCH] EPUB: PageMapping: Accept any AbstractRange in methods --- src/dom/common/lib/range.ts | 2 +- src/dom/epub/lib/page-mapping.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dom/common/lib/range.ts b/src/dom/common/lib/range.ts index 7dc1d490..4e1945b5 100644 --- a/src/dom/common/lib/range.ts +++ b/src/dom/common/lib/range.ts @@ -15,7 +15,7 @@ export class PersistentRange { endOffset: number; - constructor(range: Range) { + constructor(range: AbstractRange) { this.startContainer = range.startContainer; this.startOffset = range.startOffset; this.endContainer = range.endContainer; diff --git a/src/dom/epub/lib/page-mapping.ts b/src/dom/epub/lib/page-mapping.ts index bac0ad55..8ea2a3cf 100644 --- a/src/dom/epub/lib/page-mapping.ts +++ b/src/dom/epub/lib/page-mapping.ts @@ -138,7 +138,7 @@ class PageMapping { ((new Date().getTime() - startTime) / 1000).toFixed(2)}s`); } - getPageIndex(range: Range): number | null { + getPageIndex(range: AbstractRange): number | null { let pageStartRange = this.tree.getPairOrNextLower(new PersistentRange(range))?.[0]; if (!pageStartRange) { return null; @@ -146,7 +146,7 @@ class PageMapping { return this.tree.keysArray().indexOf(pageStartRange); } - getPageLabel(range: Range): string | null { + getPageLabel(range: AbstractRange): string | null { return this.tree.getPairOrNextLower(new PersistentRange(range))?.[1] ?? null; }