mirror of https://github.com/logseq/logseq
fix: use mldoc to check links
parent
9f2ce3dd39
commit
c8db7646e2
|
@ -164,3 +164,13 @@
|
|||
(when (string? link)
|
||||
(some-> (first (inline->edn link (default-config format)))
|
||||
ast-link?)))
|
||||
|
||||
(defn mldoc-link?
|
||||
"Check whether s is a link (including page/block refs)."
|
||||
[format s]
|
||||
(let [result (inline->edn s (default-config format))]
|
||||
(and
|
||||
(= 1 (count result))
|
||||
(let [result' (first result)]
|
||||
(or (contains? #{"Nested_link"} (first result'))
|
||||
(contains? #{"Page_ref" "Block_ref" "Complex"} (first (:url (second result')))))))))
|
||||
|
|
|
@ -88,12 +88,6 @@
|
|||
(catch :default _e
|
||||
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
|
||||
[json-string]
|
||||
(-> json-string
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
(let [{:keys [selection-start selection-end format selection value edit-id input]} m
|
||||
cur-pos (cursor/pos input)
|
||||
empty-selection? (= selection-start selection-end)
|
||||
selection-link? (and selection (gp-util/link? selection))
|
||||
selection-link? (and selection (gp-mldoc/mldoc-link? format selection))
|
||||
[content forward-pos] (cond
|
||||
empty-selection?
|
||||
(config/get-empty-link-and-forward-pos format)
|
||||
|
|
Loading…
Reference in New Issue