mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 18:36:43 +00:00
fix(editor): pasted template had chaotic orders
This commit is contained in:
@@ -1862,8 +1862,13 @@
|
||||
block-uuid (:block/uuid block)
|
||||
including-parent? (not (false? (:including-parent (:block/properties block))))
|
||||
blocks (if including-parent? (db/get-block-and-children repo block-uuid) (db/get-block-children repo block-uuid))
|
||||
level-blocks-map (blocks-with-level blocks)
|
||||
tree (blocks-vec->tree (vals level-blocks-map))]
|
||||
level-blocks (vals (blocks-with-level blocks))
|
||||
grouped-blocks (group-by #(= db-id (:db/id %)) level-blocks)
|
||||
root-block (or (first (get grouped-blocks true)) (assoc (db/pull db-id) :level 0))
|
||||
blocks-exclude-root (get grouped-blocks false)
|
||||
sorted-blocks (tree/sort-blocks blocks-exclude-root root-block)
|
||||
result-blocks (if including-parent? sorted-blocks (drop 1 sorted-blocks))
|
||||
tree (blocks-vec->tree result-blocks)]
|
||||
(paste-block-tree-at-point tree [:template :including-parent]
|
||||
(fn [content]
|
||||
(->> content
|
||||
|
||||
Reference in New Issue
Block a user