|
@@ -101,17 +101,24 @@
|
|
|
(take 5 items))))
|
|
|
page-exists? (when-not (string/blank? input)
|
|
|
(db/entity [:block/name (string/trim input)]))
|
|
|
- filter-mode? (or (string/includes? input " /")
|
|
|
- (string/starts-with? input "/"))
|
|
|
+ include-slash? (or (string/includes? input "/")
|
|
|
+ (string/starts-with? input "/"))
|
|
|
order* (cond
|
|
|
(= search-mode :graph)
|
|
|
[["Pages" :pages (visible-items :pages)]]
|
|
|
|
|
|
- filter-mode?
|
|
|
- [["Filters" :filters (visible-items :filters)]
|
|
|
- ["Pages" :pages (visible-items :pages)]
|
|
|
+ include-slash?
|
|
|
+ [(if page-exists?
|
|
|
+ ["Pages" :pages (visible-items :pages)]
|
|
|
+ ["Filters" :filters (visible-items :filters)])
|
|
|
+ (if page-exists?
|
|
|
+ ["Filters" :filters (visible-items :filters)]
|
|
|
+ ["Pages" :pages (visible-items :pages)])
|
|
|
(when-not page-exists?
|
|
|
- ["Create" :create (create-items input)])]
|
|
|
+ ["Create" :create (create-items input)])
|
|
|
+ ["Current page" :current-page (visible-items :current-page)]
|
|
|
+ ["Blocks" :blocks (visible-items :blocks)]
|
|
|
+ ["Files" :files (visible-items :files)]]
|
|
|
|
|
|
filter-group
|
|
|
[(when (= filter-group :blocks)
|
|
@@ -253,7 +260,7 @@
|
|
|
[input]
|
|
|
(or (when (string/starts-with? input "/")
|
|
|
(subs input 1))
|
|
|
- (last (gp-util/split-last " /" input))))
|
|
|
+ (last (gp-util/split-last "/" input))))
|
|
|
|
|
|
(defmethod load-results :filters [group state]
|
|
|
(let [!results (::results state)
|
|
@@ -374,8 +381,8 @@
|
|
|
(defn- get-filter-user-input
|
|
|
[input]
|
|
|
(cond
|
|
|
- (string/includes? input " /")
|
|
|
- (first (gp-util/split-last " /" input))
|
|
|
+ (string/includes? input "/")
|
|
|
+ (first (gp-util/split-last "/" input))
|
|
|
(string/starts-with? input "/")
|
|
|
""
|
|
|
:else
|
|
@@ -537,11 +544,9 @@
|
|
|
(reset! (::alt? state) alt?)
|
|
|
(when (or as-keydown? as-keyup?)
|
|
|
(.preventDefault e))
|
|
|
- (when-not esc? (util/stop-propagation e))
|
|
|
|
|
|
(cond
|
|
|
- (and meta? enter?
|
|
|
- (not (string/blank? input)))
|
|
|
+ (and meta? enter?)
|
|
|
(let [repo (state/get-current-repo)]
|
|
|
(state/close-modal!)
|
|
|
(state/sidebar-add-block! repo input :search))
|
|
@@ -552,13 +557,17 @@
|
|
|
as-keyup? (if meta?
|
|
|
(show-less)
|
|
|
(move-highlight state -1))
|
|
|
- enter? (handle-action :default state e)
|
|
|
+ enter? (do
|
|
|
+ (handle-action :default state e)
|
|
|
+ (util/stop-propagation e))
|
|
|
esc? (let [filter @(::filter state)]
|
|
|
(when (or filter (not (string/blank? input)))
|
|
|
(util/stop e)
|
|
|
(reset! (::filter state) nil)
|
|
|
(when-not filter (handle-input-change state nil ""))))
|
|
|
- (= keyname "c") (copy-block-ref state)
|
|
|
+ (and meta? (= keyname "c")) (do
|
|
|
+ (copy-block-ref state)
|
|
|
+ (util/stop-propagation e))
|
|
|
:else nil)))
|
|
|
|
|
|
(defn keyup-handler
|
|
@@ -601,20 +610,22 @@
|
|
|
:placeholder (input-placeholder false)
|
|
|
:ref #(when-not @input-ref (reset! input-ref %))
|
|
|
:on-change (fn [e]
|
|
|
- (handle-input-change state e)
|
|
|
- (when-let [on-change (:on-input-change opts)]
|
|
|
- (on-change (.-value (.-target e)))))
|
|
|
+ (let [new-value (.-value (.-target e))]
|
|
|
+ (handle-input-change state e)
|
|
|
+ (when-let [on-change (:on-input-change opts)]
|
|
|
+ (on-change new-value))))
|
|
|
:on-blur (fn [_e]
|
|
|
(when-let [on-blur (:on-input-blur opts)]
|
|
|
(on-blur input)))
|
|
|
:on-composition-end (fn [e] (handle-input-change state e))
|
|
|
:on-key-down (fn [e]
|
|
|
(let [value (.-value @input-ref)
|
|
|
- last-char (last value)]
|
|
|
+ last-char (last value)
|
|
|
+ backspace? (= (util/ekey e) "Backspace")]
|
|
|
(when (and (some? @(::filter state))
|
|
|
(or (= (util/ekey e) "/")
|
|
|
- (and (= (util/ekey e) "Backspace")
|
|
|
- (= last-char "/"))))
|
|
|
+ (and backspace? (= last-char "/"))
|
|
|
+ (and backspace? (= input ""))))
|
|
|
(reset! (::filter state) nil))))
|
|
|
:value input}]]))
|
|
|
|
|
@@ -768,7 +779,7 @@
|
|
|
:style {:background "var(--lx-gray-02)"}}
|
|
|
|
|
|
(when group-filter
|
|
|
- [:div.flex.flex-col.p-3.opacity-50.text-sm
|
|
|
+ [:div.flex.flex-col.px-3.py-1.opacity-70.text-sm
|
|
|
(search-only state (name group-filter))])
|
|
|
|
|
|
(let [items (filter
|