@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.mjs CHANGED
@@ -248,7 +248,7 @@ var generateTempId = () => {
248
248
  var isTempId = (id2) => {
249
249
  return id2.startsWith("tmp-");
250
250
  };
251
- var buildOperationsArray = (originalVariables, currentVariables) => {
251
+ var buildOperationsArray = (originalVariables, currentVariables, deletedVariables) => {
252
252
  const operations = [];
253
253
  Object.entries(currentVariables).forEach(([id2, variable]) => {
254
254
  if (isTempId(id2)) {
@@ -269,7 +269,7 @@ var buildOperationsArray = (originalVariables, currentVariables) => {
269
269
  ...original.label !== variable.label && { label: variable.label },
270
270
  ...original.value !== variable.value && { value: variable.value }
271
271
  });
272
- } else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value || original.order !== variable.order || syncChanged)) {
272
+ } else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value || original.order !== variable.order || original.type !== variable.type || syncChanged)) {
273
273
  operations.push({
274
274
  type: "update",
275
275
  id: id2,
@@ -277,23 +277,18 @@ var buildOperationsArray = (originalVariables, currentVariables) => {
277
277
  ...original.label !== variable.label && { label: variable.label },
278
278
  ...original.value !== variable.value && { value: variable.value },
279
279
  ...original.order !== variable.order && { order: variable.order },
280
+ ...original.type !== variable.type && { type: variable.type },
280
281
  ...syncChanged && { sync_to_v3: variable.sync_to_v3 }
281
282
  }
282
283
  });
283
284
  }
284
285
  }
285
286
  });
286
- Object.entries(originalVariables).forEach(([id2, variable]) => {
287
- if (isTempId(id2) || variable.deleted) {
288
- return;
289
- }
290
- const currentVariable = currentVariables[id2];
291
- if (!currentVariable || currentVariable.deleted) {
292
- operations.push({
293
- type: "delete",
294
- id: id2
295
- });
296
- }
287
+ deletedVariables.forEach((id2) => {
288
+ operations.push({
289
+ type: "delete",
290
+ id: id2
291
+ });
297
292
  });
298
293
  return operations.filter((op) => {
299
294
  const id2 = op.id || op.variable?.id;
@@ -560,8 +555,8 @@ var service = {
560
555
  };
561
556
  });
562
557
  },
563
- batchSave: (originalVariables, currentVariables) => {
564
- const operations = buildOperationsArray(originalVariables, currentVariables);
558
+ batchSave: (originalVariables, currentVariables, deletedVariables) => {
559
+ const operations = buildOperationsArray(originalVariables, currentVariables, deletedVariables);
565
560
  const batchPayload = { operations, watermark: storage.state.watermark };
566
561
  if (operations.length === 0) {
567
562
  return Promise.resolve({
@@ -1094,7 +1089,7 @@ var useVariablesManagerState = () => {
1094
1089
  const handleSave = useCallback3(async () => {
1095
1090
  const originalVariables = getVariables(false);
1096
1091
  setIsSaving(true);
1097
- const result = await service.batchSave(originalVariables, variables);
1092
+ const result = await service.batchSave(originalVariables, variables, deletedVariables);
1098
1093
  if (result.success) {
1099
1094
  await service.load();
1100
1095
  const updatedVariables = service.variables();
@@ -1103,7 +1098,7 @@ var useVariablesManagerState = () => {
1103
1098
  setIsDirty(false);
1104
1099
  }
1105
1100
  return { success: result.success };
1106
- }, [variables]);
1101
+ }, [variables, deletedVariables]);
1107
1102
  const filteredVariables = useCallback3(() => {
1108
1103
  const list = variablesToList(variables).filter((v) => !v.deleted);
1109
1104
  const typeFiltered = applySelectionFilters(list, getVariableTypes());
@@ -3562,6 +3557,9 @@ var trackOpenVariablePopover = (path, variableType) => {
3562
3557
  });
3563
3558
  };
3564
3559
 
3560
+ // src/mcp/index.ts
3561
+ import { isAngieAvailable } from "@elementor/editor-mcp";
3562
+
3565
3563
  // src/mcp/manage-variable-tool.ts
3566
3564
  import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
3567
3565
  import { z as z3 } from "@elementor/schema";
@@ -3674,6 +3672,9 @@ function getServiceActions(svc) {
3674
3672
 
3675
3673
  // src/mcp/index.ts
3676
3674
  function initMcp() {
3675
+ if (!isAngieAvailable()) {
3676
+ return;
3677
+ }
3677
3678
  initManageVariableTool();
3678
3679
  initVariablesResource();
3679
3680
  }