@elementor/editor-canvas 4.4.1 → 4.4.2
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 +134 -282
- package/dist/index.mjs +89 -242
- package/package.json +20 -20
- package/src/mcp/__tests__/canvas-mcp.test.ts +0 -1
- package/src/mcp/canvas-mcp.ts +0 -2
- package/src/mcp/tools/build-composition/__tests__/tool.test.ts +0 -240
- package/src/mcp/tools/build-composition/tool.ts +0 -236
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 z4 = getVal2(value.z);
|
|
2707
|
+
if (x === DEFAULT_XY && y === DEFAULT_XY && z4 === DEFAULT_Z) {
|
|
2708
2708
|
return null;
|
|
2709
2709
|
}
|
|
2710
|
-
return `${x} ${y} ${
|
|
2710
|
+
return `${x} ${y} ${z4}`;
|
|
2711
2711
|
});
|
|
2712
2712
|
|
|
2713
2713
|
// src/transformers/styles/transform-rotate-transformer.ts
|
|
@@ -4864,175 +4864,8 @@ 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
|
-
|
|
5034
4867
|
// src/mcp/tools/configure-element/tool.ts
|
|
5035
|
-
import { getContainer as
|
|
4868
|
+
import { getContainer as getContainer4, getWidgetsCache as getWidgetsCache6 } from "@elementor/editor-elements";
|
|
5036
4869
|
import { dispatchMcpStylesAppliedEvent } from "@elementor/editor-mcp";
|
|
5037
4870
|
import { Schema as Schema3 } from "@elementor/editor-props";
|
|
5038
4871
|
|
|
@@ -5475,29 +5308,29 @@ Note: \`link\` is valid only when the element's PropType schema (which you must
|
|
|
5475
5308
|
};
|
|
5476
5309
|
|
|
5477
5310
|
// src/mcp/tools/configure-element/schema.ts
|
|
5478
|
-
import { z
|
|
5311
|
+
import { z } from "@elementor/schema";
|
|
5479
5312
|
var inputSchema = {
|
|
5480
|
-
propertiesToChange:
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5313
|
+
propertiesToChange: z.record(
|
|
5314
|
+
z.string().describe("The property name."),
|
|
5315
|
+
z.any().describe(`PropValue, refer to [${WIDGET_SCHEMA_URI}] by correct type, as appears in elementType`),
|
|
5316
|
+
z.any()
|
|
5484
5317
|
).describe("An object record containing property names and their new values to be set on the element"),
|
|
5485
|
-
style:
|
|
5486
|
-
|
|
5487
|
-
|
|
5318
|
+
style: z.record(
|
|
5319
|
+
z.string().describe('A CSS property name, e.g. "color", "margin-top".'),
|
|
5320
|
+
z.string().nullable().describe(
|
|
5488
5321
|
'A CSS value, e.g. "red", "10px", "1px solid #000". Use null to reset the property to its default.'
|
|
5489
5322
|
)
|
|
5490
5323
|
).describe(
|
|
5491
5324
|
"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."
|
|
5492
5325
|
).default({}),
|
|
5493
|
-
elementType:
|
|
5494
|
-
elementId:
|
|
5326
|
+
elementType: z.string().describe("The type of the element to retrieve the schema"),
|
|
5327
|
+
elementId: z.string().describe("The unique id of the element to configure")
|
|
5495
5328
|
};
|
|
5496
5329
|
var outputSchema = {
|
|
5497
|
-
success:
|
|
5330
|
+
success: z.boolean().describe(
|
|
5498
5331
|
"Whether the configuration change was successful, only if propertyName and propertyValue are provided"
|
|
5499
5332
|
),
|
|
5500
|
-
warnings:
|
|
5333
|
+
warnings: z.string().describe(
|
|
5501
5334
|
'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.'
|
|
5502
5335
|
).optional()
|
|
5503
5336
|
};
|
|
@@ -5534,7 +5367,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
5534
5367
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
5535
5368
|
);
|
|
5536
5369
|
}
|
|
5537
|
-
const container =
|
|
5370
|
+
const container = getContainer4(elementId);
|
|
5538
5371
|
if (!container) {
|
|
5539
5372
|
throw new Error(`Element with id ${elementId} not found`);
|
|
5540
5373
|
}
|
|
@@ -5634,8 +5467,23 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5634
5467
|
}
|
|
5635
5468
|
|
|
5636
5469
|
// src/mcp/tools/find-icons/tool.ts
|
|
5637
|
-
import { httpService as
|
|
5638
|
-
import { z as
|
|
5470
|
+
import { httpService as httpService6 } from "@elementor/http-client";
|
|
5471
|
+
import { z as z2 } from "@elementor/schema";
|
|
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
|
+
}
|
|
5639
5487
|
|
|
5640
5488
|
// src/mcp/tools/find-icons/prompt.ts
|
|
5641
5489
|
import { toolPrompts as toolPrompts2 } from "@elementor/editor-mcp";
|
|
@@ -5663,7 +5511,7 @@ findIconsToolPrompt.example(`Browse a category, one style only:
|
|
|
5663
5511
|
{ "category": "shopping", "library": "fa-solid", "perPage": 25 }`);
|
|
5664
5512
|
|
|
5665
5513
|
// src/mcp/tools/find-icons/tool.ts
|
|
5666
|
-
var
|
|
5514
|
+
var MCP_PROXY_URL5 = "elementor/v1/mcp-proxy";
|
|
5667
5515
|
var MAX_QUERIES = 10;
|
|
5668
5516
|
var MAX_PER_PAGE = 25;
|
|
5669
5517
|
var initFindIconsTool = (reg) => {
|
|
@@ -5672,56 +5520,56 @@ var initFindIconsTool = (reg) => {
|
|
|
5672
5520
|
name: "find-icons",
|
|
5673
5521
|
description: findIconsToolPrompt.prompt(),
|
|
5674
5522
|
schema: {
|
|
5675
|
-
queries:
|
|
5523
|
+
queries: z2.array(z2.string()).max(MAX_QUERIES).optional().describe(
|
|
5676
5524
|
'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.'
|
|
5677
5525
|
),
|
|
5678
|
-
library:
|
|
5526
|
+
library: z2.string().optional().describe(
|
|
5679
5527
|
'Restrict results to one library key reported in "libraries", for example "fa-solid". Omit to search every library installed on the site.'
|
|
5680
5528
|
),
|
|
5681
|
-
category:
|
|
5529
|
+
category: z2.string().optional().describe(
|
|
5682
5530
|
'Restrict results to one Font Awesome category reported in "categories", for example "shopping". May be used without a query to browse that category.'
|
|
5683
5531
|
),
|
|
5684
|
-
page:
|
|
5685
|
-
perPage:
|
|
5532
|
+
page: z2.number().int().min(1).optional(),
|
|
5533
|
+
perPage: z2.number().int().min(1).max(MAX_PER_PAGE).optional()
|
|
5686
5534
|
},
|
|
5687
5535
|
outputSchema: {
|
|
5688
|
-
results:
|
|
5689
|
-
|
|
5690
|
-
query:
|
|
5691
|
-
matches:
|
|
5692
|
-
|
|
5693
|
-
value:
|
|
5694
|
-
library:
|
|
5695
|
-
name:
|
|
5696
|
-
label:
|
|
5697
|
-
matched_on:
|
|
5698
|
-
license:
|
|
5536
|
+
results: z2.array(
|
|
5537
|
+
z2.object({
|
|
5538
|
+
query: z2.string(),
|
|
5539
|
+
matches: z2.array(
|
|
5540
|
+
z2.object({
|
|
5541
|
+
value: z2.string(),
|
|
5542
|
+
library: z2.string(),
|
|
5543
|
+
name: z2.string(),
|
|
5544
|
+
label: z2.string(),
|
|
5545
|
+
matched_on: z2.enum(["name", "alias", "term", "category", "library"]),
|
|
5546
|
+
license: z2.enum(["free", "pro"])
|
|
5699
5547
|
})
|
|
5700
5548
|
),
|
|
5701
|
-
total:
|
|
5702
|
-
page:
|
|
5703
|
-
per_page:
|
|
5704
|
-
truncated:
|
|
5549
|
+
total: z2.number(),
|
|
5550
|
+
page: z2.number(),
|
|
5551
|
+
per_page: z2.number(),
|
|
5552
|
+
truncated: z2.boolean()
|
|
5705
5553
|
})
|
|
5706
5554
|
).describe(
|
|
5707
5555
|
'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".'
|
|
5708
5556
|
),
|
|
5709
|
-
libraries:
|
|
5557
|
+
libraries: z2.array(z2.string()).optional().describe(
|
|
5710
5558
|
"Icon library keys installed on this site. Only sent when nothing matched or when browsing."
|
|
5711
5559
|
),
|
|
5712
|
-
customLibraries:
|
|
5560
|
+
customLibraries: z2.record(z2.string(), z2.string()).optional().describe(
|
|
5713
5561
|
"Custom (uploaded) icon libraries keyed by library. Only sent when nothing matched or when browsing."
|
|
5714
5562
|
),
|
|
5715
|
-
categories:
|
|
5563
|
+
categories: z2.array(z2.string()).optional().describe(
|
|
5716
5564
|
'Icon categories for the "category" filter. Only sent when nothing matched or when browsing.'
|
|
5717
5565
|
),
|
|
5718
|
-
truncatedCustomLibraries:
|
|
5719
|
-
fontAwesomeVersion:
|
|
5720
|
-
llmInstructions:
|
|
5566
|
+
truncatedCustomLibraries: z2.array(z2.string()).optional().describe("Custom libraries with more than 250 icons; only their first 250 icons are searchable."),
|
|
5567
|
+
fontAwesomeVersion: z2.string().nullable().describe("Font Awesome version the site renders icons from."),
|
|
5568
|
+
llmInstructions: z2.string().optional().describe("Present only when nothing matched, explaining what to do next.")
|
|
5721
5569
|
},
|
|
5722
5570
|
handler: async ({ queries, library, category, page, perPage }) => {
|
|
5723
5571
|
try {
|
|
5724
|
-
const { data } = await
|
|
5572
|
+
const { data } = await httpService6().post(MCP_PROXY_URL5, {
|
|
5725
5573
|
tool: "find-icons",
|
|
5726
5574
|
input: {
|
|
5727
5575
|
...queries ? { queries } : {},
|
|
@@ -5748,36 +5596,36 @@ var initFindIconsTool = (reg) => {
|
|
|
5748
5596
|
};
|
|
5749
5597
|
|
|
5750
5598
|
// src/mcp/tools/get-page-structure/tool.ts
|
|
5751
|
-
import { getCurrentDocument
|
|
5752
|
-
import { httpService as
|
|
5753
|
-
import { z as
|
|
5754
|
-
var
|
|
5599
|
+
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
5600
|
+
import { httpService as httpService7 } from "@elementor/http-client";
|
|
5601
|
+
import { z as z3 } from "@elementor/schema";
|
|
5602
|
+
var MCP_PROXY_URL6 = "elementor/v1/mcp-proxy";
|
|
5755
5603
|
var initGetPageStructureTool = (reg) => {
|
|
5756
5604
|
const { addTool } = reg;
|
|
5757
5605
|
addTool({
|
|
5758
5606
|
name: "get-page-structure",
|
|
5759
5607
|
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.",
|
|
5760
5608
|
schema: {
|
|
5761
|
-
postId:
|
|
5609
|
+
postId: z3.number().optional().describe(
|
|
5762
5610
|
"WordPress post ID of the Elementor document. If omitted, uses the currently open document."
|
|
5763
5611
|
),
|
|
5764
|
-
elementId:
|
|
5765
|
-
includeContent:
|
|
5612
|
+
elementId: z3.string().optional().describe("If provided, returns only the subtree rooted at that element id."),
|
|
5613
|
+
includeContent: z3.boolean().optional().describe(
|
|
5766
5614
|
"If true, includes each node's settings and styles (same shape build-composition accepts as input). Requires elementId."
|
|
5767
5615
|
)
|
|
5768
5616
|
},
|
|
5769
5617
|
outputSchema: {
|
|
5770
|
-
elements:
|
|
5618
|
+
elements: z3.array(z3.any()).describe(
|
|
5771
5619
|
"Skeleton of Elementor elements (id, elType, widgetType, title, nested elements). When includeContent is true, each node also includes settings and styles."
|
|
5772
5620
|
)
|
|
5773
5621
|
},
|
|
5774
5622
|
handler: async ({ postId, elementId, includeContent }) => {
|
|
5775
|
-
const resolvedPostId = postId ??
|
|
5623
|
+
const resolvedPostId = postId ?? getCurrentDocument()?.id;
|
|
5776
5624
|
if (!resolvedPostId) {
|
|
5777
5625
|
throw new Error("No post ID provided and no active document found.");
|
|
5778
5626
|
}
|
|
5779
5627
|
try {
|
|
5780
|
-
const { data } = await
|
|
5628
|
+
const { data } = await httpService7().post(MCP_PROXY_URL6, {
|
|
5781
5629
|
tool: "get-page-structure",
|
|
5782
5630
|
input: {
|
|
5783
5631
|
post_id: resolvedPostId,
|
|
@@ -5809,7 +5657,6 @@ var initCanvasMcp = (reg) => {
|
|
|
5809
5657
|
initConfigureElementTool(reg);
|
|
5810
5658
|
initFindIconsTool(reg);
|
|
5811
5659
|
initGetPageStructureTool(reg);
|
|
5812
|
-
initBuildCompositionTool(reg);
|
|
5813
5660
|
initBreakpointsResource(reg);
|
|
5814
5661
|
};
|
|
5815
5662
|
|
|
@@ -5917,7 +5764,7 @@ import {
|
|
|
5917
5764
|
} from "@elementor/editor-elements";
|
|
5918
5765
|
import { notify as notify6 } from "@elementor/editor-notifications";
|
|
5919
5766
|
import { blockCommand as blockCommand4 } from "@elementor/editor-v1-adapters";
|
|
5920
|
-
import { __ as
|
|
5767
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
5921
5768
|
function initLinkInLinkPrevention() {
|
|
5922
5769
|
blockCommand4({
|
|
5923
5770
|
command: "document/elements/paste",
|
|
@@ -5951,7 +5798,7 @@ function blockLinkInLinkPaste(args) {
|
|
|
5951
5798
|
const sourceElements = data.clipboard.elements;
|
|
5952
5799
|
const notification = {
|
|
5953
5800
|
type: "default",
|
|
5954
|
-
message:
|
|
5801
|
+
message: __7(
|
|
5955
5802
|
"To paste a link to this element, first remove the link from it's parent container.",
|
|
5956
5803
|
"elementor"
|
|
5957
5804
|
),
|
|
@@ -5970,7 +5817,7 @@ function blockLinkInLinkMove(args) {
|
|
|
5970
5817
|
const targetElement = target;
|
|
5971
5818
|
const notification = {
|
|
5972
5819
|
type: "default",
|
|
5973
|
-
message:
|
|
5820
|
+
message: __7("To drag a link to this element, first remove the link from it's parent container.", "elementor"),
|
|
5974
5821
|
id: "move-in-link-blocked",
|
|
5975
5822
|
additionalActionProps: [learnMoreActionProps]
|
|
5976
5823
|
};
|
|
@@ -5997,7 +5844,7 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
5997
5844
|
}
|
|
5998
5845
|
|
|
5999
5846
|
// src/style-commands/paste-style.ts
|
|
6000
|
-
import { getContainer as
|
|
5847
|
+
import { getContainer as getContainer5, getElementSetting, updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
|
|
6001
5848
|
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
6002
5849
|
import {
|
|
6003
5850
|
__privateListenTo as listenTo5,
|
|
@@ -6008,7 +5855,7 @@ import {
|
|
|
6008
5855
|
// src/utils/command-utils.ts
|
|
6009
5856
|
import { getElementLabel as getElementLabel2, getWidgetsCache as getWidgetsCache7 } from "@elementor/editor-elements";
|
|
6010
5857
|
import { CLASSES_PROP_KEY } from "@elementor/editor-props";
|
|
6011
|
-
import { __ as
|
|
5858
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
6012
5859
|
function hasAtomicWidgets(args) {
|
|
6013
5860
|
const { containers = [args.container] } = args;
|
|
6014
5861
|
return containers.some(isAtomicWidget);
|
|
@@ -6044,7 +5891,7 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
6044
5891
|
}
|
|
6045
5892
|
}
|
|
6046
5893
|
function getTitleForContainers(containers) {
|
|
6047
|
-
return containers.length > 1 ?
|
|
5894
|
+
return containers.length > 1 ? __8("Elements", "elementor") : getElementLabel2(containers[0].id);
|
|
6048
5895
|
}
|
|
6049
5896
|
|
|
6050
5897
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
@@ -6055,9 +5902,9 @@ import {
|
|
|
6055
5902
|
updateElementStyle as updateElementStyle2
|
|
6056
5903
|
} from "@elementor/editor-elements";
|
|
6057
5904
|
import { ELEMENTS_STYLES_RESERVED_LABEL } from "@elementor/editor-styles-repository";
|
|
6058
|
-
import { undoable as
|
|
6059
|
-
import { __ as
|
|
6060
|
-
var undoablePasteElementStyle = () =>
|
|
5905
|
+
import { undoable as undoable2 } from "@elementor/editor-v1-adapters";
|
|
5906
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
5907
|
+
var undoablePasteElementStyle = () => undoable2(
|
|
6061
5908
|
{
|
|
6062
5909
|
do: ({ containers, newStyle }) => {
|
|
6063
5910
|
return containers.map((container) => {
|
|
@@ -6126,7 +5973,7 @@ var undoablePasteElementStyle = () => undoable3(
|
|
|
6126
5973
|
},
|
|
6127
5974
|
{
|
|
6128
5975
|
title: ({ containers }) => getTitleForContainers(containers),
|
|
6129
|
-
subtitle:
|
|
5976
|
+
subtitle: __9("Style Pasted", "elementor")
|
|
6130
5977
|
}
|
|
6131
5978
|
);
|
|
6132
5979
|
|
|
@@ -6150,7 +5997,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
6150
5997
|
}
|
|
6151
5998
|
const clipboardElements = getClipboardElements(storageKey);
|
|
6152
5999
|
const [clipboardElement] = clipboardElements ?? [];
|
|
6153
|
-
const clipboardContainer =
|
|
6000
|
+
const clipboardContainer = getContainer5(clipboardElement.id);
|
|
6154
6001
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
6155
6002
|
return;
|
|
6156
6003
|
}
|
|
@@ -6198,9 +6045,9 @@ import {
|
|
|
6198
6045
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
6199
6046
|
import { createElementStyle as createElementStyle3, deleteElementStyle as deleteElementStyle2, getElementStyles as getElementStyles3 } from "@elementor/editor-elements";
|
|
6200
6047
|
import { ELEMENTS_STYLES_RESERVED_LABEL as ELEMENTS_STYLES_RESERVED_LABEL2 } from "@elementor/editor-styles-repository";
|
|
6201
|
-
import { undoable as
|
|
6202
|
-
import { __ as
|
|
6203
|
-
var undoableResetElementStyle = () =>
|
|
6048
|
+
import { undoable as undoable3 } from "@elementor/editor-v1-adapters";
|
|
6049
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
6050
|
+
var undoableResetElementStyle = () => undoable3(
|
|
6204
6051
|
{
|
|
6205
6052
|
do: ({ containers }) => {
|
|
6206
6053
|
return containers.map((container) => {
|
|
@@ -6237,7 +6084,7 @@ var undoableResetElementStyle = () => undoable4(
|
|
|
6237
6084
|
},
|
|
6238
6085
|
{
|
|
6239
6086
|
title: ({ containers }) => getTitleForContainers(containers),
|
|
6240
|
-
subtitle:
|
|
6087
|
+
subtitle: __10("Style Reset", "elementor")
|
|
6241
6088
|
}
|
|
6242
6089
|
);
|
|
6243
6090
|
|
|
@@ -6430,10 +6277,10 @@ function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
|
6430
6277
|
}
|
|
6431
6278
|
|
|
6432
6279
|
// src/utils/after-render.ts
|
|
6433
|
-
import { getContainer as
|
|
6280
|
+
import { getContainer as getContainer6 } from "@elementor/editor-elements";
|
|
6434
6281
|
function doAfterRender(elementIds, callback) {
|
|
6435
6282
|
const pending = elementIds.map((elementId) => {
|
|
6436
|
-
const view =
|
|
6283
|
+
const view = getContainer6(elementId)?.view;
|
|
6437
6284
|
if (!view || !hasDoAfterRender(view)) {
|
|
6438
6285
|
return void 0;
|
|
6439
6286
|
}
|
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.4.
|
|
4
|
+
"version": "4.4.2",
|
|
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.4.
|
|
41
|
-
"@elementor/editor-controls": "4.4.
|
|
42
|
-
"@elementor/editor-documents": "4.4.
|
|
43
|
-
"@elementor/editor-elements": "4.4.
|
|
44
|
-
"@elementor/editor-interactions": "4.4.
|
|
45
|
-
"@elementor/editor-mcp": "4.4.
|
|
46
|
-
"@elementor/editor-notifications": "4.4.
|
|
47
|
-
"@elementor/editor-props": "4.4.
|
|
48
|
-
"@elementor/editor-responsive": "4.4.
|
|
49
|
-
"@elementor/editor-styles": "4.4.
|
|
50
|
-
"@elementor/editor-styles-repository": "4.4.
|
|
51
|
-
"@elementor/editor-ui": "4.4.
|
|
52
|
-
"@elementor/editor-v1-adapters": "4.4.
|
|
53
|
-
"@elementor/events": "4.4.
|
|
54
|
-
"@elementor/http-client": "4.4.
|
|
55
|
-
"@elementor/schema": "4.4.
|
|
56
|
-
"@elementor/twing": "4.4.
|
|
40
|
+
"@elementor/editor": "4.4.2",
|
|
41
|
+
"@elementor/editor-controls": "4.4.2",
|
|
42
|
+
"@elementor/editor-documents": "4.4.2",
|
|
43
|
+
"@elementor/editor-elements": "4.4.2",
|
|
44
|
+
"@elementor/editor-interactions": "4.4.2",
|
|
45
|
+
"@elementor/editor-mcp": "4.4.2",
|
|
46
|
+
"@elementor/editor-notifications": "4.4.2",
|
|
47
|
+
"@elementor/editor-props": "4.4.2",
|
|
48
|
+
"@elementor/editor-responsive": "4.4.2",
|
|
49
|
+
"@elementor/editor-styles": "4.4.2",
|
|
50
|
+
"@elementor/editor-styles-repository": "4.4.2",
|
|
51
|
+
"@elementor/editor-ui": "4.4.2",
|
|
52
|
+
"@elementor/editor-v1-adapters": "4.4.2",
|
|
53
|
+
"@elementor/events": "4.4.2",
|
|
54
|
+
"@elementor/http-client": "4.4.2",
|
|
55
|
+
"@elementor/schema": "4.4.2",
|
|
56
|
+
"@elementor/twing": "4.4.2",
|
|
57
57
|
"@elementor/ui": "1.41.4",
|
|
58
|
-
"@elementor/utils": "4.4.
|
|
59
|
-
"@elementor/wp-media": "4.4.
|
|
58
|
+
"@elementor/utils": "4.4.2",
|
|
59
|
+
"@elementor/wp-media": "4.4.2",
|
|
60
60
|
"@floating-ui/react": "^0.27.5",
|
|
61
61
|
"@wordpress/i18n": "^5.13.0",
|
|
62
62
|
"dompurify": "^3.2.6"
|
|
@@ -14,7 +14,6 @@ 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() } ) );
|
|
18
17
|
jest.mock( '../tools/configure-element/tool', () => ( { initConfigureElementTool: jest.fn() } ) );
|
|
19
18
|
jest.mock( '../tools/find-icons/tool', () => ( { initFindIconsTool: jest.fn() } ) );
|
|
20
19
|
jest.mock( '../tools/get-page-structure/tool', () => ( { initGetPageStructureTool: jest.fn() } ) );
|
package/src/mcp/canvas-mcp.ts
CHANGED
|
@@ -10,7 +10,6 @@ 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';
|
|
14
13
|
import { initConfigureElementTool } from './tools/configure-element/tool';
|
|
15
14
|
import { initFindIconsTool } from './tools/find-icons/tool';
|
|
16
15
|
import { initGetPageStructureTool } from './tools/get-page-structure/tool';
|
|
@@ -32,6 +31,5 @@ export const initCanvasMcp = ( reg: MCPRegistryEntry ) => {
|
|
|
32
31
|
initConfigureElementTool( reg );
|
|
33
32
|
initFindIconsTool( reg );
|
|
34
33
|
initGetPageStructureTool( reg );
|
|
35
|
-
initBuildCompositionTool( reg );
|
|
36
34
|
initBreakpointsResource( reg );
|
|
37
35
|
};
|