@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-variables",
3
- "version": "4.0.0-532",
3
+ "version": "4.0.0-533",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,22 +39,22 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.0.0-532",
43
- "@elementor/editor-canvas": "4.0.0-532",
44
- "@elementor/editor-controls": "4.0.0-532",
45
- "@elementor/editor-current-user": "4.0.0-532",
46
- "@elementor/editor-mcp": "4.0.0-532",
47
- "@elementor/editor-panels": "4.0.0-532",
48
- "@elementor/editor-props": "4.0.0-532",
49
- "@elementor/editor-ui": "4.0.0-532",
50
- "@elementor/editor-v1-adapters": "4.0.0-532",
51
- "@elementor/menus": "4.0.0-532",
52
- "@elementor/http-client": "4.0.0-532",
42
+ "@elementor/editor": "4.0.0-533",
43
+ "@elementor/editor-canvas": "4.0.0-533",
44
+ "@elementor/editor-controls": "4.0.0-533",
45
+ "@elementor/editor-current-user": "4.0.0-533",
46
+ "@elementor/editor-mcp": "4.0.0-533",
47
+ "@elementor/editor-panels": "4.0.0-533",
48
+ "@elementor/editor-props": "4.0.0-533",
49
+ "@elementor/editor-ui": "4.0.0-533",
50
+ "@elementor/editor-v1-adapters": "4.0.0-533",
51
+ "@elementor/menus": "4.0.0-533",
52
+ "@elementor/http-client": "4.0.0-533",
53
53
  "@elementor/icons": "^1.63.0",
54
- "@elementor/mixpanel": "4.0.0-532",
55
- "@elementor/schema": "4.0.0-532",
54
+ "@elementor/mixpanel": "4.0.0-533",
55
+ "@elementor/schema": "4.0.0-533",
56
56
  "@elementor/ui": "1.37.2",
57
- "@elementor/utils": "4.0.0-532",
57
+ "@elementor/utils": "4.0.0-533",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -22,7 +22,8 @@ export const isTempId = ( id: string ): boolean => {
22
22
 
23
23
  export const buildOperationsArray = (
24
24
  originalVariables: TVariablesList,
25
- currentVariables: TVariablesList
25
+ currentVariables: TVariablesList,
26
+ deletedVariables: string[]
26
27
  ): BatchOperation[] => {
27
28
  const operations: BatchOperation[] = [];
28
29
 
@@ -51,6 +52,7 @@ export const buildOperationsArray = (
51
52
  ( original.label !== variable.label ||
52
53
  original.value !== variable.value ||
53
54
  original.order !== variable.order ||
55
+ original.type !== variable.type ||
54
56
  syncChanged )
55
57
  ) {
56
58
  operations.push( {
@@ -60,6 +62,7 @@ export const buildOperationsArray = (
60
62
  ...( original.label !== variable.label && { label: variable.label } ),
61
63
  ...( original.value !== variable.value && { value: variable.value } ),
62
64
  ...( original.order !== variable.order && { order: variable.order } ),
65
+ ...( original.type !== variable.type && { type: variable.type } ),
63
66
  ...( syncChanged && { sync_to_v3: variable.sync_to_v3 } ),
64
67
  },
65
68
  } );
@@ -67,19 +70,11 @@ export const buildOperationsArray = (
67
70
  }
68
71
  } );
69
72
 
70
- Object.entries( originalVariables ).forEach( ( [ id, variable ] ) => {
71
- if ( isTempId( id ) || variable.deleted ) {
72
- return;
73
- }
74
-
75
- const currentVariable = currentVariables[ id ];
76
-
77
- if ( ! currentVariable || currentVariable.deleted ) {
78
- operations.push( {
79
- type: 'delete',
80
- id,
81
- } );
82
- }
73
+ deletedVariables.forEach( ( id: string ) => {
74
+ operations.push( {
75
+ type: 'delete',
76
+ id,
77
+ } );
83
78
  } );
84
79
 
85
80
  return operations.filter( ( op ) => {
@@ -68,7 +68,7 @@ export const useVariablesManagerState = () => {
68
68
  const handleSave = useCallback( async (): Promise< { success: boolean } > => {
69
69
  const originalVariables = getVariables( false );
70
70
  setIsSaving( true );
71
- const result = await service.batchSave( originalVariables, variables );
71
+ const result = await service.batchSave( originalVariables, variables, deletedVariables );
72
72
 
73
73
  if ( result.success ) {
74
74
  await service.load();
@@ -80,7 +80,7 @@ export const useVariablesManagerState = () => {
80
80
  }
81
81
 
82
82
  return { success: result.success };
83
- }, [ variables ] );
83
+ }, [ variables, deletedVariables ] );
84
84
 
85
85
  const filteredVariables = useCallback( () => {
86
86
  const list = variablesToList( variables ).filter( ( v ) => ! v.deleted );
package/src/mcp/index.ts CHANGED
@@ -1,7 +1,12 @@
1
+ import { isAngieAvailable } from '@elementor/editor-mcp';
2
+
1
3
  import { initManageVariableTool } from './manage-variable-tool';
2
4
  import { initVariablesResource } from './variables-resource';
3
5
 
4
6
  export function initMcp() {
7
+ if ( ! isAngieAvailable() ) {
8
+ return;
9
+ }
5
10
  initManageVariableTool();
6
11
  initVariablesResource();
7
12
  }
package/src/service.ts CHANGED
@@ -186,8 +186,8 @@ export const service = {
186
186
  } );
187
187
  },
188
188
 
189
- batchSave: ( originalVariables: TVariablesList, currentVariables: TVariablesList ) => {
190
- const operations = buildOperationsArray( originalVariables, currentVariables );
189
+ batchSave: ( originalVariables: TVariablesList, currentVariables: TVariablesList, deletedVariables: string[] ) => {
190
+ const operations = buildOperationsArray( originalVariables, currentVariables, deletedVariables );
191
191
  const batchPayload = { operations, watermark: storage.state.watermark };
192
192
 
193
193
  if ( operations.length === 0 ) {