0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 07:11:32 -05:00

🐛 Fix invalid text shapes with invalid nodes

This commit is contained in:
Andrey Antukh 2024-01-24 15:07:50 +01:00
parent e4f4ab9221
commit 2950259f97
3 changed files with 26 additions and 5 deletions

View file

@ -205,12 +205,10 @@
fix-misc-shape-issues
(fn [file-data]
(letfn [(fix-container
[container]
(letfn [(fix-container [container]
(d/update-when container :objects update-vals fix-shape))
(fix-shape
[shape]
(fix-shape [shape]
(cond-> shape
;; Some shapes has invalid gap value
(contains? shape :layout-gap)

View file

@ -6,4 +6,4 @@
(ns app.common.files.defaults)
(def version 42)
(def version 43)

View file

@ -19,6 +19,7 @@
[app.common.geom.shapes.text :as gsht]
[app.common.logging :as l]
[app.common.math :as mth]
[app.common.schema :as sm]
[app.common.svg :as csvg]
[app.common.text :as txt]
[app.common.types.shape :as cts]
@ -780,3 +781,25 @@
(-> data
(update :pages-index update-vals update-container)
(update :components update-vals update-container))))
(def ^:private valid-fill?
(sm/lazy-validator ::cts/fill))
(defmethod migrate 43
[data]
(letfn [(update-text-node [node]
(-> node
(d/update-when :fills #(filterv valid-fill? %))
(d/without-nils)))
(update-object [object]
(if (cfh/text-shape? object)
(update object :content #(txt/transform-nodes identity update-text-node %))
object))
(update-container [container]
(d/update-when container :objects update-vals update-object))]
(-> data
(update :pages-index update-vals update-container)
(update :components update-vals update-container))))