mirror of https://github.com/logseq/logseq
parent
099cad5b64
commit
2547eb3653
|
@ -1,6 +1,5 @@
|
|||
(ns frontend.components.cmdk
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
(:require [clojure.string :as string]
|
||||
[frontend.components.block :as block]
|
||||
[frontend.context.i18n :refer [t]]
|
||||
[frontend.db :as db]
|
||||
|
@ -341,6 +340,29 @@
|
|||
(search/fuzzy-search filters q {:extract-fn :text}))]
|
||||
(swap! !results update group merge {:status :success :items matched-items})))
|
||||
|
||||
(defmethod load-results :current-page [group state]
|
||||
(if-let [current-page (page-util/get-current-page-id)]
|
||||
(let [!results (::results state)
|
||||
!input (::input state)
|
||||
repo (state/get-current-repo)
|
||||
opts {:limit 100 :page current-page}]
|
||||
(swap! !results assoc-in [group :status] :loading)
|
||||
(swap! !results assoc-in [:current-page :status] :loading)
|
||||
(p/let [blocks (search/block-search repo @!input opts)
|
||||
blocks (remove nil? blocks)
|
||||
items (map (fn [block]
|
||||
(let [id (if (uuid? (:block/uuid block))
|
||||
(:block/uuid block)
|
||||
(uuid (:block/uuid block)))]
|
||||
{:icon "block"
|
||||
:icon-theme :gray
|
||||
:text (:block/content block)
|
||||
:header (block/breadcrumb {:search? true} repo id {})
|
||||
:current-page? true
|
||||
:source-block block})) blocks)]
|
||||
(swap! !results update :current-page merge {:status :success :items items})))
|
||||
(reset! (::filter state) nil)))
|
||||
|
||||
;; The default load-results function triggers all the other load-results function
|
||||
(defmethod load-results :default [_ state]
|
||||
(if-not (some-> state ::input deref seq)
|
||||
|
@ -725,7 +747,7 @@
|
|||
[:div "to filter search results"]]
|
||||
[:div.flex.flex-row.gap-1.items-center.opacity-50.hover:opacity-100
|
||||
(shui/shortcut ["mod" "enter"] context)
|
||||
[:div "to open search in the sidebar"]]]) )
|
||||
[:div "to open search in the sidebar"]]]))
|
||||
|
||||
(rum/defcs tip <
|
||||
{:init (fn [state]
|
||||
|
|
Loading…
Reference in New Issue