From 1fef33731fe35c8c0cdae60016517b3ecee4e5c9 Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Wed, 8 Mar 2023 11:02:17 +0000 Subject: [PATCH] Add methods for clearing selections --- paginator.js | 4 ++++ view.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/paginator.js b/paginator.js index 87cee8d..e9c0063 100644 --- a/paginator.js +++ b/paginator.js @@ -653,6 +653,10 @@ export class Paginator { const $style = this.#styleMap.get(this.#view?.document) if ($style) $style.textContent = style } + deselect() { + const sel = this.#view.document.defaultView.getSelection() + sel.removeAllRanges() + } async #setAnchor(anchor, select) { this.#anchor = anchor await this.#scrollToAnchor(select) diff --git a/view.js b/view.js index bcec969..1fc1292 100644 --- a/view.js +++ b/view.js @@ -280,6 +280,9 @@ export class View { console.error(`Could not go to ${target}`) } } + deselect() { + return this.renderer?.deselect() + } async getTOCItemOf(target) { try { const { index, anchor } = await this.resolveNavigation(target)