mirror of
https://github.com/penpot/penpot.git
synced 2025-02-20 13:55:34 -05:00
✨ Don't duplicate images when copy and paste in the same file.
This commit is contained in:
parent
ea2079f36f
commit
9ed01cc0df
1 changed files with 12 additions and 9 deletions
|
@ -1220,6 +1220,7 @@
|
||||||
selected (get-in state [:workspace-local :selected])
|
selected (get-in state [:workspace-local :selected])
|
||||||
pdata (reduce (partial collect-object-ids objects) {} selected)
|
pdata (reduce (partial collect-object-ids objects) {} selected)
|
||||||
initial {:type :copied-shapes
|
initial {:type :copied-shapes
|
||||||
|
:file-id (:current-file-id state)
|
||||||
:selected selected
|
:selected selected
|
||||||
:objects {}
|
:objects {}
|
||||||
:images #{}}]
|
:images #{}}]
|
||||||
|
@ -1316,16 +1317,16 @@
|
||||||
(assoc media :prev-id (:id imgpart))))))
|
(assoc media :prev-id (:id imgpart))))))
|
||||||
|
|
||||||
;; Analyze the rchange and replace staled media and
|
;; Analyze the rchange and replace staled media and
|
||||||
;; references to the previusly uploased new media-objects.
|
;; references to the new uploaded media-objects.
|
||||||
(process-rchange [media-idx item]
|
(process-rchange [media-idx item]
|
||||||
(if (= :image (get-in item [:obj :type]))
|
(if (= :image (get-in item [:obj :type]))
|
||||||
(update-in item [:obj :metadata]
|
(update-in item [:obj :metadata]
|
||||||
(fn [{:keys [id] :as mdata}]
|
(fn [{:keys [id] :as mdata}]
|
||||||
(let [mobj (get media-idx id)]
|
(if-let [mobj (get media-idx id)]
|
||||||
(assoc mdata
|
(assoc mdata
|
||||||
:id (:id mobj)
|
:id (:id mobj)
|
||||||
:path (:path mobj)
|
:path (:path mobj))
|
||||||
:thumb-path (:thumb-path mobj)))))
|
mdata)))
|
||||||
item))
|
item))
|
||||||
|
|
||||||
;; Procceed with the standard shape paste procediment.
|
;; Procceed with the standard shape paste procediment.
|
||||||
|
@ -1343,7 +1344,7 @@
|
||||||
(if (selected-frame? state)
|
(if (selected-frame? state)
|
||||||
[(first page-selected)
|
[(first page-selected)
|
||||||
(get page-objects (first page-selected))]
|
(get page-objects (first page-selected))]
|
||||||
[(cph/frame-id-by-position page-objects mouse-pos)
|
[(cp/frame-id-by-position page-objects mouse-pos)
|
||||||
(gpt/subtract mouse-pos orig-pos)])
|
(gpt/subtract mouse-pos orig-pos)])
|
||||||
|
|
||||||
objects (d/mapm (fn [_ v] (assoc v :frame-id frame-id :parent-id frame-id)) objects)
|
objects (d/mapm (fn [_ v] (assoc v :frame-id frame-id :parent-id frame-id)) objects)
|
||||||
|
@ -1369,10 +1370,12 @@
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [file-id (:current-file-id state)
|
(let [file-id (:current-file-id state)
|
||||||
mouse-pos (deref ms/mouse-position)]
|
mouse-pos (deref ms/mouse-position)]
|
||||||
(->> (rx/from (seq images))
|
(if (= file-id (:file-id data))
|
||||||
(rx/merge-map (partial upload-media file-id))
|
(do-paste state mouse-pos [])
|
||||||
(rx/reduce conj [])
|
(->> (rx/from (seq images))
|
||||||
(rx/mapcat (partial do-paste state mouse-pos))))))))
|
(rx/merge-map (partial upload-media file-id))
|
||||||
|
(rx/reduce conj [])
|
||||||
|
(rx/mapcat (partial do-paste state mouse-pos)))))))))
|
||||||
|
|
||||||
|
|
||||||
(defn as-content [text]
|
(defn as-content [text]
|
||||||
|
|
Loading…
Add table
Reference in a new issue