0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

🎉 Rename shapes inside components

This commit is contained in:
Andrés Moya 2021-01-19 10:14:23 +01:00 committed by Andrey Antukh
parent dd283381a1
commit 9805f8b9f2
4 changed files with 23 additions and 14 deletions

View file

@ -403,14 +403,17 @@
(defmethod process-operation :set
[shape op]
(let [attr (:attr op)
val (:val op)
ignore (:ignore-touched op)
shape-ref (:shape-ref shape)
group (get component-sync-attrs attr)]
(let [attr (:attr op)
val (:val op)
ignore (:ignore-touched op)
shape-ref (:shape-ref shape)
group (get component-sync-attrs attr)
root-name? (and (= group :name-group)
(:component-root? shape))]
(cond-> shape
(and shape-ref group (not ignore) (not= val (get shape attr))
(not root-name?)
;; FIXME: it's difficult to tell if the geometry changes affect
;; an individual shape inside the component, or are for
;; the whole component (in which case we shouldn't set

View file

@ -16,7 +16,8 @@
(def root uuid/zero)
(def component-sync-attrs
{:fill-color :fill-group
{:name :name-group
:fill-color :fill-group
:fill-opacity :fill-group
:fill-color-gradient :fill-group
:fill-color-ref-file :fill-group

View file

@ -401,15 +401,14 @@
update-new-shape
(fn [new-shape original-shape]
(let [new-name
(dwc/generate-unique-name @unames (:name new-shape))]
(let [new-name (dwc/generate-unique-name @unames (:name new-shape))]
(swap! unames conj new-name)
(when (nil? (:parent-id original-shape))
(swap! unames conj new-name))
(cond-> new-shape
true
(as-> $
(assoc $ :name new-name)
(geom/move $ delta)
(assoc $ :frame-id frame-id)
(assoc $ :parent-id
@ -417,12 +416,13 @@
(dissoc $ :touched))
(nil? (:shape-ref original-shape))
(assoc :shape-ref (:id original-shape))
(assoc :shape-ref (:id original-shape))
(nil? (:parent-id original-shape))
(assoc :component-id (:id original-shape)
:component-file file-id
:component-root? true)
:component-root? true
:name new-name)
(some? (:parent-id original-shape))
(dissoc :component-root?))))

View file

@ -1115,9 +1115,14 @@
:val (get dest-shape attr)
:ignore-touched true}
attr-group (get cp/component-sync-attrs attr)]
attr-group (get cp/component-sync-attrs attr)
root-name? (and (= attr-group :name-group)
(:component-root? dest-shape))]
(if (or (= (get origin-shape attr) (get dest-shape attr))
(and (touched attr-group) omit-touched?))
(and (touched attr-group) omit-touched?)
root-name?)
(recur (next attrs)
roperations
uoperations)