diff --git a/deps/publish/src/logseq/publish/render.cljs b/deps/publish/src/logseq/publish/render.cljs index 8252fc94ce..b44d01bab9 100644 --- a/deps/publish/src/logseq/publish/render.cljs +++ b/deps/publish/src/logseq/publish/render.cljs @@ -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 diff --git a/src/test/frontend/worker/publish_test.cljs b/src/test/frontend/worker/publish_test.cljs index 081614beec..de02d08d5b 100644 --- a/src/test/frontend/worker/publish_test.cljs +++ b/src/test/frontend/worker/publish_test.cljs @@ -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?))))