Skip to content

Commit fb9e735

Browse files
committed
fix: paste query block should create new block
related to logseq/db-test#572
1 parent 7619e3a commit fb9e735

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

deps/db/src/logseq/db.cljs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@
199199
:as opts}]
200200
(if-let [children (sort-by-order
201201
(if include-property-block?
202-
(entity-plus/lookup-kv-then-entity entity :block/_raw-parent)
202+
(let [children (entity-plus/lookup-kv-then-entity entity :block/_raw-parent)]
203+
(concat children
204+
(keep (fn [c] (:logseq.property/query c)) children)))
203205
(entity-plus/lookup-kv-then-entity entity :block/_parent)))]
204206
(cons entity (mapcat #(get-block-and-children-aux % opts) children))
205207
[entity]))

deps/outliner/src/logseq/outliner/core.cljs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -795,23 +795,25 @@
795795
:or {update-timestamps? true}}]
796796
{:pre [(seq blocks)
797797
(m/validate block-map-or-entity target-block)]}
798-
(let [blocks (keep (fn [b]
799-
(if-let [eid (or (:db/id b)
800-
(when-let [id (:block/uuid b)]
801-
[:block/uuid id]))]
802-
(let [b' (if-let [e (if (de/entity? b) b (d/entity db eid))]
803-
(merge
804-
(into {} e)
805-
{:db/id (:db/id e)
806-
:block/title (or (:block/raw-title e) (:block/title e))}
798+
(let [blocks (->>
799+
(keep (fn [b]
800+
(if-let [eid (or (:db/id b)
801+
(when-let [id (:block/uuid b)]
802+
[:block/uuid id]))]
803+
(let [b' (if-let [e (if (de/entity? b) b (d/entity db eid))]
804+
(merge
805+
(into {} e)
806+
{:db/id (:db/id e)
807+
:block/title (or (:block/raw-title e) (:block/title e))}
808+
b)
807809
b)
808-
b)
809-
dissoc-keys (concat [:block/tx-id]
810-
(when (contains? #{:insert-template-blocks :paste} outliner-op)
811-
[:block/refs]))]
812-
(apply dissoc b' dissoc-keys))
813-
b))
814-
blocks)
810+
dissoc-keys (concat [:block/tx-id]
811+
(when (contains? #{:insert-template-blocks :paste} outliner-op)
812+
[:block/refs]))]
813+
(apply dissoc b' dissoc-keys))
814+
b))
815+
blocks)
816+
(remove ldb/asset?))
815817
[target-block sibling?] (get-target-block db blocks target-block opts)
816818
_ (assert (some? target-block) (str "Invalid target: " target-block))
817819
replace-empty-target? (if (and (some? replace-empty-target?)

0 commit comments

Comments
 (0)