0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-07 15:39:42 -05:00

🐛 Fix copy paste texts with typography assets linked

This commit is contained in:
Pablo Alba 2023-01-30 12:23:49 +01:00
parent c59fc87fc4
commit 9f8d86a80e
3 changed files with 20 additions and 3 deletions

View file

@ -67,6 +67,7 @@
- Fix paths not flagged as modified when resized [Taiga #4742](https://tree.taiga.io/project/penpot/issue/4742)
- Fix resend invitation doesn't reset the expiration date [Taiga #4741](https://tree.taiga.io/project/penpot/issue/4741)
- Fix incorrect state after undo page creation [Taiga #4690](https://tree.taiga.io/project/penpot/issue/4690)
- Fix copy paste texts with typography assets linked [Taiga #4750](https://tree.taiga.io/project/penpot/issue/4750)
### :heart: Community contributions by (Thank you!)

View file

@ -70,3 +70,14 @@
remap-typography
content)))))
(defn remove-external-typographies
"Change the shape so that any use of an external typography now is removed"
[shape file-id]
(let [remove-ref-file #(dissoc % :typography-ref-file :typography-ref-id)]
(update shape :content
(fn [content]
(txt/transform-nodes #(not= (:typography-ref-file %) file-id)
remove-ref-file
content)))))

View file

@ -27,6 +27,7 @@
[app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctst]
[app.common.types.shape.layout :as ctl]
[app.common.types.typography :as ctt]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.main.data.comments :as dcm]
@ -1550,7 +1551,8 @@
;; Proceed with the standard shape paste process.
(do-paste [it state mouse-pos media]
(let [page (wsh/lookup-page state)
(let [file-id (:current-file-id state)
page (wsh/lookup-page state)
media-idx (d/index-by :prev-id media)
;; Calculate position for the pasted elements
@ -1565,7 +1567,10 @@
;; if foreign instance, detach the shape
(cond-> (foreign-instance? shape paste-objects state)
(dissoc :component-id :component-file :component-root?
:remote-synced? :shape-ref :touched))))
:remote-synced? :shape-ref :touched))
;; if is a text, remove references to external typographies
(cond-> (= (:type shape) :text)
(ctt/remove-external-typographies file-id))))
paste-objects (->> paste-objects (d/mapm process-shape))
@ -1587,7 +1592,7 @@
(into (d/ordered-set)))
undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id)
(rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dws/select-shapes selected)
(ptk/data-event :layout/update [frame-id])