فهرست منبع

enhance: recognize refs as links when inserting links from selection

ksqsf 3 سال پیش
والد
کامیت
9f2ce3dd39
2فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 6 0
      deps/graph-parser/src/logseq/graph_parser/util.cljs
  2. 1 1
      src/main/frontend/handler/editor.cljs

+ 6 - 0
deps/graph-parser/src/logseq/graph_parser/util.cljs

@@ -88,6 +88,12 @@
          (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

+ 1 - 1
src/main/frontend/handler/editor.cljs

@@ -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/url? selection))
+           selection-link? (and selection (gp-util/link? selection))
            [content forward-pos] (cond
                                    empty-selection?
                                    (config/get-empty-link-and-forward-pos format)