mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: breadcrumbs
This commit is contained in:
@@ -3174,35 +3174,22 @@
|
||||
|
||||
;; "block-id - uuid of the target block of breadcrumb. page uuid is also acceptable"
|
||||
(rum/defc breadcrumb-aux < rum/reactive
|
||||
[config repo block-id {:keys [show-page? indent? end-separator? level-limit _navigating-block]
|
||||
:or {show-page? true
|
||||
level-limit 3}
|
||||
[config repo block-id {:keys [show-page? indent? end-separator? _navigating-block]
|
||||
:or {show-page? true}
|
||||
:as opts}]
|
||||
(let [from-property (when (and block-id (config/db-based-graph? repo))
|
||||
(:logseq.property/created-from-property (db/entity [:block/uuid block-id])))
|
||||
parents (db/get-block-parents repo block-id {:depth (inc level-limit)})
|
||||
parents (remove nil? (concat parents [from-property]))
|
||||
page (or (db/get-block-page repo block-id) ;; only return for block uuid
|
||||
(model/query-block-by-uuid block-id)) ;; return page entity when received page uuid
|
||||
page-name (:block/name page)
|
||||
page-title (:block/title page)
|
||||
show? (or (seq parents) show-page? page-name)
|
||||
parents (if (= page-name (:block/name (first parents)))
|
||||
(rest parents)
|
||||
parents)
|
||||
more? (> (count parents) level-limit)
|
||||
parents (if more? (take-last level-limit parents) parents)
|
||||
parents (db/get-block-parents repo block-id {:depth 1000})
|
||||
parents (cond-> (remove nil? (concat parents [from-property]))
|
||||
(not show-page?)
|
||||
rest)
|
||||
config (assoc config
|
||||
:breadcrumb? true
|
||||
:disable-redirect? true
|
||||
:disable-preview? true
|
||||
:stop-click-event? false)]
|
||||
(when show?
|
||||
(let [page-name-props (when (and show-page? (not (ldb/page? (db/entity [:block/uuid block-id]))))
|
||||
[page
|
||||
(page-cp {:disable-preview? true} page)
|
||||
{:block/name (or page-title page-name)}])
|
||||
parents-props (doall
|
||||
(when (seq parents)
|
||||
(let [parents-props (doall
|
||||
(for [{:block/keys [uuid name title] :as block} parents]
|
||||
(if name
|
||||
[block (page-cp {:disable-preview? true} block) true]
|
||||
@@ -3220,18 +3207,13 @@
|
||||
(->elem :span (map-inline config ast-title))
|
||||
(->elem :div (markup-elements-cp config ast-body))))
|
||||
false]))))
|
||||
breadcrumbs (->> (into [] parents-props)
|
||||
(concat [page-name-props]
|
||||
(when more? [:more]))
|
||||
(filterv identity)
|
||||
breadcrumbs (->> parents-props
|
||||
(map (fn [x]
|
||||
(if (and (vector? x) (second x))
|
||||
(let [[block label page?] x
|
||||
label' (if page?
|
||||
label
|
||||
(breadcrumb-fragment config block label opts))]
|
||||
(rum/with-key label' (str (:block/uuid block))))
|
||||
[:span.opacity-70 {:key "dots"} "⋯"])))
|
||||
(let [[block label page?] x
|
||||
label' (if page?
|
||||
label
|
||||
(breadcrumb-fragment config block label opts))]
|
||||
(rum/with-key label' (str (:block/uuid block))))))
|
||||
(interpose (breadcrumb-separator)))]
|
||||
(when (seq breadcrumbs)
|
||||
[:div.breadcrumb.block-parents
|
||||
@@ -3247,8 +3229,7 @@
|
||||
(when end-separator? (breadcrumb-separator))])))))
|
||||
|
||||
(rum/defc breadcrumb
|
||||
[config repo block-id {:keys [_show-page? _indent? _end-separator? level-limit _navigating-block]
|
||||
:or {level-limit 3}
|
||||
[config repo block-id {:keys [_show-page? _indent? _end-separator? _navigating-block]
|
||||
:as opts}]
|
||||
(let [[block set-block!] (hooks/use-state (db/entity [:block/uuid block-id]))]
|
||||
(hooks/use-effect!
|
||||
@@ -3258,7 +3239,7 @@
|
||||
{:children? false
|
||||
:skip-refresh? true})
|
||||
_ (when-let [id (:db/id block)]
|
||||
(db-async/<get-block-parents (state/get-current-repo) id level-limit))]
|
||||
(db-async/<get-block-parents (state/get-current-repo) id 1000))]
|
||||
(set-block! block)))
|
||||
[])
|
||||
(when block
|
||||
|
||||
@@ -335,7 +335,7 @@
|
||||
|
||||
(rum/defc block-breadcrumb
|
||||
[page-name]
|
||||
[:div.ls-block-breadcrumb.text-base.pl-2
|
||||
[:div.ls-block-breadcrumb
|
||||
(when-let [page (when (and page-name (common-util/uuid-string? page-name))
|
||||
(db/entity [:block/uuid (uuid page-name)]))]
|
||||
(when (:block/parent page)
|
||||
@@ -343,8 +343,7 @@
|
||||
(component-block/breadcrumb {}
|
||||
(state/get-current-repo)
|
||||
(:block/uuid page)
|
||||
{:level-limit 2
|
||||
:header? true})]))])
|
||||
{:header? true})]))])
|
||||
|
||||
(rum/defc ^:large-vars/cleanup-todo header-aux < rum/reactive
|
||||
[{:keys [current-repo default-home new-block-mode]}]
|
||||
|
||||
@@ -327,6 +327,9 @@ html.is-zoomed-native-ios {
|
||||
}
|
||||
|
||||
.cp__header {
|
||||
.ls-block-breadcrumb {
|
||||
@apply text-sm pl-2;
|
||||
}
|
||||
.breadcrumb {
|
||||
@apply flex items-center;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@
|
||||
(block/breadcrumb {:preview? true}
|
||||
(state/get-current-repo)
|
||||
(uuid (gobj/get props "blockId"))
|
||||
{:end-separator? (gobj/get props "endSeparator")
|
||||
:level-limit (gobj/get props "levelLimit" 3)}))
|
||||
{:end-separator? (gobj/get props "endSeparator")}))
|
||||
|
||||
(rum/defc tweet
|
||||
[props]
|
||||
|
||||
@@ -777,7 +777,7 @@
|
||||
(remove nil?))))
|
||||
|
||||
(defn- rename-repeated-properties
|
||||
[conn search-db]
|
||||
[conn _search-db]
|
||||
(when (ldb/db-based-graph? @conn)
|
||||
(let [closed-values-tx (mapv (fn [[old new]]
|
||||
{:db/id (:db/id (d/entity @conn old))
|
||||
@@ -799,7 +799,7 @@
|
||||
conn))
|
||||
|
||||
(defn- rename-task-properties
|
||||
[conn search-db]
|
||||
[conn _search-db]
|
||||
(when (ldb/db-based-graph? @conn)
|
||||
(let [db @conn
|
||||
new-idents {:logseq.task/status.backlog :logseq.property/status.backlog
|
||||
|
||||
Reference in New Issue
Block a user