mirror of https://github.com/logseq/logseq
fix: show classes only when adding a tag to a block
parent
15642394fc
commit
dcf5f8f296
|
@ -129,12 +129,13 @@
|
||||||
{:will-unmount (fn [state]
|
{:will-unmount (fn [state]
|
||||||
(reset! commands/*current-command nil)
|
(reset! commands/*current-command nil)
|
||||||
state)}
|
state)}
|
||||||
"Embedded page searching popup"
|
"Page or tag searching popup"
|
||||||
[state id format]
|
[state id format]
|
||||||
(let [action (state/sub :editor/action)
|
(let [action (state/sub :editor/action)
|
||||||
db? (config/db-based-graph? (state/get-current-repo))
|
db? (config/db-based-graph? (state/get-current-repo))
|
||||||
embed? (and db? (= @commands/*current-command "Page embed"))
|
embed? (and db? (= @commands/*current-command "Page embed"))
|
||||||
tag? (= action :page-search-hashtag)
|
tag? (= action :page-search-hashtag)
|
||||||
|
db-tag? (and db? tag?)
|
||||||
create-page? (state/sub :editor/create-page?)]
|
create-page? (state/sub :editor/create-page?)]
|
||||||
(when (contains? #{:page-search :page-search-hashtag} action)
|
(when (contains? #{:page-search :page-search-hashtag} action)
|
||||||
(let [pos (state/get-editor-last-pos)
|
(let [pos (state/get-editor-last-pos)
|
||||||
|
@ -150,8 +151,11 @@
|
||||||
(when (> (count edit-content) current-pos)
|
(when (> (count edit-content) current-pos)
|
||||||
(gp-util/safe-subs edit-content pos current-pos))
|
(gp-util/safe-subs edit-content pos current-pos))
|
||||||
"")
|
"")
|
||||||
matched-pages (when-not (string/blank? q)
|
matched-pages (if db-tag?
|
||||||
(editor-handler/get-matched-pages q))
|
(editor-handler/get-matched-classes q)
|
||||||
|
;; FIXME: display refed pages recentedly or frequencyly used
|
||||||
|
(when-not (string/blank? q)
|
||||||
|
(editor-handler/get-matched-pages q)))
|
||||||
matched-pages (cond
|
matched-pages (cond
|
||||||
(contains? (set (map util/page-name-sanity-lc matched-pages))
|
(contains? (set (map util/page-name-sanity-lc matched-pages))
|
||||||
(util/page-name-sanity-lc (string/trim q))) ;; if there's a page name fully matched
|
(util/page-name-sanity-lc (string/trim q))) ;; if there's a page name fully matched
|
||||||
|
@ -159,9 +163,12 @@
|
||||||
[(count m) m])
|
[(count m) m])
|
||||||
matched-pages)
|
matched-pages)
|
||||||
|
|
||||||
(string/blank? q)
|
(and (string/blank? q) (not db-tag?))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
|
(and (string/blank? q) db-tag?)
|
||||||
|
matched-pages
|
||||||
|
|
||||||
(empty? matched-pages)
|
(empty? matched-pages)
|
||||||
(cons q matched-pages)
|
(cons q matched-pages)
|
||||||
|
|
||||||
|
@ -177,7 +184,7 @@
|
||||||
(cons q (rest matched-pages)))
|
(cons q (rest matched-pages)))
|
||||||
(cons q matched-pages))))]
|
(cons q matched-pages))))]
|
||||||
[:div
|
[:div
|
||||||
(when (and db? tag?
|
(when (and db-tag?
|
||||||
;; Don't display in heading
|
;; Don't display in heading
|
||||||
(not (some->> edit-content (re-find #"^\s*#"))))
|
(not (some->> edit-content (re-find #"^\s*#"))))
|
||||||
[:div.flex.flex-row.items-center.px-4.py-1.text-sm.opacity-70.gap-2
|
[:div.flex.flex-row.items-center.px-4.py-1.text-sm.opacity-70.gap-2
|
||||||
|
@ -197,7 +204,10 @@
|
||||||
[:div.flex
|
[:div.flex
|
||||||
(when (db-model/whiteboard-page? page-name) [:span.mr-1 (ui/icon "whiteboard" {:extension? true})])
|
(when (db-model/whiteboard-page? page-name) [:span.mr-1 (ui/icon "whiteboard" {:extension? true})])
|
||||||
[:div.flex.space-x-1
|
[:div.flex.space-x-1
|
||||||
[:div (when-not (db/page-exists? page-name) (t :new-page))]
|
[:div (when-not (db/page-exists? page-name)
|
||||||
|
(if db-tag?
|
||||||
|
(t :new-class)
|
||||||
|
(t :new-page)))]
|
||||||
(search-handler/highlight-exact-query page-name q)]]
|
(search-handler/highlight-exact-query page-name q)]]
|
||||||
:open? chosen?
|
:open? chosen?
|
||||||
:manual? true
|
:manual? true
|
||||||
|
@ -205,7 +215,9 @@
|
||||||
:tippy-distance 24
|
:tippy-distance 24
|
||||||
:tippy-position (if sidebar? "left" "right")}
|
:tippy-position (if sidebar? "left" "right")}
|
||||||
page-name)])
|
page-name)])
|
||||||
:empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 "Search for a page"]
|
:empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 (if db-tag?
|
||||||
|
"Search for a class"
|
||||||
|
"Search for a page")]
|
||||||
:class "black"})]))))))
|
:class "black"})]))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[frontend.handler.db-based.property :as db-property-handler]
|
[frontend.handler.db-based.property :as db-property-handler]
|
||||||
[frontend.fs.capacitor-fs :as capacitor-fs]))
|
[frontend.fs.capacitor-fs :as capacitor-fs]
|
||||||
|
[frontend.db.model :as model]))
|
||||||
|
|
||||||
;; FIXME: should support multiple images concurrently uploading
|
;; FIXME: should support multiple images concurrently uploading
|
||||||
|
|
||||||
|
@ -1634,6 +1635,13 @@
|
||||||
(remove (fn [p] (= (util/page-name-sanity-lc p) editing-page)) pages)
|
(remove (fn [p] (= (util/page-name-sanity-lc p) editing-page)) pages)
|
||||||
pages)))
|
pages)))
|
||||||
|
|
||||||
|
(defn get-matched-classes
|
||||||
|
"Return matched class names"
|
||||||
|
[q]
|
||||||
|
(let [classes (->> (db-model/get-all-classes (state/get-current-repo))
|
||||||
|
(map first))]
|
||||||
|
(search/fuzzy-search classes q {:limit 100})))
|
||||||
|
|
||||||
(defn get-matched-blocks
|
(defn get-matched-blocks
|
||||||
[q block-id]
|
[q block-id]
|
||||||
;; remove current block
|
;; remove current block
|
||||||
|
|
|
@ -483,6 +483,7 @@
|
||||||
|
|
||||||
:home "Home"
|
:home "Home"
|
||||||
:new-page "New page:"
|
:new-page "New page:"
|
||||||
|
:new-class "New class:"
|
||||||
;; :new-class "New class:"
|
;; :new-class "New class:"
|
||||||
:whiteboard "Whiteboard"
|
:whiteboard "Whiteboard"
|
||||||
:whiteboards "Whiteboards"
|
:whiteboards "Whiteboards"
|
||||||
|
|
Loading…
Reference in New Issue