Преглед на файлове

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?
            (when hashtag?
              (gp-util/safe-subs edit-content pos current-pos))
              (gp-util/safe-subs edit-content pos current-pos))
            (when (> (count edit-content) 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?
     (if hashtag?
       (fn [chosen e]
       (fn [chosen e]
         (util/stop e)
         (util/stop e)
         (state/clear-editor-action!)
         (state/clear-editor-action!)
         (let [wrapped? (= page-ref/left-brackets (gp-util/safe-subs edit-content (- pos 2) pos))
         (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)
               q (if (editor-handler/get-selected-text) "" q)
               last-pattern (if wrapped?
               last-pattern (if wrapped?
                              q
                              q
@@ -232,7 +233,7 @@
                                    [:db/add [:block/uuid (:block/uuid edit-block)] :block/refs (:db/id tag-entity)]]))))))
                                    [:db/add [:block/uuid (:block/uuid edit-block)] :block/refs (:db/id tag-entity)]]))))))
 
 
           (editor-handler/insert-command! id
           (editor-handler/insert-command! id
-                                          (str "#" (when wrapped? page-ref/left-brackets) chosen)
+                                          (str "#" wrapped-tag)
                                           format
                                           format
                                           {:last-pattern last-pattern
                                           {:last-pattern last-pattern
                                            :end-pattern (when wrapped? page-ref/right-brackets)
                                            :end-pattern (when wrapped? page-ref/right-brackets)