0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-04 13:50:12 -05:00

Merge pull request #5218 from penpot/niwinz-bugfix-10

🐛 Fix issues with invalid fills
This commit is contained in:
Alejandro 2024-10-29 08:57:50 +01:00 committed by GitHub
commit f4ae8ea5ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 54 additions and 24 deletions

View file

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

View file

@ -1075,6 +1075,33 @@
(update data :pages-index d/update-vals update-page)))
(defn migrate-up-56
[data]
(letfn [(fix-fills [object]
(d/update-when object :fills (partial filterv valid-fill?)))
(update-object [object]
(-> object
(fix-fills)
;; If shape contains shape-ref but has a nil value, we
;; should remove it from shape object
(cond-> (and (contains? object :shape-ref)
(nil? (get object :shape-ref)))
(dissoc :shape-ref))
;; The text shape also can has fills on the text
;; fragments so we need to fix fills there
(cond-> (cfh/text-shape? object)
(update :content (partial txt/transform-nodes identity fix-fills)))))
(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))))
(def migrations
"A vector of all applicable migrations"
[{:id 2 :migrate-up migrate-up-2}
@ -1121,4 +1148,5 @@
{:id 52 :migrate-up migrate-up-52}
{:id 53 :migrate-up migrate-up-26}
{:id 54 :migrate-up migrate-up-54}
{:id 55 :migrate-up migrate-up-55}])
{:id 55 :migrate-up migrate-up-55}
{:id 56 :migrate-up migrate-up-56}])

View file

@ -56,8 +56,8 @@
(def schema:image-color
[:map {:title "ImageColor"}
[:name {:optional true} :string]
[:width :int]
[:height :int]
[:width ::sm/int]
[:height ::sm/int]
[:mtype {:optional true} [:maybe :string]]
[:id ::sm/uuid]
[:keep-aspect-ratio {:optional true} :boolean]])

View file

@ -224,8 +224,8 @@
[:map {:title "ImageAttrs"}
[:metadata
[:map
[:width {:gen/gen (sg/small-int :min 1)} :int]
[:height {:gen/gen (sg/small-int :min 1)} :int]
[:width {:gen/gen (sg/small-int :min 1)} ::sm/int]
[:height {:gen/gen (sg/small-int :min 1)} ::sm/int]
[:mtype {:optional true
:gen/gen (sg/elements ["image/jpeg"
"image/png"])}

View file

@ -226,27 +226,27 @@
change-event-type
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (keyword event)]
(update-interaction index #(ctsi/set-event-type % value shape)))))
change-action-type
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (keyword event)]
(update-interaction index #(ctsi/set-action-type % value)))))
change-delay
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [value]
(update-interaction index #(ctsi/set-delay % value))))
change-destination
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value event
value (when (not= value "") (uuid/uuid value))]
@ -254,21 +254,21 @@
change-position-relative-to
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (uuid/uuid event)]
(update-interaction index #(ctsi/set-position-relative-to % value)))))
change-preserve-scroll
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(ctsi/set-preserve-scroll % value)))))
change-url
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [target (dom/get-target event)
value (dom/get-value target)
@ -287,7 +287,7 @@
change-overlay-pos-type
(mf/use-fn
(mf/deps shape)
(mf/deps shape update-interaction)
(fn [value]
(let [shape-id (:id shape)]
(update-interaction index #(ctsi/set-overlay-pos-type % value shape objects))
@ -296,7 +296,7 @@
toggle-overlay-pos-type
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [pos-type (-> (dom/get-current-target event)
(dom/get-data "value")
@ -305,21 +305,21 @@
change-close-click-outside
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(ctsi/set-close-click-outside % value)))))
change-background-overlay
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(ctsi/set-background-overlay % value)))))
change-animation-type
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (if (= "" event)
nil
@ -327,33 +327,35 @@
(update-interaction index #(ctsi/set-animation-type % value)))))
change-duration
(mf/use-fn (fn [value]
(update-interaction index #(ctsi/set-duration % value))))
(mf/use-fn
(mf/deps index update-interaction)
(fn [value]
(update-interaction index #(ctsi/set-duration % value))))
change-easing
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (keyword event)]
(update-interaction index #(ctsi/set-easing % value)))))
change-way
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (keyword event)]
(update-interaction index #(ctsi/set-way % value)))))
change-direction
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (keyword event)]
(update-interaction index #(ctsi/set-direction % value)))))
change-offset-effect
(mf/use-fn
(mf/deps index)
(mf/deps index update-interaction)
(fn [event]
(let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(ctsi/set-offset-effect % value)))))