fix: Deleting embedded blocks deletes source material

close #1836 #1652
This commit is contained in:
Tienson Qin
2021-05-13 16:47:33 +08:00
parent 74958f83f7
commit 4e333eb78e
3 changed files with 18 additions and 9 deletions

View File

@@ -986,12 +986,15 @@
[copy?]
(when copy? (copy-selection-blocks))
(when-let [blocks (seq (get-selected-blocks-with-children))]
(let [repo (dom/attr (first blocks) "repo")
ids (distinct (map #(uuid (dom/attr % "blockid")) blocks))
ids (if (= :up (state/get-selection-direction))
(reverse ids)
ids)]
(delete-blocks! repo ids))))
;; remove embeds and references
(let [blocks (remove (fn [block] (= "true" (dom/attr block "data-transclude"))) blocks)]
(when (seq blocks)
(let [repo (dom/attr (first blocks) "repo")
ids (distinct (map #(uuid (dom/attr % "blockid")) blocks))
ids (if (= :up (state/get-selection-direction))
(reverse ids)
ids)]
(delete-blocks! repo ids))))))
(defn- get-nearest-page
[]