@elementor/editor-variables 4.3.0-999 → 4.4.0-1065
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 +25 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/variable-selection-popover.tsx +5 -8
- package/src/mcp/manage-variable-tool.ts +17 -3
- package/src/service.ts +20 -0
package/dist/index.js
CHANGED
|
@@ -660,6 +660,18 @@ var handleWatermark = (operation, newWatermark) => {
|
|
|
660
660
|
}
|
|
661
661
|
storage.watermark(newWatermark);
|
|
662
662
|
};
|
|
663
|
+
var applyLocalMutation = (action, variableWithId, watermark) => {
|
|
664
|
+
const { id: variableId, ...variable } = variableWithId;
|
|
665
|
+
handleWatermark(OP_RW, watermark);
|
|
666
|
+
if (action === "create") {
|
|
667
|
+
storage.add(variableId, variable);
|
|
668
|
+
} else {
|
|
669
|
+
storage.update(variableId, variable);
|
|
670
|
+
}
|
|
671
|
+
styleVariablesRepository.update({
|
|
672
|
+
[variableId]: variable
|
|
673
|
+
});
|
|
674
|
+
};
|
|
663
675
|
|
|
664
676
|
// src/transformers/utils/resolve-css-variable.ts
|
|
665
677
|
var resolveCssVariable = (id, variable) => {
|
|
@@ -2493,7 +2505,6 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
2493
2505
|
// src/components/variable-selection-popover.tsx
|
|
2494
2506
|
var React22 = __toESM(require("react"));
|
|
2495
2507
|
var import_react21 = require("react");
|
|
2496
|
-
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
2497
2508
|
|
|
2498
2509
|
// src/context/variable-selection-popover.context.tsx
|
|
2499
2510
|
var React15 = __toESM(require("react"));
|
|
@@ -3222,11 +3233,11 @@ var VIEW_EDIT = "edit";
|
|
|
3222
3233
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3223
3234
|
const [currentView, setCurrentView] = (0, import_react21.useState)(VIEW_LIST);
|
|
3224
3235
|
const [editId, setEditId] = (0, import_react21.useState)("");
|
|
3225
|
-
const onSettingsAvailable = (
|
|
3236
|
+
const onSettingsAvailable = () => {
|
|
3226
3237
|
window.dispatchEvent(
|
|
3227
3238
|
new CustomEvent("elementor/toggle-design-system", { detail: { tab: "variables" } })
|
|
3228
3239
|
);
|
|
3229
|
-
}
|
|
3240
|
+
};
|
|
3230
3241
|
return /* @__PURE__ */ React22.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React22.createElement(PopoverContentRefContextProvider, null, RenderView({
|
|
3231
3242
|
propTypeKey,
|
|
3232
3243
|
currentView,
|
|
@@ -3891,7 +3902,7 @@ var import_utils3 = require("@elementor/utils");
|
|
|
3891
3902
|
var MANAGE_VARIABLES_GUIDE_URI = "elementor://variables/tools/manage-global-variable-guide";
|
|
3892
3903
|
|
|
3893
3904
|
// src/mcp/variables-resource.ts
|
|
3894
|
-
var
|
|
3905
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
3895
3906
|
var import_http_client2 = require("@elementor/http-client");
|
|
3896
3907
|
var MCP_PROXY_URL = "elementor/v1/mcp-proxy";
|
|
3897
3908
|
var GLOBAL_VARIABLES_URI = "elementor://global-variables";
|
|
@@ -3923,7 +3934,7 @@ var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
|
|
|
3923
3934
|
}
|
|
3924
3935
|
);
|
|
3925
3936
|
window.addEventListener(STORAGE_UPDATED_EVENT, notifyGlobalVariablesUpdated);
|
|
3926
|
-
(0,
|
|
3937
|
+
(0, import_editor_v1_adapters2.__privateListenTo)((0, import_editor_v1_adapters2.commandEndEvent)("document/save/update"), notifyGlobalVariablesUpdated);
|
|
3927
3938
|
});
|
|
3928
3939
|
};
|
|
3929
3940
|
|
|
@@ -3958,14 +3969,14 @@ var initManageVariableTool = (reg) => {
|
|
|
3958
3969
|
);
|
|
3959
3970
|
addTool({
|
|
3960
3971
|
name: TOOL_NAME,
|
|
3961
|
-
description: "Manage V4 global variables (color, font, size, custom-size). Read the guide resource before use. font =
|
|
3972
|
+
description: "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",
|
|
3962
3973
|
schema: {
|
|
3963
3974
|
action: import_schema3.z.enum(["create", "update", "delete"]),
|
|
3964
3975
|
id: import_schema3.z.string().optional().describe("Variable id \u2014 required for update/delete. Get from the global-variables resource."),
|
|
3965
3976
|
type: import_schema3.z.enum(RUNTIME_ALLOWED_VARIABLE_TYPES),
|
|
3966
3977
|
label: import_schema3.z.string().describe("Variable label (lowercase, dash-separated) \u2014 required for create/update."),
|
|
3967
3978
|
value: import_schema3.z.string().optional().describe(
|
|
3968
|
-
'Plain CSS value \u2014 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.'
|
|
3979
|
+
'Plain CSS value \u2014 required for create/update. Color: hex/rgba/hsl. Font: single Google Font family name only \u2014 no fallback stacks, no generic families. Size: value with unit e.g. "16px", or "auto" (Pro). Do NOT pass JSON.'
|
|
3969
3980
|
)
|
|
3970
3981
|
},
|
|
3971
3982
|
outputSchema: {
|
|
@@ -3981,10 +3992,14 @@ var initManageVariableTool = (reg) => {
|
|
|
3981
3992
|
],
|
|
3982
3993
|
isDestructive: true,
|
|
3983
3994
|
handler: async (params) => {
|
|
3984
|
-
await (0, import_http_client3.httpService)().post(MCP_PROXY_URL2, {
|
|
3995
|
+
const { data } = await (0, import_http_client3.httpService)().post(MCP_PROXY_URL2, {
|
|
3985
3996
|
tool: TOOL_NAME,
|
|
3986
3997
|
input: params
|
|
3987
3998
|
});
|
|
3999
|
+
const payload = data.data;
|
|
4000
|
+
if (payload.variable && typeof payload.watermark === "number") {
|
|
4001
|
+
applyLocalMutation(params.action, payload.variable, payload.watermark);
|
|
4002
|
+
}
|
|
3988
4003
|
return { status: "ok" };
|
|
3989
4004
|
}
|
|
3990
4005
|
});
|
|
@@ -4206,7 +4221,7 @@ function registerVariableTypes() {
|
|
|
4206
4221
|
// src/renderers/style-variables-renderer.tsx
|
|
4207
4222
|
var React38 = __toESM(require("react"));
|
|
4208
4223
|
var import_react29 = require("react");
|
|
4209
|
-
var
|
|
4224
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
4210
4225
|
var import_ui35 = require("@elementor/ui");
|
|
4211
4226
|
var VARIABLES_WRAPPER = ":root";
|
|
4212
4227
|
function StyleVariablesRenderer() {
|
|
@@ -4221,7 +4236,7 @@ function StyleVariablesRenderer() {
|
|
|
4221
4236
|
return /* @__PURE__ */ React38.createElement(import_ui35.Portal, { container }, /* @__PURE__ */ React38.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
4222
4237
|
}
|
|
4223
4238
|
function usePortalContainer() {
|
|
4224
|
-
return (0,
|
|
4239
|
+
return (0, import_editor_v1_adapters3.__privateUseListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters3.getCanvasIframeDocument)()?.head);
|
|
4225
4240
|
}
|
|
4226
4241
|
function useStyleVariables() {
|
|
4227
4242
|
const [variables, setVariables] = (0, import_react29.useState)({});
|