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