enhance: recognize refs as links when inserting links from selection

pull/8575/head
ksqsf 2023-02-13 13:30:02 +09:00 committed by Tienson Qin
parent f13151ed61
commit 9f2ce3dd39
2 changed files with 7 additions and 1 deletions

View File

@ -88,6 +88,12 @@
(catch :default _e (catch :default _e
false)))) false))))
(defn link?
"Check whether s is a link (including page/block refs)."
[s]
(or (url? s)
(re-matches #"^(\[\[|\(\().*(\]\]|\)\))$" (string/trim s))))
(defn json->clj (defn json->clj
[json-string] [json-string]
(-> json-string (-> json-string

View File

@ -131,7 +131,7 @@
(let [{:keys [selection-start selection-end format selection value edit-id input]} m (let [{:keys [selection-start selection-end format selection value edit-id input]} m
cur-pos (cursor/pos input) cur-pos (cursor/pos input)
empty-selection? (= selection-start selection-end) empty-selection? (= selection-start selection-end)
selection-link? (and selection (gp-util/url? selection)) selection-link? (and selection (gp-util/link? selection))
[content forward-pos] (cond [content forward-pos] (cond
empty-selection? empty-selection?
(config/get-empty-link-and-forward-pos format) (config/get-empty-link-and-forward-pos format)