Skip to content

Commit c5adadd

Browse files
committed
fix: Cmd+V does not insert images into the property value
related to logseq/db-test#569
1 parent 2122d3d commit c5adadd

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

deps/db/src/logseq/db.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
(remove empty?))
159159
delete-blocks-tx (when-not (string? repo-or-conn)
160160
(delete-blocks/update-refs-history-and-macros @repo-or-conn tx-data tx-meta))
161-
tx-data (concat tx-data delete-blocks-tx)]
161+
tx-data (distinct (concat tx-data delete-blocks-tx))]
162162

163163
;; Ensure worker can handle the request sequentially (one by one)
164164
;; Because UI assumes that the in-memory db has all the data except the last one transaction

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
(assoc-level-aux tree-vec children-key 1))
432432

433433
(defn- assign-temp-id
434-
[blocks replace-empty-target? target-block]
434+
[db blocks replace-empty-target? target-block]
435435
(->> blocks
436436
(map-indexed
437437
(fn [idx block]
@@ -445,8 +445,23 @@
445445
[(assoc block
446446
:db/id (:db/id target-block)
447447
:block/uuid (:block/uuid target-block))]
448-
[[:db/retractEntity (:db/id target-block)] ; retract target-block first
449-
(assoc block :db/id db-id)])
448+
(let [old-property-values (d/q
449+
'[:find ?b ?a
450+
:in $ ?v
451+
:where
452+
[?b ?a ?v]
453+
[?v :block/uuid]]
454+
db
455+
(:db/id target-block))
456+
from-property (:logseq.property/created-from-property target-block)]
457+
(concat
458+
[[:db/retractEntity (:db/id target-block)] ; retract target-block first
459+
(cond-> (assoc block :db/id db-id)
460+
from-property
461+
(assoc :logseq.property/created-from-property (:db/id from-property)))]
462+
(map (fn [[b a]]
463+
[:db/add b a db-id])
464+
old-property-values))))
450465
[(assoc block :db/id db-id)]))))
451466
(apply concat)))
452467

@@ -827,7 +842,7 @@
827842
:tx (vec blocks-tx)
828843
:blocks (vec blocks)
829844
:target-block target-block}))
830-
(let [tx (assign-temp-id blocks-tx replace-empty-target? target-block)
845+
(let [tx (assign-temp-id db blocks-tx replace-empty-target? target-block)
831846
old-db-id-blocks (->> (filter :block.temp/use-old-db-id? tx)
832847
(map :block/uuid)
833848
(set))

0 commit comments

Comments
 (0)