mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 02:28:18 -05:00
✨ Add validate and repair for component instance head is not a frame
This commit is contained in:
parent
8b5b37fe1a
commit
6b09ebb75d
2 changed files with 44 additions and 24 deletions
|
@ -387,6 +387,23 @@
|
|||
(pcb/with-file-data file-data)
|
||||
(pcb/update-shapes [(:id shape)] repair-shape))))
|
||||
|
||||
(defmethod repair-error :instance-head-not-frame
|
||||
[_ {:keys [shape page-id] :as error} file-data _]
|
||||
(let [repair-shape
|
||||
(fn [shape]
|
||||
; Convert the shape in a frame.
|
||||
(log/debug :hint " -> Set :type :frame")
|
||||
(assoc shape :type :frame
|
||||
:fills []
|
||||
:hide-in-viewer true
|
||||
:rx 0
|
||||
:ry 0))]
|
||||
|
||||
(log/info :hint "Repairing shape :instance-head-not-frame" :id (:id shape) :name (:name shape) :page-id page-id)
|
||||
(-> (pcb/empty-changes nil page-id)
|
||||
(pcb/with-file-data file-data)
|
||||
(pcb/update-shapes [(:id shape)] repair-shape))))
|
||||
|
||||
(defmethod repair-error :default
|
||||
[_ error file _]
|
||||
(log/error :hint "Unknown error code, don't know how to repair" :code (:code error))
|
||||
|
|
|
@ -349,9 +349,12 @@
|
|||
(validate-frame shape file page)
|
||||
|
||||
(if (ctk/instance-head? shape)
|
||||
(if (not= :frame (:type shape))
|
||||
(report-error :instance-head-not-frame
|
||||
(str/format "Instance head should be a frame")
|
||||
shape file page)
|
||||
|
||||
(if (ctk/instance-root? shape)
|
||||
|
||||
(if (ctk/main-instance? shape)
|
||||
(if (not= context :not-component)
|
||||
(report-error :root-main-not-allowed
|
||||
|
@ -376,7 +379,7 @@
|
|||
(report-error :nested-copy-not-allowed
|
||||
(str/format "Nested copy component only allowed inside other component")
|
||||
shape file page)
|
||||
(validate-shape-copy-root-nested shape file page libraries))))
|
||||
(validate-shape-copy-root-nested shape file page libraries)))))
|
||||
|
||||
(if (ctk/in-component-copy? shape)
|
||||
(if-not (#{:copy-top :copy-nested :copy-any} context)
|
||||
|
|
Loading…
Add table
Reference in a new issue