From beefdfb6ce1079ccd1aaa28c45f78523bf74f24d Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 13 Sep 2023 14:23:08 +0800 Subject: [PATCH] fix: create only one block if the current property's value is empty --- src/main/frontend/components/property/value.cljs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index ad57cab0d..eeacb1781 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -203,10 +203,13 @@ :block/left [:block/uuid child-1-id] :block/properties {pid true}} outliner-core/block-with-timestamps) - tx-data [parent child-1 child-2]] - (db/transact! repo tx-data {:outliner-op :insert-blocks}) + blocks (if (string/blank? value) + [parent child-1] + [parent child-1 child-2]) + last-block-id (:block/uuid (last blocks))] + (db/transact! repo blocks {:outliner-op :insert-blocks}) (add-property! block (:block/original-name property) parent-id) - (editor-handler/edit-block! (db/entity [:block/uuid child-2-id]) 0 child-2-id))) + (editor-handler/edit-block! (db/entity [:block/uuid last-block-id]) 0 last-block-id))) (defn create-new-block-from-template! [block property template]