@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/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.mjs
CHANGED
|
@@ -617,6 +617,18 @@ var handleWatermark = (operation, newWatermark) => {
|
|
|
617
617
|
}
|
|
618
618
|
storage.watermark(newWatermark);
|
|
619
619
|
};
|
|
620
|
+
var applyLocalMutation = (action, variableWithId, watermark) => {
|
|
621
|
+
const { id: variableId, ...variable } = variableWithId;
|
|
622
|
+
handleWatermark(OP_RW, watermark);
|
|
623
|
+
if (action === "create") {
|
|
624
|
+
storage.add(variableId, variable);
|
|
625
|
+
} else {
|
|
626
|
+
storage.update(variableId, variable);
|
|
627
|
+
}
|
|
628
|
+
styleVariablesRepository.update({
|
|
629
|
+
[variableId]: variable
|
|
630
|
+
});
|
|
631
|
+
};
|
|
620
632
|
|
|
621
633
|
// src/transformers/utils/resolve-css-variable.ts
|
|
622
634
|
var resolveCssVariable = (id, variable) => {
|
|
@@ -2458,7 +2470,6 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
2458
2470
|
// src/components/variable-selection-popover.tsx
|
|
2459
2471
|
import * as React22 from "react";
|
|
2460
2472
|
import { useState as useState12 } from "react";
|
|
2461
|
-
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
2462
2473
|
|
|
2463
2474
|
// src/context/variable-selection-popover.context.tsx
|
|
2464
2475
|
import * as React15 from "react";
|
|
@@ -3202,11 +3213,11 @@ var VIEW_EDIT = "edit";
|
|
|
3202
3213
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3203
3214
|
const [currentView, setCurrentView] = useState12(VIEW_LIST);
|
|
3204
3215
|
const [editId, setEditId] = useState12("");
|
|
3205
|
-
const onSettingsAvailable =
|
|
3216
|
+
const onSettingsAvailable = () => {
|
|
3206
3217
|
window.dispatchEvent(
|
|
3207
3218
|
new CustomEvent("elementor/toggle-design-system", { detail: { tab: "variables" } })
|
|
3208
3219
|
);
|
|
3209
|
-
}
|
|
3220
|
+
};
|
|
3210
3221
|
return /* @__PURE__ */ React22.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React22.createElement(PopoverContentRefContextProvider, null, RenderView({
|
|
3211
3222
|
propTypeKey,
|
|
3212
3223
|
currentView,
|
|
@@ -3938,14 +3949,14 @@ var initManageVariableTool = (reg) => {
|
|
|
3938
3949
|
);
|
|
3939
3950
|
addTool({
|
|
3940
3951
|
name: TOOL_NAME,
|
|
3941
|
-
description: "Manage V4 global variables (color, font, size, custom-size). Read the guide resource before use. font =
|
|
3952
|
+
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",
|
|
3942
3953
|
schema: {
|
|
3943
3954
|
action: z3.enum(["create", "update", "delete"]),
|
|
3944
3955
|
id: z3.string().optional().describe("Variable id \u2014 required for update/delete. Get from the global-variables resource."),
|
|
3945
3956
|
type: z3.enum(RUNTIME_ALLOWED_VARIABLE_TYPES),
|
|
3946
3957
|
label: z3.string().describe("Variable label (lowercase, dash-separated) \u2014 required for create/update."),
|
|
3947
3958
|
value: z3.string().optional().describe(
|
|
3948
|
-
'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.'
|
|
3959
|
+
'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.'
|
|
3949
3960
|
)
|
|
3950
3961
|
},
|
|
3951
3962
|
outputSchema: {
|
|
@@ -3961,10 +3972,14 @@ var initManageVariableTool = (reg) => {
|
|
|
3961
3972
|
],
|
|
3962
3973
|
isDestructive: true,
|
|
3963
3974
|
handler: async (params) => {
|
|
3964
|
-
await httpService3().post(MCP_PROXY_URL2, {
|
|
3975
|
+
const { data } = await httpService3().post(MCP_PROXY_URL2, {
|
|
3965
3976
|
tool: TOOL_NAME,
|
|
3966
3977
|
input: params
|
|
3967
3978
|
});
|
|
3979
|
+
const payload = data.data;
|
|
3980
|
+
if (payload.variable && typeof payload.watermark === "number") {
|
|
3981
|
+
applyLocalMutation(params.action, payload.variable, payload.watermark);
|
|
3982
|
+
}
|
|
3968
3983
|
return { status: "ok" };
|
|
3969
3984
|
}
|
|
3970
3985
|
});
|