mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
enhance: preserve block collapsed state when publishing
This commit is contained in:
9
deps/publish/src/logseq/publish/render.cljs
vendored
9
deps/publish/src/logseq/publish/render.cljs
vendored
@@ -978,6 +978,7 @@
|
||||
visited
|
||||
(inc depth))
|
||||
has-children? (boolean nested)
|
||||
collapsed? (:block/collapsed? display-block)
|
||||
raw-props (entity-properties display-block ctx (:entities ctx))
|
||||
icon-prop (get raw-props :logseq.property/icon)
|
||||
tags-prop (get raw-props :block/tags)
|
||||
@@ -996,8 +997,9 @@
|
||||
properties (render-properties properties ctx (:entities ctx))
|
||||
block-uuid (:block/uuid display-block)
|
||||
block-uuid-str (some-> block-uuid str)]
|
||||
[:li.block
|
||||
(cond-> {:data-block-uuid block-uuid-str}
|
||||
[:li
|
||||
(cond-> {:data-block-uuid block-uuid-str
|
||||
:class (if collapsed? "block is-collapsed" "block")}
|
||||
block-uuid-str (assoc :id (str "block-" block-uuid-str)))
|
||||
[:div.block-content
|
||||
(when positioned-left positioned-left)
|
||||
@@ -1005,7 +1007,8 @@
|
||||
(when positioned-right positioned-right)
|
||||
(when has-children?
|
||||
[:button.block-toggle
|
||||
{:type "button" :aria-expanded "true"}
|
||||
{:type "button"
|
||||
:aria-expanded (str (not collapsed?))}
|
||||
"▾"])]
|
||||
(when positioned-below positioned-below)
|
||||
(when properties
|
||||
|
||||
@@ -68,3 +68,24 @@
|
||||
second-eid (:db/id (d/entity db [:block/uuid second-uuid]))]
|
||||
(is (contains? datom-eids first-eid))
|
||||
(is (contains? datom-eids second-eid)))))
|
||||
|
||||
(deftest publish-payload-includes-collapsed-state
|
||||
(testing "collapsed blocks include :block/collapsed? in publish payload"
|
||||
(let [block-uuid (random-uuid)
|
||||
conn (db-test/create-conn-with-blocks
|
||||
[{:page {:block/title "Page"}
|
||||
:blocks [{:block/title "Collapsed"
|
||||
:block/uuid block-uuid
|
||||
:build/keep-uuid? true
|
||||
:block/collapsed? true}]}])
|
||||
db @conn
|
||||
page (db-test/find-page-by-title db "Page")
|
||||
payload (#'worker-publish/build-publish-page-payload db page nil)
|
||||
datoms (:datoms payload)
|
||||
block-eid (:db/id (d/entity db [:block/uuid block-uuid]))
|
||||
has-collapsed? (some (fn [[e a v]]
|
||||
(and (= e block-eid)
|
||||
(= a :block/collapsed?)
|
||||
(= v true)))
|
||||
datoms)]
|
||||
(is has-collapsed?))))
|
||||
|
||||
Reference in New Issue
Block a user