@elementor/editor-variables 4.0.0-532 → 4.0.0-533

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.d.mts CHANGED
@@ -90,7 +90,7 @@ declare const service: {
90
90
  id: any;
91
91
  variable: any;
92
92
  }>;
93
- batchSave: (originalVariables: TVariablesList, currentVariables: TVariablesList) => Promise<{
93
+ batchSave: (originalVariables: TVariablesList, currentVariables: TVariablesList, deletedVariables: string[]) => Promise<{
94
94
  success: boolean;
95
95
  watermark: any;
96
96
  operations: number;
package/dist/index.d.ts CHANGED
@@ -90,7 +90,7 @@ declare const service: {
90
90
  id: any;
91
91
  variable: any;
92
92
  }>;
93
- batchSave: (originalVariables: TVariablesList, currentVariables: TVariablesList) => Promise<{
93
+ batchSave: (originalVariables: TVariablesList, currentVariables: TVariablesList, deletedVariables: string[]) => Promise<{
94
94
  success: boolean;
95
95
  watermark: any;
96
96
  operations: number;
package/dist/index.js CHANGED
@@ -272,7 +272,7 @@ var generateTempId = () => {
272
272
  var isTempId = (id2) => {
273
273
  return id2.startsWith("tmp-");
274
274
  };
275
- var buildOperationsArray = (originalVariables, currentVariables) => {
275
+ var buildOperationsArray = (originalVariables, currentVariables, deletedVariables) => {
276
276
  const operations = [];
277
277
  Object.entries(currentVariables).forEach(([id2, variable]) => {
278
278
  if (isTempId(id2)) {
@@ -293,7 +293,7 @@ var buildOperationsArray = (originalVariables, currentVariables) => {
293
293
  ...original.label !== variable.label && { label: variable.label },
294
294
  ...original.value !== variable.value && { value: variable.value }
295
295
  });
296
- } else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value || original.order !== variable.order || syncChanged)) {
296
+ } else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value || original.order !== variable.order || original.type !== variable.type || syncChanged)) {
297
297
  operations.push({
298
298
  type: "update",
299
299
  id: id2,
@@ -301,23 +301,18 @@ var buildOperationsArray = (originalVariables, currentVariables) => {
301
301
  ...original.label !== variable.label && { label: variable.label },
302
302
  ...original.value !== variable.value && { value: variable.value },
303
303
  ...original.order !== variable.order && { order: variable.order },
304
+ ...original.type !== variable.type && { type: variable.type },
304
305
  ...syncChanged && { sync_to_v3: variable.sync_to_v3 }
305
306
  }
306
307
  });
307
308
  }
308
309
  }
309
310
  });
310
- Object.entries(originalVariables).forEach(([id2, variable]) => {
311
- if (isTempId(id2) || variable.deleted) {
312
- return;
313
- }
314
- const currentVariable = currentVariables[id2];
315
- if (!currentVariable || currentVariable.deleted) {
316
- operations.push({
317
- type: "delete",
318
- id: id2
319
- });
320
- }
311
+ deletedVariables.forEach((id2) => {
312
+ operations.push({
313
+ type: "delete",
314
+ id: id2
315
+ });
321
316
  });
322
317
  return operations.filter((op) => {
323
318
  const id2 = op.id || op.variable?.id;
@@ -584,8 +579,8 @@ var service = {
584
579
  };
585
580
  });
586
581
  },
587
- batchSave: (originalVariables, currentVariables) => {
588
- const operations = buildOperationsArray(originalVariables, currentVariables);
582
+ batchSave: (originalVariables, currentVariables, deletedVariables) => {
583
+ const operations = buildOperationsArray(originalVariables, currentVariables, deletedVariables);
589
584
  const batchPayload = { operations, watermark: storage.state.watermark };
590
585
  if (operations.length === 0) {
591
586
  return Promise.resolve({
@@ -1108,7 +1103,7 @@ var useVariablesManagerState = () => {
1108
1103
  const handleSave = (0, import_react6.useCallback)(async () => {
1109
1104
  const originalVariables = getVariables(false);
1110
1105
  setIsSaving(true);
1111
- const result = await service.batchSave(originalVariables, variables);
1106
+ const result = await service.batchSave(originalVariables, variables, deletedVariables);
1112
1107
  if (result.success) {
1113
1108
  await service.load();
1114
1109
  const updatedVariables = service.variables();
@@ -1117,7 +1112,7 @@ var useVariablesManagerState = () => {
1117
1112
  setIsDirty(false);
1118
1113
  }
1119
1114
  return { success: result.success };
1120
- }, [variables]);
1115
+ }, [variables, deletedVariables]);
1121
1116
  const filteredVariables = (0, import_react6.useCallback)(() => {
1122
1117
  const list = variablesToList(variables).filter((v) => !v.deleted);
1123
1118
  const typeFiltered = applySelectionFilters(list, getVariableTypes());
@@ -3556,6 +3551,9 @@ var trackOpenVariablePopover = (path, variableType) => {
3556
3551
  });
3557
3552
  };
3558
3553
 
3554
+ // src/mcp/index.ts
3555
+ var import_editor_mcp3 = require("@elementor/editor-mcp");
3556
+
3559
3557
  // src/mcp/manage-variable-tool.ts
3560
3558
  var import_editor_mcp2 = require("@elementor/editor-mcp");
3561
3559
  var import_schema3 = require("@elementor/schema");
@@ -3668,6 +3666,9 @@ function getServiceActions(svc) {
3668
3666
 
3669
3667
  // src/mcp/index.ts
3670
3668
  function initMcp() {
3669
+ if (!(0, import_editor_mcp3.isAngieAvailable)()) {
3670
+ return;
3671
+ }
3671
3672
  initManageVariableTool();
3672
3673
  initVariablesResource();
3673
3674
  }