@elementor/editor-global-classes 4.1.0-800 → 4.1.0-802

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-global-classes",
3
- "version": "4.1.0-800",
3
+ "version": "4.1.0-802",
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-800",
43
- "@elementor/editor-current-user": "4.1.0-800",
44
- "@elementor/editor-documents": "4.1.0-800",
45
- "@elementor/editor-editing-panel": "4.1.0-800",
46
- "@elementor/editor-mcp": "4.1.0-800",
47
- "@elementor/editor-panels": "4.1.0-800",
48
- "@elementor/editor-props": "4.1.0-800",
49
- "@elementor/editor-variables": "4.1.0-800",
50
- "@elementor/editor-styles": "4.1.0-800",
51
- "@elementor/editor-canvas": "4.1.0-800",
52
- "@elementor/editor-styles-repository": "4.1.0-800",
53
- "@elementor/editor-ui": "4.1.0-800",
54
- "@elementor/editor-v1-adapters": "4.1.0-800",
55
- "@elementor/http-client": "4.1.0-800",
42
+ "@elementor/editor": "4.1.0-802",
43
+ "@elementor/editor-current-user": "4.1.0-802",
44
+ "@elementor/editor-documents": "4.1.0-802",
45
+ "@elementor/editor-editing-panel": "4.1.0-802",
46
+ "@elementor/editor-mcp": "4.1.0-802",
47
+ "@elementor/editor-panels": "4.1.0-802",
48
+ "@elementor/editor-props": "4.1.0-802",
49
+ "@elementor/editor-variables": "4.1.0-802",
50
+ "@elementor/editor-styles": "4.1.0-802",
51
+ "@elementor/editor-canvas": "4.1.0-802",
52
+ "@elementor/editor-styles-repository": "4.1.0-802",
53
+ "@elementor/editor-ui": "4.1.0-802",
54
+ "@elementor/editor-v1-adapters": "4.1.0-802",
55
+ "@elementor/http-client": "4.1.0-802",
56
56
  "@elementor/icons": "^1.68.0",
57
- "@elementor/query": "4.1.0-800",
58
- "@elementor/schema": "4.1.0-800",
59
- "@elementor/store": "4.1.0-800",
57
+ "@elementor/query": "4.1.0-802",
58
+ "@elementor/schema": "4.1.0-802",
59
+ "@elementor/store": "4.1.0-802",
60
60
  "@elementor/ui": "1.37.5",
61
- "@elementor/utils": "4.1.0-800",
61
+ "@elementor/utils": "4.1.0-802",
62
62
  "@wordpress/i18n": "^5.13.0",
63
- "@elementor/events": "4.1.0-800"
63
+ "@elementor/events": "4.1.0-802"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "react": "^18.3.1",
@@ -1,4 +1,9 @@
1
- import { generateId, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';
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
- const existingIds = Object.keys( classes );
54
- const id = generateId( 'g-', existingIds );
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
- variant.props = mergeProps( variantProps, payloadProps );
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 );