@elementor/editor-global-classes 4.1.0-801 → 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/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/dist/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/global-classes-styles-provider.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
generateId
|
|
4
|
+
} from "@elementor/editor-styles";
|
|
3
5
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
4
6
|
import {
|
|
5
7
|
__dispatch as dispatch,
|
|
@@ -179,9 +181,14 @@ var slice = createSlice({
|
|
|
179
181
|
let customCss = ("custom_css" in payload ? payload.custom_css : variant?.custom_css) ?? null;
|
|
180
182
|
customCss = customCss?.raw ? customCss : null;
|
|
181
183
|
if (variant) {
|
|
182
|
-
const variantProps = JSON.parse(JSON.stringify(variant.props));
|
|
183
184
|
const payloadProps = JSON.parse(JSON.stringify(payload.props));
|
|
184
|
-
|
|
185
|
+
const mode = payload.mode ?? "merge";
|
|
186
|
+
if (mode === "replace") {
|
|
187
|
+
variant.props = payloadProps;
|
|
188
|
+
} else {
|
|
189
|
+
const variantProps = JSON.parse(JSON.stringify(variant.props));
|
|
190
|
+
variant.props = mergeProps(variantProps, payloadProps);
|
|
191
|
+
}
|
|
185
192
|
variant.custom_css = customCss;
|
|
186
193
|
style.variants = getNonEmptyVariants(style);
|
|
187
194
|
} else {
|
|
@@ -466,14 +473,15 @@ var globalClassesStylesProvider = createStylesProvider({
|
|
|
466
473
|
resolveCssName: (id2) => {
|
|
467
474
|
return selectClass(getState2(), id2)?.label ?? id2;
|
|
468
475
|
},
|
|
469
|
-
create: (label, variants = []) => {
|
|
476
|
+
create: (label, variants = [], id2) => {
|
|
470
477
|
const classes = selectGlobalClasses(getState2());
|
|
471
478
|
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
472
479
|
if (existingLabels.includes(label)) {
|
|
473
480
|
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
474
481
|
}
|
|
475
|
-
|
|
476
|
-
|
|
482
|
+
if (!id2) {
|
|
483
|
+
id2 = generateId("g-", Object.keys(classes));
|
|
484
|
+
}
|
|
477
485
|
dispatch(
|
|
478
486
|
slice.actions.add({
|
|
479
487
|
id: id2,
|
|
@@ -499,7 +507,8 @@ var globalClassesStylesProvider = createStylesProvider({
|
|
|
499
507
|
slice.actions.updateProps({
|
|
500
508
|
id: args.id,
|
|
501
509
|
meta: args.meta,
|
|
502
|
-
props: args.props
|
|
510
|
+
props: args.props,
|
|
511
|
+
mode: args.mode
|
|
503
512
|
})
|
|
504
513
|
);
|
|
505
514
|
},
|