mirror of
https://github.com/logseq/logseq.git
synced 2026-04-29 00:24:51 +00:00
enhance: click to edit should jump to the end of markdown link
This commit is contained in:
@@ -44,6 +44,14 @@
|
||||
(when (string? result)
|
||||
result)))
|
||||
|
||||
(defn- markdown-link?
|
||||
[markup current-line pos]
|
||||
(and current-line
|
||||
(= (util/nth-safe markup pos) "]")
|
||||
(= (util/nth-safe markup (inc pos)) "(")
|
||||
(string/includes? (subs current-line 0 pos) "[")
|
||||
(string/includes? (subs current-line pos) ")")))
|
||||
|
||||
;; (find-position "** hello _w_" "hello w")
|
||||
(defn find-position
|
||||
[markup text]
|
||||
@@ -66,7 +74,8 @@
|
||||
(recur t1 r2 i1 (inc i2))
|
||||
|
||||
:else
|
||||
(recur r1 t2 (inc i1) i2))))]
|
||||
(recur r1 t2 (inc i1) i2))))
|
||||
current-line (get-current-line-by-pos markup pos)]
|
||||
(cond
|
||||
(and (= (util/nth-safe markup pos)
|
||||
(util/nth-safe markup (inc pos))
|
||||
@@ -76,12 +85,15 @@
|
||||
(contains? inline-special-chars (util/nth-safe markup pos))
|
||||
(let [matched (->> (take-while inline-special-chars (util/safe-subs markup pos))
|
||||
(apply str))
|
||||
current-line (get-current-line-by-pos markup pos)
|
||||
matched? (and current-line (string/includes? current-line (string/reverse matched)))]
|
||||
(if matched?
|
||||
(+ pos (count matched))
|
||||
pos))
|
||||
|
||||
(markdown-link? markup current-line pos)
|
||||
(let [idx (string/index-of (subs current-line pos) ")")]
|
||||
(+ pos (inc idx)))
|
||||
|
||||
:else
|
||||
pos))
|
||||
(catch js/Error e
|
||||
|
||||
Reference in New Issue
Block a user