mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: [[]] should complete pages on file graphs
This commit is contained in:
@@ -137,14 +137,15 @@
|
||||
|
||||
(rum/defc page-search-aux
|
||||
[id format embed? db-tag? q current-pos input pos]
|
||||
(let [db? (config/db-based-graph? (state/get-current-repo))
|
||||
(let [db-based? (config/db-based-graph? (state/get-current-repo))
|
||||
q (string/trim q)
|
||||
[matched-pages set-matched-pages!] (rum/use-state nil)
|
||||
search-f (fn []
|
||||
(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}))]
|
||||
(editor-handler/<get-matched-blocks q {:nlp-pages? true
|
||||
:page-only? (not db-based?)}))]
|
||||
(set-matched-pages! result))))]
|
||||
(hooks/use-effect! search-f [(hooks/use-debounced-value q 150)])
|
||||
|
||||
@@ -182,53 +183,53 @@
|
||||
:on-enter (fn []
|
||||
(page-handler/page-not-exists-handler input id q current-pos))
|
||||
:item-render (fn [block _chosen?]
|
||||
(let [block (if-let [id (:block/uuid block)]
|
||||
(or (db/entity [:block/uuid id]) block)
|
||||
block)]
|
||||
(let [block' (if-let [id (:block/uuid block)]
|
||||
(or (db/entity [:block/uuid id]) block)
|
||||
block)]
|
||||
[:div.flex.flex-col
|
||||
(when (and (not (:page? block)) (:block/uuid block))
|
||||
(when (and (not (:page? block)) (:block/uuid block'))
|
||||
(when-let [breadcrumb (state/get-component :block/breadcrumb)]
|
||||
[:div.text-xs.opacity-70.mb-1 {:style {:margin-left 3}}
|
||||
(breadcrumb {:search? true} (state/get-current-repo) (:block/uuid block) {})]))
|
||||
(breadcrumb {:search? true} (state/get-current-repo) (:block/uuid block') {})]))
|
||||
[:div.flex.flex-row.items-center.gap-1
|
||||
(when-not db-tag?
|
||||
(when-not (or db-tag? (not db-based?))
|
||||
[:div.flex.items-center
|
||||
(cond
|
||||
(:nlp-date? block)
|
||||
(:nlp-date? block')
|
||||
(ui/icon "calendar" {:size 14})
|
||||
|
||||
(ldb/class? block)
|
||||
(ldb/class? block')
|
||||
(ui/icon "hash" {:size 14})
|
||||
|
||||
(ldb/property? block)
|
||||
(ldb/property? block')
|
||||
(ui/icon "letter-p" {:size 14})
|
||||
|
||||
(db-model/whiteboard-page? block)
|
||||
(db-model/whiteboard-page? block')
|
||||
(ui/icon "whiteboard" {:extension? true})
|
||||
|
||||
(:page? block)
|
||||
(:page? block')
|
||||
(ui/icon "page" {:extension? true})
|
||||
|
||||
(or (string/starts-with? (str (:block/title block)) (t :new-tag))
|
||||
(string/starts-with? (str (:block/title block)) (t :new-page)))
|
||||
(or (string/starts-with? (str (:block/title block')) (t :new-tag))
|
||||
(string/starts-with? (str (:block/title block')) (t :new-page)))
|
||||
(ui/icon "plus" {:size 14})
|
||||
|
||||
:else
|
||||
(ui/icon "letter-n" {:size 14}))])
|
||||
|
||||
(let [title (if db-tag?
|
||||
(let [target (first (:block/_alias block))]
|
||||
(let [target (first (:block/_alias block'))]
|
||||
(if (ldb/class? target)
|
||||
(str (:block/title block) " -> alias: " (:block/title target))
|
||||
(:block/title block)))
|
||||
(block-handler/block-unique-title block))]
|
||||
(str (:block/title block') " -> alias: " (:block/title target))
|
||||
(:block/title block')))
|
||||
(block-handler/block-unique-title block'))]
|
||||
(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")]
|
||||
:class "black"})
|
||||
|
||||
(when (and db? db-tag? (not (string/blank? q)))
|
||||
(when (and db-based? db-tag? (not (string/blank? q)))
|
||||
[:p.px-1.opacity-50.text-sm
|
||||
[:code (if util/mac? "Cmd+Enter" "Ctrl+Enter")]
|
||||
[:span " to display this tag inline instead of at the end of this node."]])])))
|
||||
|
||||
@@ -1750,10 +1750,11 @@
|
||||
|
||||
(defn <get-matched-blocks
|
||||
"Return matched blocks that are not built-in"
|
||||
[q & [{:keys [nlp-pages?]}]]
|
||||
[q & [{:keys [nlp-pages? page-only?]}]]
|
||||
(p/let [block (state/get-edit-block)
|
||||
result (search/block-search (state/get-current-repo) q {:built-in? false
|
||||
:enable-snippet? false})
|
||||
:enable-snippet? false
|
||||
:page-only? page-only?})
|
||||
matched (remove (fn [b] (= (:block/uuid b) (:block/uuid block))) result)]
|
||||
(-> (concat matched
|
||||
(when nlp-pages?
|
||||
|
||||
@@ -272,7 +272,7 @@ DROP TRIGGER IF EXISTS blocks_au;
|
||||
* :limit - Number of result to limit search results. Defaults to 100
|
||||
* :dev? - Allow all nodes to be seen for development. Defaults to false
|
||||
* :built-in? - Whether to return public built-in nodes for db graphs. Defaults to false"
|
||||
[repo conn search-db q {:keys [limit page enable-snippet? built-in? dev?]
|
||||
[repo conn search-db q {:keys [limit page enable-snippet? built-in? dev? page-only?]
|
||||
:as option
|
||||
:or {enable-snippet? true}}]
|
||||
(when-not (string/blank? q)
|
||||
@@ -295,7 +295,8 @@ DROP TRIGGER IF EXISTS blocks_au;
|
||||
(str select pg-sql " title match ? or title match ? order by rank limit ?")
|
||||
(str select pg-sql " title match ? order by rank limit ?"))
|
||||
non-match-sql (str select pg-sql " title like ? limit ?")
|
||||
matched-result (search-blocks-aux search-db match-sql q match-input page limit enable-snippet?)
|
||||
matched-result (when-not page-only?
|
||||
(search-blocks-aux search-db match-sql q match-input page limit enable-snippet?))
|
||||
non-match-result (when non-match-input
|
||||
(search-blocks-aux search-db non-match-sql q non-match-input page limit enable-snippet?))
|
||||
;; fuzzy is too slow for large graphs
|
||||
|
||||
Reference in New Issue
Block a user