@elementor/editor-variables 4.1.0-720 → 4.1.0-722

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
@@ -1,6 +1,7 @@
1
1
  // src/init.ts
2
2
  import { injectIntoLogic, injectIntoTop } from "@elementor/editor";
3
3
  import { registerControlReplacement } from "@elementor/editor-controls";
4
+ import { getMCPByDomain } from "@elementor/editor-mcp";
4
5
  import { __registerPanel as registerPanel } from "@elementor/editor-panels";
5
6
  import { isTransformable as isTransformable2 } from "@elementor/editor-props";
6
7
  import { controlActionsMenu } from "@elementor/menus";
@@ -515,6 +516,26 @@ var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
515
516
  }
516
517
  dispatchEvent?.(name, eventData);
517
518
  };
519
+ var trackVariableSyncToV3 = ({ variableLabel, action }) => {
520
+ try {
521
+ const { dispatchEvent, config } = getMixpanel();
522
+ if (!config?.names?.variables?.variableSyncToV3) {
523
+ return;
524
+ }
525
+ const name = config.names.variables.variableSyncToV3;
526
+ const isSync = action === "sync";
527
+ dispatchEvent?.(name, {
528
+ interaction_type: "click",
529
+ target_type: variableLabel,
530
+ target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
531
+ interaction_result: isSync ? "var_is_synced_to_V3" : "var_is_unsynced_from_V3",
532
+ target_location: "widget_panel",
533
+ location_l1: "var_manager",
534
+ interaction_description: isSync ? `user_synced_${variableLabel}_to_v3` : `user_unsync_${variableLabel}_from_v3`
535
+ });
536
+ } catch {
537
+ }
538
+ };
518
539
 
519
540
  // src/utils/validations.ts
520
541
  import { AlertTriangleFilledIcon, InfoCircleFilledIcon } from "@elementor/icons";
@@ -1920,8 +1941,8 @@ function VariablesManagerPanel() {
1920
1941
  handleOnChange,
1921
1942
  createVariable: createVariable2,
1922
1943
  handleDeleteVariable,
1923
- handleStartSync,
1924
- handleStopSync,
1944
+ handleStartSync: startSyncFromState,
1945
+ handleStopSync: stopSyncFromState,
1925
1946
  handleSave,
1926
1947
  isSaving,
1927
1948
  handleSearch,
@@ -1982,22 +2003,35 @@ function VariablesManagerPanel() {
1982
2003
  },
1983
2004
  [handleDeleteVariable]
1984
2005
  );
1985
- const handleStopSyncWithConfirmation = useCallback6(
2006
+ const commitStopSync = useCallback6(
2007
+ (itemId) => {
2008
+ stopSyncFromState(itemId);
2009
+ const variable = variables[itemId];
2010
+ if (variable) {
2011
+ trackVariableSyncToV3({ variableLabel: variable.label, action: "unsync" });
2012
+ }
2013
+ },
2014
+ [stopSyncFromState, variables]
2015
+ );
2016
+ const handleStartSync = useCallback6(
1986
2017
  (itemId) => {
1987
- handleStopSync(itemId);
1988
- setStopSyncConfirmation(null);
2018
+ startSyncFromState(itemId);
2019
+ const variable = variables[itemId];
2020
+ if (variable) {
2021
+ trackVariableSyncToV3({ variableLabel: variable.label, action: "sync" });
2022
+ }
1989
2023
  },
1990
- [handleStopSync]
2024
+ [startSyncFromState, variables]
1991
2025
  );
1992
- const handleShowStopSyncDialog = useCallback6(
2026
+ const handleStopSync = useCallback6(
1993
2027
  (itemId) => {
1994
2028
  if (!isStopSyncSuppressed) {
1995
2029
  setStopSyncConfirmation(itemId);
1996
2030
  } else {
1997
- handleStopSync(itemId);
2031
+ commitStopSync(itemId);
1998
2032
  }
1999
2033
  },
2000
- [isStopSyncSuppressed, handleStopSync]
2034
+ [isStopSyncSuppressed, commitStopSync]
2001
2035
  );
2002
2036
  const buildMenuActions = useCallback6(
2003
2037
  (variableId) => {
@@ -2010,7 +2044,7 @@ function VariablesManagerPanel() {
2010
2044
  variableId,
2011
2045
  handlers: {
2012
2046
  onStartSync: handleStartSync,
2013
- onStopSync: handleShowStopSyncDialog
2047
+ onStopSync: handleStopSync
2014
2048
  }
2015
2049
  });
2016
2050
  const deleteAction = {
@@ -2028,7 +2062,7 @@ function VariablesManagerPanel() {
2028
2062
  };
2029
2063
  return [...typeActions, deleteAction];
2030
2064
  },
2031
- [variables, handleStartSync, handleShowStopSyncDialog]
2065
+ [variables, handleStartSync, handleStopSync]
2032
2066
  );
2033
2067
  const hasVariables = Object.keys(variables).length > 0;
2034
2068
  return /* @__PURE__ */ React14.createElement(ThemeProvider, null, /* @__PURE__ */ React14.createElement(Panel, null, /* @__PURE__ */ React14.createElement(
@@ -2163,7 +2197,10 @@ function VariablesManagerPanel() {
2163
2197
  {
2164
2198
  open: true,
2165
2199
  onClose: () => setStopSyncConfirmation(null),
2166
- onConfirm: () => handleStopSyncWithConfirmation(stopSyncConfirmation)
2200
+ onConfirm: () => {
2201
+ commitStopSync(stopSyncConfirmation);
2202
+ setStopSyncConfirmation(null);
2203
+ }
2167
2204
  }
2168
2205
  ), isSaveChangesDialogOpen && /* @__PURE__ */ React14.createElement(SaveChangesDialog, null, /* @__PURE__ */ React14.createElement(SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, __10("You have unsaved changes", "elementor")), /* @__PURE__ */ React14.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React14.createElement(SaveChangesDialog.ContentText, null, __10("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React14.createElement(
2169
2206
  SaveChangesDialog.Actions,
@@ -3717,22 +3754,15 @@ var trackOpenVariablePopover = (path, variableType) => {
3717
3754
  });
3718
3755
  };
3719
3756
 
3720
- // src/mcp/index.ts
3721
- import { isAngieAvailable } from "@elementor/editor-mcp";
3722
-
3723
3757
  // src/mcp/manage-variable-tool.ts
3724
- import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
3725
3758
  import { z as z3 } from "@elementor/schema";
3726
3759
 
3727
3760
  // src/mcp/variables-resource.ts
3728
- import { getMCPByDomain } from "@elementor/editor-mcp";
3729
3761
  var GLOBAL_VARIABLES_URI = "elementor://global-variables";
3730
- var initVariablesResource = () => {
3731
- const canvasMcpEntry = getMCPByDomain("canvas");
3732
- const variablesMcpEntry = getMCPByDomain("variables");
3762
+ var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
3733
3763
  [canvasMcpEntry, variablesMcpEntry].forEach((entry) => {
3734
- const { mcpServer } = entry;
3735
- mcpServer.resource(
3764
+ const { resource, sendResourceUpdated } = entry;
3765
+ resource(
3736
3766
  "global-variables",
3737
3767
  GLOBAL_VARIABLES_URI,
3738
3768
  {
@@ -3751,7 +3781,7 @@ var initVariablesResource = () => {
3751
3781
  }
3752
3782
  );
3753
3783
  window.addEventListener("variables:updated", () => {
3754
- mcpServer.server.sendResourceUpdated({
3784
+ sendResourceUpdated({
3755
3785
  uri: GLOBAL_VARIABLES_URI
3756
3786
  });
3757
3787
  });
@@ -3759,8 +3789,9 @@ var initVariablesResource = () => {
3759
3789
  };
3760
3790
 
3761
3791
  // src/mcp/manage-variable-tool.ts
3762
- var initManageVariableTool = () => {
3763
- getMCPByDomain2("variables").addTool({
3792
+ var initManageVariableTool = (reg) => {
3793
+ const { addTool } = reg;
3794
+ addTool({
3764
3795
  name: "manage-global-variable",
3765
3796
  schema: {
3766
3797
  action: z3.enum(["create", "update", "delete"]).describe("Operation to perform"),
@@ -3830,12 +3861,18 @@ function getServiceActions(svc) {
3830
3861
  }
3831
3862
 
3832
3863
  // src/mcp/index.ts
3833
- function initMcp() {
3834
- if (!isAngieAvailable()) {
3835
- return;
3836
- }
3837
- initManageVariableTool();
3838
- initVariablesResource();
3864
+ function initMcp(reg, canvasMcpEntry) {
3865
+ const { setMCPDescription } = reg;
3866
+ setMCPDescription(
3867
+ `Everything related to V4 ( Atomic ) variables.
3868
+ # Global variables
3869
+ - Create/update/delete global variables
3870
+ - Get list of global variables
3871
+ - Get details of a global variable
3872
+ `
3873
+ );
3874
+ initManageVariableTool(reg);
3875
+ initVariablesResource(reg, canvasMcpEntry);
3839
3876
  }
3840
3877
 
3841
3878
  // src/register-variable-types.tsx
@@ -4157,7 +4194,7 @@ function init() {
4157
4194
  useProps: usePropVariableAction
4158
4195
  });
4159
4196
  service.init().then(() => {
4160
- initMcp();
4197
+ initMcp(getMCPByDomain("variables"), getMCPByDomain("canvas"));
4161
4198
  });
4162
4199
  injectIntoTop({
4163
4200
  id: "canvas-style-variables-render",