fix: editing block should be property instead of its parent block

This commit is contained in:
Tienson Qin
2023-07-03 14:55:42 +08:00
parent ccf35df699
commit 58162cc09d
7 changed files with 62 additions and 48 deletions

View File

@@ -27,7 +27,6 @@
[frontend.handler.route :as route-handler]
[frontend.handler.db-based.editor :as db-editor-handler]
[frontend.handler.file-based.editor :as file-editor-handler]
[frontend.handler.property :as property-handler]
[frontend.mobile.util :as mobile-util]
[frontend.modules.outliner.core :as outliner-core]
[frontend.modules.outliner.transaction :as outliner-tx]
@@ -1162,17 +1161,13 @@
(defn save-block-aux!
[block value opts]
(let [entity (db/entity [:block/uuid (:block/uuid block)])
editing-property (:ui/editing-property @state/state)]
(when (:db/id entity)
(let [entity (db/entity [:block/uuid (:block/uuid block)])]
(when (and (:db/id entity)
(not (contains? #{"property"} (:block/type entity))))
(let [value (string/trim value)]
(if editing-property
(property-handler/add-property! (state/get-current-repo) entity
(:block/name editing-property)
value)
;; FIXME: somehow frontend.components.editor's will-unmount event will loop forever
;; maybe we shouldn't save the block/file in "will-unmount" event?
(save-block-if-changed! block value opts))))))
;; FIXME: somehow frontend.components.editor's will-unmount event will loop forever
;; maybe we shouldn't save the block/file in "will-unmount" event?
(save-block-if-changed! block value opts)))))
(defn save-block!
([repo block-or-uuid content]