enhance(ux): put pages before blocks when auto-complete node refs

We can improve it further to display horizontal split views for both
pages and blocks on desktop.
This commit is contained in:
Tienson Qin
2025-06-06 03:55:40 +08:00
parent e6601fcd55
commit 20ec61641d
2 changed files with 11 additions and 6 deletions

View File

@@ -852,6 +852,7 @@
{:class "text-xl bg-transparent border-none w-full outline-none px-3 py-3"
:auto-focus true
:autoComplete "off"
:autoCapitalize false
:placeholder (input-placeholder false)
:ref #(when-not @input-ref (reset! input-ref %))
:on-change debounced-on-change

View File

@@ -155,8 +155,9 @@
(when-not (string/blank? q)
(p/let [result (if db-tag?
(editor-handler/get-matched-classes q)
(editor-handler/<get-matched-blocks q {:nlp-pages? true
:page-only? (not db-based?)}))]
(p/let [result (editor-handler/<get-matched-blocks q {:nlp-pages? true
:page-only? (not db-based?)})]
(reverse (sort-by (fn [result] (:page? result)) result))))]
(set-matched-pages! result))))]
(hooks/use-effect! search-f [(hooks/use-debounced-value q 150)])
@@ -206,10 +207,10 @@
(ui/icon "letter-p" {:size 14})
(db-model/whiteboard-page? block')
(ui/icon "writing")
(ui/icon "writing" {:size 14})
(:page? block')
(ui/icon "file")
(or (ldb/page? block') (:page? block'))
(ui/icon "file" {:size 14})
(or (string/starts-with? (str (:block/title block')) (t :new-tag))
(string/starts-with? (str (:block/title block')) (t :new-page)))
@@ -225,7 +226,10 @@
(str title " -> alias: " (:block/title target))
title))
(block-handler/block-unique-title block'))]
(search-handler/highlight-exact-query title q))]]))
(if (or (string/starts-with? title (t :new-tag))
(string/starts-with? title (t :new-page)))
title
(search-handler/highlight-exact-query title q)))]]))
:empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 (if db-tag?
"Search for a tag"
"Search for a node")]