@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/dist/index.js CHANGED
@@ -207,9 +207,14 @@ var slice = (0, import_store.__createSlice)({
207
207
  let customCss = ("custom_css" in payload ? payload.custom_css : variant?.custom_css) ?? null;
208
208
  customCss = customCss?.raw ? customCss : null;
209
209
  if (variant) {
210
- const variantProps = JSON.parse(JSON.stringify(variant.props));
211
210
  const payloadProps = JSON.parse(JSON.stringify(payload.props));
212
- variant.props = mergeProps(variantProps, payloadProps);
211
+ const mode = payload.mode ?? "merge";
212
+ if (mode === "replace") {
213
+ variant.props = payloadProps;
214
+ } else {
215
+ const variantProps = JSON.parse(JSON.stringify(variant.props));
216
+ variant.props = mergeProps(variantProps, payloadProps);
217
+ }
213
218
  variant.custom_css = customCss;
214
219
  style.variants = getNonEmptyVariants(style);
215
220
  } else {
@@ -494,14 +499,15 @@ var globalClassesStylesProvider = (0, import_editor_styles_repository.createStyl
494
499
  resolveCssName: (id2) => {
495
500
  return selectClass((0, import_store4.__getState)(), id2)?.label ?? id2;
496
501
  },
497
- create: (label, variants = []) => {
502
+ create: (label, variants = [], id2) => {
498
503
  const classes = selectGlobalClasses((0, import_store4.__getState)());
499
504
  const existingLabels = Object.values(classes).map((style) => style.label);
500
505
  if (existingLabels.includes(label)) {
501
506
  throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
502
507
  }
503
- const existingIds = Object.keys(classes);
504
- const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
508
+ if (!id2) {
509
+ id2 = (0, import_editor_styles2.generateId)("g-", Object.keys(classes));
510
+ }
505
511
  (0, import_store4.__dispatch)(
506
512
  slice.actions.add({
507
513
  id: id2,
@@ -527,7 +533,8 @@ var globalClassesStylesProvider = (0, import_editor_styles_repository.createStyl
527
533
  slice.actions.updateProps({
528
534
  id: args.id,
529
535
  meta: args.meta,
530
- props: args.props
536
+ props: args.props,
537
+ mode: args.mode
531
538
  })
532
539
  );
533
540
  },