@elementor/editor-canvas 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +36 -0
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/styles-prop-resolver.test.ts +61 -1
- package/src/init-style-transformers.ts +1 -0
- package/src/transformers/styles/filter-transformer.ts +15 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mockStylesSchema } from 'test-utils';
|
|
2
2
|
import { styleTransformersRegistry } from '@elementor/editor-canvas';
|
|
3
3
|
import {
|
|
4
|
+
backdropFilterPropTypeUtil,
|
|
4
5
|
backgroundColorOverlayPropTypeUtil,
|
|
5
6
|
backgroundGradientOverlayPropTypeUtil,
|
|
6
7
|
backgroundImageOverlayPropTypeUtil,
|
|
@@ -15,15 +16,21 @@ import {
|
|
|
15
16
|
brightnessFilterPropTypeUtil,
|
|
16
17
|
colorPropTypeUtil,
|
|
17
18
|
colorStopPropTypeUtil,
|
|
19
|
+
contrastFilterPropTypeUtil,
|
|
18
20
|
dimensionsPropTypeUtil,
|
|
19
21
|
filterPropTypeUtil,
|
|
20
22
|
gradientColorStopPropTypeUtil,
|
|
23
|
+
grayscaleFilterPropTypeUtil,
|
|
24
|
+
hueRotateFilterPropTypeUtil,
|
|
21
25
|
imageAttachmentIdPropType,
|
|
22
26
|
imagePropTypeUtil,
|
|
23
27
|
imageSrcPropTypeUtil,
|
|
28
|
+
invertFilterPropTypeUtil,
|
|
24
29
|
layoutDirectionPropTypeUtil,
|
|
25
30
|
numberPropTypeUtil,
|
|
26
31
|
type Props,
|
|
32
|
+
saturateFilterPropTypeUtil,
|
|
33
|
+
sepiaFilterPropTypeUtil,
|
|
27
34
|
shadowPropTypeUtil,
|
|
28
35
|
sizePropTypeUtil,
|
|
29
36
|
stringPropTypeUtil,
|
|
@@ -280,10 +287,63 @@ describe( 'styles prop resolver', () => {
|
|
|
280
287
|
brightnessFilterPropTypeUtil.create( {
|
|
281
288
|
amount: sizePropTypeUtil.create( { size: 90, unit: '%' } ),
|
|
282
289
|
} ),
|
|
290
|
+
contrastFilterPropTypeUtil.create( {
|
|
291
|
+
contrast: sizePropTypeUtil.create( { size: 50, unit: '%' } ),
|
|
292
|
+
} ),
|
|
293
|
+
grayscaleFilterPropTypeUtil.create( {
|
|
294
|
+
grayscale: sizePropTypeUtil.create( { size: 70, unit: '%' } ),
|
|
295
|
+
} ),
|
|
296
|
+
invertFilterPropTypeUtil.create( {
|
|
297
|
+
invert: sizePropTypeUtil.create( { size: 60, unit: '%' } ),
|
|
298
|
+
} ),
|
|
299
|
+
sepiaFilterPropTypeUtil.create( {
|
|
300
|
+
sepia: sizePropTypeUtil.create( { size: 30, unit: '%' } ),
|
|
301
|
+
} ),
|
|
302
|
+
saturateFilterPropTypeUtil.create( {
|
|
303
|
+
saturate: sizePropTypeUtil.create( { size: 25, unit: '%' } ),
|
|
304
|
+
} ),
|
|
305
|
+
hueRotateFilterPropTypeUtil.create( {
|
|
306
|
+
'hue-rotate': sizePropTypeUtil.create( { size: 10, unit: 'deg' } ),
|
|
307
|
+
} ),
|
|
308
|
+
] ),
|
|
309
|
+
},
|
|
310
|
+
expected: {
|
|
311
|
+
filter: 'blur(1px) brightness(90%) contrast(50%) grayscale(70%) invert(60%) sepia(30%) saturate(25%) hue-rotate(10deg)',
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
name: 'backdrop-filter',
|
|
316
|
+
props: {
|
|
317
|
+
'backdrop-filter': backdropFilterPropTypeUtil.create( [
|
|
318
|
+
blurFilterPropTypeUtil.create( {
|
|
319
|
+
radius: sizePropTypeUtil.create( { size: 2, unit: 'rem' } ),
|
|
320
|
+
} ),
|
|
321
|
+
brightnessFilterPropTypeUtil.create( {
|
|
322
|
+
amount: sizePropTypeUtil.create( { size: 80, unit: '%' } ),
|
|
323
|
+
} ),
|
|
324
|
+
contrastFilterPropTypeUtil.create( {
|
|
325
|
+
contrast: sizePropTypeUtil.create( { size: 50, unit: '%' } ),
|
|
326
|
+
} ),
|
|
327
|
+
grayscaleFilterPropTypeUtil.create( {
|
|
328
|
+
grayscale: sizePropTypeUtil.create( { size: 70, unit: '%' } ),
|
|
329
|
+
} ),
|
|
330
|
+
invertFilterPropTypeUtil.create( {
|
|
331
|
+
invert: sizePropTypeUtil.create( { size: 60, unit: '%' } ),
|
|
332
|
+
} ),
|
|
333
|
+
sepiaFilterPropTypeUtil.create( {
|
|
334
|
+
sepia: sizePropTypeUtil.create( { size: 30, unit: '%' } ),
|
|
335
|
+
} ),
|
|
336
|
+
saturateFilterPropTypeUtil.create( {
|
|
337
|
+
saturate: sizePropTypeUtil.create( { size: 25, unit: '%' } ),
|
|
338
|
+
} ),
|
|
339
|
+
hueRotateFilterPropTypeUtil.create( {
|
|
340
|
+
'hue-rotate': sizePropTypeUtil.create( { size: 10, unit: 'deg' } ),
|
|
341
|
+
} ),
|
|
283
342
|
] ),
|
|
284
343
|
},
|
|
285
344
|
expected: {
|
|
286
|
-
filter:
|
|
345
|
+
'backdrop-filter':
|
|
346
|
+
'blur(2rem) brightness(80%) contrast(50%) grayscale(70%) invert(60%) sepia(30%) saturate(25%) hue-rotate(10deg)',
|
|
287
347
|
},
|
|
288
348
|
},
|
|
289
349
|
{
|
|
@@ -32,6 +32,7 @@ export function initStyleTransformers() {
|
|
|
32
32
|
)
|
|
33
33
|
)
|
|
34
34
|
.register( 'filter', filterTransformer )
|
|
35
|
+
.register( 'backdrop-filter', filterTransformer )
|
|
35
36
|
.register( 'box-shadow', createCombineArrayTransformer( ',' ) )
|
|
36
37
|
.register( 'background', backgroundTransformer )
|
|
37
38
|
.register( 'background-overlay', backgroundOverlayTransformer )
|
|
@@ -7,17 +7,28 @@ export const filterTransformer = createTransformer( ( filterValues: FilterItemPr
|
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
return filterValues.map( mapToFilterFunctionString ).join( ' ' );
|
|
10
|
+
return filterValues.filter( Boolean ).map( mapToFilterFunctionString ).join( ' ' );
|
|
11
11
|
} );
|
|
12
12
|
|
|
13
13
|
const mapToFilterFunctionString = ( value: FilterItemPropValue[ 'value' ] ): string => {
|
|
14
14
|
if ( 'radius' in value ) {
|
|
15
|
-
return `blur(${ value.radius })
|
|
15
|
+
return value.radius ? `blur(${ value.radius })` : '';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
if ( 'amount' in value ) {
|
|
19
|
-
return `brightness(${ value.amount })
|
|
19
|
+
return value.amount ? `brightness(${ value.amount })` : '';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
if ( 'xAxis' in value && 'yAxis' in value && 'blur' in value && 'color' in value ) {
|
|
23
|
+
const { xAxis, yAxis, blur, color } = value;
|
|
24
|
+
return `drop-shadow(${ xAxis || '0px' } ${ yAxis || '0px' } ${ blur || '10px' } ${ color || 'transparent' })`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const keys = Object.keys( value );
|
|
28
|
+
|
|
29
|
+
if ( ! keys[ 0 ] ) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return value[ keys[ 0 ] ] ? `${ keys[ 0 ] }(${ value[ keys[ 0 ] ] })` : '';
|
|
23
34
|
};
|