mirror of https://github.com/logseq/logseq
support mod+shift+left-click
parent
cba1150e1a
commit
aaf856e803
|
@ -2156,24 +2156,28 @@
|
||||||
shift? (gobj/get e "shiftKey")
|
shift? (gobj/get e "shiftKey")
|
||||||
meta? (util/meta-key? e)
|
meta? (util/meta-key? e)
|
||||||
forbidden-edit? (target-forbidden-edit? target)]
|
forbidden-edit? (target-forbidden-edit? target)]
|
||||||
(when-not forbidden-edit? (.stopPropagation e))
|
(when (and (not forbidden-edit?) (contains? #{1 0} button))
|
||||||
(if (and meta?
|
(util/stop-propagation e)
|
||||||
(not (state/get-edit-input-id))
|
(let [selection-blocks (state/get-selection-blocks)
|
||||||
(not (dom/has-class? target "page-ref"))
|
starting-block (state/get-selection-start-block-or-first)]
|
||||||
(not= "A" (gobj/get target "tagName")))
|
(cond
|
||||||
|
(and meta? shift?)
|
||||||
|
(when-not (empty? selection-blocks)
|
||||||
|
(util/stop e)
|
||||||
|
(editor-handler/highlight-selection-area! block-id true))
|
||||||
|
|
||||||
|
meta?
|
||||||
(do
|
(do
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
(let [block-dom-element (gdom/getElement block-id)]
|
(let [block-dom-element (gdom/getElement block-id)]
|
||||||
(if (some #(= block-dom-element %) (state/get-selection-blocks))
|
(if (some #(= block-dom-element %) selection-blocks)
|
||||||
(state/drop-selection-block! block-dom-element)
|
(state/drop-selection-block! block-dom-element)
|
||||||
(state/conj-selection-block! block-dom-element :down)))
|
(state/conj-selection-block! block-dom-element :down)))
|
||||||
(if (empty? (state/get-selection-blocks))
|
(if (empty? (state/get-selection-blocks))
|
||||||
(state/clear-selection!)
|
(state/clear-selection!)
|
||||||
(state/set-selection-start-block! block-id)))
|
(state/set-selection-start-block! block-id)))
|
||||||
(when (contains? #{1 0} button)
|
|
||||||
(when-not forbidden-edit?
|
(and shift? starting-block)
|
||||||
(cond
|
|
||||||
(and shift? (state/get-selection-start-block-or-first))
|
|
||||||
(do
|
(do
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
(util/clear-selection!)
|
(util/clear-selection!)
|
||||||
|
@ -2211,7 +2215,7 @@
|
||||||
(f)
|
(f)
|
||||||
(js/setTimeout f 5))
|
(js/setTimeout f 5))
|
||||||
|
|
||||||
(when block-id (state/set-selection-start-block! block-id)))))))))))
|
(state/set-selection-start-block! block-id)))))))))
|
||||||
|
|
||||||
(rum/defc dnd-separator-wrapper < rum/reactive
|
(rum/defc dnd-separator-wrapper < rum/reactive
|
||||||
[block block-id slide? top? block-content?]
|
[block block-id slide? top? block-content?]
|
||||||
|
|
|
@ -1226,14 +1226,19 @@
|
||||||
(delete-block-aux! block true))))
|
(delete-block-aux! block true))))
|
||||||
|
|
||||||
(defn highlight-selection-area!
|
(defn highlight-selection-area!
|
||||||
[end-block]
|
([end-block]
|
||||||
|
(highlight-selection-area! end-block false))
|
||||||
|
([end-block append?]
|
||||||
(when-let [start-block (state/get-selection-start-block-or-first)]
|
(when-let [start-block (state/get-selection-start-block-or-first)]
|
||||||
(let [blocks (util/get-nodes-between-two-nodes start-block end-block "ls-block")
|
(let [blocks (util/get-nodes-between-two-nodes start-block end-block "ls-block")
|
||||||
direction (util/get-direction-between-two-nodes start-block end-block "ls-block")
|
direction (util/get-direction-between-two-nodes start-block end-block "ls-block")
|
||||||
blocks (if (= :up direction)
|
blocks (if (= :up direction)
|
||||||
(reverse blocks)
|
(reverse blocks)
|
||||||
blocks)]
|
blocks)]
|
||||||
(state/exit-editing-and-set-selected-blocks! blocks direction))))
|
(if append?
|
||||||
|
(do (state/clear-edit!)
|
||||||
|
(state/conj-selection-block! blocks direction))
|
||||||
|
(state/exit-editing-and-set-selected-blocks! blocks direction))))))
|
||||||
|
|
||||||
(defn- select-block-up-down
|
(defn- select-block-up-down
|
||||||
[direction]
|
[direction]
|
||||||
|
|
|
@ -1042,19 +1042,24 @@ Similar to re-frame subscriptions"
|
||||||
(and (in-selection-mode?) (seq (get-selection-blocks))))
|
(and (in-selection-mode?) (seq (get-selection-blocks))))
|
||||||
|
|
||||||
(defn conj-selection-block!
|
(defn conj-selection-block!
|
||||||
[block direction]
|
[block-or-blocks direction]
|
||||||
|
(let [selection-blocks (get-selection-blocks)
|
||||||
|
blocks (-> (if (sequential? block-or-blocks)
|
||||||
|
(apply conj selection-blocks block-or-blocks)
|
||||||
|
(conj selection-blocks block-or-blocks))
|
||||||
|
distinct
|
||||||
|
util/sort-by-height
|
||||||
|
vec)]
|
||||||
(swap! state assoc
|
(swap! state assoc
|
||||||
:selection/mode true
|
:selection/mode true
|
||||||
:selection/blocks (-> (conj (vec (:selection/blocks @state)) block)
|
:selection/blocks blocks
|
||||||
util/sort-by-height
|
:selection/direction direction)))
|
||||||
vec)
|
|
||||||
:selection/direction direction))
|
|
||||||
|
|
||||||
(defn drop-selection-block!
|
(defn drop-selection-block!
|
||||||
[block]
|
[block]
|
||||||
(swap! state assoc
|
(swap! state assoc
|
||||||
:selection/mode true
|
:selection/mode true
|
||||||
:selection/blocks (-> (filter #(not= block %) (get-selection-blocks))
|
:selection/blocks (-> (remove #(= block %) (get-selection-blocks))
|
||||||
util/sort-by-height
|
util/sort-by-height
|
||||||
vec)))
|
vec)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue