Просмотр исходного кода

fix: collapsed property shouldn't be displayed

Tienson Qin 4 лет назад
Родитель
Сommit
b4040315cd
2 измененных файлов с 19 добавлено и 14 удалено
  1. 17 13
      src/main/frontend/handler/editor.cljs
  2. 2 1
      src/main/frontend/state.cljs

+ 17 - 13
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))]

+ 2 - 1
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]