cut blocks remains uuid

This commit is contained in:
Mega Yu
2023-04-12 16:31:12 +08:00
committed by Tienson Qin
parent c8ed14ef05
commit 730b8e0528
4 changed files with 30 additions and 16 deletions

View File

@@ -801,6 +801,10 @@
(declare save-block!)
(defn- block-has-no-ref?
[eid]
(empty? (:block/_refs (db/entity eid))))
(defn delete-block!
([repo]
(delete-block! repo true))
@@ -988,6 +992,7 @@
(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)]
(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)))))
(defn copy-block-refs
@@ -1056,6 +1061,7 @@
(defn cut-selection-blocks
[copy?]
(when copy? (copy-selection-blocks true))
(state/set-block-op-type! :cut)
(when-let [blocks (seq (get-selected-blocks))]
;; remove embeds, references and queries
(let [dom-blocks (remove (fn [block]
@@ -1204,6 +1210,7 @@
html (export-html/export-blocks-as-html repo [block-id] nil)
sorted-blocks (tree/get-sorted-block-and-children repo (:db/id block))]
(common-handler/copy-to-clipboard-without-id-property! (:block/format block) md-content html sorted-blocks)
(state/set-block-op-type! :cut)
(delete-block-aux! block true))))
(defn highlight-selection-area!
@@ -2018,16 +2025,16 @@
empty-target? (string/blank? (:block/content target-block))
paste-nested-blocks? (nested-blocks blocks)
target-block-has-children? (db/has-children? (:block/uuid target-block))
replace-empty-target? (if (and paste-nested-blocks? empty-target? target-block-has-children?)
false
true)
target-block' (if replace-empty-target? target-block
(db/pull (:db/id (:block/left target-block))))
replace-empty-target? (and empty-target?
(or (not target-block-has-children?)
(and target-block-has-children? (= (count blocks) 1)))
(block-has-no-ref? (:db/id target-block)))
target-block' (if (and empty-target? target-block-has-children? paste-nested-blocks?)
(db/pull (:db/id (:block/left target-block)))
target-block)
sibling? (cond
(and paste-nested-blocks? empty-target?)
(if (= (:block/parent target-block') (:block/parent target-block))
true
false)
(= (:block/parent target-block') (:block/parent target-block))
(some? sibling?)
sibling?
@@ -2056,6 +2063,7 @@
:outliner-op :paste
:replace-empty-target? replace-empty-target?
:keep-uuid? keep-uuid?})]
(state/set-block-op-type! nil)
(edit-last-block-after-inserted! result))))))
(defn- block-tree->blocks