@elementor/editor-canvas 4.5.0-1179 → 4.5.0-1180
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.js
CHANGED
|
@@ -2747,11 +2747,11 @@ function getVal2(val) {
|
|
|
2747
2747
|
var transformOriginTransformer = createTransformer((value) => {
|
|
2748
2748
|
const x = getVal2(value.x);
|
|
2749
2749
|
const y = getVal2(value.y);
|
|
2750
|
-
const
|
|
2751
|
-
if (x === DEFAULT_XY && y === DEFAULT_XY &&
|
|
2750
|
+
const z5 = getVal2(value.z);
|
|
2751
|
+
if (x === DEFAULT_XY && y === DEFAULT_XY && z5 === DEFAULT_Z) {
|
|
2752
2752
|
return null;
|
|
2753
2753
|
}
|
|
2754
|
-
return `${x} ${y} ${
|
|
2754
|
+
return `${x} ${y} ${z5}`;
|
|
2755
2755
|
});
|
|
2756
2756
|
|
|
2757
2757
|
// src/transformers/styles/transform-rotate-transformer.ts
|
|
@@ -4889,16 +4889,178 @@ function getElementDisplayName(container) {
|
|
|
4889
4889
|
}
|
|
4890
4890
|
}
|
|
4891
4891
|
|
|
4892
|
+
// src/mcp/tools/build-composition/tool.ts
|
|
4893
|
+
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
4894
|
+
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
4895
|
+
var import_editor_v1_adapters23 = require("@elementor/editor-v1-adapters");
|
|
4896
|
+
var import_http_client7 = require("@elementor/http-client");
|
|
4897
|
+
var import_schema = require("@elementor/schema");
|
|
4898
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
4899
|
+
|
|
4900
|
+
// src/mcp/utils/get-mcp-error-message.ts
|
|
4901
|
+
var import_http_client6 = require("@elementor/http-client");
|
|
4902
|
+
function getMcpErrorMessage(error, toolName) {
|
|
4903
|
+
if (error instanceof import_http_client6.AxiosError) {
|
|
4904
|
+
const data = error.response?.data;
|
|
4905
|
+
if (data?.message) {
|
|
4906
|
+
return data.code ? `${data.code}: ${data.message}` : data.message;
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4909
|
+
if (error instanceof Error) {
|
|
4910
|
+
return error.message;
|
|
4911
|
+
}
|
|
4912
|
+
return `${toolName} failed with an unknown error.`;
|
|
4913
|
+
}
|
|
4914
|
+
|
|
4915
|
+
// src/mcp/tools/build-composition/tool.ts
|
|
4916
|
+
var MCP_PROXY_URL5 = "elementor/v1/mcp-proxy";
|
|
4917
|
+
var TOOL_NAME = "build-composition";
|
|
4918
|
+
var DOCUMENT_ROOT = "document";
|
|
4919
|
+
var ELEMENTS_TO_JSON_OPTIONS = { remove: ["default", "editSettings", "defaultEditSettings"] };
|
|
4920
|
+
var BUILD_COMPOSITION_GUIDE_URI = "elementor://tools/build-composition-guide";
|
|
4921
|
+
var initBuildCompositionTool = (reg) => {
|
|
4922
|
+
const { addTool, resource } = reg;
|
|
4923
|
+
resource(
|
|
4924
|
+
"build-composition-guide",
|
|
4925
|
+
BUILD_COMPOSITION_GUIDE_URI,
|
|
4926
|
+
{
|
|
4927
|
+
title: "Build Composition Guide",
|
|
4928
|
+
description: "Full guide for the build-composition tool",
|
|
4929
|
+
mimeType: "text/markdown"
|
|
4930
|
+
},
|
|
4931
|
+
async (uri) => {
|
|
4932
|
+
const { data } = await (0, import_http_client7.httpService)().get(MCP_PROXY_URL5, {
|
|
4933
|
+
params: { uri: uri.href }
|
|
4934
|
+
});
|
|
4935
|
+
return {
|
|
4936
|
+
contents: [{ uri: uri.href, mimeType: "text/markdown", text: data.data }]
|
|
4937
|
+
};
|
|
4938
|
+
}
|
|
4939
|
+
);
|
|
4940
|
+
addTool({
|
|
4941
|
+
name: TOOL_NAME,
|
|
4942
|
+
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.",
|
|
4943
|
+
schema: {
|
|
4944
|
+
xml_structure: import_schema.z.string().describe(
|
|
4945
|
+
'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.'
|
|
4946
|
+
),
|
|
4947
|
+
element_config: import_schema.z.record(import_schema.z.string(), import_schema.z.any()).optional().describe("configuration-id \u2192 plain widget settings matching elementor://widgets/schema/{type}."),
|
|
4948
|
+
editor_settings: import_schema.z.record(import_schema.z.string(), import_schema.z.any()).optional().describe("configuration-id \u2192 editor-only fields."),
|
|
4949
|
+
style: import_schema.z.record(import_schema.z.string(), import_schema.z.string()).optional().describe(
|
|
4950
|
+
"configuration-id \u2192 plain CSS string. Supports &:hover/&:focus/&:active nesting and @media(--breakpoint) blocks."
|
|
4951
|
+
),
|
|
4952
|
+
classes: import_schema.z.record(import_schema.z.string(), import_schema.z.array(import_schema.z.string())).optional().describe("configuration-id \u2192 existing global class labels to attach."),
|
|
4953
|
+
interactions: import_schema.z.record(import_schema.z.string(), import_schema.z.array(import_schema.z.record(import_schema.z.string(), import_schema.z.any()))).optional().describe("configuration-id \u2192 interaction items. See elementor://interactions/schema."),
|
|
4954
|
+
parent_id: import_schema.z.string().optional().describe("Element id of the parent container. Omit to insert at the document root."),
|
|
4955
|
+
mode: import_schema.z.enum(["append", "replace_children"]).optional().describe(
|
|
4956
|
+
"append (default) or replace_children, which removes the existing children of parent_id first."
|
|
4957
|
+
)
|
|
4958
|
+
},
|
|
4959
|
+
outputSchema: {
|
|
4960
|
+
root_element_ids: import_schema.z.array(import_schema.z.string()).describe("Ids of the created root-level elements."),
|
|
4961
|
+
resolved_xml: import_schema.z.string().optional().describe("The XML with the new element ids embedded."),
|
|
4962
|
+
removed_element_ids: import_schema.z.array(import_schema.z.string()).optional(),
|
|
4963
|
+
warnings: import_schema.z.array(import_schema.z.string()).optional(),
|
|
4964
|
+
warning_details: import_schema.z.array(import_schema.z.any()).optional(),
|
|
4965
|
+
pro_features_discovery: import_schema.z.array(import_schema.z.object({ message: import_schema.z.string(), upgrade_url: import_schema.z.string() })).optional()
|
|
4966
|
+
},
|
|
4967
|
+
requiredResources: [
|
|
4968
|
+
{ uri: BUILD_COMPOSITION_GUIDE_URI, description: "Full guide for XML structure, ids, layouts and styles" }
|
|
4969
|
+
],
|
|
4970
|
+
handler: async ({ parent_id: parentId = DOCUMENT_ROOT, mode = "append", ...input }) => {
|
|
4971
|
+
const postId = (0, import_editor_documents2.getCurrentDocument)()?.id;
|
|
4972
|
+
const documentContainer = (0, import_editor_elements12.getCurrentDocumentContainer)();
|
|
4973
|
+
if (!postId || !documentContainer) {
|
|
4974
|
+
throw new Error("No active document found.");
|
|
4975
|
+
}
|
|
4976
|
+
const parentContainer = parentId === DOCUMENT_ROOT ? documentContainer : (0, import_editor_elements12.getContainer)(parentId);
|
|
4977
|
+
if (!parentContainer) {
|
|
4978
|
+
throw new Error(`Parent element not found: ${parentId}`);
|
|
4979
|
+
}
|
|
4980
|
+
let plan;
|
|
4981
|
+
try {
|
|
4982
|
+
const { data } = await (0, import_http_client7.httpService)().post(MCP_PROXY_URL5, {
|
|
4983
|
+
tool: TOOL_NAME,
|
|
4984
|
+
input: {
|
|
4985
|
+
...input,
|
|
4986
|
+
post_id: postId,
|
|
4987
|
+
parent_id: parentId,
|
|
4988
|
+
mode,
|
|
4989
|
+
dry_run: true,
|
|
4990
|
+
document_elements: serializeElements(documentContainer)
|
|
4991
|
+
}
|
|
4992
|
+
});
|
|
4993
|
+
plan = data.data;
|
|
4994
|
+
} catch (error) {
|
|
4995
|
+
throw new Error(getMcpErrorMessage(error, TOOL_NAME));
|
|
4996
|
+
}
|
|
4997
|
+
applyPlan(parentContainer, plan);
|
|
4998
|
+
const { elements, ...result } = plan;
|
|
4999
|
+
return result;
|
|
5000
|
+
}
|
|
5001
|
+
});
|
|
5002
|
+
};
|
|
5003
|
+
function serializeElements(container) {
|
|
5004
|
+
const elements = container.model.get("elements");
|
|
5005
|
+
return elements?.toJSON(ELEMENTS_TO_JSON_OPTIONS) ?? [];
|
|
5006
|
+
}
|
|
5007
|
+
function applyPlan(parentContainer, { elements, removed_element_ids: removedIds = [] }) {
|
|
5008
|
+
if (!Array.isArray(elements) || !elements.length) {
|
|
5009
|
+
throw new Error("The planned composition has no elements to build");
|
|
5010
|
+
}
|
|
5011
|
+
const apply = () => {
|
|
5012
|
+
const removed = [];
|
|
5013
|
+
removedIds.forEach((id) => {
|
|
5014
|
+
const container = (0, import_editor_elements12.getContainer)(id);
|
|
5015
|
+
if (!container?.parent) {
|
|
5016
|
+
return;
|
|
5017
|
+
}
|
|
5018
|
+
removed.push({
|
|
5019
|
+
model: container.model.toJSON(),
|
|
5020
|
+
parentId: container.parent.id,
|
|
5021
|
+
at: container.view?._index ?? 0
|
|
5022
|
+
});
|
|
5023
|
+
(0, import_editor_elements12.deleteElement)({ container, options: { useHistory: false } });
|
|
5024
|
+
});
|
|
5025
|
+
const target = parentContainer.lookup?.() ?? parentContainer;
|
|
5026
|
+
const createdIds = elements.map(
|
|
5027
|
+
(model) => (0, import_editor_elements12.createElement)({ container: target, model, options: { useHistory: false } }).id
|
|
5028
|
+
);
|
|
5029
|
+
return { removed, createdIds };
|
|
5030
|
+
};
|
|
5031
|
+
(0, import_editor_v1_adapters23.undoable)(
|
|
5032
|
+
{
|
|
5033
|
+
do: apply,
|
|
5034
|
+
undo: (_, { removed, createdIds }) => {
|
|
5035
|
+
[...createdIds].reverse().forEach((id) => {
|
|
5036
|
+
const container = (0, import_editor_elements12.getContainer)(id);
|
|
5037
|
+
if (container) {
|
|
5038
|
+
(0, import_editor_elements12.deleteElement)({ container, options: { useHistory: false } });
|
|
5039
|
+
}
|
|
5040
|
+
});
|
|
5041
|
+
[...removed].reverse().forEach(({ model, parentId, at }) => {
|
|
5042
|
+
const parent = (0, import_editor_elements12.getContainer)(parentId);
|
|
5043
|
+
if (parent) {
|
|
5044
|
+
(0, import_editor_elements12.createElement)({ container: parent, model, options: { useHistory: false, at } });
|
|
5045
|
+
}
|
|
5046
|
+
});
|
|
5047
|
+
},
|
|
5048
|
+
redo: apply
|
|
5049
|
+
},
|
|
5050
|
+
{ title: (0, import_i18n7.__)("Build composition", "elementor") }
|
|
5051
|
+
)();
|
|
5052
|
+
}
|
|
5053
|
+
|
|
4892
5054
|
// src/mcp/tools/configure-element/tool.ts
|
|
4893
|
-
var
|
|
5055
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
4894
5056
|
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
4895
5057
|
var import_editor_props8 = require("@elementor/editor-props");
|
|
4896
5058
|
|
|
4897
5059
|
// src/mcp/utils/do-update-element-property.ts
|
|
4898
|
-
var
|
|
5060
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4899
5061
|
var import_editor_props7 = require("@elementor/editor-props");
|
|
4900
5062
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
4901
|
-
var
|
|
5063
|
+
var import_editor_v1_adapters25 = require("@elementor/editor-v1-adapters");
|
|
4902
5064
|
|
|
4903
5065
|
// src/mcp/utils/merge-custom-css.ts
|
|
4904
5066
|
var CUSTOM_CSS_SEPARATOR = "\n";
|
|
@@ -4915,7 +5077,7 @@ var readStoredCustomCssText = (raw) => {
|
|
|
4915
5077
|
};
|
|
4916
5078
|
|
|
4917
5079
|
// src/mcp/utils/resolve-canonical-prop-name.ts
|
|
4918
|
-
var
|
|
5080
|
+
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
4919
5081
|
function buildAliasToCanonicalMap(schema) {
|
|
4920
5082
|
const aliasToCanonical = {};
|
|
4921
5083
|
for (const [canonical, propType] of Object.entries(schema)) {
|
|
@@ -4932,14 +5094,14 @@ function buildAliasToCanonicalMap(schema) {
|
|
|
4932
5094
|
return aliasToCanonical;
|
|
4933
5095
|
}
|
|
4934
5096
|
function resolveCanonicalPropName(elementType, propertyName) {
|
|
4935
|
-
const schema = (0,
|
|
5097
|
+
const schema = (0, import_editor_elements13.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4936
5098
|
if (!schema || schema[propertyName]) {
|
|
4937
5099
|
return propertyName;
|
|
4938
5100
|
}
|
|
4939
5101
|
return buildAliasToCanonicalMap(schema)[propertyName] ?? propertyName;
|
|
4940
5102
|
}
|
|
4941
5103
|
function resolveCanonicalPropKeys(elementType, props) {
|
|
4942
|
-
const schema = (0,
|
|
5104
|
+
const schema = (0, import_editor_elements13.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
4943
5105
|
if (!schema) {
|
|
4944
5106
|
return { ...props };
|
|
4945
5107
|
}
|
|
@@ -4967,11 +5129,11 @@ function resolveCanonicalPropKeys(elementType, props) {
|
|
|
4967
5129
|
}
|
|
4968
5130
|
|
|
4969
5131
|
// src/mcp/utils/resolve-dynamic-tag.ts
|
|
4970
|
-
var
|
|
5132
|
+
var import_editor_v1_adapters24 = require("@elementor/editor-v1-adapters");
|
|
4971
5133
|
var DYNAMIC_PROP_TYPE_KEY = "dynamic";
|
|
4972
5134
|
var OMITTED_DYNAMIC_SETTING_KEYS = ["fallback"];
|
|
4973
5135
|
var getAtomicDynamicTags = () => {
|
|
4974
|
-
const config = (0,
|
|
5136
|
+
const config = (0, import_editor_v1_adapters24.getElementorConfig)();
|
|
4975
5137
|
return config.atomicDynamicTags?.tags ?? {};
|
|
4976
5138
|
};
|
|
4977
5139
|
var getDynamicTagNamesByCategories = (categories) => {
|
|
@@ -5061,7 +5223,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
5061
5223
|
const { elementId, propertyValue, elementType, customCssWriteMode = "replace" } = params;
|
|
5062
5224
|
const propertyName = params.propertyName === "_styles" ? params.propertyName : resolveCanonicalPropName(elementType, params.propertyName);
|
|
5063
5225
|
if (propertyName === "_styles") {
|
|
5064
|
-
const elementStyles = (0,
|
|
5226
|
+
const elementStyles = (0, import_editor_elements14.getElementStyles)(elementId) || {};
|
|
5065
5227
|
const propertyMapValue = propertyValue;
|
|
5066
5228
|
const styleSchema = (0, import_editor_styles4.getStylesSchema)();
|
|
5067
5229
|
const transformedStyleValues = Object.fromEntries(
|
|
@@ -5118,7 +5280,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
5118
5280
|
});
|
|
5119
5281
|
delete transformedStyleValues.custom_css;
|
|
5120
5282
|
if (!localStyle) {
|
|
5121
|
-
(0,
|
|
5283
|
+
(0, import_editor_elements14.createElementStyle)({
|
|
5122
5284
|
elementId,
|
|
5123
5285
|
...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
|
|
5124
5286
|
classesProp: "classes",
|
|
@@ -5132,7 +5294,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
5132
5294
|
}
|
|
5133
5295
|
});
|
|
5134
5296
|
} else {
|
|
5135
|
-
(0,
|
|
5297
|
+
(0, import_editor_elements14.updateElementStyle)({
|
|
5136
5298
|
elementId,
|
|
5137
5299
|
styleId: localStyle.id,
|
|
5138
5300
|
meta: {
|
|
@@ -5147,7 +5309,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
5147
5309
|
}
|
|
5148
5310
|
return;
|
|
5149
5311
|
}
|
|
5150
|
-
const elementPropSchema = (0,
|
|
5312
|
+
const elementPropSchema = (0, import_editor_elements14.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
5151
5313
|
if (!elementPropSchema) {
|
|
5152
5314
|
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
5153
5315
|
}
|
|
@@ -5165,14 +5327,14 @@ var doUpdateElementProperty = (params) => {
|
|
|
5165
5327
|
Expected Schema: ${jsonSchema}`
|
|
5166
5328
|
);
|
|
5167
5329
|
}
|
|
5168
|
-
(0,
|
|
5330
|
+
(0, import_editor_elements14.updateElementSettings)({
|
|
5169
5331
|
id: elementId,
|
|
5170
5332
|
props: {
|
|
5171
5333
|
[propertyName]: value
|
|
5172
5334
|
},
|
|
5173
5335
|
withHistory: false
|
|
5174
5336
|
});
|
|
5175
|
-
(0,
|
|
5337
|
+
(0, import_editor_v1_adapters25.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
|
|
5176
5338
|
};
|
|
5177
5339
|
|
|
5178
5340
|
// src/mcp/tools/configure-element/prompt.ts
|
|
@@ -5327,29 +5489,29 @@ Note: \`link\` is valid only when the element's PropType schema (which you must
|
|
|
5327
5489
|
};
|
|
5328
5490
|
|
|
5329
5491
|
// src/mcp/tools/configure-element/schema.ts
|
|
5330
|
-
var
|
|
5492
|
+
var import_schema2 = require("@elementor/schema");
|
|
5331
5493
|
var inputSchema = {
|
|
5332
|
-
propertiesToChange:
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5494
|
+
propertiesToChange: import_schema2.z.record(
|
|
5495
|
+
import_schema2.z.string().describe("The property name."),
|
|
5496
|
+
import_schema2.z.any().describe(`PropValue, refer to [${WIDGET_SCHEMA_URI}] by correct type, as appears in elementType`),
|
|
5497
|
+
import_schema2.z.any()
|
|
5336
5498
|
).describe("An object record containing property names and their new values to be set on the element"),
|
|
5337
|
-
style:
|
|
5338
|
-
|
|
5339
|
-
|
|
5499
|
+
style: import_schema2.z.record(
|
|
5500
|
+
import_schema2.z.string().describe('A CSS property name, e.g. "color", "margin-top".'),
|
|
5501
|
+
import_schema2.z.string().nullable().describe(
|
|
5340
5502
|
'A CSS value, e.g. "red", "10px", "1px solid #000". Use null to reset the property to its default.'
|
|
5341
5503
|
)
|
|
5342
5504
|
).describe(
|
|
5343
5505
|
"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."
|
|
5344
5506
|
).default({}),
|
|
5345
|
-
elementType:
|
|
5346
|
-
elementId:
|
|
5507
|
+
elementType: import_schema2.z.string().describe("The type of the element to retrieve the schema"),
|
|
5508
|
+
elementId: import_schema2.z.string().describe("The unique id of the element to configure")
|
|
5347
5509
|
};
|
|
5348
5510
|
var outputSchema = {
|
|
5349
|
-
success:
|
|
5511
|
+
success: import_schema2.z.boolean().describe(
|
|
5350
5512
|
"Whether the configuration change was successful, only if propertyName and propertyValue are provided"
|
|
5351
5513
|
),
|
|
5352
|
-
warnings:
|
|
5514
|
+
warnings: import_schema2.z.string().describe(
|
|
5353
5515
|
'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.'
|
|
5354
5516
|
).optional()
|
|
5355
5517
|
};
|
|
@@ -5380,13 +5542,13 @@ var initConfigureElementTool = (reg) => {
|
|
|
5380
5542
|
{ description: "Dynamic tags catalog", uri: DYNAMIC_TAGS_URI }
|
|
5381
5543
|
],
|
|
5382
5544
|
handler: async ({ elementId, propertiesToChange, elementType, style }) => {
|
|
5383
|
-
const widgetData = (0,
|
|
5545
|
+
const widgetData = (0, import_editor_elements15.getWidgetsCache)()?.[elementType];
|
|
5384
5546
|
if (!widgetData) {
|
|
5385
5547
|
throw new Error(
|
|
5386
5548
|
`Unknown element type: ${elementType}. Check the available-widgets resource for valid types.`
|
|
5387
5549
|
);
|
|
5388
5550
|
}
|
|
5389
|
-
const container = (0,
|
|
5551
|
+
const container = (0, import_editor_elements15.getContainer)(elementId);
|
|
5390
5552
|
if (!container) {
|
|
5391
5553
|
throw new Error(`Element with id ${elementId} not found`);
|
|
5392
5554
|
}
|
|
@@ -5486,23 +5648,8 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5486
5648
|
}
|
|
5487
5649
|
|
|
5488
5650
|
// src/mcp/tools/find-icons/tool.ts
|
|
5489
|
-
var
|
|
5490
|
-
var
|
|
5491
|
-
|
|
5492
|
-
// src/mcp/utils/get-mcp-error-message.ts
|
|
5493
|
-
var import_http_client6 = require("@elementor/http-client");
|
|
5494
|
-
function getMcpErrorMessage(error, toolName) {
|
|
5495
|
-
if (error instanceof import_http_client6.AxiosError) {
|
|
5496
|
-
const data = error.response?.data;
|
|
5497
|
-
if (data?.message) {
|
|
5498
|
-
return data.code ? `${data.code}: ${data.message}` : data.message;
|
|
5499
|
-
}
|
|
5500
|
-
}
|
|
5501
|
-
if (error instanceof Error) {
|
|
5502
|
-
return error.message;
|
|
5503
|
-
}
|
|
5504
|
-
return `${toolName} failed with an unknown error.`;
|
|
5505
|
-
}
|
|
5651
|
+
var import_http_client8 = require("@elementor/http-client");
|
|
5652
|
+
var import_schema4 = require("@elementor/schema");
|
|
5506
5653
|
|
|
5507
5654
|
// src/mcp/tools/find-icons/prompt.ts
|
|
5508
5655
|
var import_editor_mcp4 = require("@elementor/editor-mcp");
|
|
@@ -5530,7 +5677,7 @@ findIconsToolPrompt.example(`Browse a category, one style only:
|
|
|
5530
5677
|
{ "category": "shopping", "library": "fa-solid", "perPage": 25 }`);
|
|
5531
5678
|
|
|
5532
5679
|
// src/mcp/tools/find-icons/tool.ts
|
|
5533
|
-
var
|
|
5680
|
+
var MCP_PROXY_URL6 = "elementor/v1/mcp-proxy";
|
|
5534
5681
|
var MAX_QUERIES = 10;
|
|
5535
5682
|
var MAX_PER_PAGE = 25;
|
|
5536
5683
|
var initFindIconsTool = (reg) => {
|
|
@@ -5539,56 +5686,56 @@ var initFindIconsTool = (reg) => {
|
|
|
5539
5686
|
name: "find-icons",
|
|
5540
5687
|
description: findIconsToolPrompt.prompt(),
|
|
5541
5688
|
schema: {
|
|
5542
|
-
queries:
|
|
5689
|
+
queries: import_schema4.z.array(import_schema4.z.string()).max(MAX_QUERIES).optional().describe(
|
|
5543
5690
|
'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.'
|
|
5544
5691
|
),
|
|
5545
|
-
library:
|
|
5692
|
+
library: import_schema4.z.string().optional().describe(
|
|
5546
5693
|
'Restrict results to one library key reported in "libraries", for example "fa-solid". Omit to search every library installed on the site.'
|
|
5547
5694
|
),
|
|
5548
|
-
category:
|
|
5695
|
+
category: import_schema4.z.string().optional().describe(
|
|
5549
5696
|
'Restrict results to one Font Awesome category reported in "categories", for example "shopping". May be used without a query to browse that category.'
|
|
5550
5697
|
),
|
|
5551
|
-
page:
|
|
5552
|
-
perPage:
|
|
5698
|
+
page: import_schema4.z.number().int().min(1).optional(),
|
|
5699
|
+
perPage: import_schema4.z.number().int().min(1).max(MAX_PER_PAGE).optional()
|
|
5553
5700
|
},
|
|
5554
5701
|
outputSchema: {
|
|
5555
|
-
results:
|
|
5556
|
-
|
|
5557
|
-
query:
|
|
5558
|
-
matches:
|
|
5559
|
-
|
|
5560
|
-
value:
|
|
5561
|
-
library:
|
|
5562
|
-
name:
|
|
5563
|
-
label:
|
|
5564
|
-
matched_on:
|
|
5565
|
-
license:
|
|
5702
|
+
results: import_schema4.z.array(
|
|
5703
|
+
import_schema4.z.object({
|
|
5704
|
+
query: import_schema4.z.string(),
|
|
5705
|
+
matches: import_schema4.z.array(
|
|
5706
|
+
import_schema4.z.object({
|
|
5707
|
+
value: import_schema4.z.string(),
|
|
5708
|
+
library: import_schema4.z.string(),
|
|
5709
|
+
name: import_schema4.z.string(),
|
|
5710
|
+
label: import_schema4.z.string(),
|
|
5711
|
+
matched_on: import_schema4.z.enum(["name", "alias", "term", "category", "library"]),
|
|
5712
|
+
license: import_schema4.z.enum(["free", "pro"])
|
|
5566
5713
|
})
|
|
5567
5714
|
),
|
|
5568
|
-
total:
|
|
5569
|
-
page:
|
|
5570
|
-
per_page:
|
|
5571
|
-
truncated:
|
|
5715
|
+
total: import_schema4.z.number(),
|
|
5716
|
+
page: import_schema4.z.number(),
|
|
5717
|
+
per_page: import_schema4.z.number(),
|
|
5718
|
+
truncated: import_schema4.z.boolean()
|
|
5572
5719
|
})
|
|
5573
5720
|
).describe(
|
|
5574
5721
|
'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".'
|
|
5575
5722
|
),
|
|
5576
|
-
libraries:
|
|
5723
|
+
libraries: import_schema4.z.array(import_schema4.z.string()).optional().describe(
|
|
5577
5724
|
"Icon library keys installed on this site. Only sent when nothing matched or when browsing."
|
|
5578
5725
|
),
|
|
5579
|
-
customLibraries:
|
|
5726
|
+
customLibraries: import_schema4.z.record(import_schema4.z.string(), import_schema4.z.string()).optional().describe(
|
|
5580
5727
|
"Custom (uploaded) icon libraries keyed by library. Only sent when nothing matched or when browsing."
|
|
5581
5728
|
),
|
|
5582
|
-
categories:
|
|
5729
|
+
categories: import_schema4.z.array(import_schema4.z.string()).optional().describe(
|
|
5583
5730
|
'Icon categories for the "category" filter. Only sent when nothing matched or when browsing.'
|
|
5584
5731
|
),
|
|
5585
|
-
truncatedCustomLibraries:
|
|
5586
|
-
fontAwesomeVersion:
|
|
5587
|
-
llmInstructions:
|
|
5732
|
+
truncatedCustomLibraries: import_schema4.z.array(import_schema4.z.string()).optional().describe("Custom libraries with more than 250 icons; only their first 250 icons are searchable."),
|
|
5733
|
+
fontAwesomeVersion: import_schema4.z.string().nullable().describe("Font Awesome version the site renders icons from."),
|
|
5734
|
+
llmInstructions: import_schema4.z.string().optional().describe("Present only when nothing matched, explaining what to do next.")
|
|
5588
5735
|
},
|
|
5589
5736
|
handler: async ({ queries, library, category, page, perPage }) => {
|
|
5590
5737
|
try {
|
|
5591
|
-
const { data } = await (0,
|
|
5738
|
+
const { data } = await (0, import_http_client8.httpService)().post(MCP_PROXY_URL6, {
|
|
5592
5739
|
tool: "find-icons",
|
|
5593
5740
|
input: {
|
|
5594
5741
|
...queries ? { queries } : {},
|
|
@@ -5615,36 +5762,36 @@ var initFindIconsTool = (reg) => {
|
|
|
5615
5762
|
};
|
|
5616
5763
|
|
|
5617
5764
|
// src/mcp/tools/get-page-structure/tool.ts
|
|
5618
|
-
var
|
|
5619
|
-
var
|
|
5620
|
-
var
|
|
5621
|
-
var
|
|
5765
|
+
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
5766
|
+
var import_http_client9 = require("@elementor/http-client");
|
|
5767
|
+
var import_schema5 = require("@elementor/schema");
|
|
5768
|
+
var MCP_PROXY_URL7 = "elementor/v1/mcp-proxy";
|
|
5622
5769
|
var initGetPageStructureTool = (reg) => {
|
|
5623
5770
|
const { addTool } = reg;
|
|
5624
5771
|
addTool({
|
|
5625
5772
|
name: "get-page-structure",
|
|
5626
5773
|
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.",
|
|
5627
5774
|
schema: {
|
|
5628
|
-
postId:
|
|
5775
|
+
postId: import_schema5.z.number().optional().describe(
|
|
5629
5776
|
"WordPress post ID of the Elementor document. If omitted, uses the currently open document."
|
|
5630
5777
|
),
|
|
5631
|
-
elementId:
|
|
5632
|
-
includeContent:
|
|
5778
|
+
elementId: import_schema5.z.string().optional().describe("If provided, returns only the subtree rooted at that element id."),
|
|
5779
|
+
includeContent: import_schema5.z.boolean().optional().describe(
|
|
5633
5780
|
"If true, includes each node's settings and styles (same shape build-composition accepts as input). Requires elementId."
|
|
5634
5781
|
)
|
|
5635
5782
|
},
|
|
5636
5783
|
outputSchema: {
|
|
5637
|
-
elements:
|
|
5784
|
+
elements: import_schema5.z.array(import_schema5.z.any()).describe(
|
|
5638
5785
|
"Skeleton of Elementor elements (id, elType, widgetType, title, nested elements). When includeContent is true, each node also includes settings and styles."
|
|
5639
5786
|
)
|
|
5640
5787
|
},
|
|
5641
5788
|
handler: async ({ postId, elementId, includeContent }) => {
|
|
5642
|
-
const resolvedPostId = postId ?? (0,
|
|
5789
|
+
const resolvedPostId = postId ?? (0, import_editor_documents3.getCurrentDocument)()?.id;
|
|
5643
5790
|
if (!resolvedPostId) {
|
|
5644
5791
|
throw new Error("No post ID provided and no active document found.");
|
|
5645
5792
|
}
|
|
5646
5793
|
try {
|
|
5647
|
-
const { data } = await (0,
|
|
5794
|
+
const { data } = await (0, import_http_client9.httpService)().post(MCP_PROXY_URL7, {
|
|
5648
5795
|
tool: "get-page-structure",
|
|
5649
5796
|
input: {
|
|
5650
5797
|
post_id: resolvedPostId,
|
|
@@ -5676,6 +5823,7 @@ var initCanvasMcp = (reg) => {
|
|
|
5676
5823
|
initConfigureElementTool(reg);
|
|
5677
5824
|
initFindIconsTool(reg);
|
|
5678
5825
|
initGetPageStructureTool(reg);
|
|
5826
|
+
initBuildCompositionTool(reg);
|
|
5679
5827
|
initBreakpointsResource(reg);
|
|
5680
5828
|
};
|
|
5681
5829
|
|
|
@@ -5776,16 +5924,16 @@ Note: The "size" property controls image resolution/loading, not visual size. Se
|
|
|
5776
5924
|
`;
|
|
5777
5925
|
|
|
5778
5926
|
// src/prevent-link-in-link-commands.ts
|
|
5779
|
-
var
|
|
5927
|
+
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
5780
5928
|
var import_editor_notifications6 = require("@elementor/editor-notifications");
|
|
5781
|
-
var
|
|
5782
|
-
var
|
|
5929
|
+
var import_editor_v1_adapters26 = require("@elementor/editor-v1-adapters");
|
|
5930
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
5783
5931
|
function initLinkInLinkPrevention() {
|
|
5784
|
-
(0,
|
|
5932
|
+
(0, import_editor_v1_adapters26.blockCommand)({
|
|
5785
5933
|
command: "document/elements/paste",
|
|
5786
5934
|
condition: blockLinkInLinkPaste
|
|
5787
5935
|
});
|
|
5788
|
-
(0,
|
|
5936
|
+
(0, import_editor_v1_adapters26.blockCommand)({
|
|
5789
5937
|
command: "document/elements/move",
|
|
5790
5938
|
condition: blockLinkInLinkMove
|
|
5791
5939
|
});
|
|
@@ -5813,7 +5961,7 @@ function blockLinkInLinkPaste(args) {
|
|
|
5813
5961
|
const sourceElements = data.clipboard.elements;
|
|
5814
5962
|
const notification = {
|
|
5815
5963
|
type: "default",
|
|
5816
|
-
message: (0,
|
|
5964
|
+
message: (0, import_i18n8.__)(
|
|
5817
5965
|
"To paste a link to this element, first remove the link from it's parent container.",
|
|
5818
5966
|
"elementor"
|
|
5819
5967
|
),
|
|
@@ -5832,7 +5980,7 @@ function blockLinkInLinkMove(args) {
|
|
|
5832
5980
|
const targetElement = target;
|
|
5833
5981
|
const notification = {
|
|
5834
5982
|
type: "default",
|
|
5835
|
-
message: (0,
|
|
5983
|
+
message: (0, import_i18n8.__)("To drag a link to this element, first remove the link from it's parent container.", "elementor"),
|
|
5836
5984
|
id: "move-in-link-blocked",
|
|
5837
5985
|
additionalActionProps: [learnMoreActionProps]
|
|
5838
5986
|
};
|
|
@@ -5847,26 +5995,26 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
5847
5995
|
return false;
|
|
5848
5996
|
}
|
|
5849
5997
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
5850
|
-
return src?.id ? (0,
|
|
5998
|
+
return src?.id ? (0, import_editor_elements16.isElementAnchored)(src.id) || !!(0, import_editor_elements16.getAnchoredDescendantId)(src.id) : false;
|
|
5851
5999
|
});
|
|
5852
6000
|
if (!isSourceContainsAnAnchor) {
|
|
5853
6001
|
return false;
|
|
5854
6002
|
}
|
|
5855
6003
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
5856
|
-
return target?.id ? (0,
|
|
6004
|
+
return target?.id ? (0, import_editor_elements16.isElementAnchored)(target.id) || !!(0, import_editor_elements16.getAnchoredAncestorId)(target.id) : false;
|
|
5857
6005
|
});
|
|
5858
6006
|
return isTargetContainsAnAnchor;
|
|
5859
6007
|
}
|
|
5860
6008
|
|
|
5861
6009
|
// src/style-commands/paste-style.ts
|
|
5862
|
-
var
|
|
6010
|
+
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
5863
6011
|
var import_editor_props11 = require("@elementor/editor-props");
|
|
5864
|
-
var
|
|
6012
|
+
var import_editor_v1_adapters28 = require("@elementor/editor-v1-adapters");
|
|
5865
6013
|
|
|
5866
6014
|
// src/utils/command-utils.ts
|
|
5867
|
-
var
|
|
6015
|
+
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
5868
6016
|
var import_editor_props10 = require("@elementor/editor-props");
|
|
5869
|
-
var
|
|
6017
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
5870
6018
|
function hasAtomicWidgets(args) {
|
|
5871
6019
|
const { containers = [args.container] } = args;
|
|
5872
6020
|
return containers.some(isAtomicWidget);
|
|
@@ -5889,7 +6037,7 @@ function getClassesProp(container) {
|
|
|
5889
6037
|
}
|
|
5890
6038
|
function getContainerSchema(container) {
|
|
5891
6039
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
5892
|
-
const widgetsCache = (0,
|
|
6040
|
+
const widgetsCache = (0, import_editor_elements17.getWidgetsCache)();
|
|
5893
6041
|
const elementType = widgetsCache?.[type];
|
|
5894
6042
|
return elementType?.atomic_props_schema ?? null;
|
|
5895
6043
|
}
|
|
@@ -5902,15 +6050,15 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
5902
6050
|
}
|
|
5903
6051
|
}
|
|
5904
6052
|
function getTitleForContainers(containers) {
|
|
5905
|
-
return containers.length > 1 ? (0,
|
|
6053
|
+
return containers.length > 1 ? (0, import_i18n9.__)("Elements", "elementor") : (0, import_editor_elements17.getElementLabel)(containers[0].id);
|
|
5906
6054
|
}
|
|
5907
6055
|
|
|
5908
6056
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
5909
|
-
var
|
|
6057
|
+
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5910
6058
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
5911
|
-
var
|
|
5912
|
-
var
|
|
5913
|
-
var undoablePasteElementStyle = () => (0,
|
|
6059
|
+
var import_editor_v1_adapters27 = require("@elementor/editor-v1-adapters");
|
|
6060
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
6061
|
+
var undoablePasteElementStyle = () => (0, import_editor_v1_adapters27.undoable)(
|
|
5914
6062
|
{
|
|
5915
6063
|
do: ({ containers, newStyle }) => {
|
|
5916
6064
|
return containers.map((container) => {
|
|
@@ -5919,7 +6067,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters26.undoable)(
|
|
|
5919
6067
|
if (!classesProp) {
|
|
5920
6068
|
return null;
|
|
5921
6069
|
}
|
|
5922
|
-
const originalStyles = (0,
|
|
6070
|
+
const originalStyles = (0, import_editor_elements18.getElementStyles)(container.id);
|
|
5923
6071
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
5924
6072
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
5925
6073
|
const revertData = {
|
|
@@ -5928,7 +6076,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters26.undoable)(
|
|
|
5928
6076
|
};
|
|
5929
6077
|
if (styleId) {
|
|
5930
6078
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
5931
|
-
(0,
|
|
6079
|
+
(0, import_editor_elements18.updateElementStyle)({
|
|
5932
6080
|
elementId,
|
|
5933
6081
|
styleId,
|
|
5934
6082
|
meta,
|
|
@@ -5939,7 +6087,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters26.undoable)(
|
|
|
5939
6087
|
} else {
|
|
5940
6088
|
const [firstVariant] = newStyle.variants;
|
|
5941
6089
|
const additionalVariants = newStyle.variants.slice(1);
|
|
5942
|
-
revertData.styleId = (0,
|
|
6090
|
+
revertData.styleId = (0, import_editor_elements18.createElementStyle)({
|
|
5943
6091
|
elementId,
|
|
5944
6092
|
classesProp,
|
|
5945
6093
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -5957,7 +6105,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters26.undoable)(
|
|
|
5957
6105
|
return;
|
|
5958
6106
|
}
|
|
5959
6107
|
if (!revertData.originalStyle) {
|
|
5960
|
-
(0,
|
|
6108
|
+
(0, import_editor_elements18.deleteElementStyle)(container.id, revertData.styleId);
|
|
5961
6109
|
return;
|
|
5962
6110
|
}
|
|
5963
6111
|
const classesProp = getClassesProp(container);
|
|
@@ -5966,7 +6114,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters26.undoable)(
|
|
|
5966
6114
|
}
|
|
5967
6115
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
5968
6116
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
5969
|
-
(0,
|
|
6117
|
+
(0, import_editor_elements18.createElementStyle)({
|
|
5970
6118
|
elementId: container.id,
|
|
5971
6119
|
classesProp,
|
|
5972
6120
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -5979,19 +6127,19 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters26.undoable)(
|
|
|
5979
6127
|
},
|
|
5980
6128
|
{
|
|
5981
6129
|
title: ({ containers }) => getTitleForContainers(containers),
|
|
5982
|
-
subtitle: (0,
|
|
6130
|
+
subtitle: (0, import_i18n10.__)("Style Pasted", "elementor")
|
|
5983
6131
|
}
|
|
5984
6132
|
);
|
|
5985
6133
|
|
|
5986
6134
|
// src/style-commands/paste-style.ts
|
|
5987
6135
|
function initPasteStyleCommand() {
|
|
5988
6136
|
const pasteElementStyleCommand = undoablePasteElementStyle();
|
|
5989
|
-
(0,
|
|
6137
|
+
(0, import_editor_v1_adapters28.blockCommand)({
|
|
5990
6138
|
command: "document/elements/paste-style",
|
|
5991
6139
|
condition: hasAtomicWidgets
|
|
5992
6140
|
});
|
|
5993
|
-
(0,
|
|
5994
|
-
(0,
|
|
6141
|
+
(0, import_editor_v1_adapters28.__privateListenTo)(
|
|
6142
|
+
(0, import_editor_v1_adapters28.commandStartEvent)("document/elements/paste-style"),
|
|
5995
6143
|
(e) => pasteStyles(e.args, pasteElementStyleCommand)
|
|
5996
6144
|
);
|
|
5997
6145
|
}
|
|
@@ -6003,7 +6151,7 @@ function pasteStyles(args, pasteLocalStyle) {
|
|
|
6003
6151
|
}
|
|
6004
6152
|
const clipboardElements = getClipboardElements(storageKey);
|
|
6005
6153
|
const [clipboardElement] = clipboardElements ?? [];
|
|
6006
|
-
const clipboardContainer = (0,
|
|
6154
|
+
const clipboardContainer = (0, import_editor_elements19.getContainer)(clipboardElement.id);
|
|
6007
6155
|
if (!clipboardElement || !clipboardContainer || !isAtomicWidget(clipboardContainer)) {
|
|
6008
6156
|
return;
|
|
6009
6157
|
}
|
|
@@ -6022,7 +6170,7 @@ function getClassesWithoutLocalStyle(clipboardContainer, style) {
|
|
|
6022
6170
|
if (!classesProp) {
|
|
6023
6171
|
return [];
|
|
6024
6172
|
}
|
|
6025
|
-
const classesSetting = (0,
|
|
6173
|
+
const classesSetting = (0, import_editor_elements19.getElementSetting)(clipboardContainer.id, classesProp);
|
|
6026
6174
|
return classesSetting?.value.filter((styleId) => styleId !== style?.id) ?? [];
|
|
6027
6175
|
}
|
|
6028
6176
|
function pasteClasses(containers, classes) {
|
|
@@ -6031,10 +6179,10 @@ function pasteClasses(containers, classes) {
|
|
|
6031
6179
|
if (!classesProp) {
|
|
6032
6180
|
return;
|
|
6033
6181
|
}
|
|
6034
|
-
const classesSetting = (0,
|
|
6182
|
+
const classesSetting = (0, import_editor_elements19.getElementSetting)(container.id, classesProp);
|
|
6035
6183
|
const currentClasses = import_editor_props11.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
6036
6184
|
const newClasses = import_editor_props11.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
6037
|
-
(0,
|
|
6185
|
+
(0, import_editor_elements19.updateElementSettings)({
|
|
6038
6186
|
id: container.id,
|
|
6039
6187
|
props: { [classesProp]: newClasses }
|
|
6040
6188
|
});
|
|
@@ -6042,21 +6190,21 @@ function pasteClasses(containers, classes) {
|
|
|
6042
6190
|
}
|
|
6043
6191
|
|
|
6044
6192
|
// src/style-commands/reset-style.ts
|
|
6045
|
-
var
|
|
6193
|
+
var import_editor_v1_adapters30 = require("@elementor/editor-v1-adapters");
|
|
6046
6194
|
|
|
6047
6195
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
6048
|
-
var
|
|
6196
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
6049
6197
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
6050
|
-
var
|
|
6051
|
-
var
|
|
6052
|
-
var undoableResetElementStyle = () => (0,
|
|
6198
|
+
var import_editor_v1_adapters29 = require("@elementor/editor-v1-adapters");
|
|
6199
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
6200
|
+
var undoableResetElementStyle = () => (0, import_editor_v1_adapters29.undoable)(
|
|
6053
6201
|
{
|
|
6054
6202
|
do: ({ containers }) => {
|
|
6055
6203
|
return containers.map((container) => {
|
|
6056
6204
|
const elementId = container.model.get("id");
|
|
6057
|
-
const containerStyles = (0,
|
|
6205
|
+
const containerStyles = (0, import_editor_elements20.getElementStyles)(elementId);
|
|
6058
6206
|
Object.keys(containerStyles ?? {}).forEach(
|
|
6059
|
-
(styleId) => (0,
|
|
6207
|
+
(styleId) => (0, import_editor_elements20.deleteElementStyle)(elementId, styleId)
|
|
6060
6208
|
);
|
|
6061
6209
|
return containerStyles;
|
|
6062
6210
|
});
|
|
@@ -6072,7 +6220,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters28.undoable)(
|
|
|
6072
6220
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
6073
6221
|
const [firstVariant] = style.variants;
|
|
6074
6222
|
const additionalVariants = style.variants.slice(1);
|
|
6075
|
-
(0,
|
|
6223
|
+
(0, import_editor_elements20.createElementStyle)({
|
|
6076
6224
|
elementId,
|
|
6077
6225
|
classesProp,
|
|
6078
6226
|
styleId,
|
|
@@ -6086,19 +6234,19 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters28.undoable)(
|
|
|
6086
6234
|
},
|
|
6087
6235
|
{
|
|
6088
6236
|
title: ({ containers }) => getTitleForContainers(containers),
|
|
6089
|
-
subtitle: (0,
|
|
6237
|
+
subtitle: (0, import_i18n11.__)("Style Reset", "elementor")
|
|
6090
6238
|
}
|
|
6091
6239
|
);
|
|
6092
6240
|
|
|
6093
6241
|
// src/style-commands/reset-style.ts
|
|
6094
6242
|
function initResetStyleCommand() {
|
|
6095
6243
|
const resetElementStyles = undoableResetElementStyle();
|
|
6096
|
-
(0,
|
|
6244
|
+
(0, import_editor_v1_adapters30.blockCommand)({
|
|
6097
6245
|
command: "document/elements/reset-style",
|
|
6098
6246
|
condition: hasAtomicWidgets
|
|
6099
6247
|
});
|
|
6100
|
-
(0,
|
|
6101
|
-
(0,
|
|
6248
|
+
(0, import_editor_v1_adapters30.__privateListenTo)(
|
|
6249
|
+
(0, import_editor_v1_adapters30.commandStartEvent)("document/elements/reset-style"),
|
|
6102
6250
|
(e) => resetStyles(e.args, resetElementStyles)
|
|
6103
6251
|
);
|
|
6104
6252
|
}
|
|
@@ -6250,9 +6398,9 @@ function getRectClipPath(rect, viewport) {
|
|
|
6250
6398
|
}
|
|
6251
6399
|
|
|
6252
6400
|
// src/hooks/use-canvas-document.ts
|
|
6253
|
-
var
|
|
6401
|
+
var import_editor_v1_adapters31 = require("@elementor/editor-v1-adapters");
|
|
6254
6402
|
function useCanvasDocument() {
|
|
6255
|
-
return (0,
|
|
6403
|
+
return (0, import_editor_v1_adapters31.__privateUseListenTo)((0, import_editor_v1_adapters31.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters31.getCanvasIframeDocument)());
|
|
6256
6404
|
}
|
|
6257
6405
|
|
|
6258
6406
|
// src/hooks/use-escape-on-canvas.ts
|
|
@@ -6275,10 +6423,10 @@ function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
|
6275
6423
|
}
|
|
6276
6424
|
|
|
6277
6425
|
// src/utils/after-render.ts
|
|
6278
|
-
var
|
|
6426
|
+
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
6279
6427
|
function doAfterRender(elementIds, callback) {
|
|
6280
6428
|
const pending = elementIds.map((elementId) => {
|
|
6281
|
-
const view = (0,
|
|
6429
|
+
const view = (0, import_editor_elements21.getContainer)(elementId)?.view;
|
|
6282
6430
|
if (!view || !hasDoAfterRender(view)) {
|
|
6283
6431
|
return void 0;
|
|
6284
6432
|
}
|