Enhance/PDF viewer (#7369)

* fix(pdf): WIP potential memory leaks
* enhance(pdf): sync page number in highlights metafile
* enhance(pdf): support preview highlight area image in a lightbox
* fix: clojurescript unit tests
* fix(pdf): page number overflow when more digits
This commit is contained in:
Charlie
2022-11-17 20:31:08 +08:00
committed by GitHub
parent a6f6b0abae
commit dd2ef163ba
12 changed files with 208 additions and 115 deletions

View File

@@ -61,6 +61,7 @@
[frontend.util.drawer :as drawer]
[frontend.util.property :as property]
[frontend.util.text :as text-util]
[frontend.handler.notification :as notification]
[goog.dom :as gdom]
[goog.object :as gobj]
[lambdaisland.glogi :as log]
@@ -264,14 +265,6 @@
(when (seq images)
(lightbox/preview-images! images))))
(defn copy-image-to-clipboard
[src]
(-> (js/fetch src)
(.then (fn [data]
(-> (.blob data)
(.then (fn [blob]
(js/navigator.clipboard.write (clj->js [(js/ClipboardItem. (clj->js {(.-type blob) blob}))])))))))))
(defonce *resizing-image? (atom false))
(rum/defcs resizable-image <
(rum/local nil ::size)
@@ -353,12 +346,13 @@
(ui/icon "trash")]
[:button.asset-action-btn
{:title (t :asset/copy)
:tabIndex "-1"
{:title (t :asset/copy)
:tabIndex "-1"
:on-mouse-down util/stop
:on-click (fn [e]
(util/stop e)
(copy-image-to-clipboard image-src))}
:on-click (fn [e]
(util/stop e)
(-> (util/copy-image-to-clipboard image-src)
(p/then #(notification/show! "Copied!" :success))))}
(ui/icon "copy")]
[:button.asset-action-btn
@@ -1045,7 +1039,7 @@
[:a.asset-ref.is-pdf
{:on-mouse-down (fn [_event]
(when-let [current (pdf-assets/inflate-asset s)]
(state/set-state! :pdf/current current)))}
(state/set-current-pdf! current)))}
(or label-text
(->elem :span (map-inline config label)))]