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

fix: alias auto-complete

Tienson Qin преди 7 месеца
родител
ревизия
61cc4382c4
променени са 3 файла, в които са добавени 11 реда и са изтрити 7 реда
  1. 3 2
      src/main/frontend/components/cmdk/core.cljs
  2. 6 4
      src/main/frontend/components/editor.cljs
  3. 2 1
      src/main/frontend/worker/search.cljs

+ 3 - 2
src/main/frontend/components/cmdk/core.cljs

@@ -281,10 +281,11 @@
 (defn- page-item
   [repo page]
   (let [entity (db/entity [:block/uuid (:block/uuid page)])
-        source-page (model/get-alias-source-page repo (:db/id entity))
+        source-page (or (:block/title (model/get-alias-source-page repo (:db/id entity)))
+                        (:alias page))
         icon (get-page-icon entity)
         title (block-handler/block-unique-title page)
-        title' (if source-page (str title " -> alias: " (:block/title source-page)) title)]
+        title' (if source-page (str title " -> alias: " source-page) title)]
     (hash-map :icon icon
               :icon-theme :gray
               :text title'

+ 6 - 4
src/main/frontend/components/editor.cljs

@@ -186,7 +186,9 @@
          :item-render (fn [block _chosen?]
                         (let [block' (if-let [id (:block/uuid block)]
                                        (if-let [e (db/entity [:block/uuid id])]
-                                         (assoc e :block/title (:block/title block))
+                                         (assoc e
+                                                :block/title (:block/title block)
+                                                :alias (:alias block))
                                          block)
                                        block)]
                           [:div.flex.flex-col
@@ -221,12 +223,12 @@
                                  :else
                                  (ui/icon "letter-n" {:size 14}))])
 
-                            (let [title (let [target (first (:block/_alias block'))
+                            (let [title (let [alias (:alias block')
                                               title (if (and db-based? (not (ldb/built-in? block')))
                                                       (block-handler/block-unique-title block')
                                                       (:block/title block'))]
-                                          (if target
-                                            (str title " -> alias: " (:block/title target))
+                                          (if alias
+                                            (str title " -> alias: " alias)
                                             title))]
                               (if (or (string/starts-with? title (t :new-tag))
                                       (string/starts-with? title (t :new-page)))

+ 2 - 1
src/main/frontend/worker/search.cljs

@@ -325,7 +325,8 @@ DROP TRIGGER IF EXISTS blocks_au;
                                                    (uuid page)
                                                    nil)
                                      :block/tags (seq (map :db/id (:block/tags block)))
-                                     :page? (ldb/page? block)}))))))
+                                     :page? (ldb/page? block)
+                                     :alias (:block/title (first (:block/_alias block)))}))))))
           page-or-object-result (filter (fn [b] (or (:page? b) (:block/tags result))) result)]
       (->>
        (concat page-or-object-result