@elementor/editor-global-classes 4.1.0-801 → 4.1.0-803
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 +13 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/global-classes-styles-provider.ts +11 -4
- package/src/store.ts +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-global-classes",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-803",
|
|
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-current-user": "4.1.0-
|
|
44
|
-
"@elementor/editor-documents": "4.1.0-
|
|
45
|
-
"@elementor/editor-editing-panel": "4.1.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.1.0-
|
|
47
|
-
"@elementor/editor-panels": "4.1.0-
|
|
48
|
-
"@elementor/editor-props": "4.1.0-
|
|
49
|
-
"@elementor/editor-variables": "4.1.0-
|
|
50
|
-
"@elementor/editor-styles": "4.1.0-
|
|
51
|
-
"@elementor/editor-canvas": "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-
|
|
55
|
-
"@elementor/http-client": "4.1.0-
|
|
42
|
+
"@elementor/editor": "4.1.0-803",
|
|
43
|
+
"@elementor/editor-current-user": "4.1.0-803",
|
|
44
|
+
"@elementor/editor-documents": "4.1.0-803",
|
|
45
|
+
"@elementor/editor-editing-panel": "4.1.0-803",
|
|
46
|
+
"@elementor/editor-mcp": "4.1.0-803",
|
|
47
|
+
"@elementor/editor-panels": "4.1.0-803",
|
|
48
|
+
"@elementor/editor-props": "4.1.0-803",
|
|
49
|
+
"@elementor/editor-variables": "4.1.0-803",
|
|
50
|
+
"@elementor/editor-styles": "4.1.0-803",
|
|
51
|
+
"@elementor/editor-canvas": "4.1.0-803",
|
|
52
|
+
"@elementor/editor-styles-repository": "4.1.0-803",
|
|
53
|
+
"@elementor/editor-ui": "4.1.0-803",
|
|
54
|
+
"@elementor/editor-v1-adapters": "4.1.0-803",
|
|
55
|
+
"@elementor/http-client": "4.1.0-803",
|
|
56
56
|
"@elementor/icons": "^1.68.0",
|
|
57
|
-
"@elementor/query": "4.1.0-
|
|
58
|
-
"@elementor/schema": "4.1.0-
|
|
59
|
-
"@elementor/store": "4.1.0-
|
|
57
|
+
"@elementor/query": "4.1.0-803",
|
|
58
|
+
"@elementor/schema": "4.1.0-803",
|
|
59
|
+
"@elementor/store": "4.1.0-803",
|
|
60
60
|
"@elementor/ui": "1.37.5",
|
|
61
|
-
"@elementor/utils": "4.1.0-
|
|
61
|
+
"@elementor/utils": "4.1.0-803",
|
|
62
62
|
"@wordpress/i18n": "^5.13.0",
|
|
63
|
-
"@elementor/events": "4.1.0-
|
|
63
|
+
"@elementor/events": "4.1.0-803"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"react": "^18.3.1",
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
generateId,
|
|
3
|
+
type StyleDefinition,
|
|
4
|
+
type StyleDefinitionID,
|
|
5
|
+
type StyleDefinitionVariant,
|
|
6
|
+
} from '@elementor/editor-styles';
|
|
2
7
|
import { createStylesProvider } from '@elementor/editor-styles-repository';
|
|
3
8
|
import {
|
|
4
9
|
__dispatch as dispatch,
|
|
@@ -41,7 +46,7 @@ export const globalClassesStylesProvider = createStylesProvider( {
|
|
|
41
46
|
resolveCssName: ( id: string ) => {
|
|
42
47
|
return selectClass( getState(), id )?.label ?? id;
|
|
43
48
|
},
|
|
44
|
-
create: ( label, variants: StyleDefinitionVariant[] = [] ) => {
|
|
49
|
+
create: ( label, variants: StyleDefinitionVariant[] = [], id?: StyleDefinitionID ) => {
|
|
45
50
|
const classes = selectGlobalClasses( getState() );
|
|
46
51
|
|
|
47
52
|
const existingLabels = Object.values( classes ).map( ( style ) => style.label );
|
|
@@ -50,8 +55,9 @@ export const globalClassesStylesProvider = createStylesProvider( {
|
|
|
50
55
|
throw new GlobalClassLabelAlreadyExistsError( { context: { label } } );
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
if ( ! id ) {
|
|
59
|
+
id = generateId( 'g-', Object.keys( classes ) );
|
|
60
|
+
}
|
|
55
61
|
|
|
56
62
|
dispatch(
|
|
57
63
|
slice.actions.add( {
|
|
@@ -80,6 +86,7 @@ export const globalClassesStylesProvider = createStylesProvider( {
|
|
|
80
86
|
id: args.id,
|
|
81
87
|
meta: args.meta,
|
|
82
88
|
props: args.props,
|
|
89
|
+
mode: args.mode,
|
|
83
90
|
} )
|
|
84
91
|
);
|
|
85
92
|
},
|
package/src/store.ts
CHANGED
|
@@ -132,6 +132,7 @@ export const slice = createSlice( {
|
|
|
132
132
|
meta: StyleDefinitionVariant[ 'meta' ];
|
|
133
133
|
props: Props;
|
|
134
134
|
custom_css?: CustomCss | null;
|
|
135
|
+
mode?: 'merge' | 'replace';
|
|
135
136
|
} >
|
|
136
137
|
) {
|
|
137
138
|
const style = state.data.items[ payload.id ];
|
|
@@ -147,10 +148,16 @@ export const slice = createSlice( {
|
|
|
147
148
|
customCss = customCss?.raw ? customCss : null;
|
|
148
149
|
|
|
149
150
|
if ( variant ) {
|
|
150
|
-
// mergeProps fails with Proxy objects from store, manually re-create clones
|
|
151
|
-
const variantProps = JSON.parse( JSON.stringify( variant.props ) ) as Props;
|
|
152
151
|
const payloadProps = JSON.parse( JSON.stringify( payload.props ) ) as Props;
|
|
153
|
-
|
|
152
|
+
const mode = payload.mode ?? 'merge';
|
|
153
|
+
|
|
154
|
+
if ( mode === 'replace' ) {
|
|
155
|
+
variant.props = payloadProps;
|
|
156
|
+
} else {
|
|
157
|
+
const variantProps = JSON.parse( JSON.stringify( variant.props ) ) as Props;
|
|
158
|
+
variant.props = mergeProps( variantProps, payloadProps );
|
|
159
|
+
}
|
|
160
|
+
|
|
154
161
|
variant.custom_css = customCss;
|
|
155
162
|
|
|
156
163
|
style.variants = getNonEmptyVariants( style );
|