0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-06 06:18:32 -05:00

Preserve components on copy&paste when possible

This commit is contained in:
Andrés Moya 2021-06-28 12:31:08 +02:00 committed by Alonso Torres
parent e818170eec
commit 08d2dbc9bb
2 changed files with 18 additions and 9 deletions

View file

@ -4,13 +4,13 @@
### :sparkles: New features ### :sparkles: New features
- Allow nested asset groups [Taiga #1716](https://tree.taiga.io/project/penpot/us/1716) - Allow nested asset groups [Taiga #1716](https://tree.taiga.io/project/penpot/us/1716).
- Allow to ungroup assets [Taiga #1719](https://tree.taiga.io/project/penpot/us/1719) - Allow to ungroup assets [Taiga #1719](https://tree.taiga.io/project/penpot/us/1719).
- Allow to rename assets groups [Taiga #1721](https://tree.taiga.io/project/penpot/us/1721) - Allow to rename assets groups [Taiga #1721](https://tree.taiga.io/project/penpot/us/1721).
- Memorize collapse state of assets in panel [Taiga #1718](https://tree.taiga.io/project/penpot/us/1718) - Memorize collapse state of assets in panel [Taiga #1718](https://tree.taiga.io/project/penpot/us/1718).
- Headers button sets and menus review [Taiga #1663](https://tree.taiga.io/project/penpot/us/1663) - Headers button sets and menus review [Taiga #1663](https://tree.taiga.io/project/penpot/us/1663).
- Add the ability to offload file data to a cheaper storage when file - Preserve components if possible, when pasted into a different file [Taiga #1063](https://tree.taiga.io/project/penpot/issue/1063).
becomes inactive. - Add the ability to offload file data to a cheaper storage when file becomes inactive.
### :bug: Bugs fixed ### :bug: Bugs fixed

View file

@ -1537,6 +1537,15 @@
(assoc change :index (get map-ids (:old-id change))) (assoc change :index (get map-ids (:old-id change)))
change))) change)))
;; Check if the shape is an instance whose master is defined in a
;; library that is not linked to the current file
(foreign-instance? [shape objects state]
(let [root (cph/get-root-shape shape objects)
root-file-id (:component-file root)]
(and (some? root)
(not= root-file-id (:current-file-id state))
(nil? (get-in state [:workspace-libraries root-file-id])))))
;; Procceed with the standard shape paste procediment. ;; Procceed with the standard shape paste procediment.
(do-paste [it state mouse-pos media] (do-paste [it state mouse-pos media]
(let [media-idx (d/index-by :prev-id media) (let [media-idx (d/index-by :prev-id media)
@ -1551,8 +1560,8 @@
(assoc :parent-id parent-id) (assoc :parent-id parent-id)
(cond-> (cond->
;; Pasting from another file, we deattach components ;; if foreign instance, detach the shape
(not= (:current-file-id state) (:file-id data)) (foreign-instance? shape objects state)
(dissoc :component-id (dissoc :component-id
:component-file :component-file
:component-root? :component-root?