Tienson Qin 2 лет назад
Родитель
Сommit
61d2cfbddb

+ 3 - 3
src/main/frontend/components/block.cljs

@@ -1832,7 +1832,7 @@
                                  (when order-list? " as-order-list typed-list"))}
 
                     [:span.bullet (cond->
-                                    {:blockid (str uuid)}
+                                   {:blockid (str uuid)}
                                     selected?
                                     (assoc :class "selected"))
                      (when order-list?
@@ -1840,6 +1840,7 @@
        (cond
          (and (or (mobile-util/native-platform?)
                   (:ui/show-empty-bullets? (state/get-config))
+                  (= @(:editor/new-created-block-id @state/state) uuid)
                   collapsed?
                   collapsable?)
               (not doc-mode?))
@@ -3102,8 +3103,7 @@
                            (block-mouse-leave e *control-show? block-id doc-mode?))}
         (when (and (not slide?) (not in-whiteboard?) (not hidden?))
           (let [edit? (or edit?
-                          (= uuid (:block/uuid (state/get-edit-block)))
-                          (contains? @(:editor/new-created-blocks @state/state) uuid))]
+                          (= uuid (:block/uuid (state/get-edit-block))))]
             (block-control config block uuid block-id collapsed? *control-show? edit? selected?)))
 
         (when (and @*show-left-menu? (not in-whiteboard?) (not hidden?))

+ 10 - 7
src/main/frontend/modules/outliner/pipeline.cljs

@@ -77,12 +77,13 @@
             (update-current-tx-editor-cursor! tx-report)))
 
         (when-not (:graph/importing @state/state)
-          (let [new-datoms (filter (fn [datom]
-                                     (and
-                                      (= :block/uuid (:a datom))
-                                      (true? (:added datom)))) tx-data)]
-            (when (seq new-datoms)
-              (state/set-state! :editor/new-created-blocks (set (map :v new-datoms)))))
+          (when (and (= (:outliner-op tx-meta) :insert-blocks) (:local-tx? tx-meta))
+            (let [new-datoms (filter (fn [datom]
+                                       (and
+                                        (= :block/uuid (:a datom))
+                                        (true? (:added datom)))) tx-data)]
+              (when (seq new-datoms)
+                (state/set-state! :editor/new-created-block-id (last (map :v new-datoms))))))
 
           (react/refresh! repo tx-report affected-keys)
 
@@ -113,4 +114,6 @@
                                (= :block/uuid (:a datom))
                                (= (:v datom) deleting-block-id)
                                (true? (:added datom)))) tx-data) ; editing-block was added back (could be undo or from remote sync)
-        (state/set-state! :ui/deleting-block nil)))))
+        (state/set-state! :ui/deleting-block nil)))
+
+    (state/set-state! :editor/new-created-block-id nil)))

+ 1 - 1
src/main/frontend/state.cljs

@@ -156,7 +156,7 @@
 
       :db/properties-changed-pages           {}
       :editor/cursor-range                   (atom nil)
-      :editor/new-created-blocks             (atom #{})
+      :editor/new-created-block-id           (atom nil)
 
       :selection/mode                        (atom false)
       ;; Warning: blocks order is determined when setting this attribute