@elementor/editor-variables 4.1.0-837 → 4.1.0-beta1
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 +33 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/global-styles-import-listener.tsx +3 -14
- package/src/components/variables-manager/hooks/use-variables-manager-state.ts +16 -2
- package/src/components/variables-manager/variables-manager-panel.tsx +0 -1
- package/src/init.ts +9 -1
- package/src/mcp/index.ts +0 -9
- package/src/mcp/manage-variable-tool.ts +11 -9
- package/src/mcp/variables-resource.ts +2 -2
- package/src/storage.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -334,12 +334,13 @@ var buildOperationsArray = (originalVariables, currentVariables, deletedVariable
|
|
|
334
334
|
// src/storage.ts
|
|
335
335
|
var STORAGE_KEY = "elementor-global-variables";
|
|
336
336
|
var STORAGE_WATERMARK_KEY = "elementor-global-variables-watermark";
|
|
337
|
+
var STORAGE_UPDATED_EVENT = "variables:updated";
|
|
337
338
|
var OP_RW = "RW";
|
|
338
339
|
var OP_RO = "RO";
|
|
339
340
|
var Storage = class {
|
|
340
341
|
state;
|
|
341
342
|
notifyChange() {
|
|
342
|
-
window.dispatchEvent(new Event(
|
|
343
|
+
window.dispatchEvent(new Event(STORAGE_UPDATED_EVENT));
|
|
343
344
|
}
|
|
344
345
|
constructor() {
|
|
345
346
|
this.state = {
|
|
@@ -1059,6 +1060,17 @@ var useVariablesManagerState = () => {
|
|
|
1059
1060
|
const [isDirty, setIsDirty] = (0, import_react5.useState)(false);
|
|
1060
1061
|
const [isSaving, setIsSaving] = (0, import_react5.useState)(false);
|
|
1061
1062
|
const [searchValue, setSearchValue] = (0, import_react5.useState)("");
|
|
1063
|
+
(0, import_react5.useEffect)(() => {
|
|
1064
|
+
const handleStorageUpdated = () => {
|
|
1065
|
+
setVariables(getVariables(false));
|
|
1066
|
+
setDeletedVariables([]);
|
|
1067
|
+
setIsDirty(false);
|
|
1068
|
+
};
|
|
1069
|
+
window.addEventListener(STORAGE_UPDATED_EVENT, handleStorageUpdated);
|
|
1070
|
+
return () => {
|
|
1071
|
+
window.removeEventListener(STORAGE_UPDATED_EVENT, handleStorageUpdated);
|
|
1072
|
+
};
|
|
1073
|
+
}, []);
|
|
1062
1074
|
const handleOnChange = (0, import_react5.useCallback)(
|
|
1063
1075
|
(newVariables) => {
|
|
1064
1076
|
setVariables({ ...variables, ...newVariables });
|
|
@@ -2321,8 +2333,7 @@ function VariablesManagerPanelRoot({
|
|
|
2321
2333
|
display: "flex",
|
|
2322
2334
|
flexDirection: "column",
|
|
2323
2335
|
flex: 1,
|
|
2324
|
-
minHeight: 0
|
|
2325
|
-
overflow: "hidden"
|
|
2336
|
+
minHeight: 0
|
|
2326
2337
|
}
|
|
2327
2338
|
},
|
|
2328
2339
|
bodyInner
|
|
@@ -2412,14 +2423,7 @@ var import_react14 = require("react");
|
|
|
2412
2423
|
var import_editor_canvas4 = require("@elementor/editor-canvas");
|
|
2413
2424
|
function GlobalStylesImportListener() {
|
|
2414
2425
|
(0, import_react14.useEffect)(() => {
|
|
2415
|
-
const handleGlobalStylesImported = (
|
|
2416
|
-
const importedVars = event.detail?.global_variables;
|
|
2417
|
-
if (!importedVars) {
|
|
2418
|
-
return;
|
|
2419
|
-
}
|
|
2420
|
-
if (importedVars.data && typeof importedVars.data === "object") {
|
|
2421
|
-
styleVariablesRepository.update(importedVars.data);
|
|
2422
|
-
}
|
|
2426
|
+
const handleGlobalStylesImported = () => {
|
|
2423
2427
|
service.load();
|
|
2424
2428
|
};
|
|
2425
2429
|
window.addEventListener(import_editor_canvas4.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
@@ -3956,7 +3960,7 @@ var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
|
|
|
3956
3960
|
};
|
|
3957
3961
|
}
|
|
3958
3962
|
);
|
|
3959
|
-
window.addEventListener(
|
|
3963
|
+
window.addEventListener(STORAGE_UPDATED_EVENT, notifyGlobalVariablesUpdated);
|
|
3960
3964
|
(0, import_editor_v1_adapters6.__privateListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("document/save/update"), notifyGlobalVariablesUpdated);
|
|
3961
3965
|
});
|
|
3962
3966
|
};
|
|
@@ -3971,7 +3975,9 @@ var initManageVariableTool = (reg) => {
|
|
|
3971
3975
|
id: import_schema3.z.string().optional().describe("Variable id (required for update/delete). Get from list-global-variables."),
|
|
3972
3976
|
type: import_schema3.z.string().optional().describe('Variable type: "global-color-variable" or "global-font-variable" (required for create)'),
|
|
3973
3977
|
label: import_schema3.z.string().optional().describe("Variable label (required for create/update)"),
|
|
3974
|
-
value: import_schema3.z.string().optional().describe(
|
|
3978
|
+
value: import_schema3.z.string().optional().describe(
|
|
3979
|
+
"The variable value (required for create/update). Provide a plain CSS value matching the variable type (font: family name; color: CSS color; size: value with unit). Never JSON."
|
|
3980
|
+
)
|
|
3975
3981
|
},
|
|
3976
3982
|
outputSchema: {
|
|
3977
3983
|
status: import_schema3.z.enum(["ok"]).describe("Operation status"),
|
|
@@ -3987,14 +3993,11 @@ var initManageVariableTool = (reg) => {
|
|
|
3987
3993
|
description: "Global variables"
|
|
3988
3994
|
}
|
|
3989
3995
|
],
|
|
3990
|
-
description: `
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
# NAMING - IMPORTANT
|
|
3996
|
-
the variables names should ALWAYS be lowercased and dashed spaced. example: "Headline Primary" should be "headline-primary"
|
|
3997
|
-
`,
|
|
3996
|
+
description: `Create, update, or delete V4 global variables (distinct from legacy "globals").
|
|
3997
|
+
- Values: any valid CSS value, inserted as-is (1:1 with \`--css-var: VALUE\`). Do NOT pass JSON or legacy-globals object structures.
|
|
3998
|
+
- Names: lowercase, dash-separated (e.g. "Headline Primary" \u2192 "headline-primary").
|
|
3999
|
+
- Update: when renaming, keep the existing value; when updating value, keep the exact label.
|
|
4000
|
+
- Delete: destructive \u2014 confirm with user first.`,
|
|
3998
4001
|
handler: async (params) => {
|
|
3999
4002
|
const operations = getServiceActions(service);
|
|
4000
4003
|
const op = operations[params.action];
|
|
@@ -4043,15 +4046,6 @@ function getServiceActions(svc) {
|
|
|
4043
4046
|
|
|
4044
4047
|
// src/mcp/index.ts
|
|
4045
4048
|
function initMcp(reg, canvasMcpEntry) {
|
|
4046
|
-
const { setMCPDescription } = reg;
|
|
4047
|
-
setMCPDescription(
|
|
4048
|
-
`Everything related to V4 ( Atomic ) variables.
|
|
4049
|
-
# Global variables
|
|
4050
|
-
- Create/update/delete global variables
|
|
4051
|
-
- Get list of global variables
|
|
4052
|
-
- Get details of a global variable
|
|
4053
|
-
`
|
|
4054
|
-
);
|
|
4055
4049
|
initManageVariableTool(reg);
|
|
4056
4050
|
initVariablesResource(reg, canvasMcpEntry);
|
|
4057
4051
|
}
|
|
@@ -4563,7 +4557,15 @@ function init() {
|
|
|
4563
4557
|
useProps: usePropVariableAction
|
|
4564
4558
|
});
|
|
4565
4559
|
service.init().then(() => {
|
|
4566
|
-
|
|
4560
|
+
const variablesMcpRegistry = (0, import_editor_mcp.getMCPByDomain)("variables", {
|
|
4561
|
+
instructions: `Everything related to V4 ( Atomic ) variables.
|
|
4562
|
+
# Global variables
|
|
4563
|
+
- Create/update/delete global variables
|
|
4564
|
+
- Get list of global variables
|
|
4565
|
+
- Get details of a global variable
|
|
4566
|
+
`
|
|
4567
|
+
});
|
|
4568
|
+
initMcp(variablesMcpRegistry, (0, import_editor_mcp.getMCPByDomain)("canvas"));
|
|
4567
4569
|
});
|
|
4568
4570
|
(0, import_editor.injectIntoTop)({
|
|
4569
4571
|
id: "canvas-style-variables-render",
|