mirror of
https://github.com/logseq/logseq.git
synced 2026-04-26 23:25:05 +00:00
fix: block id could be empty sometimes
This commit is contained in:
@@ -2513,51 +2513,52 @@
|
||||
:or {show-page? true
|
||||
level-limit 3}
|
||||
:as opts}]
|
||||
(let [parents (db/get-block-parents repo block-id (inc level-limit))
|
||||
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-original-name (:block/original-name 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)
|
||||
config (assoc config :breadcrumb? true)]
|
||||
(when show?
|
||||
(let [page-name-props (when show-page?
|
||||
[page
|
||||
(page-cp (dissoc config :breadcrumb? true) page)
|
||||
{:block/name (or page-original-name page-name)}])
|
||||
parents-props (doall
|
||||
(for [{:block/keys [uuid name content] :as block} parents]
|
||||
(when-not name ; not page
|
||||
(let [{:block/keys [title body]} (block/parse-title-and-body
|
||||
uuid
|
||||
(:block/format block)
|
||||
(:block/pre-block? block)
|
||||
content)
|
||||
config (assoc config :block/uuid uuid)]
|
||||
[block
|
||||
(if (seq title)
|
||||
(->elem :span (map-inline config title))
|
||||
(->elem :div (markup-elements-cp config body)))]))))
|
||||
breadcrumb (->> (into [] parents-props)
|
||||
(concat [page-name-props] (when more? [:more]))
|
||||
(filterv identity)
|
||||
(map (fn [x] (if (vector? x)
|
||||
(let [[block label] x]
|
||||
(rum/with-key (breadcrumb-fragment config block label opts) (:block/uuid block)))
|
||||
[:span.opacity-70 "⋯"])))
|
||||
(interpose (breadcrumb-separator)))]
|
||||
[:div.breadcrumb.block-parents.flex-row.flex-1
|
||||
{:class (when (seq breadcrumb)
|
||||
(str (when-not (:search? config)
|
||||
" my-2")
|
||||
(when indent?
|
||||
" ml-4")))}
|
||||
breadcrumb (when end-separator? (breadcrumb-separator))]))))
|
||||
(when block-id
|
||||
(let [parents (db/get-block-parents repo block-id (inc level-limit))
|
||||
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-original-name (:block/original-name 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)
|
||||
config (assoc config :breadcrumb? true)]
|
||||
(when show?
|
||||
(let [page-name-props (when show-page?
|
||||
[page
|
||||
(page-cp (dissoc config :breadcrumb? true) page)
|
||||
{:block/name (or page-original-name page-name)}])
|
||||
parents-props (doall
|
||||
(for [{:block/keys [uuid name content] :as block} parents]
|
||||
(when-not name ; not page
|
||||
(let [{:block/keys [title body]} (block/parse-title-and-body
|
||||
uuid
|
||||
(:block/format block)
|
||||
(:block/pre-block? block)
|
||||
content)
|
||||
config (assoc config :block/uuid uuid)]
|
||||
[block
|
||||
(if (seq title)
|
||||
(->elem :span (map-inline config title))
|
||||
(->elem :div (markup-elements-cp config body)))]))))
|
||||
breadcrumb (->> (into [] parents-props)
|
||||
(concat [page-name-props] (when more? [:more]))
|
||||
(filterv identity)
|
||||
(map (fn [x] (if (vector? x)
|
||||
(let [[block label] x]
|
||||
(rum/with-key (breadcrumb-fragment config block label opts) (:block/uuid block)))
|
||||
[:span.opacity-70 "⋯"])))
|
||||
(interpose (breadcrumb-separator)))]
|
||||
[:div.breadcrumb.block-parents.flex-row.flex-1
|
||||
{:class (when (seq breadcrumb)
|
||||
(str (when-not (:search? config)
|
||||
" my-2")
|
||||
(when indent?
|
||||
" ml-4")))}
|
||||
breadcrumb (when end-separator? (breadcrumb-separator))])))))
|
||||
|
||||
(defn- block-drag-over
|
||||
[event uuid top? block-id *move-to]
|
||||
|
||||
Reference in New Issue
Block a user