Fix the display issue caused by inconsistent page order and dbid order of blocks

This commit is contained in:
Mega Yu
2023-04-13 16:08:29 +08:00
committed by Tienson Qin
parent 730b8e0528
commit 47f6893457

View File

@@ -990,7 +990,20 @@
block (db/entity [:block/uuid (first ids)])]
(when block
(let [html (export-html/export-blocks-as-html repo top-level-block-uuids nil)
copied-blocks (get-all-blocks-by-ids repo top-level-block-uuids)]
copied-blocks (get-all-blocks-by-ids repo top-level-block-uuids)
selected-blocks (dom/sel ".ls-block.selected.noselect")
selected-block-ids (->> selected-blocks
(reduce
(fn [selected-block-ids selected-block]
(let [selected-block-id (dom/attr selected-block "blockid")]
(if (some #(= selected-block-id %) selected-block-ids)
selected-block-ids
(reduce #(conj %1 (dom/attr %2 "blockid"))
(conj selected-block-ids selected-block-id)
(seq (dom/by-class selected-block "ls-block"))))))
[])
(map uuid))
copied-blocks (sort-by #(.indexOf selected-block-ids (:block/uuid %)) copied-blocks)]
(common-handler/copy-to-clipboard-without-id-property! (:block/format block) content (when html? html) copied-blocks))
(state/set-block-op-type! :copy)
(notification/show! "Copied!" :success)))))