mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 18:36:43 +00:00
refactor: extract out cursor pos function
This commit is contained in:
@@ -107,7 +107,7 @@
|
||||
(defn html-link-format! []
|
||||
(when-let [m (get-selection-and-format)]
|
||||
(let [{:keys [selection-start selection-end format value block edit-id input]} m
|
||||
cur-pos (:pos (util/get-caret-pos input))
|
||||
cur-pos (cursor/pos input)
|
||||
empty-selection? (= selection-start selection-end)
|
||||
selection (subs value selection-start selection-end)
|
||||
selection-link? (and selection (or (util/starts-with? selection "http://")
|
||||
@@ -1796,7 +1796,7 @@
|
||||
[]
|
||||
(when-let [id (state/get-edit-input-id)]
|
||||
(when-let [input (gdom/getElement id)]
|
||||
(let [current-pos (:pos (util/get-caret-pos input))
|
||||
(let [current-pos (cursor/pos input)
|
||||
pos (:editor/last-saved-cursor @state/state)
|
||||
edit-content (or (state/sub [:editor/content id]) "")]
|
||||
(or
|
||||
@@ -1812,7 +1812,7 @@
|
||||
(when-let [q (get-search-q)]
|
||||
(let [value (gobj/get input "value")
|
||||
pos (:editor/last-saved-cursor @state/state)
|
||||
current-pos (:pos (util/get-caret-pos input))]
|
||||
current-pos (cursor/pos input)]
|
||||
(when (or (< current-pos pos)
|
||||
(string/includes? q "]")
|
||||
(string/includes? q ")"))
|
||||
@@ -2365,7 +2365,7 @@
|
||||
[cut? e]
|
||||
(let [^js input (state/get-input)
|
||||
id (state/get-edit-input-id)
|
||||
current-pos (:pos (util/get-caret-pos input))
|
||||
current-pos (cursor/pos input)
|
||||
value (gobj/get input "value")
|
||||
deleted (and (> current-pos 0)
|
||||
(util/nth-safe value (dec current-pos)))
|
||||
@@ -2461,7 +2461,7 @@
|
||||
(cond
|
||||
(state/editing?)
|
||||
(let [input (state/get-input)
|
||||
pos (:pos (util/get-caret-pos input))]
|
||||
pos (cursor/pos input)]
|
||||
(when (and (not (state/get-editor-show-input))
|
||||
(not (state/get-editor-show-date-picker?))
|
||||
(not (state/get-editor-show-template-search?)))
|
||||
@@ -2529,7 +2529,7 @@
|
||||
(= key "#"))
|
||||
(do
|
||||
(commands/handle-step [:editor/search-page-hashtag])
|
||||
(state/set-last-pos! (:pos (util/get-caret-pos input)))
|
||||
(state/set-last-pos! (cursor/pos input))
|
||||
(reset! commands/*slash-caret-pos (util/get-caret-pos input)))
|
||||
|
||||
(let [sym "$"]
|
||||
|
||||
Reference in New Issue
Block a user