fix: open block for editing after pressing Enter in a text property

This commit is contained in:
Tienson Qin
2024-01-26 12:53:38 +08:00
parent 0aa39fb15a
commit c8a7a4e627
3 changed files with 14 additions and 11 deletions

View File

@@ -312,12 +312,14 @@
(defn <create-new-block!
[block property value]
(p/let [last-block-id (db-property-handler/create-property-text-block! block property value
editor-handler/wrap-parse-block
(let [{:keys [last-block-id result]} (db-property-handler/create-property-text-block! block property value
editor-handler/wrap-parse-block
{})
_ (exit-edit-property)]
(editor-handler/edit-block! (db/entity [:block/uuid last-block-id]) :max last-block-id)))
{})]
(p/do!
result
(exit-edit-property)
(editor-handler/edit-block! (db/entity [:block/uuid last-block-id]) :max last-block-id))))
(defn <create-new-block-from-template!
"`template`: tag block"

View File

@@ -617,11 +617,12 @@
class? (contains? (:block/type block) "class")
property-key (:block/original-name property)]
(db/transact! repo (if page (cons page blocks) blocks) {:outliner-op :insert-blocks})
(when property-key
(if (and class? class-schema?)
(class-add-property! repo (:block/uuid block) property-key)
(set-block-property! repo (:block/uuid block) property-key (:block/uuid first-block) {})))
last-block-id))
(let [result (when property-key
(if (and class? class-schema?)
(class-add-property! repo (:block/uuid block) property-key)
(set-block-property! repo (:block/uuid block) property-key (:block/uuid first-block) {})))]
{:last-block-id last-block-id
:result result})))
(defn property-create-new-block-from-template
[block property template]

View File

@@ -291,7 +291,7 @@
;; add property
(db-property-handler/upsert-property! repo k {:type :default} {})
(let [property (db/entity [:block/name k])
last-block-id (db-property-handler/create-property-text-block! fb property "Block content" editor-handler/wrap-parse-block {})
{:keys [last-block-id]} (db-property-handler/create-property-text-block! fb property "Block content" editor-handler/wrap-parse-block {})
{:keys [from-block-id from-property-id]} (db-property-handler/get-property-block-created-block [:block/uuid last-block-id])]
(is (= from-block-id (:db/id fb)))
(is (= from-property-id (:db/id property)))))))