浏览代码

fix: tag autocomplete if its name has any space

Tienson Qin 1 年之前
父节点
当前提交
48b610a9f0
共有 1 个文件被更改,包括 6 次插入5 次删除
  1. 6 5
      src/main/frontend/handler/page.cljs

+ 6 - 5
src/main/frontend/handler/page.cljs

@@ -202,15 +202,16 @@
            (when hashtag?
              (gp-util/safe-subs edit-content pos current-pos))
            (when (> (count edit-content) current-pos)
-             (gp-util/safe-subs edit-content pos current-pos)))]
+             (gp-util/safe-subs edit-content pos current-pos)))
+        db-based? (config/db-based-graph? (state/get-current-repo))]
     (if hashtag?
       (fn [chosen e]
         (util/stop e)
         (state/clear-editor-action!)
         (let [wrapped? (= page-ref/left-brackets (gp-util/safe-subs edit-content (- pos 2) pos))
-              chosen (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
-                       (page-ref/->page-ref chosen)
-                       chosen)
+              wrapped-tag (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
+                            (page-ref/->page-ref chosen)
+                            chosen)
               q (if (editor-handler/get-selected-text) "" q)
               last-pattern (if wrapped?
                              q
@@ -232,7 +233,7 @@
                                    [:db/add [:block/uuid (:block/uuid edit-block)] :block/refs (:db/id tag-entity)]]))))))
 
           (editor-handler/insert-command! id
-                                          (str "#" (when wrapped? page-ref/left-brackets) chosen)
+                                          (str "#" wrapped-tag)
                                           format
                                           {:last-pattern last-pattern
                                            :end-pattern (when wrapped? page-ref/right-brackets)