From b4040315cdc6a8a9bff58055e5a243712a45508b Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 12 Jul 2021 11:35:47 +0800 Subject: [PATCH] fix: collapsed property shouldn't be displayed --- src/main/frontend/handler/editor.cljs | 30 +++++++++++++++------------ src/main/frontend/state.cljs | 3 ++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 8086cb97d..70d46b484 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -895,29 +895,31 @@ (property/insert-property format content key value)) block (outliner-core/block {:block/uuid block-id :block/properties properties - :block/content content})] + :block/content content}) + input-pos (or (state/get-edit-pos) :max)] (outliner-core/save-node block) + (db/refresh! (state/get-current-repo) + {:key :block/change + :data [(db/pull [:block/uuid block-id])]}) + ;; update editing input content (when-let [editing-block (state/get-edit-block)] - (and (= (:block/uuid editing-block) block-id) - (state/set-edit-content! (state/get-edit-input-id) content)))))))) + (when (= (:block/uuid editing-block) block-id) + (edit-block! editing-block + input-pos + format + (state/get-edit-input-id))))))))) (defn remove-block-property! [block-id key] (let [key (keyword key)] - (block-property-aux! block-id key nil)) - (db/refresh! (state/get-current-repo) - {:key :block/change - :data [(db/pull [:block/uuid block-id])]})) + (block-property-aux! block-id key nil))) (defn set-block-property! [block-id key value] (let [key (keyword key)] - (block-property-aux! block-id key value)) - (db/refresh! (state/get-current-repo) - {:key :block/change - :data [(db/pull [:block/uuid block-id])]})) + (block-property-aux! block-id key value))) (defn set-block-timestamp! [block-id key value] @@ -2937,7 +2939,8 @@ (remove-block-property! block-id :collapsed)) (defn expand! - [] + [e] + (util/stop e) (cond (state/editing?) (when-let [block-id (:block/uuid (state/get-edit-block))] @@ -2970,7 +2973,8 @@ (expand-block! uuid))))))))) (defn collapse! - [] + [e] + (util/stop e) (cond (state/editing?) (when-let [block-id (:block/uuid (state/get-edit-block))] diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 1e9545304..cfab4db53 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -551,7 +551,8 @@ (defn get-edit-pos [] - (.-selectionStart (get-input))) + (when-let [input (get-input)] + (.-selectionStart input))) (defn set-selection-start-block! [start-block]