Browse Source

fix: open the last block when the template has only one block

Tienson Qin 4 years ago
parent
commit
9bc5bc94b7
1 changed files with 4 additions and 5 deletions
  1. 4 5
      src/main/frontend/handler/editor.cljs

+ 4 - 5
src/main/frontend/handler/editor.cljs

@@ -2202,11 +2202,10 @@
              last-block (paste-block-vec-tree-at-target tree [:id :template :template-including-parent] opts)]
          (clear-when-saved!)
          (db/refresh! repo {:key :block/insert :data [(db/pull db-id)]})
-         (let [block (:data (last (flatten last-block)))]
-           (edit-block! block :max (:block/format block) (:block/uuid block))))))
-
-   (when-let [input (gdom/getElement element-id)]
-     (.focus input))))
+         (let [block (if (tree/satisfied-inode? last-block)
+                       (:data last-block)
+                       (:data (last (flatten last-block))))]
+           (edit-block! block :max (:block/format block) (:block/uuid block))))))))
 
 (defn template-on-chosen-handler
   [element-id]