@elementor/editor-variables 4.3.0-999 → 4.4.0-1064

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.3.0-999",
3
+ "version": "4.4.0-1064",
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-999",
43
- "@elementor/editor-canvas": "4.3.0-999",
44
- "@elementor/editor-controls": "4.3.0-999",
45
- "@elementor/editor-current-user": "4.3.0-999",
46
- "@elementor/editor-mcp": "4.3.0-999",
47
- "@elementor/editor-panels": "4.3.0-999",
48
- "@elementor/editor-props": "4.3.0-999",
49
- "@elementor/editor-ui": "4.3.0-999",
50
- "@elementor/editor-v1-adapters": "4.3.0-999",
51
- "@elementor/menus": "4.3.0-999",
52
- "@elementor/http-client": "4.3.0-999",
42
+ "@elementor/editor": "4.4.0-1064",
43
+ "@elementor/editor-canvas": "4.4.0-1064",
44
+ "@elementor/editor-controls": "4.4.0-1064",
45
+ "@elementor/editor-current-user": "4.4.0-1064",
46
+ "@elementor/editor-mcp": "4.4.0-1064",
47
+ "@elementor/editor-panels": "4.4.0-1064",
48
+ "@elementor/editor-props": "4.4.0-1064",
49
+ "@elementor/editor-ui": "4.4.0-1064",
50
+ "@elementor/editor-v1-adapters": "4.4.0-1064",
51
+ "@elementor/menus": "4.4.0-1064",
52
+ "@elementor/http-client": "4.4.0-1064",
53
53
  "@elementor/icons": "~1.75.1",
54
- "@elementor/events": "4.3.0-999",
55
- "@elementor/schema": "4.3.0-999",
54
+ "@elementor/events": "4.4.0-1064",
55
+ "@elementor/schema": "4.4.0-1064",
56
56
  "@elementor/ui": "1.37.5",
57
- "@elementor/utils": "4.3.0-999",
57
+ "@elementor/utils": "4.4.0-1064",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useState } from 'react';
3
3
  import type { PropTypeKey } from '@elementor/editor-props';
4
- import { isExperimentActive } from '@elementor/editor-v1-adapters';
5
4
 
6
5
  import { PopoverContentRefContextProvider } from '../context/variable-selection-popover.context';
7
6
  import { VariableTypeProvider } from '../context/variable-type-context';
@@ -27,13 +26,11 @@ type Props = {
27
26
  export const VariableSelectionPopover = ( { closePopover, propTypeKey, selectedVariable }: Props ) => {
28
27
  const [ currentView, setCurrentView ] = useState< View >( VIEW_LIST );
29
28
  const [ editId, setEditId ] = useState< string >( '' );
30
- const onSettingsAvailable = isExperimentActive( 'e_variables_manager' )
31
- ? () => {
32
- window.dispatchEvent(
33
- new CustomEvent( 'elementor/toggle-design-system', { detail: { tab: 'variables' as const } } )
34
- );
35
- }
36
- : undefined;
29
+ const onSettingsAvailable = () => {
30
+ window.dispatchEvent(
31
+ new CustomEvent( 'elementor/toggle-design-system', { detail: { tab: 'variables' as const } } )
32
+ );
33
+ };
37
34
 
38
35
  return (
39
36
  <VariableTypeProvider propTypeKey={ propTypeKey }>
@@ -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',
@@ -44,7 +52,7 @@ export const initManageVariableTool = ( reg: MCPRegistryEntry ) => {
44
52
  addTool( {
45
53
  name: TOOL_NAME,
46
54
  description:
47
- 'Manage V4 global variables (color, font, size, custom-size). Read the guide resource before use. font = font-famliy, size = measured unit, custom-size = calculated values',
55
+ 'Manage V4 global variables (color, font, size, custom-size). Read the guide resource before use. font = single Google Font family name, no fallback stacks, size = measured unit, custom-size = calculated values',
48
56
  schema: {
49
57
  action: z.enum( [ 'create', 'update', 'delete' ] ),
50
58
  id: z
@@ -57,7 +65,7 @@ export const initManageVariableTool = ( reg: MCPRegistryEntry ) => {
57
65
  .string()
58
66
  .optional()
59
67
  .describe(
60
- 'Plain CSS value — required for create/update. Color: hex/rgba/hsl. Font: family name only. Size: value with unit e.g. "16px", or "auto" (Pro). Do NOT pass JSON.'
68
+ 'Plain CSS value — required for create/update. Color: hex/rgba/hsl. Font: single Google Font family name only — no fallback stacks, no generic families. Size: value with unit e.g. "16px", or "auto" (Pro). Do NOT pass JSON.'
61
69
  ),
62
70
  },
63
71
  outputSchema: {
@@ -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
+ };