enhance: enhance PDF reading experience. (#12121)

* enhance: enhance PDF reading experience.
- [X] Save zoom in/out scale for next opening
- [X] prevent zoom level reset when window/frame changed. fix for #4402
- [X] add a reset zoom button on the pdf toolbar, it gives an opportunity to user manually reset zoom scale to 'auto', it mimics Zotero PDF reader behavior.
- [X] Support zoom in/out with Meta/CTL + mouse wheel and track pad pinch

* enhance(pdf): allow number or string for last visit scale in debounce function

* enhance(pdf): improve scale conditions for the wheel event

---------

Co-authored-by: charlie <xyhp915@qq.com>
This commit is contained in:
An Li
2025-10-04 19:35:17 +08:00
committed by GitHub
parent 846f9307c3
commit 584b980a97
4 changed files with 160 additions and 73 deletions

View File

@@ -2,7 +2,6 @@
(:require ["/frontend/extensions/pdf/utils" :as js-utils]
[cljs-bean.core :as bean]
[clojure.string :as string]
[frontend.util :as util]
[logseq.common.uuid :as common-uuid]
[promesa.core :as p]))
@@ -109,10 +108,13 @@
([^js win]
(some-> win (.getSelection) (.removeAllRanges))))
(def adjust-viewer-size!
(util/debounce
(fn [^js viewer] (set! (. viewer -currentScaleValue) "auto"))
200))
(defn adjust-viewer-size!
[^js viewer]
(let [bus (.-eventBus viewer)]
(.dispatch bus "resizing")))
(defn reset-viewer-auto! [^js viewer]
(set! (. viewer -currentScaleValue) "auto"))
(defn fix-nested-js
[its]