enhance: show as "empty" if a property block's value is empty

pull/11177/head
Tienson Qin 2024-04-24 15:25:34 +08:00
parent d2bdc2f55c
commit 60067304a4
2 changed files with 17 additions and 15 deletions

View File

@ -2343,21 +2343,22 @@
:block-content-slotted
(-> block (dissoc :block/children :block/page)))]
(let [title-collapse-enabled? (:outliner/block-title-collapse-enabled? (state/get-config))]
(when (and (not block-ref-with-title?)
(seq body)
(or (not title-collapse-enabled?)
(and title-collapse-enabled?
(or (not collapsed?)
(some? (mldoc/extract-first-query-from-ast body))))))
[:div.block-body
;; TODO: consistent id instead of the idx (since it could be changed later)
(let [body (block/trim-break-lines! (:block/body block))
uuid (:block/uuid block)]
(for [[idx child] (medley/indexed body)]
(when-let [block (markup-element-cp config child)]
(rum/with-key (block-child block)
(str uuid "-" idx)))))]))))
(if (and (:property-block? config) (:hide-bullet? config) (string/blank? (:block/content block)))
[:div.opacity-50.text-sm "Empty"]
(let [title-collapse-enabled? (:outliner/block-title-collapse-enabled? (state/get-config))]
(when (and (not block-ref-with-title?)
(seq body)
(or (not title-collapse-enabled?)
(and title-collapse-enabled?
(or (not collapsed?)
(some? (mldoc/extract-first-query-from-ast body))))))
[:div.block-body
(let [body (block/trim-break-lines! (:block/body block))
uuid (:block/uuid block)]
(for [[idx child] (medley/indexed body)]
(when-let [block (markup-element-cp config child)]
(rum/with-key (block-child block)
(str uuid "-" idx)))))])))))
(rum/defc tags
[config block]

View File

@ -471,6 +471,7 @@
[:div.property-block-container.content.flex.flex-1
(block-cp children {:id (str (:block/uuid parent))
:editor-box editor-box
:property-block? true
:hide-bullet? (= (count children) 1)
:closed-values? closed-values?})]
(property-empty-value)))))