mirror of https://github.com/logseq/logseq
fix: shift-select up
parent
442b65d210
commit
39e2f0ac1c
|
@ -367,7 +367,7 @@
|
|||
(and block-id (parse-uuid block-id))
|
||||
(let [block (.closest target ".ls-block")]
|
||||
(when block
|
||||
(util/select-highlight! [block]))
|
||||
(state/conj-selection-block! block :down))
|
||||
(common-handler/show-custom-context-menu!
|
||||
e
|
||||
(block-context-menu-content target (uuid block-id))))
|
||||
|
|
|
@ -204,7 +204,6 @@
|
|||
|
||||
(defn clear-selection!
|
||||
[]
|
||||
(util/select-unhighlight! (dom/by-class "selected"))
|
||||
(state/clear-selection!))
|
||||
|
||||
(defn- text-range-by-lst-fst-line [content [direction pos]]
|
||||
|
@ -1222,8 +1221,7 @@
|
|||
|
||||
(defn clear-last-selected-block!
|
||||
[]
|
||||
(let [block (state/drop-last-selection-block!)]
|
||||
(util/select-unhighlight! [block])))
|
||||
(state/drop-last-selection-block!))
|
||||
|
||||
(defn highlight-selection-area!
|
||||
[end-block]
|
||||
|
@ -1238,18 +1236,18 @@
|
|||
(defn- select-block-up-down
|
||||
[direction]
|
||||
(cond
|
||||
;; when editing, quit editing and select current block
|
||||
;; when editing, quit editing and select current block
|
||||
(state/editing?)
|
||||
(state/exit-editing-and-set-selected-blocks! [(gdom/getElement (state/get-editing-block-dom-id))])
|
||||
|
||||
;; when selection and one block selected, select next block
|
||||
;; when selection and one block selected, select next block
|
||||
(and (state/selection?) (== 1 (count (state/get-selection-blocks))))
|
||||
(let [f (if (= :up direction) util/get-prev-block-non-collapsed util/get-next-block-non-collapsed-skip)
|
||||
element (f (first (state/get-selection-blocks)))]
|
||||
(when element
|
||||
(state/conj-selection-block! element direction)))
|
||||
|
||||
;; if same direction, keep conj on same direction
|
||||
;; if same direction, keep conj on same direction
|
||||
(and (state/selection?) (= direction (state/get-selection-direction)))
|
||||
(let [f (if (= :up direction) util/get-prev-block-non-collapsed util/get-next-block-non-collapsed-skip)
|
||||
first-last (if (= :up direction) first last)
|
||||
|
@ -1257,7 +1255,7 @@
|
|||
(when element
|
||||
(state/conj-selection-block! element direction)))
|
||||
|
||||
;; if different direction, keep clear until one left
|
||||
;; if different direction, keep clear until one left
|
||||
(state/selection?)
|
||||
(clear-last-selected-block!))
|
||||
nil)
|
||||
|
|
|
@ -715,7 +715,6 @@
|
|||
|
||||
(defn conj-selection-block!
|
||||
[block direction]
|
||||
(dom/add-class! block "selected noselect")
|
||||
(swap! state assoc
|
||||
:selection/mode true
|
||||
:selection/blocks (-> (conj (vec (:selection/blocks @state)) block)
|
||||
|
@ -724,10 +723,18 @@
|
|||
|
||||
(defn drop-last-selection-block!
|
||||
[]
|
||||
(let [last-block (peek (vec (:selection/blocks @state)))]
|
||||
(let [direction (:selection/direction @state)
|
||||
up? (= direction :up)
|
||||
blocks (:selection/blocks @state)
|
||||
last-block (if up?
|
||||
(first blocks)
|
||||
(peek (vec blocks)))
|
||||
blocks' (if up?
|
||||
(rest blocks)
|
||||
(pop (vec blocks)))]
|
||||
(swap! state assoc
|
||||
:selection/mode true
|
||||
:selection/blocks (pop (vec (:selection/blocks @state))))
|
||||
:selection/blocks blocks')
|
||||
last-block))
|
||||
|
||||
(defn get-selection-direction
|
||||
|
|
|
@ -1075,18 +1075,6 @@
|
|||
(= (get-relative-path "a/b/c/d/g.org" "a/b/c/e/f.org")
|
||||
"../e/f.org"))
|
||||
|
||||
#?(:cljs
|
||||
(defn select-highlight!
|
||||
[blocks]
|
||||
(doseq [block blocks]
|
||||
(d/add-class! block "selected noselect"))))
|
||||
|
||||
#?(:cljs
|
||||
(defn select-unhighlight!
|
||||
[blocks]
|
||||
(doseq [block blocks]
|
||||
(d/remove-class! block "selected" "noselect"))))
|
||||
|
||||
(defn keyname [key] (str (namespace key) "/" (name key)))
|
||||
|
||||
(defn batch [in max-time handler buf-atom]
|
||||
|
|
Loading…
Reference in New Issue