enhance: hide block refs count for blocks created in property

This commit is contained in:
Tienson Qin
2023-08-07 18:53:28 +08:00
parent fe9c082e5e
commit e2c28aa91a
3 changed files with 12 additions and 7 deletions

View File

@@ -2370,8 +2370,9 @@
(rum/defc block-refs-count < rum/static
[block *hide-block-refs?]
(let [block-refs-count (count (:block/_refs block))]
(when (> block-refs-count 0)
(let [created-in-property? (pu/get-property block :created-in-property)
block-refs-count (count (:block/_refs block))]
(when (and (not created-in-property?) (> block-refs-count 0))
[:div
[:a.open-block-ref-link.bg-base-2.text-sm.ml-2.fade-link
{:title "Open block references"

View File

@@ -236,12 +236,14 @@
(let [repo (state/get-current-repo)
content (string/trim (util/evalue e))]
(when-not (string/blank? content)
(let [new-block (-> (editor-handler/wrap-parse-block {:block/format :markdown
(let [pid (:block/uuid (db/entity [:block/name "created-in-property"]))
new-block (-> (editor-handler/wrap-parse-block {:block/format :markdown
:block/content content})
(outliner-core/block-with-timestamps)
(assoc :block/page {:db/id
(or (:db/id (:block/page block))
(:db/id block))}))
(merge {:block/page {:db/id
(or (:db/id (:block/page block))
(:db/id block))}
:block/properties {pid true}}))
id (:block/uuid new-block)]
(db/transact! repo [new-block] {:outliner-op :insert-blocks})
(add-property! block (:block/original-name property) id)