mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
enhance(ux): shift select after esc
This commit is contained in:
@@ -281,7 +281,7 @@
|
||||
(p/let [_ (draw/create-draw-with-default-content path)]
|
||||
(println "draw file created, " path))
|
||||
text)) "Draw a graph with Excalidraw"]
|
||||
|
||||
|
||||
["Embed HTML " (->inline "html")]
|
||||
|
||||
["Embed Video URL" [[:editor/input "{{video }}" {:last-pattern (state/get-editor-command-trigger)
|
||||
@@ -405,25 +405,26 @@
|
||||
:as _option}]
|
||||
(let [selected? (not (string/blank? selected))
|
||||
input (gdom/getElement id)
|
||||
edit-content (gobj/get input "value")
|
||||
current-pos (cursor/pos input)
|
||||
prefix (subs edit-content 0 current-pos)
|
||||
postfix (if selected?
|
||||
(string/replace-first (subs edit-content current-pos)
|
||||
selected
|
||||
"")
|
||||
(subs edit-content current-pos))
|
||||
new-value (str prefix value postfix)
|
||||
new-pos (- (+ (count prefix)
|
||||
(count value)
|
||||
(or forward-pos 0))
|
||||
(or backward-pos 0))]
|
||||
(state/set-block-content-and-last-pos! id new-value new-pos)
|
||||
(cursor/move-cursor-to input new-pos)
|
||||
(when selected?
|
||||
(.setSelectionRange input new-pos (+ new-pos (count selected))))
|
||||
(when check-fn
|
||||
(check-fn new-value (dec (count prefix))))))
|
||||
edit-content (gobj/get input "value")]
|
||||
(when-not (string/blank? edit-content)
|
||||
(let [current-pos (cursor/pos input)
|
||||
prefix (subs edit-content 0 current-pos)
|
||||
postfix (if selected?
|
||||
(string/replace-first (subs edit-content current-pos)
|
||||
selected
|
||||
"")
|
||||
(subs edit-content current-pos))
|
||||
new-value (str prefix value postfix)
|
||||
new-pos (- (+ (count prefix)
|
||||
(count value)
|
||||
(or forward-pos 0))
|
||||
(or backward-pos 0))]
|
||||
(state/set-block-content-and-last-pos! id new-value new-pos)
|
||||
(cursor/move-cursor-to input new-pos)
|
||||
(when selected?
|
||||
(.setSelectionRange input new-pos (+ new-pos (count selected))))
|
||||
(when check-fn
|
||||
(check-fn new-value (dec (count prefix))))))))
|
||||
|
||||
(defn delete-pair!
|
||||
[id]
|
||||
|
||||
@@ -1927,7 +1927,7 @@
|
||||
(when (contains? #{1 0} button)
|
||||
(when-not (target-forbidden-edit? target)
|
||||
(cond
|
||||
(and shift? (state/get-selection-start-block))
|
||||
(and shift? (state/get-selection-start-block-or-first))
|
||||
(editor-handler/highlight-selection-area! block-id)
|
||||
|
||||
shift?
|
||||
|
||||
@@ -1210,7 +1210,7 @@
|
||||
|
||||
(defn highlight-selection-area!
|
||||
[end-block]
|
||||
(when-let [start-block (state/get-selection-start-block)]
|
||||
(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")
|
||||
direction (util/get-direction-between-two-nodes start-block end-block "ls-block")
|
||||
|
||||
|
||||
@@ -700,6 +700,12 @@
|
||||
(uuid id)))
|
||||
(distinct)))
|
||||
|
||||
(defn get-selection-start-block-or-first
|
||||
[]
|
||||
(or (get-selection-start-block)
|
||||
(some-> (first (get-selection-blocks))
|
||||
(gobj/get "id"))))
|
||||
|
||||
(defn in-selection-mode?
|
||||
[]
|
||||
(:selection/mode @state))
|
||||
|
||||
Reference in New Issue
Block a user