@elementor/editor-editing-panel 4.1.0-712 → 4.1.0-714
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 +84 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
- package/src/controls-registry/styles-field.tsx +88 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-editing-panel",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-714",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,28 +39,28 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.1.0-
|
|
43
|
-
"@elementor/editor-canvas": "4.1.0-
|
|
44
|
-
"@elementor/editor-controls": "4.1.0-
|
|
45
|
-
"@elementor/editor-documents": "4.1.0-
|
|
46
|
-
"@elementor/editor-elements": "4.1.0-
|
|
47
|
-
"@elementor/editor-interactions": "4.1.0-
|
|
48
|
-
"@elementor/editor-panels": "4.1.0-
|
|
49
|
-
"@elementor/editor-props": "4.1.0-
|
|
50
|
-
"@elementor/editor-responsive": "4.1.0-
|
|
51
|
-
"@elementor/editor-styles": "4.1.0-
|
|
52
|
-
"@elementor/editor-styles-repository": "4.1.0-
|
|
53
|
-
"@elementor/editor-ui": "4.1.0-
|
|
54
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
42
|
+
"@elementor/editor": "4.1.0-714",
|
|
43
|
+
"@elementor/editor-canvas": "4.1.0-714",
|
|
44
|
+
"@elementor/editor-controls": "4.1.0-714",
|
|
45
|
+
"@elementor/editor-documents": "4.1.0-714",
|
|
46
|
+
"@elementor/editor-elements": "4.1.0-714",
|
|
47
|
+
"@elementor/editor-interactions": "4.1.0-714",
|
|
48
|
+
"@elementor/editor-panels": "4.1.0-714",
|
|
49
|
+
"@elementor/editor-props": "4.1.0-714",
|
|
50
|
+
"@elementor/editor-responsive": "4.1.0-714",
|
|
51
|
+
"@elementor/editor-styles": "4.1.0-714",
|
|
52
|
+
"@elementor/editor-styles-repository": "4.1.0-714",
|
|
53
|
+
"@elementor/editor-ui": "4.1.0-714",
|
|
54
|
+
"@elementor/editor-v1-adapters": "4.1.0-714",
|
|
55
55
|
"@elementor/icons": "^1.68.0",
|
|
56
|
-
"@elementor/editor-variables": "4.1.0-
|
|
57
|
-
"@elementor/locations": "4.1.0-
|
|
58
|
-
"@elementor/menus": "4.1.0-
|
|
59
|
-
"@elementor/schema": "4.1.0-
|
|
60
|
-
"@elementor/session": "4.1.0-
|
|
56
|
+
"@elementor/editor-variables": "4.1.0-714",
|
|
57
|
+
"@elementor/locations": "4.1.0-714",
|
|
58
|
+
"@elementor/menus": "4.1.0-714",
|
|
59
|
+
"@elementor/schema": "4.1.0-714",
|
|
60
|
+
"@elementor/session": "4.1.0-714",
|
|
61
61
|
"@elementor/ui": "1.36.17",
|
|
62
|
-
"@elementor/utils": "4.1.0-
|
|
63
|
-
"@elementor/wp-media": "4.1.0-
|
|
62
|
+
"@elementor/utils": "4.1.0-714",
|
|
63
|
+
"@elementor/wp-media": "4.1.0-714",
|
|
64
64
|
"@wordpress/i18n": "^5.13.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ControlAdornmentsProvider, PropKeyProvider, PropProvider } from '@elementor/editor-controls';
|
|
3
|
-
import { type PropKey, type PropValue } from '@elementor/editor-props';
|
|
3
|
+
import { dimensionsPropTypeUtil, type PropKey, type PropValue, sizePropTypeUtil } from '@elementor/editor-props';
|
|
4
4
|
import { getStylesSchema } from '@elementor/editor-styles';
|
|
5
5
|
|
|
6
6
|
import { useStylesInheritanceChain } from '../contexts/styles-inheritance-context';
|
|
@@ -9,6 +9,83 @@ import { useStylesField } from '../hooks/use-styles-field';
|
|
|
9
9
|
import { ConditionalField } from './conditional-field';
|
|
10
10
|
import { createTopLevelObjectType } from './create-top-level-object-type';
|
|
11
11
|
|
|
12
|
+
const DIMENSION_SIDES = [ 'block-start', 'block-end', 'inline-start', 'inline-end' ] as const;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* When a breakpoint inherits from a parent that only set *some* dimension sides, the remaining
|
|
16
|
+
* sides should still show the next ancestor's value as a placeholder — not go blank.
|
|
17
|
+
*
|
|
18
|
+
* Example: Desktop = 10px (uniform). Tablet = inline-start 5px only. Mobile = no local value.
|
|
19
|
+
* Without merging, mobile's Right / Bottom / Top placeholders would be empty because the closest
|
|
20
|
+
* inherited value (tablet's partial dims) has no value for those sides.
|
|
21
|
+
* With merging, we walk further up the chain and fill the gaps: inline-start gets 5px from tablet,
|
|
22
|
+
* the other three sides get 10px from desktop's uniform size.
|
|
23
|
+
*
|
|
24
|
+
* Non-dimensions values (color, font-size, …) are returned as-is — no merging needed there.
|
|
25
|
+
* @param chain
|
|
26
|
+
* @param startIndex
|
|
27
|
+
*/
|
|
28
|
+
function buildResolvedPlaceholder( chain: { value: PropValue }[], startIndex: number ): PropValue | undefined {
|
|
29
|
+
const firstEntry = chain[ startIndex ];
|
|
30
|
+
if ( ! firstEntry ) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const firstValue = firstEntry.value;
|
|
35
|
+
|
|
36
|
+
if ( ! dimensionsPropTypeUtil.isValid( firstValue ) ) {
|
|
37
|
+
return firstValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const firstDims = dimensionsPropTypeUtil.extract( firstValue );
|
|
41
|
+
|
|
42
|
+
if ( DIMENSION_SIDES.every( ( side ) => firstDims?.[ side ] !== null && firstDims?.[ side ] !== undefined ) ) {
|
|
43
|
+
return firstValue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const merged: Partial< Record< ( typeof DIMENSION_SIDES )[ number ], PropValue > > = {};
|
|
47
|
+
DIMENSION_SIDES.forEach( ( side ) => {
|
|
48
|
+
if ( firstDims?.[ side ] !== null && firstDims?.[ side ] !== undefined ) {
|
|
49
|
+
merged[ side ] = firstDims[ side ];
|
|
50
|
+
}
|
|
51
|
+
} );
|
|
52
|
+
|
|
53
|
+
for ( let i = startIndex + 1; i < chain.length; i++ ) {
|
|
54
|
+
const val = chain[ i ].value;
|
|
55
|
+
|
|
56
|
+
if ( sizePropTypeUtil.isValid( val ) ) {
|
|
57
|
+
DIMENSION_SIDES.forEach( ( side ) => {
|
|
58
|
+
if ( merged[ side ] === null || merged[ side ] === undefined ) {
|
|
59
|
+
merged[ side ] = val;
|
|
60
|
+
}
|
|
61
|
+
} );
|
|
62
|
+
break;
|
|
63
|
+
} else if ( dimensionsPropTypeUtil.isValid( val ) ) {
|
|
64
|
+
const dims = dimensionsPropTypeUtil.extract( val );
|
|
65
|
+
DIMENSION_SIDES.forEach( ( side ) => {
|
|
66
|
+
if (
|
|
67
|
+
( merged[ side ] === null || merged[ side ] === undefined ) &&
|
|
68
|
+
dims?.[ side ] !== null &&
|
|
69
|
+
dims?.[ side ] !== undefined
|
|
70
|
+
) {
|
|
71
|
+
merged[ side ] = dims[ side ];
|
|
72
|
+
}
|
|
73
|
+
} );
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if ( DIMENSION_SIDES.every( ( side ) => merged[ side ] !== null && merged[ side ] !== undefined ) ) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return dimensionsPropTypeUtil.create( {
|
|
82
|
+
'block-start': merged[ 'block-start' ] ?? null,
|
|
83
|
+
'block-end': merged[ 'block-end' ] ?? null,
|
|
84
|
+
'inline-start': merged[ 'inline-start' ] ?? null,
|
|
85
|
+
'inline-end': merged[ 'inline-end' ] ?? null,
|
|
86
|
+
} );
|
|
87
|
+
}
|
|
88
|
+
|
|
12
89
|
export type StylesFieldProps = {
|
|
13
90
|
bind: PropKey;
|
|
14
91
|
placeholder?: PropValue;
|
|
@@ -25,10 +102,18 @@ export const StylesField = ( { bind, propDisplayName, children }: StylesFieldPro
|
|
|
25
102
|
|
|
26
103
|
const propType = createTopLevelObjectType( { schema: stylesSchema } );
|
|
27
104
|
|
|
28
|
-
|
|
105
|
+
// Placeholders represent the inherited value the user would see if they cleared their local
|
|
106
|
+
// override. The chain is ordered most-specific-first, so when the current breakpoint has its
|
|
107
|
+
// own value, chain[0] IS that value — showing it as a placeholder would be meaningless.
|
|
108
|
+
// We skip to chain[1] so controls display what's truly inherited from parent breakpoints.
|
|
109
|
+
//
|
|
110
|
+
// buildResolvedPlaceholder also handles the case where the inherited value itself is a partial
|
|
111
|
+
// dimensions (e.g. tablet only overrides inline-start): it merges subsequent chain entries to
|
|
112
|
+
// fill the missing sides, so "Right / Bottom" inputs don't lose their inherited placeholder.
|
|
113
|
+
const placeholderStartIndex = value ? 1 : 0;
|
|
29
114
|
|
|
30
115
|
const placeholderValues = {
|
|
31
|
-
[ bind ]:
|
|
116
|
+
[ bind ]: buildResolvedPlaceholder( stylesInheritanceChain, placeholderStartIndex ),
|
|
32
117
|
};
|
|
33
118
|
|
|
34
119
|
const setValue = ( newValue: Record< string, PropValue > ) => {
|