Merge pull request #7785 from penpot/niwinz-develop-binary-fills

🐛 Fix invalid fills schema when binary fills are used
This commit is contained in:
Alejandro Alonso
2025-11-20 09:06:45 +01:00
committed by GitHub
3 changed files with 16 additions and 11 deletions

View File

@@ -11,6 +11,7 @@
[app.common.exceptions :as ex] [app.common.exceptions :as ex]
[app.common.flags :as flags] [app.common.flags :as flags]
[app.common.schema :as sm] [app.common.schema :as sm]
[app.common.schema.generators :as sg]
[app.common.types.color :as types.color] [app.common.types.color :as types.color]
[app.common.types.fills.impl :as impl] [app.common.types.fills.impl :as impl]
[clojure.core :as c] [clojure.core :as c]
@@ -49,12 +50,19 @@
(= 1 (count result)))) (= 1 (count result))))
(def schema:fill (def schema:fill
[:and schema:fill-attrs [:and schema:fill-attrs [:fn has-valid-fill-attrs?]])
[:fn has-valid-fill-attrs?]])
(def check-fill (def check-fill
(sm/check-fn schema:fill)) (sm/check-fn schema:fill))
(def ^:private schema:fills-as-vector
[:vector {:gen/max 2} schema:fill])
(def schema:fills
[:or {:gen/gen (sg/generator schema:fills-as-vector)}
schema:fills-as-vector
[:fn impl/fills?]])
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CONSTRUCTORS ;; CONSTRUCTORS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@@ -19,7 +19,7 @@
[app.common.schema.generators :as sg] [app.common.schema.generators :as sg]
[app.common.transit :as t] [app.common.transit :as t]
[app.common.types.color :as clr] [app.common.types.color :as clr]
[app.common.types.fills :refer [schema:fill fill->color]] [app.common.types.fills :refer [schema:fills fill->color]]
[app.common.types.grid :as ctg] [app.common.types.grid :as ctg]
[app.common.types.path :as path] [app.common.types.path :as path]
[app.common.types.plugins :as ctpg] [app.common.types.plugins :as ctpg]
@@ -192,8 +192,7 @@
[:locked {:optional true} :boolean] [:locked {:optional true} :boolean]
[:hidden {:optional true} :boolean] [:hidden {:optional true} :boolean]
[:masked-group {:optional true} :boolean] [:masked-group {:optional true} :boolean]
[:fills {:optional true} [:fills {:optional true} schema:fills]
[:vector {:gen/max 2} schema:fill]]
[:proportion {:optional true} ::sm/safe-number] [:proportion {:optional true} ::sm/safe-number]
[:proportion-lock {:optional true} :boolean] [:proportion-lock {:optional true} :boolean]
[:constraints-h {:optional true} [:constraints-h {:optional true}

View File

@@ -7,7 +7,7 @@
(ns app.common.types.shape.text (ns app.common.types.shape.text
(:require (:require
[app.common.schema :as sm] [app.common.schema :as sm]
[app.common.types.fills :refer [schema:fill]])) [app.common.types.fills :refer [schema:fills]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SCHEMA ;; SCHEMA
@@ -32,8 +32,7 @@
[:type [:= "paragraph"]] [:type [:= "paragraph"]]
[:key {:optional true} :string] [:key {:optional true} :string]
[:fills {:optional true} [:fills {:optional true}
[:maybe [:maybe schema:fills]]
[:vector {:gen/max 2} schema:fill]]]
[:font-family {:optional true} ::sm/text] [:font-family {:optional true} ::sm/text]
[:font-size {:optional true} ::sm/text] [:font-size {:optional true} ::sm/text]
[:font-style {:optional true} ::sm/text] [:font-style {:optional true} ::sm/text]
@@ -49,8 +48,7 @@
[:text :string] [:text :string]
[:key {:optional true} :string] [:key {:optional true} :string]
[:fills {:optional true} [:fills {:optional true}
[:maybe [:maybe schema:fills]]
[:vector {:gen/max 2} schema:fill]]]
[:font-family {:optional true} ::sm/text] [:font-family {:optional true} ::sm/text]
[:font-size {:optional true} ::sm/text] [:font-size {:optional true} ::sm/text]
[:font-style {:optional true} ::sm/text] [:font-style {:optional true} ::sm/text]
@@ -71,7 +69,7 @@
[:y ::sm/safe-number] [:y ::sm/safe-number]
[:width ::sm/safe-number] [:width ::sm/safe-number]
[:height ::sm/safe-number] [:height ::sm/safe-number]
[:fills [:vector {:gen/max 2} schema:fill]] [:fills schema:fills]
[:font-family {:optional true} ::sm/text] [:font-family {:optional true} ::sm/text]
[:font-size {:optional true} ::sm/text] [:font-size {:optional true} ::sm/text]
[:font-style {:optional true} ::sm/text] [:font-style {:optional true} ::sm/text]