@elementor/editor-variables 3.33.0-301 → 3.33.0-303
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 +34 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/mcp/index.ts +2 -0
- package/src/mcp/variables-resource.ts +28 -0
- package/src/storage.ts +7 -0
package/dist/index.mjs
CHANGED
|
@@ -295,6 +295,9 @@ var OP_RW = "RW";
|
|
|
295
295
|
var OP_RO = "RO";
|
|
296
296
|
var Storage = class {
|
|
297
297
|
state;
|
|
298
|
+
notifyChange() {
|
|
299
|
+
window.dispatchEvent(new Event("variables:updated"));
|
|
300
|
+
}
|
|
298
301
|
constructor() {
|
|
299
302
|
this.state = {
|
|
300
303
|
watermark: -1,
|
|
@@ -314,16 +317,19 @@ var Storage = class {
|
|
|
314
317
|
this.state.watermark = watermark;
|
|
315
318
|
localStorage.setItem(STORAGE_WATERMARK_KEY, this.state.watermark.toString());
|
|
316
319
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
|
|
320
|
+
this.notifyChange();
|
|
317
321
|
}
|
|
318
322
|
add(id2, variable) {
|
|
319
323
|
this.load();
|
|
320
324
|
this.state.variables[id2] = variable;
|
|
321
325
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
|
|
326
|
+
this.notifyChange();
|
|
322
327
|
}
|
|
323
328
|
update(id2, variable) {
|
|
324
329
|
this.load();
|
|
325
330
|
this.state.variables[id2] = variable;
|
|
326
331
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
|
|
332
|
+
this.notifyChange();
|
|
327
333
|
}
|
|
328
334
|
watermark(watermark) {
|
|
329
335
|
this.state.watermark = watermark;
|
|
@@ -3256,7 +3262,7 @@ var trackOpenVariablePopover = (path, variableType) => {
|
|
|
3256
3262
|
};
|
|
3257
3263
|
|
|
3258
3264
|
// src/mcp/index.ts
|
|
3259
|
-
import { getMCPByDomain as
|
|
3265
|
+
import { getMCPByDomain as getMCPByDomain6 } from "@elementor/editor-mcp";
|
|
3260
3266
|
|
|
3261
3267
|
// src/mcp/create-variable-tool.ts
|
|
3262
3268
|
import { getMCPByDomain } from "@elementor/editor-mcp";
|
|
@@ -3497,14 +3503,40 @@ Failed update, which must be displayed to the end user. If the error message is
|
|
|
3497
3503
|
});
|
|
3498
3504
|
};
|
|
3499
3505
|
|
|
3506
|
+
// src/mcp/variables-resource.ts
|
|
3507
|
+
import { getMCPByDomain as getMCPByDomain5 } from "@elementor/editor-mcp";
|
|
3508
|
+
var GLOBAL_VARIABLES_URI = "elementor://variables";
|
|
3509
|
+
var initVariablesResource = () => {
|
|
3510
|
+
const { mcpServer } = getMCPByDomain5("variables");
|
|
3511
|
+
mcpServer.resource(
|
|
3512
|
+
"global-variables",
|
|
3513
|
+
GLOBAL_VARIABLES_URI,
|
|
3514
|
+
{
|
|
3515
|
+
description: "Global variables list. Variables are being used in this way: If it is directly in the schema, you need to put the ID which is the key inside the object."
|
|
3516
|
+
},
|
|
3517
|
+
async () => {
|
|
3518
|
+
return {
|
|
3519
|
+
contents: [{ uri: GLOBAL_VARIABLES_URI, text: localStorage["elementor-global-variables"] }]
|
|
3520
|
+
};
|
|
3521
|
+
}
|
|
3522
|
+
);
|
|
3523
|
+
window.addEventListener("variables:updated", () => {
|
|
3524
|
+
mcpServer.server.sendResourceUpdated({
|
|
3525
|
+
uri: GLOBAL_VARIABLES_URI,
|
|
3526
|
+
contents: [{ uri: GLOBAL_VARIABLES_URI, text: localStorage["elementor-global-variables"] }]
|
|
3527
|
+
});
|
|
3528
|
+
});
|
|
3529
|
+
};
|
|
3530
|
+
|
|
3500
3531
|
// src/mcp/index.ts
|
|
3501
3532
|
function initMcp() {
|
|
3502
|
-
const { setMCPDescription } =
|
|
3533
|
+
const { setMCPDescription } = getMCPByDomain6("variables");
|
|
3503
3534
|
setMCPDescription(`Elementor Editor Variables MCP`);
|
|
3504
3535
|
initListVariablesTool();
|
|
3505
3536
|
initCreateVariableTool();
|
|
3506
3537
|
initUpdateVariableTool();
|
|
3507
3538
|
initDeleteVariableTool();
|
|
3539
|
+
initVariablesResource();
|
|
3508
3540
|
}
|
|
3509
3541
|
|
|
3510
3542
|
// src/register-variable-types.tsx
|