@elementor/editor-canvas 4.5.0-1179 → 4.5.0-1181
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 +282 -134
- package/dist/index.mjs +242 -89
- package/package.json +20 -20
- package/src/mcp/__tests__/canvas-mcp.test.ts +1 -0
- package/src/mcp/canvas-mcp.ts +2 -0
- package/src/mcp/tools/build-composition/__tests__/tool.test.ts +240 -0
- package/src/mcp/tools/build-composition/tool.ts +236 -0
package/dist/index.mjs
CHANGED
|
@@ -2703,11 +2703,11 @@ function getVal2(val) {
|
|
|
2703
2703
|
var transformOriginTransformer = createTransformer((value) => {
|
|
2704
2704
|
const x = getVal2(value.x);
|
|
2705
2705
|
const y = getVal2(value.y);
|
|
2706
|
-
const
|
|
2707
|
-
if (x === DEFAULT_XY && y === DEFAULT_XY &&
|
|
2706
|
+
const z5 = getVal2(value.z);
|
|
2707
|
+
if (x === DEFAULT_XY && y === DEFAULT_XY && z5 === DEFAULT_Z) {
|
|
2708
2708
|
return null;
|
|
2709
2709
|
}
|
|
2710
|
-
return `${x} ${y} ${
|
|
2710
|
+
return `${x} ${y} ${z5}`;
|
|
2711
2711
|
});
|
|
2712
2712
|
|
|
2713
2713
|
// src/transformers/styles/transform-rotate-transformer.ts
|
|
@@ -4864,8 +4864,175 @@ function getElementDisplayName(container) {
|
|
|
4864
4864
|
}
|
|
4865
4865
|
}
|
|
4866
4866
|
|
|
4867
|
+
// src/mcp/tools/build-composition/tool.ts
|
|
4868
|
+
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
4869
|
+
import {
|
|
4870
|
+
createElement as createElement12,
|
|
4871
|
+
deleteElement,
|
|
4872
|
+
getContainer as getContainer4,
|
|
4873
|
+
getCurrentDocumentContainer
|
|
4874
|
+
} from "@elementor/editor-elements";
|
|
4875
|
+
import { undoable as undoable2 } from "@elementor/editor-v1-adapters";
|
|
4876
|
+
import { httpService as httpService6 } from "@elementor/http-client";
|
|
4877
|
+
import { z } from "@elementor/schema";
|
|
4878
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
4879
|
+
|
|
4880
|
+
// src/mcp/utils/get-mcp-error-message.ts
|
|
4881
|
+
import { AxiosError } from "@elementor/http-client";
|
|
4882
|
+
function getMcpErrorMessage(error, toolName) {
|
|
4883
|
+
if (error instanceof AxiosError) {
|
|
4884
|
+
const data = error.response?.data;
|
|
4885
|
+
if (data?.message) {
|
|
4886
|
+
return data.code ? `${data.code}: ${data.message}` : data.message;
|
|
4887
|
+
}
|
|
4888
|
+
}
|
|
4889
|
+
if (error instanceof Error) {
|
|
4890
|
+
return error.message;
|
|
4891
|
+
}
|
|
4892
|
+
return `${toolName} failed with an unknown error.`;
|
|
4893
|
+
}
|
|
4894
|
+
|
|
4895
|
+
// src/mcp/tools/build-composition/tool.ts
|
|
4896
|
+
var MCP_PROXY_URL5 = "elementor/v1/mcp-proxy";
|
|
4897
|
+
var TOOL_NAME = "build-composition";
|
|
4898
|
+
var DOCUMENT_ROOT = "document";
|
|
4899
|
+
var ELEMENTS_TO_JSON_OPTIONS = { remove: ["default", "editSettings", "defaultEditSettings"] };
|
|
4900
|
+
var BUILD_COMPOSITION_GUIDE_URI = "elementor://tools/build-composition-guide";
|
|
4901
|
+
var initBuildCompositionTool = (reg) => {
|
|
4902
|
+
const { addTool, resource } = reg;
|
|
4903
|
+
resource(
|
|
4904
|
+
"build-composition-guide",
|
|
4905
|
+
BUILD_COMPOSITION_GUIDE_URI,
|
|
4906
|
+
{
|
|
4907
|
+
title: "Build Composition Guide",
|
|
4908
|
+
description: "Full guide for the build-composition tool",
|
|
4909
|
+
mimeType: "text/markdown"
|
|
4910
|
+
},
|
|
4911
|
+
async (uri) => {
|
|
4912
|
+
const { data } = await httpService6().get(MCP_PROXY_URL5, {
|
|
4913
|
+
params: { uri: uri.href }
|
|
4914
|
+
});
|
|
4915
|
+
return {
|
|
4916
|
+
contents: [{ uri: uri.href, mimeType: "text/markdown", text: data.data }]
|
|
4917
|
+
};
|
|
4918
|
+
}
|
|
4919
|
+
);
|
|
4920
|
+
addTool({
|
|
4921
|
+
name: TOOL_NAME,
|
|
4922
|
+
description: "Build a V4 layout on the open page from an XML structure in one call. Read the build-composition guide resource before use. Every element in xml_structure needs a unique configuration-id; element_config, style, classes and interactions are keyed by it. The elements are added to the editor (unsaved, undoable) and their new element ids are returned in resolved_xml and root_element_ids.",
|
|
4923
|
+
schema: {
|
|
4924
|
+
xml_structure: z.string().describe(
|
|
4925
|
+
'Raw XML of Elementor widget tags, e.g. <e-div-block configuration-id="hero"><e-heading configuration-id="hero-title"></e-heading></e-div-block>. No other attributes, ids, classes or text nodes.'
|
|
4926
|
+
),
|
|
4927
|
+
element_config: z.record(z.string(), z.any()).optional().describe("configuration-id \u2192 plain widget settings matching elementor://widgets/schema/{type}."),
|
|
4928
|
+
editor_settings: z.record(z.string(), z.any()).optional().describe("configuration-id \u2192 editor-only fields."),
|
|
4929
|
+
style: z.record(z.string(), z.string()).optional().describe(
|
|
4930
|
+
"configuration-id \u2192 plain CSS string. Supports &:hover/&:focus/&:active nesting and @media(--breakpoint) blocks."
|
|
4931
|
+
),
|
|
4932
|
+
classes: z.record(z.string(), z.array(z.string())).optional().describe("configuration-id \u2192 existing global class labels to attach."),
|
|
4933
|
+
interactions: z.record(z.string(), z.array(z.record(z.string(), z.any()))).optional().describe("configuration-id \u2192 interaction items. See elementor://interactions/schema."),
|
|
4934
|
+
parent_id: z.string().optional().describe("Element id of the parent container. Omit to insert at the document root."),
|
|
4935
|
+
mode: z.enum(["append", "replace_children"]).optional().describe(
|
|
4936
|
+
"append (default) or replace_children, which removes the existing children of parent_id first."
|
|
4937
|
+
)
|
|
4938
|
+
},
|
|
4939
|
+
outputSchema: {
|
|
4940
|
+
root_element_ids: z.array(z.string()).describe("Ids of the created root-level elements."),
|
|
4941
|
+
resolved_xml: z.string().optional().describe("The XML with the new element ids embedded."),
|
|
4942
|
+
removed_element_ids: z.array(z.string()).optional(),
|
|
4943
|
+
warnings: z.array(z.string()).optional(),
|
|
4944
|
+
warning_details: z.array(z.any()).optional(),
|
|
4945
|
+
pro_features_discovery: z.array(z.object({ message: z.string(), upgrade_url: z.string() })).optional()
|
|
4946
|
+
},
|
|
4947
|
+
requiredResources: [
|
|
4948
|
+
{ uri: BUILD_COMPOSITION_GUIDE_URI, description: "Full guide for XML structure, ids, layouts and styles" }
|
|
4949
|
+
],
|
|
4950
|
+
handler: async ({ parent_id: parentId = DOCUMENT_ROOT, mode = "append", ...input }) => {
|
|
4951
|
+
const postId = getCurrentDocument()?.id;
|
|
4952
|
+
const documentContainer = getCurrentDocumentContainer();
|
|
4953
|
+
if (!postId || !documentContainer) {
|
|
4954
|
+
throw new Error("No active document found.");
|
|
4955
|
+
}
|
|
4956
|
+
const parentContainer = parentId === DOCUMENT_ROOT ? documentContainer : getContainer4(parentId);
|
|
4957
|
+
if (!parentContainer) {
|
|
4958
|
+
throw new Error(`Parent element not found: ${parentId}`);
|
|
4959
|
+
}
|
|
4960
|
+
let plan;
|
|
4961
|
+
try {
|
|
4962
|
+
const { data } = await httpService6().post(MCP_PROXY_URL5, {
|
|
4963
|
+
tool: TOOL_NAME,
|
|
4964
|
+
input: {
|
|
4965
|
+
...input,
|
|
4966
|
+
post_id: postId,
|
|
4967
|
+
parent_id: parentId,
|
|
4968
|
+
mode,
|
|
4969
|
+
dry_run: true,
|
|
4970
|
+
document_elements: serializeElements(documentContainer)
|
|
4971
|
+
}
|
|
4972
|
+
});
|
|
4973
|
+
plan = data.data;
|
|
4974
|
+
} catch (error) {
|
|
4975
|
+
throw new Error(getMcpErrorMessage(error, TOOL_NAME));
|
|
4976
|
+
}
|
|
4977
|
+
applyPlan(parentContainer, plan);
|
|
4978
|
+
const { elements, ...result } = plan;
|
|
4979
|
+
return result;
|
|
4980
|
+
}
|
|
4981
|
+
});
|
|
4982
|
+
};
|
|
4983
|
+
function serializeElements(container) {
|
|
4984
|
+
const elements = container.model.get("elements");
|
|
4985
|
+
return elements?.toJSON(ELEMENTS_TO_JSON_OPTIONS) ?? [];
|
|
4986
|
+
}
|
|
4987
|
+
function applyPlan(parentContainer, { elements, removed_element_ids: removedIds = [] }) {
|
|
4988
|
+
if (!Array.isArray(elements) || !elements.length) {
|
|
4989
|
+
throw new Error("The planned composition has no elements to build");
|
|
4990
|
+
}
|
|
4991
|
+
const apply = () => {
|
|
4992
|
+
const removed = [];
|
|
4993
|
+
removedIds.forEach((id) => {
|
|
4994
|
+
const container = getContainer4(id);
|
|
4995
|
+
if (!container?.parent) {
|
|
4996
|
+
return;
|
|
4997
|
+
}
|
|
4998
|
+
removed.push({
|
|
4999
|
+
model: container.model.toJSON(),
|
|
5000
|
+
parentId: container.parent.id,
|
|
5001
|
+
at: container.view?._index ?? 0
|
|
5002
|
+
});
|
|
5003
|
+
deleteElement({ container, options: { useHistory: false } });
|
|
5004
|
+
});
|
|
5005
|
+
const target = parentContainer.lookup?.() ?? parentContainer;
|
|
5006
|
+
const createdIds = elements.map(
|
|
5007
|
+
(model) => createElement12({ container: target, model, options: { useHistory: false } }).id
|
|
5008
|
+
);
|
|
5009
|
+
return { removed, createdIds };
|
|
5010
|
+
};
|
|
5011
|
+
undoable2(
|
|
5012
|
+
{
|
|
5013
|
+
do: apply,
|
|
5014
|
+
undo: (_, { removed, createdIds }) => {
|
|
5015
|
+
[...createdIds].reverse().forEach((id) => {
|
|
5016
|
+
const container = getContainer4(id);
|
|
5017
|
+
if (container) {
|
|
5018
|
+
deleteElement({ container, options: { useHistory: false } });
|
|
5019
|
+
}
|
|
5020
|
+
});
|
|
5021
|
+
[...removed].reverse().forEach(({ model, parentId, at }) => {
|
|
5022
|
+
const parent = getContainer4(parentId);
|
|
5023
|
+
if (parent) {
|
|
5024
|
+
createElement12({ container: parent, model, options: { useHistory: false, at } });
|
|
5025
|
+
}
|
|
5026
|
+
});
|
|
5027
|
+
},
|
|
5028
|
+
redo: apply
|
|
5029
|
+
},
|
|
5030
|
+
{ title: __7("Build composition", "elementor") }
|
|
5031
|
+
)();
|
|
5032
|
+
}
|
|
5033
|
+
|
|
4867
5034
|
// src/mcp/tools/configure-element/tool.ts
|
|
4868
|
-
import { getContainer as
|
|
5035
|
+
import { getContainer as getContainer5, getWidgetsCache as getWidgetsCache6 } from "@elementor/editor-elements";
|
|
4869
5036
|
import { dispatchMcpStylesAppliedEvent } from "@elementor/editor-mcp";
|
|
4870
5037
|
import { Schema as Schema3 } from "@elementor/editor-props";
|
|
4871
5038
|
|
|
@@ -5308,29 +5475,29 @@ Note: \`link\` is valid only when the element's PropType schema (which you must
|
|
|
5308
5475
|
};
|
|
5309
5476
|
|
|
5310
5477
|
// src/mcp/tools/configure-element/schema.ts
|
|
5311
|
-
import { z } from "@elementor/schema";
|
|
5478
|
+
import { z as z2 } from "@elementor/schema";
|
|
5312
5479
|
var inputSchema = {
|
|
5313
|
-
propertiesToChange:
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5480
|
+
propertiesToChange: z2.record(
|
|
5481
|
+
z2.string().describe("The property name."),
|
|
5482
|
+
z2.any().describe(`PropValue, refer to [${WIDGET_SCHEMA_URI}] by correct type, as appears in elementType`),
|
|
5483
|
+
z2.any()
|
|
5317
5484
|
).describe("An object record containing property names and their new values to be set on the element"),
|
|
5318
|
-
style:
|
|
5319
|
-
|
|
5320
|
-
|
|
5485
|
+
style: z2.record(
|
|
5486
|
+
z2.string().describe('A CSS property name, e.g. "color", "margin-top".'),
|
|
5487
|
+
z2.string().nullable().describe(
|
|
5321
5488
|
'A CSS value, e.g. "red", "10px", "1px solid #000". Use null to reset the property to its default.'
|
|
5322
5489
|
)
|
|
5323
5490
|
).describe(
|
|
5324
5491
|
"Raw CSS declarations as a flat property\u2192value map. Converted to native styles server-side; any declaration that cannot be converted is stored as the element custom CSS. A null value resets that property to its default."
|
|
5325
5492
|
).default({}),
|
|
5326
|
-
elementType:
|
|
5327
|
-
elementId:
|
|
5493
|
+
elementType: z2.string().describe("The type of the element to retrieve the schema"),
|
|
5494
|
+
elementId: z2.string().describe("The unique id of the element to configure")
|
|
5328
5495
|
};
|
|
5329
5496
|
var outputSchema = {
|
|
5330
|
-
success:
|
|
5497
|
+
success: z2.boolean().describe(
|
|
5331
5498
|
"Whether the configuration change was successful, only if propertyName and propertyValue are provided"
|
|
5332
5499
|
),
|
|
5333
|
-
warnings:
|
|
5500
|
+
warnings: z2.string().describe(
|
|
5334
5501
|
'Non-fatal notices. Present when some props were skipped because they are not in the element schema (e.g. a "link" on a widget with no link prop). Other changes were still applied.'
|
|
5335
5502
|
).optional()
|
|
5336
5503
|
};
|
|
@@ -5367,7 +5534,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
5367
5534
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
5368
5535
|
);
|
|
5369
5536
|
}
|
|
5370
|
-
const container =
|
|
5537
|
+
const container = getContainer5(elementId);
|
|
5371
5538
|
if (!container) {
|
|
5372
5539
|
throw new Error(`Element with id ${elementId} not found`);
|
|
5373
5540
|
}
|
|
@@ -5467,23 +5634,8 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5467
5634
|
}
|
|
5468
5635
|
|
|
5469
5636
|
// src/mcp/tools/find-icons/tool.ts
|
|
5470
|
-
import { httpService as
|
|
5471
|
-
import { z as
|
|
5472
|
-
|
|
5473
|
-
// src/mcp/utils/get-mcp-error-message.ts
|
|
5474
|
-
import { AxiosError } from "@elementor/http-client";
|
|
5475
|
-
function getMcpErrorMessage(error, toolName) {
|
|
5476
|
-
if (error instanceof AxiosError) {
|
|
5477
|
-
const data = error.response?.data;
|
|
5478
|
-
if (data?.message) {
|
|
5479
|
-
return data.code ? `${data.code}: ${data.message}` : data.message;
|
|
5480
|
-
}
|
|
5481
|
-
}
|
|
5482
|
-
if (error instanceof Error) {
|
|
5483
|
-
return error.message;
|
|
5484
|
-
}
|
|
5485
|
-
return `${toolName} failed with an unknown error.`;
|
|
5486
|
-
}
|
|
5637
|
+
import { httpService as httpService7 } from "@elementor/http-client";
|
|
5638
|
+
import { z as z3 } from "@elementor/schema";
|
|
5487
5639
|
|
|
5488
5640
|
// src/mcp/tools/find-icons/prompt.ts
|
|
5489
5641
|
import { toolPrompts as toolPrompts2 } from "@elementor/editor-mcp";
|
|
@@ -5511,7 +5663,7 @@ findIconsToolPrompt.example(`Browse a category, one style only:
|
|
|
5511
5663
|
{ "category": "shopping", "library": "fa-solid", "perPage": 25 }`);
|
|
5512
5664
|
|
|
5513
5665
|
// src/mcp/tools/find-icons/tool.ts
|
|
5514
|
-
var
|
|
5666
|
+
var MCP_PROXY_URL6 = "elementor/v1/mcp-proxy";
|
|
5515
5667
|
var MAX_QUERIES = 10;
|
|
5516
5668
|
var MAX_PER_PAGE = 25;
|
|
5517
5669
|
var initFindIconsTool = (reg) => {
|
|
@@ -5520,56 +5672,56 @@ var initFindIconsTool = (reg) => {
|
|
|
5520
5672
|
name: "find-icons",
|
|
5521
5673
|
description: findIconsToolPrompt.prompt(),
|
|
5522
5674
|
schema: {
|
|
5523
|
-
queries:
|
|
5675
|
+
queries: z3.array(z3.string()).max(MAX_QUERIES).optional().describe(
|
|
5524
5676
|
'One plain-language phrase per icon you need, for example ["add to cart", "free shipping"]. Batch every icon a page needs into a single call.'
|
|
5525
5677
|
),
|
|
5526
|
-
library:
|
|
5678
|
+
library: z3.string().optional().describe(
|
|
5527
5679
|
'Restrict results to one library key reported in "libraries", for example "fa-solid". Omit to search every library installed on the site.'
|
|
5528
5680
|
),
|
|
5529
|
-
category:
|
|
5681
|
+
category: z3.string().optional().describe(
|
|
5530
5682
|
'Restrict results to one Font Awesome category reported in "categories", for example "shopping". May be used without a query to browse that category.'
|
|
5531
5683
|
),
|
|
5532
|
-
page:
|
|
5533
|
-
perPage:
|
|
5684
|
+
page: z3.number().int().min(1).optional(),
|
|
5685
|
+
perPage: z3.number().int().min(1).max(MAX_PER_PAGE).optional()
|
|
5534
5686
|
},
|
|
5535
5687
|
outputSchema: {
|
|
5536
|
-
results:
|
|
5537
|
-
|
|
5538
|
-
query:
|
|
5539
|
-
matches:
|
|
5540
|
-
|
|
5541
|
-
value:
|
|
5542
|
-
library:
|
|
5543
|
-
name:
|
|
5544
|
-
label:
|
|
5545
|
-
matched_on:
|
|
5546
|
-
license:
|
|
5688
|
+
results: z3.array(
|
|
5689
|
+
z3.object({
|
|
5690
|
+
query: z3.string(),
|
|
5691
|
+
matches: z3.array(
|
|
5692
|
+
z3.object({
|
|
5693
|
+
value: z3.string(),
|
|
5694
|
+
library: z3.string(),
|
|
5695
|
+
name: z3.string(),
|
|
5696
|
+
label: z3.string(),
|
|
5697
|
+
matched_on: z3.enum(["name", "alias", "term", "category", "library"]),
|
|
5698
|
+
license: z3.enum(["free", "pro"])
|
|
5547
5699
|
})
|
|
5548
5700
|
),
|
|
5549
|
-
total:
|
|
5550
|
-
page:
|
|
5551
|
-
per_page:
|
|
5552
|
-
truncated:
|
|
5701
|
+
total: z3.number(),
|
|
5702
|
+
page: z3.number(),
|
|
5703
|
+
per_page: z3.number(),
|
|
5704
|
+
truncated: z3.boolean()
|
|
5553
5705
|
})
|
|
5554
5706
|
).describe(
|
|
5555
5707
|
'One entry per query, each with ranked "matches". Every match carries the "value" and "library" pair to write on the e-svg icon prop, plus "matched_on" and "license".'
|
|
5556
5708
|
),
|
|
5557
|
-
libraries:
|
|
5709
|
+
libraries: z3.array(z3.string()).optional().describe(
|
|
5558
5710
|
"Icon library keys installed on this site. Only sent when nothing matched or when browsing."
|
|
5559
5711
|
),
|
|
5560
|
-
customLibraries:
|
|
5712
|
+
customLibraries: z3.record(z3.string(), z3.string()).optional().describe(
|
|
5561
5713
|
"Custom (uploaded) icon libraries keyed by library. Only sent when nothing matched or when browsing."
|
|
5562
5714
|
),
|
|
5563
|
-
categories:
|
|
5715
|
+
categories: z3.array(z3.string()).optional().describe(
|
|
5564
5716
|
'Icon categories for the "category" filter. Only sent when nothing matched or when browsing.'
|
|
5565
5717
|
),
|
|
5566
|
-
truncatedCustomLibraries:
|
|
5567
|
-
fontAwesomeVersion:
|
|
5568
|
-
llmInstructions:
|
|
5718
|
+
truncatedCustomLibraries: z3.array(z3.string()).optional().describe("Custom libraries with more than 250 icons; only their first 250 icons are searchable."),
|
|
5719
|
+
fontAwesomeVersion: z3.string().nullable().describe("Font Awesome version the site renders icons from."),
|
|
5720
|
+
llmInstructions: z3.string().optional().describe("Present only when nothing matched, explaining what to do next.")
|
|
5569
5721
|
},
|
|
5570
5722
|
handler: async ({ queries, library, category, page, perPage }) => {
|
|
5571
5723
|
try {
|
|
5572
|
-
const { data } = await
|
|
5724
|
+
const { data } = await httpService7().post(MCP_PROXY_URL6, {
|
|
5573
5725
|
tool: "find-icons",
|
|
5574
5726
|
input: {
|
|
5575
5727
|
...queries ? { queries } : {},
|
|
@@ -5596,36 +5748,36 @@ var initFindIconsTool = (reg) => {
|
|
|
5596
5748
|
};
|
|
5597
5749
|
|
|
5598
5750
|
// src/mcp/tools/get-page-structure/tool.ts
|
|
5599
|
-
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
5600
|
-
import { httpService as
|
|
5601
|
-
import { z as
|
|
5602
|
-
var
|
|
5751
|
+
import { getCurrentDocument as getCurrentDocument2 } from "@elementor/editor-documents";
|
|
5752
|
+
import { httpService as httpService8 } from "@elementor/http-client";
|
|
5753
|
+
import { z as z4 } from "@elementor/schema";
|
|
5754
|
+
var MCP_PROXY_URL7 = "elementor/v1/mcp-proxy";
|
|
5603
5755
|
var initGetPageStructureTool = (reg) => {
|
|
5604
5756
|
const { addTool } = reg;
|
|
5605
5757
|
addTool({
|
|
5606
5758
|
name: "get-page-structure",
|
|
5607
5759
|
description: "Returns a lean Elementor element tree skeleton (id, elType, widgetType, title, nested elements) for a post or page. If no postId is provided, uses the currently open document. Optionally scope to a subtree with elementId. Set includeContent=true (requires elementId) to also return each node's settings and styles.",
|
|
5608
5760
|
schema: {
|
|
5609
|
-
postId:
|
|
5761
|
+
postId: z4.number().optional().describe(
|
|
5610
5762
|
"WordPress post ID of the Elementor document. If omitted, uses the currently open document."
|
|
5611
5763
|
),
|
|
5612
|
-
elementId:
|
|
5613
|
-
includeContent:
|
|
5764
|
+
elementId: z4.string().optional().describe("If provided, returns only the subtree rooted at that element id."),
|
|
5765
|
+
includeContent: z4.boolean().optional().describe(
|
|
5614
5766
|
"If true, includes each node's settings and styles (same shape build-composition accepts as input). Requires elementId."
|
|
5615
5767
|
)
|
|
5616
5768
|
},
|
|
5617
5769
|
outputSchema: {
|
|
5618
|
-
elements:
|
|
5770
|
+
elements: z4.array(z4.any()).describe(
|
|
5619
5771
|
"Skeleton of Elementor elements (id, elType, widgetType, title, nested elements). When includeContent is true, each node also includes settings and styles."
|
|
5620
5772
|
)
|
|
5621
5773
|
},
|
|
5622
5774
|
handler: async ({ postId, elementId, includeContent }) => {
|
|
5623
|
-
const resolvedPostId = postId ??
|
|
5775
|
+
const resolvedPostId = postId ?? getCurrentDocument2()?.id;
|
|
5624
5776
|
if (!resolvedPostId) {
|
|
5625
5777
|
throw new Error("No post ID provided and no active document found.");
|
|
5626
5778
|
}
|
|
5627
5779
|
try {
|
|
5628
|
-
const { data } = await
|
|
5780
|
+
const { data } = await httpService8().post(MCP_PROXY_URL7, {
|
|
5629
5781
|
tool: "get-page-structure",
|
|
5630
5782
|
input: {
|
|
5631
5783
|
post_id: resolvedPostId,
|
|
@@ -5657,6 +5809,7 @@ var initCanvasMcp = (reg) => {
|
|
|
5657
5809
|
initConfigureElementTool(reg);
|
|
5658
5810
|
initFindIconsTool(reg);
|
|
5659
5811
|
initGetPageStructureTool(reg);
|
|
5812
|
+
initBuildCompositionTool(reg);
|
|
5660
5813
|
initBreakpointsResource(reg);
|
|
5661
5814
|
};
|
|
5662
5815
|
|
|
@@ -5764,7 +5917,7 @@ import {
|
|
|
5764
5917
|
} from "@elementor/editor-elements";
|
|
5765
5918
|
import { notify as notify6 } from "@elementor/editor-notifications";
|
|
5766
5919
|
import { blockCommand as blockCommand4 } from "@elementor/editor-v1-adapters";
|
|
5767
|
-
import { __ as
|
|
5920
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
5768
5921
|
function initLinkInLinkPrevention() {
|
|
5769
5922
|
blockCommand4({
|
|
5770
5923
|
command: "document/elements/paste",
|
|
@@ -5798,7 +5951,7 @@ function blockLinkInLinkPaste(args) {
|
|
|
5798
5951
|
const sourceElements = data.clipboard.elements;
|
|
5799
5952
|
const notification = {
|
|
5800
5953
|
type: "default",
|
|
5801
|
-
message:
|
|
5954
|
+
message: __8(
|
|
5802
5955
|
"To paste a link to this element, first remove the link from it's parent container.",
|
|
5803
5956
|
"elementor"
|
|
5804
5957
|
),
|
|
@@ -5817,7 +5970,7 @@ function blockLinkInLinkMove(args) {
|
|
|
5817
5970
|
const targetElement = target;
|
|
5818
5971
|
const notification = {
|
|
5819
5972
|
type: "default",
|
|
5820
|
-
message:
|
|
5973
|
+
message: __8("To drag a link to this element, first remove the link from it's parent container.", "elementor"),
|
|
5821
5974
|
id: "move-in-link-blocked",
|
|
5822
5975
|
additionalActionProps: [learnMoreActionProps]
|
|
5823
5976
|
};
|
|
@@ -5844,7 +5997,7 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
5844
5997
|
}
|
|
5845
5998
|
|
|
5846
5999
|
// src/style-commands/paste-style.ts
|
|
5847
|
-
import { getContainer as
|
|
6000
|
+
import { getContainer as getContainer6, getElementSetting, updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
|
|
5848
6001
|
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
5849
6002
|
import {
|
|
5850
6003
|
__privateListenTo as listenTo5,
|
|
@@ -5855,7 +6008,7 @@ import {
|
|
|
5855
6008
|
// src/utils/command-utils.ts
|
|
5856
6009
|
import { getElementLabel as getElementLabel2, getWidgetsCache as getWidgetsCache7 } from "@elementor/editor-elements";
|
|
5857
6010
|
import { CLASSES_PROP_KEY } from "@elementor/editor-props";
|
|
5858
|
-
import { __ as
|
|
6011
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
5859
6012
|
function hasAtomicWidgets(args) {
|
|
5860
6013
|
const { containers = [args.container] } = args;
|
|
5861
6014
|
return containers.some(isAtomicWidget);
|
|
@@ -5891,7 +6044,7 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
5891
6044
|
}
|
|
5892
6045
|
}
|
|
5893
6046
|
function getTitleForContainers(containers) {
|
|
5894
|
-
return containers.length > 1 ?
|
|
6047
|
+
return containers.length > 1 ? __9("Elements", "elementor") : getElementLabel2(containers[0].id);
|
|
5895
6048
|
}
|
|
5896
6049
|
|
|
5897
6050
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
@@ -5902,9 +6055,9 @@ import {
|
|
|
5902
6055
|
updateElementStyle as updateElementStyle2
|
|
5903
6056
|
} from "@elementor/editor-elements";
|
|
5904
6057
|
import { ELEMENTS_STYLES_RESERVED_LABEL } from "@elementor/editor-styles-repository";
|
|
5905
|
-
import { undoable as
|
|
5906
|
-
import { __ as
|
|
5907
|
-
var undoablePasteElementStyle = () =>
|
|
6058
|
+
import { undoable as undoable3 } from "@elementor/editor-v1-adapters";
|
|
6059
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
6060
|
+
var undoablePasteElementStyle = () => undoable3(
|
|
5908
6061
|
{
|
|
5909
6062
|
do: ({ containers, newStyle }) => {
|
|
5910
6063
|
return containers.map((container) => {
|
|
@@ -5973,7 +6126,7 @@ var undoablePasteElementStyle = () => undoable2(
|
|
|
5973
6126
|
},
|
|
5974
6127
|
{
|
|
5975
6128
|
title: ({ containers }) => getTitleForContainers(containers),
|
|
5976
|
-
subtitle:
|
|
6129
|
+
subtitle: __10("Style Pasted", "elementor")
|
|
5977
6130
|
}
|
|
5978
6131
|
);
|
|
5979
6132
|
|
|
@@ -5997,7 +6150,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
5997
6150
|
}
|
|
5998
6151
|
const clipboardElements = getClipboardElements(storageKey);
|
|
5999
6152
|
const [clipboardElement] = clipboardElements ?? [];
|
|
6000
|
-
const clipboardContainer =
|
|
6153
|
+
const clipboardContainer = getContainer6(clipboardElement.id);
|
|
6001
6154
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
6002
6155
|
return;
|
|
6003
6156
|
}
|
|
@@ -6045,9 +6198,9 @@ import {
|
|
|
6045
6198
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
6046
6199
|
import { createElementStyle as createElementStyle3, deleteElementStyle as deleteElementStyle2, getElementStyles as getElementStyles3 } from "@elementor/editor-elements";
|
|
6047
6200
|
import { ELEMENTS_STYLES_RESERVED_LABEL as ELEMENTS_STYLES_RESERVED_LABEL2 } from "@elementor/editor-styles-repository";
|
|
6048
|
-
import { undoable as
|
|
6049
|
-
import { __ as
|
|
6050
|
-
var undoableResetElementStyle = () =>
|
|
6201
|
+
import { undoable as undoable4 } from "@elementor/editor-v1-adapters";
|
|
6202
|
+
import { __ as __11 } from "@wordpress/i18n";
|
|
6203
|
+
var undoableResetElementStyle = () => undoable4(
|
|
6051
6204
|
{
|
|
6052
6205
|
do: ({ containers }) => {
|
|
6053
6206
|
return containers.map((container) => {
|
|
@@ -6084,7 +6237,7 @@ var undoableResetElementStyle = () => undoable3(
|
|
|
6084
6237
|
},
|
|
6085
6238
|
{
|
|
6086
6239
|
title: ({ containers }) => getTitleForContainers(containers),
|
|
6087
|
-
subtitle:
|
|
6240
|
+
subtitle: __11("Style Reset", "elementor")
|
|
6088
6241
|
}
|
|
6089
6242
|
);
|
|
6090
6243
|
|
|
@@ -6277,10 +6430,10 @@ function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
|
6277
6430
|
}
|
|
6278
6431
|
|
|
6279
6432
|
// src/utils/after-render.ts
|
|
6280
|
-
import { getContainer as
|
|
6433
|
+
import { getContainer as getContainer7 } from "@elementor/editor-elements";
|
|
6281
6434
|
function doAfterRender(elementIds, callback) {
|
|
6282
6435
|
const pending = elementIds.map((elementId) => {
|
|
6283
|
-
const view =
|
|
6436
|
+
const view = getContainer7(elementId)?.view;
|
|
6284
6437
|
if (!view || !hasDoAfterRender(view)) {
|
|
6285
6438
|
return void 0;
|
|
6286
6439
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "4.5.0-
|
|
4
|
+
"version": "4.5.0-1181",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "4.5.0-
|
|
41
|
-
"@elementor/editor-controls": "4.5.0-
|
|
42
|
-
"@elementor/editor-documents": "4.5.0-
|
|
43
|
-
"@elementor/editor-elements": "4.5.0-
|
|
44
|
-
"@elementor/editor-interactions": "4.5.0-
|
|
45
|
-
"@elementor/editor-mcp": "4.5.0-
|
|
46
|
-
"@elementor/editor-notifications": "4.5.0-
|
|
47
|
-
"@elementor/editor-props": "4.5.0-
|
|
48
|
-
"@elementor/editor-responsive": "4.5.0-
|
|
49
|
-
"@elementor/editor-styles": "4.5.0-
|
|
50
|
-
"@elementor/editor-styles-repository": "4.5.0-
|
|
51
|
-
"@elementor/editor-ui": "4.5.0-
|
|
52
|
-
"@elementor/editor-v1-adapters": "4.5.0-
|
|
53
|
-
"@elementor/events": "4.5.0-
|
|
54
|
-
"@elementor/http-client": "4.5.0-
|
|
55
|
-
"@elementor/schema": "4.5.0-
|
|
56
|
-
"@elementor/twing": "4.5.0-
|
|
40
|
+
"@elementor/editor": "4.5.0-1181",
|
|
41
|
+
"@elementor/editor-controls": "4.5.0-1181",
|
|
42
|
+
"@elementor/editor-documents": "4.5.0-1181",
|
|
43
|
+
"@elementor/editor-elements": "4.5.0-1181",
|
|
44
|
+
"@elementor/editor-interactions": "4.5.0-1181",
|
|
45
|
+
"@elementor/editor-mcp": "4.5.0-1181",
|
|
46
|
+
"@elementor/editor-notifications": "4.5.0-1181",
|
|
47
|
+
"@elementor/editor-props": "4.5.0-1181",
|
|
48
|
+
"@elementor/editor-responsive": "4.5.0-1181",
|
|
49
|
+
"@elementor/editor-styles": "4.5.0-1181",
|
|
50
|
+
"@elementor/editor-styles-repository": "4.5.0-1181",
|
|
51
|
+
"@elementor/editor-ui": "4.5.0-1181",
|
|
52
|
+
"@elementor/editor-v1-adapters": "4.5.0-1181",
|
|
53
|
+
"@elementor/events": "4.5.0-1181",
|
|
54
|
+
"@elementor/http-client": "4.5.0-1181",
|
|
55
|
+
"@elementor/schema": "4.5.0-1181",
|
|
56
|
+
"@elementor/twing": "4.5.0-1181",
|
|
57
57
|
"@elementor/ui": "1.41.4",
|
|
58
|
-
"@elementor/utils": "4.5.0-
|
|
59
|
-
"@elementor/wp-media": "4.5.0-
|
|
58
|
+
"@elementor/utils": "4.5.0-1181",
|
|
59
|
+
"@elementor/wp-media": "4.5.0-1181",
|
|
60
60
|
"@floating-ui/react": "^0.27.5",
|
|
61
61
|
"@wordpress/i18n": "^5.13.0",
|
|
62
62
|
"dompurify": "^3.2.6"
|
|
@@ -14,6 +14,7 @@ jest.mock( '../resources/editor-state-resource', () => ( { initEditorStateResour
|
|
|
14
14
|
jest.mock( '../resources/general-context-resource', () => ( { initGeneralContextResource: jest.fn() } ) );
|
|
15
15
|
jest.mock( '../resources/selected-element-resource', () => ( { initSelectedElementResource: jest.fn() } ) );
|
|
16
16
|
jest.mock( '../resources/widgets-schema-resource', () => ( { initWidgetsSchemaResource: jest.fn() } ) );
|
|
17
|
+
jest.mock( '../tools/build-composition/tool', () => ( { initBuildCompositionTool: jest.fn() } ) );
|
|
17
18
|
jest.mock( '../tools/configure-element/tool', () => ( { initConfigureElementTool: jest.fn() } ) );
|
|
18
19
|
jest.mock( '../tools/find-icons/tool', () => ( { initFindIconsTool: jest.fn() } ) );
|
|
19
20
|
jest.mock( '../tools/get-page-structure/tool', () => ( { initGetPageStructureTool: jest.fn() } ) );
|
package/src/mcp/canvas-mcp.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { initEditorStateResource } from './resources/editor-state-resource';
|
|
|
10
10
|
import { initGeneralContextResource } from './resources/general-context-resource';
|
|
11
11
|
import { initSelectedElementResource } from './resources/selected-element-resource';
|
|
12
12
|
import { initWidgetsSchemaResource } from './resources/widgets-schema-resource';
|
|
13
|
+
import { initBuildCompositionTool } from './tools/build-composition/tool';
|
|
13
14
|
import { initConfigureElementTool } from './tools/configure-element/tool';
|
|
14
15
|
import { initFindIconsTool } from './tools/find-icons/tool';
|
|
15
16
|
import { initGetPageStructureTool } from './tools/get-page-structure/tool';
|
|
@@ -31,5 +32,6 @@ export const initCanvasMcp = ( reg: MCPRegistryEntry ) => {
|
|
|
31
32
|
initConfigureElementTool( reg );
|
|
32
33
|
initFindIconsTool( reg );
|
|
33
34
|
initGetPageStructureTool( reg );
|
|
35
|
+
initBuildCompositionTool( reg );
|
|
34
36
|
initBreakpointsResource( reg );
|
|
35
37
|
};
|