mirror of
https://github.com/penpot/penpot.git
synced 2025-05-17 18:46:12 +02:00
✨ Fix extensibility and naming of workspace shape fixer
This commit is contained in:
parent
c7f9774524
commit
a097ed29a9
4 changed files with 20 additions and 13 deletions
|
@ -97,6 +97,7 @@
|
|||
[:map {:title "FixObjChange"}
|
||||
[:type [:= :fix-obj]]
|
||||
[:id ::sm/uuid]
|
||||
[:fix {:optional true} :keyword]
|
||||
[:page-id {:optional true} ::sm/uuid]
|
||||
[:component-id {:optional true} ::sm/uuid]]]
|
||||
|
||||
|
@ -402,10 +403,16 @@
|
|||
(d/update-in-when data [:components component-id] ctst/delete-shape id ignore-touched)))
|
||||
|
||||
(defmethod process-change :fix-obj
|
||||
[data {:keys [page-id component-id] :as params}]
|
||||
(if page-id
|
||||
(d/update-in-when data [:pages-index page-id] ctst/fix-shape-children params)
|
||||
(d/update-in-when data [:components component-id] ctst/fix-shape-children params)))
|
||||
[data {:keys [page-id component-id id] :as params}]
|
||||
(letfn [(fix-container [container]
|
||||
(case (:fix params :broken-children)
|
||||
:broken-children (ctst/fix-broken-children container id)
|
||||
(ex/raise :type :internal
|
||||
:code :fix-not-implemented
|
||||
:fix (:fix params))))]
|
||||
(if page-id
|
||||
(d/update-in-when data [:pages-index page-id] fix-container)
|
||||
(d/update-in-when data [:components component-id] fix-container))))
|
||||
|
||||
;; FIXME: remove, seems like this method is already unused
|
||||
;; reg-objects operation "regenerates" the geometry and selrect of the parent groups
|
||||
|
|
|
@ -99,10 +99,10 @@
|
|||
|
||||
(update container :objects delete-from-objects))))
|
||||
|
||||
(defn fix-shape-children
|
||||
(defn fix-broken-children
|
||||
"Checks and fix the children relations of the shape. If a children does not
|
||||
exists on the objects tree, it will be removed from shape."
|
||||
[{:keys [objects] :as container} {:keys [id] :as params}]
|
||||
[{:keys [objects] :as container} id]
|
||||
(let [contains? (partial contains? objects)]
|
||||
(d/update-in-when container [:objects id :shapes]
|
||||
(fn [shapes]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue