mirror of
https://github.com/penpot/penpot.git
synced 2025-01-27 00:49:28 -05:00
🎉 Rename shapes inside components
This commit is contained in:
parent
dd283381a1
commit
9805f8b9f2
4 changed files with 23 additions and 14 deletions
|
@ -403,14 +403,17 @@
|
||||||
|
|
||||||
(defmethod process-operation :set
|
(defmethod process-operation :set
|
||||||
[shape op]
|
[shape op]
|
||||||
(let [attr (:attr op)
|
(let [attr (:attr op)
|
||||||
val (:val op)
|
val (:val op)
|
||||||
ignore (:ignore-touched op)
|
ignore (:ignore-touched op)
|
||||||
shape-ref (:shape-ref shape)
|
shape-ref (:shape-ref shape)
|
||||||
group (get component-sync-attrs attr)]
|
group (get component-sync-attrs attr)
|
||||||
|
root-name? (and (= group :name-group)
|
||||||
|
(:component-root? shape))]
|
||||||
|
|
||||||
(cond-> shape
|
(cond-> shape
|
||||||
(and shape-ref group (not ignore) (not= val (get shape attr))
|
(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
|
;; FIXME: it's difficult to tell if the geometry changes affect
|
||||||
;; an individual shape inside the component, or are for
|
;; an individual shape inside the component, or are for
|
||||||
;; the whole component (in which case we shouldn't set
|
;; the whole component (in which case we shouldn't set
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
(def root uuid/zero)
|
(def root uuid/zero)
|
||||||
|
|
||||||
(def component-sync-attrs
|
(def component-sync-attrs
|
||||||
{:fill-color :fill-group
|
{:name :name-group
|
||||||
|
:fill-color :fill-group
|
||||||
:fill-opacity :fill-group
|
:fill-opacity :fill-group
|
||||||
:fill-color-gradient :fill-group
|
:fill-color-gradient :fill-group
|
||||||
:fill-color-ref-file :fill-group
|
:fill-color-ref-file :fill-group
|
||||||
|
|
|
@ -401,15 +401,14 @@
|
||||||
|
|
||||||
update-new-shape
|
update-new-shape
|
||||||
(fn [new-shape original-shape]
|
(fn [new-shape original-shape]
|
||||||
(let [new-name
|
(let [new-name (dwc/generate-unique-name @unames (:name new-shape))]
|
||||||
(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
|
(cond-> new-shape
|
||||||
true
|
true
|
||||||
(as-> $
|
(as-> $
|
||||||
(assoc $ :name new-name)
|
|
||||||
(geom/move $ delta)
|
(geom/move $ delta)
|
||||||
(assoc $ :frame-id frame-id)
|
(assoc $ :frame-id frame-id)
|
||||||
(assoc $ :parent-id
|
(assoc $ :parent-id
|
||||||
|
@ -417,12 +416,13 @@
|
||||||
(dissoc $ :touched))
|
(dissoc $ :touched))
|
||||||
|
|
||||||
(nil? (:shape-ref original-shape))
|
(nil? (:shape-ref original-shape))
|
||||||
(assoc :shape-ref (:id original-shape))
|
(assoc :shape-ref (:id original-shape))
|
||||||
|
|
||||||
(nil? (:parent-id original-shape))
|
(nil? (:parent-id original-shape))
|
||||||
(assoc :component-id (:id original-shape)
|
(assoc :component-id (:id original-shape)
|
||||||
:component-file file-id
|
:component-file file-id
|
||||||
:component-root? true)
|
:component-root? true
|
||||||
|
:name new-name)
|
||||||
|
|
||||||
(some? (:parent-id original-shape))
|
(some? (:parent-id original-shape))
|
||||||
(dissoc :component-root?))))
|
(dissoc :component-root?))))
|
||||||
|
|
|
@ -1115,9 +1115,14 @@
|
||||||
:val (get dest-shape attr)
|
:val (get dest-shape attr)
|
||||||
:ignore-touched true}
|
: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))
|
(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)
|
(recur (next attrs)
|
||||||
roperations
|
roperations
|
||||||
uoperations)
|
uoperations)
|
||||||
|
|
Loading…
Add table
Reference in a new issue