Parcourir la source

fix: paste-block-tree-after-target when target-block is page-block

rcmerci il y a 4 ans
Parent
commit
fa03b7dae1
1 fichiers modifiés avec 9 ajouts et 2 suppressions
  1. 9 2
      src/main/frontend/handler/editor.cljs

+ 9 - 2
src/main/frontend/handler/editor.cljs

@@ -2088,11 +2088,18 @@
 (defn paste-block-tree-after-target
   [target-block-id sibling? tree format]
   (let [vec-tree (tree->vec-tree tree)
-        block-tree (vec-tree->vec-block-tree vec-tree format)]
+        block-tree (vec-tree->vec-block-tree vec-tree format)
+        target-block (db/pull target-block-id)
+        page-block (if (:block/name target-block) target-block
+                       (db/entity (:db/id (:block/page (db/pull target-block-id)))))
+        ;; sibling? = false, when target-block is a page-block
+        sibling? (if (=  target-block-id (:db/id page-block))
+                   false
+                   sibling?)]
     (paste-block-vec-tree-at-target
      block-tree [] nil
      #(get-block-tree-insert-pos-after-target target-block-id sibling?)
-     (db/entity (:db/id (:block/page (db/pull target-block-id)))))))
+     page-block)))
 
 (defn template-on-chosen-handler
   [_input id _q format _edit-block _edit-content]