mirror of
https://github.com/logseq/logseq.git
synced 2026-04-25 22:54:48 +00:00
chore: clean up and some docs
This commit is contained in:
@@ -22,6 +22,12 @@
|
||||
int)})
|
||||
|
||||
(defn get-caret-pos
|
||||
"Get caret offset position as well as input element rect.
|
||||
|
||||
This function is only used by autocomplete command or up/down command
|
||||
where offset position is needed.
|
||||
|
||||
If you only need character position, use `pos` instead. Do NOT call this."
|
||||
[input]
|
||||
(let [pos (.-selectionStart input)
|
||||
rect (bean/->clj (.. input (getBoundingClientRect) (toJSON)))]
|
||||
@@ -44,6 +50,14 @@
|
||||
(when input
|
||||
(.-selectionStart input)))
|
||||
|
||||
(defn start? [input]
|
||||
(and input (zero? (.-selectionStart input))))
|
||||
|
||||
(defn end? [input]
|
||||
(and input
|
||||
(= (count (.-value input))
|
||||
(.-selectionStart input))))
|
||||
|
||||
(defn move-cursor-to [input n]
|
||||
(.setSelectionRange input n n))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user