@elementor/editor-canvas 4.2.0-beta2 → 4.2.3
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/dist/index.js
CHANGED
|
@@ -522,8 +522,8 @@ function toGridTracks(computedStyle) {
|
|
|
522
522
|
return {
|
|
523
523
|
columns: parseTrackList(computedStyle.gridTemplateColumns),
|
|
524
524
|
rows: parseTrackList(computedStyle.gridTemplateRows),
|
|
525
|
-
columnGap:
|
|
526
|
-
rowGap:
|
|
525
|
+
columnGap: resolveGapPx(computedStyle.columnGap, computedStyle.width),
|
|
526
|
+
rowGap: resolveGapPx(computedStyle.rowGap, computedStyle.height),
|
|
527
527
|
padding: {
|
|
528
528
|
top: toPx(computedStyle.paddingTop),
|
|
529
529
|
right: toPx(computedStyle.paddingRight),
|
|
@@ -598,6 +598,14 @@ function toPx(value) {
|
|
|
598
598
|
const parsed = parseFloat(value);
|
|
599
599
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
600
600
|
}
|
|
601
|
+
function resolveGapPx(value, referenceSize) {
|
|
602
|
+
if (value.trim().endsWith("%")) {
|
|
603
|
+
const percent = parseFloat(value);
|
|
604
|
+
const reference = parseFloat(referenceSize);
|
|
605
|
+
return Number.isFinite(percent) && Number.isFinite(reference) ? percent / 100 * reference : 0;
|
|
606
|
+
}
|
|
607
|
+
return toPx(value);
|
|
608
|
+
}
|
|
601
609
|
|
|
602
610
|
// src/hooks/use-grid-children.ts
|
|
603
611
|
var import_react3 = require("react");
|
|
@@ -2782,13 +2790,13 @@ function initStyleTransformers() {
|
|
|
2782
2790
|
"layout-direction",
|
|
2783
2791
|
createMultiPropsTransformer(["row", "column"], ({ propKey, key }) => `${key}-${propKey}`)
|
|
2784
2792
|
).register("flex", flexTransformer).register(
|
|
2785
|
-
"border-width",
|
|
2793
|
+
"border-width-v2",
|
|
2786
2794
|
createMultiPropsTransformer(
|
|
2787
2795
|
["block-start", "block-end", "inline-start", "inline-end"],
|
|
2788
2796
|
({ key }) => `border-${key}-width`
|
|
2789
2797
|
)
|
|
2790
2798
|
).register(
|
|
2791
|
-
"border-radius",
|
|
2799
|
+
"border-radius-v2",
|
|
2792
2800
|
createMultiPropsTransformer(
|
|
2793
2801
|
["start-start", "start-end", "end-start", "end-end"],
|
|
2794
2802
|
({ key }) => `border-${key}-radius`
|
package/dist/index.mjs
CHANGED
|
@@ -460,8 +460,8 @@ function toGridTracks(computedStyle) {
|
|
|
460
460
|
return {
|
|
461
461
|
columns: parseTrackList(computedStyle.gridTemplateColumns),
|
|
462
462
|
rows: parseTrackList(computedStyle.gridTemplateRows),
|
|
463
|
-
columnGap:
|
|
464
|
-
rowGap:
|
|
463
|
+
columnGap: resolveGapPx(computedStyle.columnGap, computedStyle.width),
|
|
464
|
+
rowGap: resolveGapPx(computedStyle.rowGap, computedStyle.height),
|
|
465
465
|
padding: {
|
|
466
466
|
top: toPx(computedStyle.paddingTop),
|
|
467
467
|
right: toPx(computedStyle.paddingRight),
|
|
@@ -536,6 +536,14 @@ function toPx(value) {
|
|
|
536
536
|
const parsed = parseFloat(value);
|
|
537
537
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
538
538
|
}
|
|
539
|
+
function resolveGapPx(value, referenceSize) {
|
|
540
|
+
if (value.trim().endsWith("%")) {
|
|
541
|
+
const percent = parseFloat(value);
|
|
542
|
+
const reference = parseFloat(referenceSize);
|
|
543
|
+
return Number.isFinite(percent) && Number.isFinite(reference) ? percent / 100 * reference : 0;
|
|
544
|
+
}
|
|
545
|
+
return toPx(value);
|
|
546
|
+
}
|
|
539
547
|
|
|
540
548
|
// src/hooks/use-grid-children.ts
|
|
541
549
|
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
@@ -2736,13 +2744,13 @@ function initStyleTransformers() {
|
|
|
2736
2744
|
"layout-direction",
|
|
2737
2745
|
createMultiPropsTransformer(["row", "column"], ({ propKey, key }) => `${key}-${propKey}`)
|
|
2738
2746
|
).register("flex", flexTransformer).register(
|
|
2739
|
-
"border-width",
|
|
2747
|
+
"border-width-v2",
|
|
2740
2748
|
createMultiPropsTransformer(
|
|
2741
2749
|
["block-start", "block-end", "inline-start", "inline-end"],
|
|
2742
2750
|
({ key }) => `border-${key}-width`
|
|
2743
2751
|
)
|
|
2744
2752
|
).register(
|
|
2745
|
-
"border-radius",
|
|
2753
|
+
"border-radius-v2",
|
|
2746
2754
|
createMultiPropsTransformer(
|
|
2747
2755
|
["start-start", "start-end", "end-start", "end-end"],
|
|
2748
2756
|
({ key }) => `border-${key}-radius`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,27 +37,27 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "4.2.
|
|
40
|
+
"@elementor/editor": "4.2.3",
|
|
41
41
|
"dompurify": "^3.2.6",
|
|
42
|
-
"@elementor/editor-controls": "4.2.
|
|
43
|
-
"@elementor/editor-documents": "4.2.
|
|
44
|
-
"@elementor/editor-elements": "4.2.
|
|
45
|
-
"@elementor/editor-interactions": "4.2.
|
|
46
|
-
"@elementor/editor-mcp": "4.2.
|
|
47
|
-
"@elementor/editor-notifications": "4.2.
|
|
48
|
-
"@elementor/editor-props": "4.2.
|
|
49
|
-
"@elementor/editor-responsive": "4.2.
|
|
50
|
-
"@elementor/editor-styles": "4.2.
|
|
51
|
-
"@elementor/editor-styles-repository": "4.2.
|
|
52
|
-
"@elementor/editor-ui": "4.2.
|
|
53
|
-
"@elementor/editor-v1-adapters": "4.2.
|
|
54
|
-
"@elementor/events": "4.2.
|
|
55
|
-
"@elementor/http-client": "4.2.
|
|
56
|
-
"@elementor/schema": "4.2.
|
|
57
|
-
"@elementor/twing": "4.2.
|
|
42
|
+
"@elementor/editor-controls": "4.2.3",
|
|
43
|
+
"@elementor/editor-documents": "4.2.3",
|
|
44
|
+
"@elementor/editor-elements": "4.2.3",
|
|
45
|
+
"@elementor/editor-interactions": "4.2.3",
|
|
46
|
+
"@elementor/editor-mcp": "4.2.3",
|
|
47
|
+
"@elementor/editor-notifications": "4.2.3",
|
|
48
|
+
"@elementor/editor-props": "4.2.3",
|
|
49
|
+
"@elementor/editor-responsive": "4.2.3",
|
|
50
|
+
"@elementor/editor-styles": "4.2.3",
|
|
51
|
+
"@elementor/editor-styles-repository": "4.2.3",
|
|
52
|
+
"@elementor/editor-ui": "4.2.3",
|
|
53
|
+
"@elementor/editor-v1-adapters": "4.2.3",
|
|
54
|
+
"@elementor/events": "4.2.3",
|
|
55
|
+
"@elementor/http-client": "4.2.3",
|
|
56
|
+
"@elementor/schema": "4.2.3",
|
|
57
|
+
"@elementor/twing": "4.2.3",
|
|
58
58
|
"@elementor/ui": "1.37.5",
|
|
59
|
-
"@elementor/utils": "4.2.
|
|
60
|
-
"@elementor/wp-media": "4.2.
|
|
59
|
+
"@elementor/utils": "4.2.3",
|
|
60
|
+
"@elementor/wp-media": "4.2.3",
|
|
61
61
|
"@floating-ui/react": "^0.27.5",
|
|
62
62
|
"@wordpress/i18n": "^5.13.0"
|
|
63
63
|
},
|
|
@@ -80,14 +80,14 @@ export function initStyleTransformers() {
|
|
|
80
80
|
)
|
|
81
81
|
.register( 'flex', flexTransformer )
|
|
82
82
|
.register(
|
|
83
|
-
'border-width',
|
|
83
|
+
'border-width-v2',
|
|
84
84
|
createMultiPropsTransformer(
|
|
85
85
|
[ 'block-start', 'block-end', 'inline-start', 'inline-end' ],
|
|
86
86
|
( { key } ) => `border-${ key }-width`
|
|
87
87
|
)
|
|
88
88
|
)
|
|
89
89
|
.register(
|
|
90
|
-
'border-radius',
|
|
90
|
+
'border-radius-v2',
|
|
91
91
|
createMultiPropsTransformer(
|
|
92
92
|
[ 'start-start', 'start-end', 'end-start', 'end-end' ],
|
|
93
93
|
( { key } ) => `border-${ key }-radius`
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
computeCellRects,
|
|
4
4
|
computeGridLines,
|
|
5
5
|
parseTrackList,
|
|
6
|
+
resolveGapPx,
|
|
6
7
|
snapToHalfPixel,
|
|
7
8
|
toGridTracks,
|
|
8
9
|
toPx,
|
|
@@ -215,11 +216,29 @@ describe( 'toPx', () => {
|
|
|
215
216
|
} );
|
|
216
217
|
} );
|
|
217
218
|
|
|
219
|
+
describe( 'resolveGapPx', () => {
|
|
220
|
+
it( 'resolves a percentage gap against the reference size', () => {
|
|
221
|
+
expect( resolveGapPx( '20%', '1000px' ) ).toBe( 200 );
|
|
222
|
+
expect( resolveGapPx( '10%', '500px' ) ).toBe( 50 );
|
|
223
|
+
} );
|
|
224
|
+
|
|
225
|
+
it( 'falls back to px parsing for non-percentage gaps', () => {
|
|
226
|
+
expect( resolveGapPx( '16px', '1000px' ) ).toBe( 16 );
|
|
227
|
+
expect( resolveGapPx( 'normal', '1000px' ) ).toBe( 0 );
|
|
228
|
+
} );
|
|
229
|
+
|
|
230
|
+
it( 'returns 0 when the reference size is not a finite number', () => {
|
|
231
|
+
expect( resolveGapPx( '20%', 'auto' ) ).toBe( 0 );
|
|
232
|
+
} );
|
|
233
|
+
} );
|
|
234
|
+
|
|
218
235
|
type ComputedStyleParts = {
|
|
219
236
|
gridTemplateColumns: string;
|
|
220
237
|
gridTemplateRows: string;
|
|
221
238
|
columnGap: string;
|
|
222
239
|
rowGap: string;
|
|
240
|
+
width: string;
|
|
241
|
+
height: string;
|
|
223
242
|
paddingTop: string;
|
|
224
243
|
paddingRight: string;
|
|
225
244
|
paddingBottom: string;
|
|
@@ -233,6 +252,8 @@ function mockComputedStyle( parts: Partial< ComputedStyleParts > = {} ): CSSStyl
|
|
|
233
252
|
gridTemplateRows: 'none',
|
|
234
253
|
columnGap: 'normal',
|
|
235
254
|
rowGap: 'normal',
|
|
255
|
+
width: '1000px',
|
|
256
|
+
height: '500px',
|
|
236
257
|
paddingTop: '0px',
|
|
237
258
|
paddingRight: '0px',
|
|
238
259
|
paddingBottom: '0px',
|
|
@@ -246,6 +267,8 @@ function mockComputedStyle( parts: Partial< ComputedStyleParts > = {} ): CSSStyl
|
|
|
246
267
|
gridTemplateRows: resolved.gridTemplateRows,
|
|
247
268
|
columnGap: resolved.columnGap,
|
|
248
269
|
rowGap: resolved.rowGap,
|
|
270
|
+
width: resolved.width,
|
|
271
|
+
height: resolved.height,
|
|
249
272
|
paddingTop: resolved.paddingTop,
|
|
250
273
|
paddingRight: resolved.paddingRight,
|
|
251
274
|
paddingBottom: resolved.paddingBottom,
|
|
@@ -286,6 +309,22 @@ describe( 'toGridTracks', () => {
|
|
|
286
309
|
expect( tracks.rows ).toEqual( [] );
|
|
287
310
|
} );
|
|
288
311
|
|
|
312
|
+
it( 'resolves percentage gaps against the content-box width and height', () => {
|
|
313
|
+
const tracks = toGridTracks(
|
|
314
|
+
mockComputedStyle( {
|
|
315
|
+
gridTemplateColumns: '100px 100px',
|
|
316
|
+
gridTemplateRows: '80px 80px',
|
|
317
|
+
columnGap: '20%',
|
|
318
|
+
rowGap: '10%',
|
|
319
|
+
width: '1000px',
|
|
320
|
+
height: '500px',
|
|
321
|
+
} )
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
expect( tracks.columnGap ).toBe( 200 );
|
|
325
|
+
expect( tracks.rowGap ).toBe( 50 );
|
|
326
|
+
} );
|
|
327
|
+
|
|
289
328
|
it( 'reports gap as 0 when computed style returns "normal"', () => {
|
|
290
329
|
const tracks = toGridTracks(
|
|
291
330
|
mockComputedStyle( { gridTemplateColumns: '100px 100px', columnGap: 'normal', rowGap: 'normal' } )
|
|
@@ -28,8 +28,8 @@ export function toGridTracks( computedStyle: CSSStyleDeclaration ): GridTracks {
|
|
|
28
28
|
return {
|
|
29
29
|
columns: parseTrackList( computedStyle.gridTemplateColumns ),
|
|
30
30
|
rows: parseTrackList( computedStyle.gridTemplateRows ),
|
|
31
|
-
columnGap:
|
|
32
|
-
rowGap:
|
|
31
|
+
columnGap: resolveGapPx( computedStyle.columnGap, computedStyle.width ),
|
|
32
|
+
rowGap: resolveGapPx( computedStyle.rowGap, computedStyle.height ),
|
|
33
33
|
padding: {
|
|
34
34
|
top: toPx( computedStyle.paddingTop ),
|
|
35
35
|
right: toPx( computedStyle.paddingRight ),
|
|
@@ -142,3 +142,14 @@ export function toPx( value: string ): number {
|
|
|
142
142
|
|
|
143
143
|
return Number.isFinite( parsed ) ? parsed : 0;
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
export function resolveGapPx( value: string, referenceSize: string ): number {
|
|
147
|
+
if ( value.trim().endsWith( '%' ) ) {
|
|
148
|
+
const percent = parseFloat( value );
|
|
149
|
+
const reference = parseFloat( referenceSize );
|
|
150
|
+
|
|
151
|
+
return Number.isFinite( percent ) && Number.isFinite( reference ) ? ( percent / 100 ) * reference : 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return toPx( value );
|
|
155
|
+
}
|