🎉 Add background blur info to plugins API

This commit is contained in:
Eva Marco 2026-06-11 13:23:00 +02:00 committed by alonso.torres
parent 3e601ed00a
commit 44dd70fe5e
6 changed files with 49 additions and 21 deletions

View File

@ -42,9 +42,6 @@
[{:id "shape" :type :blend-filters}] [{:id "shape" :type :blend-filters}]
(->> shape :shadow (apply-filters :style :inner-shadow)) (->> shape :shadow (apply-filters :style :inner-shadow))
;; Background blur won't work in current SVG specification
;; We can revisit this in the future
#_(->> shape :background-blur list (apply-filters :type :background-blur))
(->> shape :blur list (apply-filters :type :layer-blur)))) (->> shape :blur list (apply-filters :type :layer-blur))))
(defn- calculate-filter-bounds (defn- calculate-filter-bounds

View File

@ -232,16 +232,14 @@
;; export interface Blur { ;; export interface Blur {
;; id?: string; ;; id?: string;
;; type?: 'layer-blur' | 'background-blur';
;; value?: number; ;; value?: number;
;; hidden?: boolean; ;; hidden?: boolean;
;; } ;; }
(defn format-blur (defn format-blur
[{:keys [id type value hidden] :as blur}] [{:keys [id value hidden] :as blur}]
(when (some? blur) (when (some? blur)
(obj/without-empty (obj/without-empty
#js {:id (format-id id) #js {:id (format-id id)
:type (format-key type)
:value value :value value
:hidden hidden}))) :hidden hidden})))

View File

@ -237,7 +237,6 @@
;; export interface Blur { ;; export interface Blur {
;; id?: string; ;; id?: string;
;; type?: 'layer-blur';
;; value?: number; ;; value?: number;
;; hidden?: boolean; ;; hidden?: boolean;
;; } ;; }
@ -246,7 +245,6 @@
(when (some? blur) (when (some? blur)
(d/without-nils (d/without-nils
{:id (-> (obj/get blur "id") parse-id) {:id (-> (obj/get blur "id") parse-id)
:type (-> (obj/get blur "type") parse-keyword)
:value (obj/get blur "value") :value (obj/get blur "value")
:hidden (obj/get blur "hidden")}))) :hidden (obj/get blur "hidden")})))

View File

@ -509,7 +509,8 @@
(if (nil? value) (if (nil? value)
(st/emit! (dwsh/update-shapes [id] #(dissoc % :blur))) (st/emit! (dwsh/update-shapes [id] #(dissoc % :blur)))
(let [id (obj/get self "$id") (let [id (obj/get self "$id")
value (blur-defaults (parser/parse-blur value))] value (blur-defaults (parser/parse-blur value))
value (assoc value :type :layer-blur)]
(cond (cond
(not (sm/validate ctsb/schema:blur value)) (not (sm/validate ctsb/schema:blur value))
(u/not-valid plugin-id :blur value) (u/not-valid plugin-id :blur value)
@ -528,7 +529,8 @@
(if (nil? value) (if (nil? value)
(st/emit! (dwsh/update-shapes [id] #(dissoc % :background-blur))) (st/emit! (dwsh/update-shapes [id] #(dissoc % :background-blur)))
(let [id (obj/get self "$id") (let [id (obj/get self "$id")
value (background-blur-defaults (parser/parse-blur value))] value (background-blur-defaults (parser/parse-blur value))
value (assoc value :type :background-blur)]
(cond (cond
(not (sm/validate ctsbb/schema:background-blur value)) (not (sm/validate ctsbb/schema:background-blur value))
(u/not-valid plugin-id :background-blur value) (u/not-valid plugin-id :background-blur value)

View File

@ -960,12 +960,11 @@ Blur:
============== ==============
Represents blur properties in Penpot. Represents blur properties in Penpot.
This interface includes properties for defining the type and intensity of a blur effect, along with its visibility. This interface includes properties for defining the intensity of a blur effect, along with its visibility.
``` ```
interface Blur { interface Blur {
id?: string; id?: string;
type?: "layer-blur";
value?: number; value?: number;
hidden?: boolean; hidden?: boolean;
} }
@ -980,13 +979,44 @@ Blur:
``` ```
The optional unique identifier for the blur effect. The optional unique identifier for the blur effect.
type: |- value: |-
``` ```
type?: "layer-blur" value?: number
``` ```
The optional type of the blur effect. The optional intensity value of the blur effect.
Currently, only 'layer-blur' is supported. hidden: |-
```
hidden?: boolean
```
Specifies whether the blur effect is hidden.
Defaults to false if omitted.
BackgroundBlur:
overview: |-
Interface BackgroundBlur
==============
Represents background blur properties in Penpot.
This interface includes properties for defining the intensity of a blur effect, along with its visibility.
```
interface Blur {
id?: string;
value?: number;
hidden?: boolean;
}
```
Referenced by: Board, Boolean, Ellipse, Group, Image, Path, Rectangle, ShapeBase, SvgRaw, Text, VariantContainer
members:
Properties:
id: |-
```
id?: string
```
The optional unique identifier for the blur effect.
value: |- value: |-
``` ```
value?: number value?: number
@ -15436,6 +15466,7 @@ ShapeBase:
| "luminosity"; | "luminosity";
shadows: Shadow[]; shadows: Shadow[];
blur?: Blur; blur?: Blur;
backgroundBlur?: Blur;
exports: Export[]; exports: Export[];
boardX: number; boardX: number;
boardY: number; boardY: number;

View File

@ -194,11 +194,6 @@ export interface Blur {
* The optional unique identifier for the blur effect. * The optional unique identifier for the blur effect.
*/ */
id?: string; id?: string;
/**
* The optional type of the blur effect.
* Currently, only 'layer-blur' is supported.
*/
type?: 'layer-blur';
/** /**
* The optional intensity value of the blur effect. * The optional intensity value of the blur effect.
*/ */
@ -3717,6 +3712,13 @@ export interface ShapeBase extends PluginData {
*/ */
blur?: Blur; blur?: Blur;
/**
* The background blur effect applied to the shape.
* Background blur creates a blur effect on the content behind the shape,
* rather than on the shape's own content.
*/
backgroundBlur?: Blur;
/** /**
* The export settings of the shape. * The export settings of the shape.
*/ */