@elementor/editor-variables 4.3.0-1001 → 4.3.0-1003
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 +17 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/mcp/manage-variable-tool.ts +15 -1
- package/src/service.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-variables",
|
|
3
|
-
"version": "4.3.0-
|
|
3
|
+
"version": "4.3.0-1003",
|
|
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.3.0-
|
|
43
|
-
"@elementor/editor-canvas": "4.3.0-
|
|
44
|
-
"@elementor/editor-controls": "4.3.0-
|
|
45
|
-
"@elementor/editor-current-user": "4.3.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.3.0-
|
|
47
|
-
"@elementor/editor-panels": "4.3.0-
|
|
48
|
-
"@elementor/editor-props": "4.3.0-
|
|
49
|
-
"@elementor/editor-ui": "4.3.0-
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.3.0-
|
|
51
|
-
"@elementor/menus": "4.3.0-
|
|
52
|
-
"@elementor/http-client": "4.3.0-
|
|
42
|
+
"@elementor/editor": "4.3.0-1003",
|
|
43
|
+
"@elementor/editor-canvas": "4.3.0-1003",
|
|
44
|
+
"@elementor/editor-controls": "4.3.0-1003",
|
|
45
|
+
"@elementor/editor-current-user": "4.3.0-1003",
|
|
46
|
+
"@elementor/editor-mcp": "4.3.0-1003",
|
|
47
|
+
"@elementor/editor-panels": "4.3.0-1003",
|
|
48
|
+
"@elementor/editor-props": "4.3.0-1003",
|
|
49
|
+
"@elementor/editor-ui": "4.3.0-1003",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.3.0-1003",
|
|
51
|
+
"@elementor/menus": "4.3.0-1003",
|
|
52
|
+
"@elementor/http-client": "4.3.0-1003",
|
|
53
53
|
"@elementor/icons": "~1.75.1",
|
|
54
|
-
"@elementor/events": "4.3.0-
|
|
55
|
-
"@elementor/schema": "4.3.0-
|
|
54
|
+
"@elementor/events": "4.3.0-1003",
|
|
55
|
+
"@elementor/schema": "4.3.0-1003",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.3.0-
|
|
57
|
+
"@elementor/utils": "4.3.0-1003",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
@@ -3,12 +3,20 @@ import { type HttpResponse, httpService } from '@elementor/http-client';
|
|
|
3
3
|
import { z } from '@elementor/schema';
|
|
4
4
|
import { isProActive } from '@elementor/utils';
|
|
5
5
|
|
|
6
|
+
import { applyLocalMutation } from '../service';
|
|
7
|
+
import { type TVariable } from '../storage';
|
|
6
8
|
import { MANAGE_VARIABLES_GUIDE_URI } from './variable-tool-prompt';
|
|
7
9
|
import { GLOBAL_VARIABLES_URI } from './variables-resource';
|
|
8
10
|
|
|
9
11
|
const MCP_PROXY_URL = 'elementor/v1/mcp-proxy';
|
|
10
12
|
const TOOL_NAME = 'manage-global-variable';
|
|
11
13
|
|
|
14
|
+
type ManageVariableResponse = {
|
|
15
|
+
status: string;
|
|
16
|
+
variable?: TVariable & { id: string };
|
|
17
|
+
watermark?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
12
20
|
const VARIABLE_TYPES = {
|
|
13
21
|
COLOR: 'global-color-variable',
|
|
14
22
|
FONT: 'global-font-variable',
|
|
@@ -73,11 +81,17 @@ export const initManageVariableTool = ( reg: MCPRegistryEntry ) => {
|
|
|
73
81
|
],
|
|
74
82
|
isDestructive: true,
|
|
75
83
|
handler: async ( params ) => {
|
|
76
|
-
await httpService().post( MCP_PROXY_URL, {
|
|
84
|
+
const { data } = await httpService().post< HttpResponse< ManageVariableResponse > >( MCP_PROXY_URL, {
|
|
77
85
|
tool: TOOL_NAME,
|
|
78
86
|
input: params,
|
|
79
87
|
} );
|
|
80
88
|
|
|
89
|
+
const payload = data.data;
|
|
90
|
+
|
|
91
|
+
if ( payload.variable && typeof payload.watermark === 'number' ) {
|
|
92
|
+
applyLocalMutation( params.action, payload.variable, payload.watermark );
|
|
93
|
+
}
|
|
94
|
+
|
|
81
95
|
return { status: 'ok' };
|
|
82
96
|
},
|
|
83
97
|
} );
|
package/src/service.ts
CHANGED
|
@@ -277,3 +277,23 @@ const handleWatermark = ( operation: string, newWatermark: number ) => {
|
|
|
277
277
|
}
|
|
278
278
|
storage.watermark( newWatermark );
|
|
279
279
|
};
|
|
280
|
+
|
|
281
|
+
export const applyLocalMutation = (
|
|
282
|
+
action: 'create' | 'update' | 'delete',
|
|
283
|
+
variableWithId: TVariable & { id: string },
|
|
284
|
+
watermark: number
|
|
285
|
+
) => {
|
|
286
|
+
const { id: variableId, ...variable } = variableWithId;
|
|
287
|
+
|
|
288
|
+
handleWatermark( OP_RW, watermark );
|
|
289
|
+
|
|
290
|
+
if ( action === 'create' ) {
|
|
291
|
+
storage.add( variableId, variable );
|
|
292
|
+
} else {
|
|
293
|
+
storage.update( variableId, variable );
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
styleVariablesRepository.update( {
|
|
297
|
+
[ variableId ]: variable,
|
|
298
|
+
} );
|
|
299
|
+
};
|