Skip to content

Commit

Permalink
enhance(ux): alt key for the pdf highlight mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 committed Jul 29, 2024
1 parent 940e95c commit aafa4f4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/frontend/extensions/pdf/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@

(let [*el (rum/use-ref nil)
^js cnt (.-container viewer)
^js body (some-> (.-ownerDocument cnt) (.-body))
key-alt? (= (some-> body (.-dataset) (.-activeKeystroke)) "Alt")
head-height 0 ;; 48 temp
top (- (+ (:y point) (.-scrollTop cnt)) head-height)
left (+ (:x point) (.-scrollLeft cnt))
id (:id highlight)
new? (nil? id)
new-&-highlight-mode? (and @*highlight-mode? new?)
show-ctx-menu? (and (not new-&-highlight-mode?)
(or (not selection) (and selection (state/sub :pdf/auto-open-ctx-menu?))))
(or (not selection) (and selection (or (state/sub :pdf/auto-open-ctx-menu?) key-alt?))))
content (:content highlight)
area? (not (string/blank? (:image content)))
action-fn! (fn [action clear?]
Expand Down Expand Up @@ -692,13 +694,13 @@
;; hl context tip menu
(when-let [_hl (:highlight ctx-menu-state)]
(js/ReactDOM.createPortal
(pdf-highlights-ctx-menu viewer ctx-menu-state
{:clear-ctx-menu! clear-ctx-menu!
:add-hl! add-hl!
:del-hl! del-hl!
:upd-hl! upd-hl!})
(pdf-highlights-ctx-menu viewer ctx-menu-state
{:clear-ctx-menu! clear-ctx-menu!
:add-hl! add-hl!
:del-hl! del-hl!
:upd-hl! upd-hl!})

(.querySelector el ".pp-holder")))
(.querySelector el ".pp-holder")))

;; debug highlights anchor
;;(if (seq highlights)
Expand Down

0 comments on commit aafa4f4

Please sign in to comment.