mirror of
https://github.com/penpot/penpot.git
synced 2025-05-06 00:35:54 +02:00
✨ Improve validator syntax
This commit is contained in:
parent
2924791cb0
commit
8cc3669aac
1 changed files with 25 additions and 25 deletions
|
@ -328,7 +328,7 @@
|
||||||
;; Remove v2 info from components that have been copied and pasted
|
;; Remove v2 info from components that have been copied and pasted
|
||||||
;; from a v2 file
|
;; from a v2 file
|
||||||
(some? (:main-instance shape))
|
(some? (:main-instance shape))
|
||||||
(dissoc shape :main-instance)
|
(dissoc :main-instance)
|
||||||
|
|
||||||
(and (cfh/text-shape? shape)
|
(and (cfh/text-shape? shape)
|
||||||
(valid-text-content? (:content shape))
|
(valid-text-content? (:content shape))
|
||||||
|
@ -733,6 +733,24 @@
|
||||||
(update :pages-index update-vals fix-container)
|
(update :pages-index update-vals fix-container)
|
||||||
(d/update-when :components update-vals fix-container))))
|
(d/update-when :components update-vals fix-container))))
|
||||||
|
|
||||||
|
|
||||||
|
fix-component-root-without-component
|
||||||
|
(fn [file-data]
|
||||||
|
;; Ensure that if component-root is set component-file and component-id are set too
|
||||||
|
(letfn [(fix-container [container]
|
||||||
|
(d/update-when container :objects update-vals fix-shape))
|
||||||
|
|
||||||
|
(fix-shape [shape]
|
||||||
|
(cond-> shape
|
||||||
|
(and (ctk/instance-root? shape)
|
||||||
|
(or (not (ctk/instance-head? shape))
|
||||||
|
(not (some? (:component-file shape)))))
|
||||||
|
(dissoc :component-id
|
||||||
|
:component-file
|
||||||
|
:component-root)))]
|
||||||
|
(-> file-data
|
||||||
|
(update :pages-index update-vals fix-container))))
|
||||||
|
|
||||||
fix-copies-of-detached
|
fix-copies-of-detached
|
||||||
(fn [file-data]
|
(fn [file-data]
|
||||||
;; Find any copy that is referencing a shape inside a component that have
|
;; Find any copy that is referencing a shape inside a component that have
|
||||||
|
@ -749,25 +767,7 @@
|
||||||
(ctk/detach-shape)))]
|
(ctk/detach-shape)))]
|
||||||
(-> file-data
|
(-> file-data
|
||||||
(update :pages-index update-vals fix-container)
|
(update :pages-index update-vals fix-container)
|
||||||
(d/update-when :components update-vals fix-container))))
|
(d/update-when :components update-vals fix-container))))]
|
||||||
|
|
||||||
fix-component-root-without-component
|
|
||||||
(fn [file-data]
|
|
||||||
;; Ensure that parent-id and frame-id are not nil
|
|
||||||
(letfn [(fix-container [container]
|
|
||||||
(d/update-when container :objects update-vals fix-shape))
|
|
||||||
|
|
||||||
(fix-shape [shape]
|
|
||||||
(cond-> shape
|
|
||||||
(and (ctk/instance-root? shape)
|
|
||||||
(or (not (ctk/instance-head? shape))
|
|
||||||
(not (some? (:component-file shape)))))
|
|
||||||
(dissoc shape
|
|
||||||
:component-id
|
|
||||||
:component-file
|
|
||||||
:component-root)))]
|
|
||||||
(-> file-data
|
|
||||||
(update :pages-index update-vals fix-container))))]
|
|
||||||
|
|
||||||
(-> file-data
|
(-> file-data
|
||||||
(fix-file-data)
|
(fix-file-data)
|
||||||
|
|
Loading…
Add table
Reference in a new issue