@elementor/editor-canvas 3.33.0-271 → 3.33.0-272
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 +747 -21
- package/dist/index.mjs +755 -15
- package/package.json +17 -15
- package/src/init.tsx +9 -0
- package/src/mcp/canvas-mcp.ts +15 -0
- package/src/mcp/mcp-description.ts +33 -0
- package/src/mcp/resources/widgets-schema-resource.ts +154 -0
- package/src/mcp/tools/build-composition/prompt.ts +119 -0
- package/src/mcp/tools/build-composition/schema.ts +27 -0
- package/src/mcp/tools/build-composition/tool.ts +158 -0
- package/src/mcp/tools/configure-element/prompt.ts +92 -0
- package/src/mcp/tools/configure-element/schema.ts +25 -0
- package/src/mcp/tools/configure-element/tool.ts +67 -0
- package/src/mcp/utils/do-update-element-property.ts +115 -0
- package/src/mcp/utils/generate-available-tags.ts +23 -0
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
47
47
|
// src/init.tsx
|
|
48
48
|
var import_editor = require("@elementor/editor");
|
|
49
49
|
var import_editor_interactions2 = require("@elementor/editor-interactions");
|
|
50
|
+
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
50
51
|
|
|
51
52
|
// src/components/classes-rename.tsx
|
|
52
53
|
var import_react = require("react");
|
|
@@ -1147,11 +1148,11 @@ function getVal2(val) {
|
|
|
1147
1148
|
var transformOriginTransformer = createTransformer((value) => {
|
|
1148
1149
|
const x = getVal2(value.x);
|
|
1149
1150
|
const y = getVal2(value.y);
|
|
1150
|
-
const
|
|
1151
|
-
if (x === DEFAULT_XY && y === DEFAULT_XY &&
|
|
1151
|
+
const z3 = getVal2(value.z);
|
|
1152
|
+
if (x === DEFAULT_XY && y === DEFAULT_XY && z3 === DEFAULT_Z) {
|
|
1152
1153
|
return null;
|
|
1153
1154
|
}
|
|
1154
|
-
return `${x} ${y} ${
|
|
1155
|
+
return `${x} ${y} ${z3}`;
|
|
1155
1156
|
});
|
|
1156
1157
|
|
|
1157
1158
|
// src/transformers/styles/transform-rotate-transformer.ts
|
|
@@ -1493,8 +1494,728 @@ function initLegacyViews() {
|
|
|
1493
1494
|
});
|
|
1494
1495
|
}
|
|
1495
1496
|
|
|
1496
|
-
// src/
|
|
1497
|
+
// src/mcp/resources/widgets-schema-resource.ts
|
|
1497
1498
|
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
1499
|
+
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
1500
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
1501
|
+
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
1502
|
+
var WIDGET_SCHEMA_URI = "elementor://widgets/schema/{widgetType}";
|
|
1503
|
+
var STYLE_SCHEMA_URI = "elementor://styles/schema/{category}";
|
|
1504
|
+
var initWidgetsSchemaResource = (reg) => {
|
|
1505
|
+
const { mcpServer } = reg;
|
|
1506
|
+
mcpServer.resource(
|
|
1507
|
+
"styles-schema",
|
|
1508
|
+
new import_editor_mcp.ResourceTemplate(STYLE_SCHEMA_URI, {
|
|
1509
|
+
list: () => {
|
|
1510
|
+
const categories = [...Object.keys((0, import_editor_styles4.getStylesSchema)()), "custom_css"];
|
|
1511
|
+
return {
|
|
1512
|
+
resources: categories.map((category) => ({
|
|
1513
|
+
uri: `elementor://styles/schema/${category}`,
|
|
1514
|
+
name: "Style schema for " + category
|
|
1515
|
+
}))
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
}),
|
|
1519
|
+
{
|
|
1520
|
+
description: "Common styles schema for the specified category"
|
|
1521
|
+
},
|
|
1522
|
+
async (uri, variables) => {
|
|
1523
|
+
const category = typeof variables.category === "string" ? variables.category : variables.category?.[0];
|
|
1524
|
+
if (category === "custom_css") {
|
|
1525
|
+
return {
|
|
1526
|
+
contents: [
|
|
1527
|
+
{
|
|
1528
|
+
uri: uri.toString(),
|
|
1529
|
+
text: "Free style inline CSS string of properties and their values. Applicable for a single element, only the properties and values are accepted."
|
|
1530
|
+
}
|
|
1531
|
+
]
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
const stylesSchema = (0, import_editor_styles4.getStylesSchema)()[category];
|
|
1535
|
+
if (!stylesSchema) {
|
|
1536
|
+
throw new Error(`No styles schema found for category: ${category}`);
|
|
1537
|
+
}
|
|
1538
|
+
const cleanedupPropSchema = cleanupPropType(stylesSchema);
|
|
1539
|
+
const asJson = import_editor_props2.Schema.propTypeToJsonSchema(cleanedupPropSchema);
|
|
1540
|
+
return {
|
|
1541
|
+
contents: [
|
|
1542
|
+
{
|
|
1543
|
+
uri: uri.toString(),
|
|
1544
|
+
text: JSON.stringify(asJson)
|
|
1545
|
+
}
|
|
1546
|
+
]
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
);
|
|
1550
|
+
mcpServer.resource(
|
|
1551
|
+
"widget-schema-by-type",
|
|
1552
|
+
new import_editor_mcp.ResourceTemplate(WIDGET_SCHEMA_URI, {
|
|
1553
|
+
list: () => {
|
|
1554
|
+
const cache = (0, import_editor_elements3.getWidgetsCache)() || {};
|
|
1555
|
+
const availableWidgets = Object.keys(cache || {}).filter(
|
|
1556
|
+
(widgetType) => cache[widgetType]?.atomic_props_schema
|
|
1557
|
+
);
|
|
1558
|
+
return {
|
|
1559
|
+
resources: availableWidgets.map((widgetType) => ({
|
|
1560
|
+
uri: `elementor://widgets/schema/${widgetType}`,
|
|
1561
|
+
name: "Widget schema for " + widgetType
|
|
1562
|
+
}))
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
}),
|
|
1566
|
+
{
|
|
1567
|
+
description: "PropType schema for the specified widget type"
|
|
1568
|
+
},
|
|
1569
|
+
async (uri, variables) => {
|
|
1570
|
+
const widgetType = typeof variables.widgetType === "string" ? variables.widgetType : variables.widgetType?.[0];
|
|
1571
|
+
const propSchema = (0, import_editor_elements3.getWidgetsCache)()?.[widgetType]?.atomic_props_schema;
|
|
1572
|
+
if (!propSchema) {
|
|
1573
|
+
throw new Error(`No prop schema found for element type: ${widgetType}`);
|
|
1574
|
+
}
|
|
1575
|
+
const cleanedupPropSchema = cleanupPropSchema(propSchema);
|
|
1576
|
+
const asJson = Object.fromEntries(
|
|
1577
|
+
Object.entries(cleanedupPropSchema).map(([key, propType]) => [
|
|
1578
|
+
key,
|
|
1579
|
+
import_editor_props2.Schema.propTypeToJsonSchema(propType)
|
|
1580
|
+
])
|
|
1581
|
+
);
|
|
1582
|
+
delete asJson.classes;
|
|
1583
|
+
delete asJson._cssid;
|
|
1584
|
+
delete asJson.attributes;
|
|
1585
|
+
return {
|
|
1586
|
+
contents: [
|
|
1587
|
+
{
|
|
1588
|
+
uri: uri.toString(),
|
|
1589
|
+
text: JSON.stringify(asJson)
|
|
1590
|
+
}
|
|
1591
|
+
]
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
);
|
|
1595
|
+
};
|
|
1596
|
+
function cleanupPropSchema(propSchema) {
|
|
1597
|
+
const result = {};
|
|
1598
|
+
Object.keys(propSchema).forEach((propName) => {
|
|
1599
|
+
result[propName] = cleanupPropType(propSchema[propName]);
|
|
1600
|
+
});
|
|
1601
|
+
return result;
|
|
1602
|
+
}
|
|
1603
|
+
function cleanupPropType(propType) {
|
|
1604
|
+
const result = {};
|
|
1605
|
+
Object.keys(propType).forEach((property) => {
|
|
1606
|
+
switch (property) {
|
|
1607
|
+
case "key":
|
|
1608
|
+
case "kind":
|
|
1609
|
+
result[property] = propType[property];
|
|
1610
|
+
break;
|
|
1611
|
+
case "meta":
|
|
1612
|
+
case "settings":
|
|
1613
|
+
{
|
|
1614
|
+
if (Object.keys(propType[property] || {}).length > 0) {
|
|
1615
|
+
result[property] = propType[property];
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
break;
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
if (result.kind === "plain") {
|
|
1622
|
+
Object.defineProperty(result, "kind", { value: "string" });
|
|
1623
|
+
} else if (result.kind === "array") {
|
|
1624
|
+
result.item_prop_type = cleanupPropType(propType.item_prop_type);
|
|
1625
|
+
} else if (result.kind === "object") {
|
|
1626
|
+
const shape = propType.shape;
|
|
1627
|
+
const cleanedShape = cleanupPropSchema(shape);
|
|
1628
|
+
result.shape = cleanedShape;
|
|
1629
|
+
} else if (result.kind === "union") {
|
|
1630
|
+
const propTypes = propType.prop_types;
|
|
1631
|
+
const cleanedPropTypes = {};
|
|
1632
|
+
Object.keys(propTypes).forEach((key) => {
|
|
1633
|
+
cleanedPropTypes[key] = cleanupPropType(propTypes[key]);
|
|
1634
|
+
});
|
|
1635
|
+
result.prop_types = cleanedPropTypes;
|
|
1636
|
+
}
|
|
1637
|
+
return result;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/mcp/tools/build-composition/tool.ts
|
|
1641
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1642
|
+
|
|
1643
|
+
// src/mcp/utils/do-update-element-property.ts
|
|
1644
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
1645
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
1646
|
+
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
1647
|
+
function resolvePropValue(value, forceKey) {
|
|
1648
|
+
return import_editor_props3.Schema.adjustLlmPropValueSchema(value, forceKey);
|
|
1649
|
+
}
|
|
1650
|
+
var doUpdateElementProperty = (params) => {
|
|
1651
|
+
const { elementId, propertyName, propertyValue, elementType } = params;
|
|
1652
|
+
if (propertyName === "_styles") {
|
|
1653
|
+
const elementStyles = (0, import_editor_elements4.getElementStyles)(elementId) || {};
|
|
1654
|
+
const propertyMapValue = propertyValue;
|
|
1655
|
+
const styleSchema = (0, import_editor_styles5.getStylesSchema)();
|
|
1656
|
+
const transformedStyleValues = Object.fromEntries(
|
|
1657
|
+
Object.entries(propertyMapValue).map(([key, val]) => {
|
|
1658
|
+
if (key === "custom_css") {
|
|
1659
|
+
return [key, val];
|
|
1660
|
+
}
|
|
1661
|
+
const { key: propKey, kind } = styleSchema?.[key] || {};
|
|
1662
|
+
if (!propKey && kind !== "union") {
|
|
1663
|
+
throw new Error(`_styles property ${key} is not supported.`);
|
|
1664
|
+
}
|
|
1665
|
+
return [key, resolvePropValue(val, propKey)];
|
|
1666
|
+
})
|
|
1667
|
+
);
|
|
1668
|
+
let customCss;
|
|
1669
|
+
Object.keys(propertyMapValue).forEach((stylePropName) => {
|
|
1670
|
+
const propertyRawSchema = styleSchema[stylePropName];
|
|
1671
|
+
if (stylePropName === "custom_css") {
|
|
1672
|
+
customCss = {
|
|
1673
|
+
raw: btoa(propertyMapValue[stylePropName])
|
|
1674
|
+
};
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
const isSupported = !!propertyRawSchema;
|
|
1678
|
+
if (!isSupported) {
|
|
1679
|
+
throw new Error(`_styles property ${stylePropName} is not supported.`);
|
|
1680
|
+
}
|
|
1681
|
+
if (propertyRawSchema.kind === "plain") {
|
|
1682
|
+
if (typeof propertyMapValue[stylePropName] !== "object") {
|
|
1683
|
+
const propUtil = (0, import_editor_props3.getPropSchemaFromCache)(propertyRawSchema.key);
|
|
1684
|
+
if (propUtil) {
|
|
1685
|
+
const plainValue = propUtil.create(propertyMapValue[stylePropName]);
|
|
1686
|
+
propertyMapValue[stylePropName] = plainValue;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
|
|
1692
|
+
if (!localStyle) {
|
|
1693
|
+
(0, import_editor_elements4.createElementStyle)({
|
|
1694
|
+
elementId,
|
|
1695
|
+
custom_css: customCss,
|
|
1696
|
+
classesProp: "classes",
|
|
1697
|
+
label: "local",
|
|
1698
|
+
meta: {
|
|
1699
|
+
breakpoint: "desktop",
|
|
1700
|
+
state: null
|
|
1701
|
+
},
|
|
1702
|
+
props: {
|
|
1703
|
+
...transformedStyleValues
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1706
|
+
} else {
|
|
1707
|
+
(0, import_editor_elements4.updateElementStyle)({
|
|
1708
|
+
elementId,
|
|
1709
|
+
styleId: localStyle.id,
|
|
1710
|
+
meta: {
|
|
1711
|
+
breakpoint: "desktop",
|
|
1712
|
+
state: null
|
|
1713
|
+
},
|
|
1714
|
+
props: {
|
|
1715
|
+
...transformedStyleValues
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
const elementPropSchema = (0, import_editor_elements4.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
|
|
1722
|
+
if (!elementPropSchema) {
|
|
1723
|
+
throw new Error(`No prop schema found for element type: ${elementType}`);
|
|
1724
|
+
}
|
|
1725
|
+
if (!elementPropSchema[propertyName]) {
|
|
1726
|
+
const propertyNames = Object.keys(elementPropSchema);
|
|
1727
|
+
throw new Error(
|
|
1728
|
+
`Property "${propertyName}" does not exist on element type "${elementType}". Available properties are: ${propertyNames.join(
|
|
1729
|
+
", "
|
|
1730
|
+
)}`
|
|
1731
|
+
);
|
|
1732
|
+
}
|
|
1733
|
+
const value = resolvePropValue(propertyValue);
|
|
1734
|
+
(0, import_editor_elements4.updateElementSettings)({
|
|
1735
|
+
id: elementId,
|
|
1736
|
+
props: {
|
|
1737
|
+
[propertyName]: value
|
|
1738
|
+
},
|
|
1739
|
+
withHistory: false
|
|
1740
|
+
});
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1743
|
+
// src/mcp/tools/build-composition/prompt.ts
|
|
1744
|
+
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
1745
|
+
var CUSTOM_CSS_URI = STYLE_SCHEMA_URI.replace("{category}", "custom_css");
|
|
1746
|
+
var generatePrompt = () => {
|
|
1747
|
+
const buildCompositionsToolPrompt = (0, import_editor_mcp2.toolPrompts)("build-compositions");
|
|
1748
|
+
buildCompositionsToolPrompt.description(`
|
|
1749
|
+
Build entire elementor widget comositions representing complex structures of nested elements.
|
|
1750
|
+
|
|
1751
|
+
# When to use this tool
|
|
1752
|
+
Always prefer this tool when the user requires to build a composition of elements, such as cards, heros, or inspired from other pages or HTML compositions.
|
|
1753
|
+
Prefer this tool over any other tool for building HTML structure, unless you are specified to use a different tool.
|
|
1754
|
+
|
|
1755
|
+
# **CRITICAL - REQUIRED RESOURCES (Must read before using this tool)**
|
|
1756
|
+
1. [${WIDGET_SCHEMA_URI}]
|
|
1757
|
+
Required to understand which widgets are available, and what are their configuration schemas.
|
|
1758
|
+
Every widgetType (i.e. e-heading, e-button) that is supported has it's own property schema, that you must follow in order to apply property values correctly.
|
|
1759
|
+
2. [${CUSTOM_CSS_URI}]
|
|
1760
|
+
Required to understand the styles schema for the widgets. All widgets share the same styles schema.
|
|
1761
|
+
USE ONLY THE "custom_css" CATEGORY FROM THE STYLES SCHEMA FOR STYLING THE ELEMENTS with this tool.
|
|
1762
|
+
3. List of allowed custom tags for building the structure is derived from the list of widgets schema resources.
|
|
1763
|
+
|
|
1764
|
+
# Instructions
|
|
1765
|
+
1. Understand the user requirements carefully.
|
|
1766
|
+
2. Build a valid XML structure using only the allowed custom tags provided. For example, if you
|
|
1767
|
+
use the "e-button" element, it would be represented as <e-button></e-button> in the XML structure.
|
|
1768
|
+
3. Plan the configuration for each element according to the user requirements, using the configuration schema provided for each custom tag.
|
|
1769
|
+
Every widget type has it's own configuration schema, retreivable from the resource [${WIDGET_SCHEMA_URI}].
|
|
1770
|
+
PropValues must follow the exact PropType schema provided in the resource.
|
|
1771
|
+
4. For every element, provide a "configuration-id" attribute. For example:
|
|
1772
|
+
\`<e-flexbox configuration-id="flex1"><e-heading configuration-id="heading2"></e-heading></e-flexbox>\`
|
|
1773
|
+
In the elementConfig property, provide the actual configuration object for each configuration-id used in the XML structure.
|
|
1774
|
+
In the stylesConfig property, provide the actual styles configuration object for each configuration-id used in the XML structure.
|
|
1775
|
+
For easy execution, USE ONLY "custom_css" category from the styles schema resource to apply styles.
|
|
1776
|
+
5. Ensure the XML structure is valid and parsable.
|
|
1777
|
+
6. Do not add any attribute nodes, classes, id's, and no text nodes allowed, for inline styles prefer USE the [${CUSTOM_CSS_URI}] resource for custom_css.
|
|
1778
|
+
7. Some elements allow nesting of other elements, and most of the DO NOT. The allowed elements that can have nested children are "e-div-block" and "e-flexbox".
|
|
1779
|
+
8. Make sure that non-container elements do NOT have any nested elements.
|
|
1780
|
+
9. Unsless the user specifically requires structure only, BE EXPRESSIVE AND VISUALLY CREATIVE AS POSSIBLE IN APPLYING STYLE CONFIGURATION.
|
|
1781
|
+
In the case of doubt, prefer adding more styles to make the composition visually appealing.
|
|
1782
|
+
|
|
1783
|
+
# Additional Guidelines
|
|
1784
|
+
- Most users expect the structure to be well designed and visually appealing.
|
|
1785
|
+
- Use layout properties, ensure "white space" design approach is followed, and make sure the composition is visually balanced.
|
|
1786
|
+
- Use appropriate spacing, alignment, and sizing to create a harmonious layout.
|
|
1787
|
+
- Consider the visual hierarchy of elements to guide the user's attention effectively.
|
|
1788
|
+
- You are encouraged to use colors, typography, and other style properties to enhance the visual appeal, as long as they are part of the configuration schema for the elements used.
|
|
1789
|
+
- Always aim for a clean and professional look that aligns with modern design principles.
|
|
1790
|
+
- When you are required to create placeholder texts, use texts that have a length that fits the goal. When long texts are required, use longer placeholder texts. When the user specifies exact texts, use the exact texts.
|
|
1791
|
+
- Image size does not affect the actual size on the screen, only which quality to use. If you use images, specifically add _styles PropValues to define the image sizes.
|
|
1792
|
+
|
|
1793
|
+
# CONSTRAINTS
|
|
1794
|
+
When a tool execution fails, retry up to 10 more times, read the error message carefully, and adjust the XML structure or the configurations accordingly.
|
|
1795
|
+
If a "$$type" is missing, update the invalid object, if the XML has parsing errors, fix it, etc. and RETRY.
|
|
1796
|
+
VALIDATE the XML structure before delivering it as the final result.
|
|
1797
|
+
VALIDATE the JSON structure used in the "configuration" attributes for each element before delivering the final result. The configuration must MATCH the PropValue schemas.
|
|
1798
|
+
NO LINKS ALLOWED. Never apply links to elements, even if they appear in the PropType schema.
|
|
1799
|
+
elementConfig values must align with the widget's PropType schema, available at the resource [${WIDGET_SCHEMA_URI}].
|
|
1800
|
+
stylesConfig values must align with the common styles PropType schema, available at the resource [${STYLE_SCHEMA_URI}].
|
|
1801
|
+
|
|
1802
|
+
# Parameters
|
|
1803
|
+
All parameters are MANDATORY.
|
|
1804
|
+
- xmlStructure
|
|
1805
|
+
- elementConfig
|
|
1806
|
+
- stylesConfig
|
|
1807
|
+
|
|
1808
|
+
If unsure about the configuration of a specific property, read the schema resources carefully.
|
|
1809
|
+
|
|
1810
|
+
|
|
1811
|
+
`);
|
|
1812
|
+
buildCompositionsToolPrompt.example(`
|
|
1813
|
+
A Heading and a button inside a flexbox
|
|
1814
|
+
{
|
|
1815
|
+
xmlStructure: "<e-flexbox configuration-id="flex1"><e-heading configuration-id="heading1"></e-heading><e-button configuration-id="button1"></e-button></e-flexbox>"
|
|
1816
|
+
elementConfig: {
|
|
1817
|
+
"flex1": {
|
|
1818
|
+
"tag": {
|
|
1819
|
+
"$$type": "string",
|
|
1820
|
+
"value": "section"
|
|
1821
|
+
},
|
|
1822
|
+
},
|
|
1823
|
+
styleConfig: {
|
|
1824
|
+
"heading1": {
|
|
1825
|
+
"custom_css": "font-size: 24px; color: #333;"
|
|
1826
|
+
}
|
|
1827
|
+
},
|
|
1828
|
+
}
|
|
1829
|
+
`);
|
|
1830
|
+
buildCompositionsToolPrompt.parameter(
|
|
1831
|
+
"xmlStructure",
|
|
1832
|
+
`**MANDATORY** A valid XML structure representing the composition to be built, using custom elementor tags, styling and configuration PropValues.`
|
|
1833
|
+
);
|
|
1834
|
+
buildCompositionsToolPrompt.parameter(
|
|
1835
|
+
"elementConfig",
|
|
1836
|
+
`**MANDATORY** A record mapping configuration IDs to their corresponding configuration objects, defining the PropValues for each element created.`
|
|
1837
|
+
);
|
|
1838
|
+
buildCompositionsToolPrompt.parameter(
|
|
1839
|
+
"styleConfig",
|
|
1840
|
+
`**MANDATORY** A record mapping style PropTypes to their corresponding style configuration objects, defining the PropValues for styles to be applied to elements.`
|
|
1841
|
+
);
|
|
1842
|
+
buildCompositionsToolPrompt.instruction(
|
|
1843
|
+
`You will be provided the XML structure with element IDs. These IDs represent the actual elementor widgets created on the page/post.
|
|
1844
|
+
You should use these IDs as reference for further configuration, styling or changing elements later on.`
|
|
1845
|
+
);
|
|
1846
|
+
buildCompositionsToolPrompt.instruction(
|
|
1847
|
+
`If you have global styles/classes available in the project, you should prefer using them over inline styles, and you are welcome to execute relevant tools AFTER this tool execution, to apply global classes to the created elements.`
|
|
1848
|
+
);
|
|
1849
|
+
return buildCompositionsToolPrompt.prompt();
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
// src/mcp/tools/build-composition/schema.ts
|
|
1853
|
+
var import_schema = require("@elementor/schema");
|
|
1854
|
+
var inputSchema = {
|
|
1855
|
+
xmlStructure: import_schema.z.string().describe("The XML structure representing the composition to be built"),
|
|
1856
|
+
elementConfig: import_schema.z.record(
|
|
1857
|
+
import_schema.z.string().describe("The configuration id"),
|
|
1858
|
+
import_schema.z.record(import_schema.z.string().describe("property name"), import_schema.z.any().describe("The PropValue for the property"))
|
|
1859
|
+
).describe("A record mapping element IDs to their configuration objects. REQUIRED"),
|
|
1860
|
+
stylesConfig: import_schema.z.record(
|
|
1861
|
+
import_schema.z.string().describe("The configuration id"),
|
|
1862
|
+
import_schema.z.record(
|
|
1863
|
+
import_schema.z.string().describe("_styles property name"),
|
|
1864
|
+
import_schema.z.any().describe("The PropValue for the style property. MANDATORY")
|
|
1865
|
+
)
|
|
1866
|
+
).describe("A record mapping element IDs to their styles configuration objects.").default({})
|
|
1867
|
+
};
|
|
1868
|
+
var outputSchema = {
|
|
1869
|
+
errors: import_schema.z.string().describe("Error message if the composition building failed").optional(),
|
|
1870
|
+
xmlStructure: import_schema.z.string().describe("The built XML structure as a string").optional(),
|
|
1871
|
+
llmInstructions: import_schema.z.string().describe("Instructions used to further actions for you").optional()
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
// src/mcp/tools/build-composition/tool.ts
|
|
1875
|
+
var initBuildCompositionsTool = (reg) => {
|
|
1876
|
+
const { addTool } = reg;
|
|
1877
|
+
addTool({
|
|
1878
|
+
name: "build-compositions",
|
|
1879
|
+
description: generatePrompt(),
|
|
1880
|
+
schema: inputSchema,
|
|
1881
|
+
outputSchema,
|
|
1882
|
+
handler: async (params) => {
|
|
1883
|
+
let xml = null;
|
|
1884
|
+
const { xmlStructure, elementConfig, stylesConfig } = params;
|
|
1885
|
+
const errors = [];
|
|
1886
|
+
const softErrors = [];
|
|
1887
|
+
const widgetsCache = (0, import_editor_elements5.getWidgetsCache)() || {};
|
|
1888
|
+
const documentContainer = (0, import_editor_elements5.getContainer)("document");
|
|
1889
|
+
const rootContainer = (0, import_editor_elements5.createElement)({
|
|
1890
|
+
containerId: documentContainer.id,
|
|
1891
|
+
model: {
|
|
1892
|
+
elType: "container",
|
|
1893
|
+
id: (0, import_editor_elements5.generateElementId)()
|
|
1894
|
+
},
|
|
1895
|
+
options: { useHistory: false }
|
|
1896
|
+
});
|
|
1897
|
+
try {
|
|
1898
|
+
const parser = new DOMParser();
|
|
1899
|
+
xml = parser.parseFromString(xmlStructure, "application/xml");
|
|
1900
|
+
const errorNode = xml.querySelector("parsererror");
|
|
1901
|
+
if (errorNode) {
|
|
1902
|
+
throw new Error("Failed to parse XML structure: " + errorNode.textContent);
|
|
1903
|
+
}
|
|
1904
|
+
const children = Array.from(xml.children);
|
|
1905
|
+
const iterate = (node, containerElement) => {
|
|
1906
|
+
const elementTag = node.tagName;
|
|
1907
|
+
if (!widgetsCache[elementTag]) {
|
|
1908
|
+
errors.push(new Error(`Unknown widget type: ${elementTag}`));
|
|
1909
|
+
}
|
|
1910
|
+
const isContainer = elementTag === "e-flexbox" || elementTag === "e-div-block";
|
|
1911
|
+
const newElement = isContainer ? (0, import_editor_elements5.createElement)({
|
|
1912
|
+
containerId: containerElement.id,
|
|
1913
|
+
model: {
|
|
1914
|
+
elType: elementTag,
|
|
1915
|
+
id: (0, import_editor_elements5.generateElementId)()
|
|
1916
|
+
},
|
|
1917
|
+
options: { useHistory: false }
|
|
1918
|
+
}) : (0, import_editor_elements5.createElement)({
|
|
1919
|
+
containerId: containerElement.id,
|
|
1920
|
+
model: {
|
|
1921
|
+
elType: "widget",
|
|
1922
|
+
widgetType: elementTag,
|
|
1923
|
+
id: (0, import_editor_elements5.generateElementId)()
|
|
1924
|
+
},
|
|
1925
|
+
options: { useHistory: false }
|
|
1926
|
+
});
|
|
1927
|
+
node.setAttribute("id", newElement.id);
|
|
1928
|
+
const configId = node.getAttribute("configuration-id") || "";
|
|
1929
|
+
try {
|
|
1930
|
+
const configObject = elementConfig[configId] || {};
|
|
1931
|
+
const styleObject = stylesConfig[configId] || {};
|
|
1932
|
+
configObject._styles = styleObject;
|
|
1933
|
+
for (const [propertyName, propertyValue] of Object.entries(configObject)) {
|
|
1934
|
+
const widgetSchema = widgetsCache[elementTag];
|
|
1935
|
+
if (!widgetSchema?.atomic_props_schema?.[propertyName] && propertyName !== "_styles") {
|
|
1936
|
+
softErrors.push(
|
|
1937
|
+
new Error(
|
|
1938
|
+
`Property "${propertyName}" does not exist on element type "${elementTag}".`
|
|
1939
|
+
)
|
|
1940
|
+
);
|
|
1941
|
+
continue;
|
|
1942
|
+
}
|
|
1943
|
+
try {
|
|
1944
|
+
doUpdateElementProperty({
|
|
1945
|
+
elementId: newElement.id,
|
|
1946
|
+
propertyName,
|
|
1947
|
+
propertyValue,
|
|
1948
|
+
elementType: elementTag
|
|
1949
|
+
});
|
|
1950
|
+
} catch (error) {
|
|
1951
|
+
softErrors.push(error);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
if (isContainer) {
|
|
1955
|
+
for (const child of node.children) {
|
|
1956
|
+
iterate(child, newElement);
|
|
1957
|
+
}
|
|
1958
|
+
} else {
|
|
1959
|
+
node.innerHTML = "";
|
|
1960
|
+
node.removeAttribute("configuration");
|
|
1961
|
+
}
|
|
1962
|
+
} finally {
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
for (const childNode of children) {
|
|
1966
|
+
iterate(childNode, rootContainer);
|
|
1967
|
+
try {
|
|
1968
|
+
} catch (error) {
|
|
1969
|
+
errors.push(error);
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
} catch (error) {
|
|
1973
|
+
errors.push(error);
|
|
1974
|
+
}
|
|
1975
|
+
if (errors.length) {
|
|
1976
|
+
(0, import_editor_elements5.deleteElement)({
|
|
1977
|
+
elementId: rootContainer.id,
|
|
1978
|
+
options: { useHistory: false }
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
if (errors.length > 0) {
|
|
1982
|
+
const errorText = `Failed to build composition with the following errors:
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
${errors.map((e) => typeof e === "string" ? e : e.message).join("\n\n")}
|
|
1986
|
+
"Missing $$type" errors indicate that the configuration objects are invalid. Try again and apply **ALL** object entries with correct $$type.
|
|
1987
|
+
Now that you have these errors, fix them and try again. Errors regarding configuration objects, please check again the PropType schemas`;
|
|
1988
|
+
throw new Error(errorText);
|
|
1989
|
+
}
|
|
1990
|
+
if (!xml) {
|
|
1991
|
+
throw new Error("XML structure is null after parsing.");
|
|
1992
|
+
}
|
|
1993
|
+
return {
|
|
1994
|
+
xmlStructure: new XMLSerializer().serializeToString(xml),
|
|
1995
|
+
llmInstructions: (softErrors.length ? `The composition was built successfully, but there were some issues with the provided configurations:
|
|
1996
|
+
|
|
1997
|
+
${softErrors.map((e) => `- ${e.message}`).join("\n")}
|
|
1998
|
+
|
|
1999
|
+
Please use confiugure-element tool to fix these issues. Now that you have information about these issues, use the configure-element tool to fix them!` : "") + `
|
|
2000
|
+
Next Steps:
|
|
2001
|
+
- Use "apply-global-class" tool as there may be global styles ready to be applied to elements.
|
|
2002
|
+
- Use "configure-element" tool to further configure elements as needed, including styles.
|
|
2003
|
+
`
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
});
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
// src/mcp/tools/configure-element/prompt.ts
|
|
2010
|
+
var configureElementToolPrompt = `Configure an existing element on the page.
|
|
2011
|
+
|
|
2012
|
+
# **CRITICAL - REQUIRED RESOURCES (Must read before using this tool)**
|
|
2013
|
+
1. [${WIDGET_SCHEMA_URI}]
|
|
2014
|
+
Required to understand which widgets are available, and what are their configuration schemas.
|
|
2015
|
+
Every widgetType (i.e. e-heading, e-button) that is supported has it's own property schema, that you must follow in order to apply property values correctly.
|
|
2016
|
+
2. [${STYLE_SCHEMA_URI}]
|
|
2017
|
+
Required to understand the styles schema for the widgets. All widgets share the same styles schema, grouped by categories.
|
|
2018
|
+
Use this resource to understand which style properties are available for each element, and how to structure the "_styles" configuration property.
|
|
2019
|
+
|
|
2020
|
+
Before using this tool, check the definitions of the elements PropTypes at the resource "widget-schema-by-type" at editor-canvas__elementor://widgets/schema/{widgetType}
|
|
2021
|
+
All widgets share a common _style property for styling, which uses the common styles schema.
|
|
2022
|
+
Retreive and check the common styles schema at the resource list "styles-schema" at editor-canvas__elementor://styles/schema/{category}
|
|
2023
|
+
|
|
2024
|
+
Unless specifically noted, attempt to use the _style property "custom_css" for any styling, read the resource editor-canvas__elementor://styles/schema/custom_css for more information.
|
|
2025
|
+
|
|
2026
|
+
# Parameters
|
|
2027
|
+
- propertiesToChange: An object containing the properties to change, with their new values. MANDATORY
|
|
2028
|
+
- elementId: The ID of the element to configure. MANDATORY
|
|
2029
|
+
- elementType: The type of the element to configure (i.e. e-heading, e-button). MANDATORY
|
|
2030
|
+
|
|
2031
|
+
# When to use this tool
|
|
2032
|
+
When a user requires to change anything in an element, such as updating text, colors, sizes, or other configurable properties.
|
|
2033
|
+
This tool handles elements of type "widget".
|
|
2034
|
+
This tool handles styling elements, using the _styles property in the configuration.
|
|
2035
|
+
|
|
2036
|
+
The element's schema must be known before using this tool.
|
|
2037
|
+
|
|
2038
|
+
Attached resource link describing how PropType schema should be parsed as PropValue for this tool.
|
|
2039
|
+
|
|
2040
|
+
Read carefully the PropType Schema of the element and it's styles, then apply correct PropValue according to the schema.
|
|
2041
|
+
|
|
2042
|
+
PropValue structure:
|
|
2043
|
+
{
|
|
2044
|
+
"$$type": string, // MANDATORY as defined in the PropType schema under the "key" property
|
|
2045
|
+
value: unknown // The value according to the PropType schema for kinds of "array", use array with PropValues items inside. For "object", read the shape property of the PropType schema. For "plain", use strings.
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
<IMPORTANT>
|
|
2049
|
+
ALWAYS MAKE SURE you have the PropType schemas for the element you are configuring, and the common-styles schema for styling. If you are not sure, retreive the schema from the resources mentioned above.
|
|
2050
|
+
</IMPORTANT>
|
|
2051
|
+
|
|
2052
|
+
You can use multiple property changes at once by providing multiple entries in the propertiesToChange object, including _style alongside non-style props.
|
|
2053
|
+
Some properties are nested, use the root property name, then objects with nested values inside, as the complete schema suggests.
|
|
2054
|
+
Nested properties, such as for the _styles, should include a "_styles" property with object containing the definitions to change.
|
|
2055
|
+
|
|
2056
|
+
Make sure you have the "widget-schema-by-type" resource available to retreive the PropType schema for the element type you are configuring.
|
|
2057
|
+
|
|
2058
|
+
# How to configure elements
|
|
2059
|
+
We use a dedicated PropType Schema for configuring elements, including styles. When you configure an element, you must use the EXACT PropType Value as defined in the schema.
|
|
2060
|
+
For _styles, use the style schema provided, as it also uses the PropType format.
|
|
2061
|
+
For all non-primitive types, provide the key property as defined in the schema as $$type in the generated objecct, as it is MANDATORY for parsing.
|
|
2062
|
+
|
|
2063
|
+
Use the EXACT "PROP-TYPE" Schema given, and ALWAYS include the "key" property from the original configuration for every property you are changing.
|
|
2064
|
+
|
|
2065
|
+
# Example
|
|
2066
|
+
\`\`\`json
|
|
2067
|
+
{
|
|
2068
|
+
propertiesToChange: {
|
|
2069
|
+
title: {
|
|
2070
|
+
$$type: 'string',
|
|
2071
|
+
value: 'New Title Text'
|
|
2072
|
+
},
|
|
2073
|
+
border: {
|
|
2074
|
+
$$type: 'boolean',
|
|
2075
|
+
value: false
|
|
2076
|
+
},
|
|
2077
|
+
_styles: {
|
|
2078
|
+
'line-height': {
|
|
2079
|
+
$$type: 'size',
|
|
2080
|
+
value: {
|
|
2081
|
+
size: {
|
|
2082
|
+
$$type: 'number',
|
|
2083
|
+
value: 20
|
|
2084
|
+
},
|
|
2085
|
+
unit: {
|
|
2086
|
+
$$type: 'string',
|
|
2087
|
+
value: 'px'
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
2094
|
+
\`\`\`
|
|
2095
|
+
|
|
2096
|
+
<IMPORTANT>
|
|
2097
|
+
The $$type property is MANDATORY for every value, it is required to parse the value and apply application-level effects.
|
|
2098
|
+
</IMPORTANT>
|
|
2099
|
+
`;
|
|
2100
|
+
|
|
2101
|
+
// src/mcp/tools/configure-element/schema.ts
|
|
2102
|
+
var import_schema3 = require("@elementor/schema");
|
|
2103
|
+
var inputSchema2 = {
|
|
2104
|
+
propertiesToChange: import_schema3.z.record(
|
|
2105
|
+
import_schema3.z.string().describe(
|
|
2106
|
+
"The property name. If nested property, provide the root property name, and the object delta only."
|
|
2107
|
+
),
|
|
2108
|
+
import_schema3.z.any().describe("The property's value")
|
|
2109
|
+
).describe("An object record containing property names and their new values to be set on the element").optional(),
|
|
2110
|
+
elementType: import_schema3.z.string().describe("The type of the element to retreive the schema"),
|
|
2111
|
+
elementId: import_schema3.z.string().describe("The unique id of the element to configure")
|
|
2112
|
+
};
|
|
2113
|
+
var outputSchema2 = {
|
|
2114
|
+
success: import_schema3.z.boolean().describe(
|
|
2115
|
+
"Whether the configuration change was successful, only if propertyName and propertyValue are provided"
|
|
2116
|
+
)
|
|
2117
|
+
};
|
|
2118
|
+
|
|
2119
|
+
// src/mcp/tools/configure-element/tool.ts
|
|
2120
|
+
var initConfigureElementTool = (reg) => {
|
|
2121
|
+
const { addTool } = reg;
|
|
2122
|
+
addTool({
|
|
2123
|
+
name: "configure-element",
|
|
2124
|
+
description: configureElementToolPrompt,
|
|
2125
|
+
schema: inputSchema2,
|
|
2126
|
+
outputSchema: outputSchema2,
|
|
2127
|
+
handler: ({ elementId, propertiesToChange, elementType }) => {
|
|
2128
|
+
if (!propertiesToChange) {
|
|
2129
|
+
throw new Error(
|
|
2130
|
+
"propertiesToChange is required to configure an element. Now that you have this information, ensure you have the schema and try again."
|
|
2131
|
+
);
|
|
2132
|
+
}
|
|
2133
|
+
const toUpdate = Object.entries(propertiesToChange);
|
|
2134
|
+
for (const [propertyName, propertyValue] of toUpdate) {
|
|
2135
|
+
if (!propertyName && !elementId && !elementType) {
|
|
2136
|
+
throw new Error(
|
|
2137
|
+
"propertyName, elementId, elementType are required to configure an element. If you want to retreive the schema, use the get-element-configuration-schema tool."
|
|
2138
|
+
);
|
|
2139
|
+
}
|
|
2140
|
+
try {
|
|
2141
|
+
doUpdateElementProperty({
|
|
2142
|
+
elementId,
|
|
2143
|
+
elementType,
|
|
2144
|
+
propertyName,
|
|
2145
|
+
propertyValue
|
|
2146
|
+
});
|
|
2147
|
+
} catch (error) {
|
|
2148
|
+
const errorMessage = createUpdateErrorMessage({
|
|
2149
|
+
propertyName,
|
|
2150
|
+
elementId,
|
|
2151
|
+
elementType,
|
|
2152
|
+
error
|
|
2153
|
+
});
|
|
2154
|
+
throw new Error(errorMessage);
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
return {
|
|
2158
|
+
success: true
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
});
|
|
2162
|
+
};
|
|
2163
|
+
function createUpdateErrorMessage(opts) {
|
|
2164
|
+
const { propertyName, elementId, elementType, error } = opts;
|
|
2165
|
+
return `Failed to update property "${propertyName}" on element "${elementId}": ${error.message}.
|
|
2166
|
+
Check the element's PropType schema at the resource [${WIDGET_SCHEMA_URI.replace(
|
|
2167
|
+
"{widgetType}",
|
|
2168
|
+
elementType
|
|
2169
|
+
)}] for type "${elementType}" to ensure the property exists and the value matches the expected PropType.
|
|
2170
|
+
Now that you have this information, ensure you have the schema and try again.`;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
// src/mcp/canvas-mcp.ts
|
|
2174
|
+
var initCanvasMcp = (reg) => {
|
|
2175
|
+
const { setMCPDescription } = reg;
|
|
2176
|
+
setMCPDescription(
|
|
2177
|
+
'Everything related to creative design, layout, styling and building the pages, specifically element of type "widget"'
|
|
2178
|
+
);
|
|
2179
|
+
initWidgetsSchemaResource(reg);
|
|
2180
|
+
initBuildCompositionsTool(reg);
|
|
2181
|
+
initConfigureElementTool(reg);
|
|
2182
|
+
};
|
|
2183
|
+
|
|
2184
|
+
// src/mcp/mcp-description.ts
|
|
2185
|
+
var mcpDescription = `Canvas MCP - Working with widgets and styles: how to use the PropType schemas and generate PropValue structures
|
|
2186
|
+
|
|
2187
|
+
# Elementor's PropValue configuration system
|
|
2188
|
+
|
|
2189
|
+
Every widget in Elementor has a set of properties that can be configured. These properties are defined using a strict schema, which specifies the type and structure of each property's value.
|
|
2190
|
+
All values are wrapped in a special structure called a "PropValue", which includes data and additional information about the type of the value.
|
|
2191
|
+
|
|
2192
|
+
To correctly configure a widget's properties, you must follow the PropType schema defined for that widget. This schema outlines the expected structure and types for each property, ensuring that the values you provide are valid and can be properly interpreted by Elementor.
|
|
2193
|
+
Every widget has it's own PropType schema, retreivable from the resource [${WIDGET_SCHEMA_URI}].
|
|
2194
|
+
ALL WIDGETS share a common _styles property with a uniform styles schema, retreivable from the resource [${STYLE_SCHEMA_URI}].
|
|
2195
|
+
The style schema is grouped by categories, such as "typography", "background", "border", etc.
|
|
2196
|
+
|
|
2197
|
+
All array types that can receive union types, are typed as mixed array, which means that each item in the array can be of any of the allowed types defined in the PropType schema.
|
|
2198
|
+
Example: the "background" can have a background-overlay property, which can contain multiple overlays, such as color, gradient, image, etc. Each item in the array must follow the PropType schema for each overlay type.
|
|
2199
|
+
All _style properties are OPTIONAL. When a _style is defined, we MERGE the values with existing styles, so only the properties you define will be changed, and the rest will remain as is.
|
|
2200
|
+
|
|
2201
|
+
When applicable for styles, use the "custom_css" property for free-form CSS styling. This property accepts a string of CSS rules that will be applied directly to the element.
|
|
2202
|
+
The css string must follow standard CSS syntax, with properties and values separated by semicolons, no selectors, or nesting rules allowed.
|
|
2203
|
+
|
|
2204
|
+
Additionaly, some PropTypes have metadata information (meta property) that can help in understaind the PropType usage, such as description or other useful information.
|
|
2205
|
+
|
|
2206
|
+
# Note about null values
|
|
2207
|
+
If a PropValue's value is null, omit the entire PropValue object.
|
|
2208
|
+
|
|
2209
|
+
Example of "image" PropValue structure:
|
|
2210
|
+
|
|
2211
|
+
PropValue structure:
|
|
2212
|
+
{$$type:'image',value:{src:{$$type:'image-src',value:{url:{$$type:'url',value:'https://example.com/image.jpg'}}},size:{$$type:'string',value:'full'}}}
|
|
2213
|
+
|
|
2214
|
+
Example of
|
|
2215
|
+
`;
|
|
2216
|
+
|
|
2217
|
+
// src/prevent-link-in-link-commands.ts
|
|
2218
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
1498
2219
|
var import_editor_notifications = require("@elementor/editor-notifications");
|
|
1499
2220
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
1500
2221
|
var import_i18n = require("@wordpress/i18n");
|
|
@@ -1565,13 +2286,13 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
1565
2286
|
return false;
|
|
1566
2287
|
}
|
|
1567
2288
|
const isSourceContainsAnAnchor = sourceElements.some((src) => {
|
|
1568
|
-
return src?.id ? (0,
|
|
2289
|
+
return src?.id ? (0, import_editor_elements6.isElementAnchored)(src.id) || !!(0, import_editor_elements6.getAnchoredDescendantId)(src.id) : false;
|
|
1569
2290
|
});
|
|
1570
2291
|
if (!isSourceContainsAnAnchor) {
|
|
1571
2292
|
return false;
|
|
1572
2293
|
}
|
|
1573
2294
|
const isTargetContainsAnAnchor = targetElements.some((target) => {
|
|
1574
|
-
return target?.id ? (0,
|
|
2295
|
+
return target?.id ? (0, import_editor_elements6.isElementAnchored)(target.id) || !!(0, import_editor_elements6.getAnchoredAncestorId)(target.id) : false;
|
|
1575
2296
|
});
|
|
1576
2297
|
return isTargetContainsAnAnchor;
|
|
1577
2298
|
}
|
|
@@ -1580,14 +2301,14 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
1580
2301
|
var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
1581
2302
|
|
|
1582
2303
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
1583
|
-
var
|
|
2304
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
1584
2305
|
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
1585
2306
|
var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
|
|
1586
2307
|
var import_i18n3 = require("@wordpress/i18n");
|
|
1587
2308
|
|
|
1588
2309
|
// src/style-commands/utils.ts
|
|
1589
|
-
var
|
|
1590
|
-
var
|
|
2310
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
2311
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
1591
2312
|
var import_i18n2 = require("@wordpress/i18n");
|
|
1592
2313
|
function hasAtomicWidgets(args) {
|
|
1593
2314
|
const { containers = [args.container] } = args;
|
|
@@ -1605,13 +2326,13 @@ function getClassesProp(container) {
|
|
|
1605
2326
|
return null;
|
|
1606
2327
|
}
|
|
1607
2328
|
const [propKey] = Object.entries(propsSchema).find(
|
|
1608
|
-
([, propType]) => propType.kind === "plain" && propType.key ===
|
|
2329
|
+
([, propType]) => propType.kind === "plain" && propType.key === import_editor_props4.CLASSES_PROP_KEY
|
|
1609
2330
|
) ?? [];
|
|
1610
2331
|
return propKey ?? null;
|
|
1611
2332
|
}
|
|
1612
2333
|
function getContainerSchema(container) {
|
|
1613
2334
|
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
1614
|
-
const widgetsCache = (0,
|
|
2335
|
+
const widgetsCache = (0, import_editor_elements7.getWidgetsCache)();
|
|
1615
2336
|
const elementType = widgetsCache?.[type];
|
|
1616
2337
|
return elementType?.atomic_props_schema ?? null;
|
|
1617
2338
|
}
|
|
@@ -1624,7 +2345,7 @@ function getClipboardElements(storageKey = "clipboard") {
|
|
|
1624
2345
|
}
|
|
1625
2346
|
}
|
|
1626
2347
|
function getTitleForContainers(containers) {
|
|
1627
|
-
return containers.length > 1 ? (0, import_i18n2.__)("Elements", "elementor") : (0,
|
|
2348
|
+
return containers.length > 1 ? (0, import_i18n2.__)("Elements", "elementor") : (0, import_editor_elements7.getElementLabel)(containers[0].id);
|
|
1628
2349
|
}
|
|
1629
2350
|
|
|
1630
2351
|
// src/style-commands/undoable-actions/paste-element-style.ts
|
|
@@ -1637,7 +2358,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
1637
2358
|
if (!classesProp) {
|
|
1638
2359
|
return null;
|
|
1639
2360
|
}
|
|
1640
|
-
const originalStyles = (0,
|
|
2361
|
+
const originalStyles = (0, import_editor_elements8.getElementStyles)(container.id);
|
|
1641
2362
|
const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
|
|
1642
2363
|
const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
|
|
1643
2364
|
const revertData = {
|
|
@@ -1646,7 +2367,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
1646
2367
|
};
|
|
1647
2368
|
if (styleId) {
|
|
1648
2369
|
newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
|
|
1649
|
-
(0,
|
|
2370
|
+
(0, import_editor_elements8.updateElementStyle)({
|
|
1650
2371
|
elementId,
|
|
1651
2372
|
styleId,
|
|
1652
2373
|
meta,
|
|
@@ -1657,7 +2378,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
1657
2378
|
} else {
|
|
1658
2379
|
const [firstVariant] = newStyle.variants;
|
|
1659
2380
|
const additionalVariants = newStyle.variants.slice(1);
|
|
1660
|
-
revertData.styleId = (0,
|
|
2381
|
+
revertData.styleId = (0, import_editor_elements8.createElementStyle)({
|
|
1661
2382
|
elementId,
|
|
1662
2383
|
classesProp,
|
|
1663
2384
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -1675,7 +2396,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
1675
2396
|
return;
|
|
1676
2397
|
}
|
|
1677
2398
|
if (!revertData.originalStyle) {
|
|
1678
|
-
(0,
|
|
2399
|
+
(0, import_editor_elements8.deleteElementStyle)(container.id, revertData.styleId);
|
|
1679
2400
|
return;
|
|
1680
2401
|
}
|
|
1681
2402
|
const classesProp = getClassesProp(container);
|
|
@@ -1684,7 +2405,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters9.undoable)(
|
|
|
1684
2405
|
}
|
|
1685
2406
|
const [firstVariant] = revertData.originalStyle.variants;
|
|
1686
2407
|
const additionalVariants = revertData.originalStyle.variants.slice(1);
|
|
1687
|
-
(0,
|
|
2408
|
+
(0, import_editor_elements8.createElementStyle)({
|
|
1688
2409
|
elementId: container.id,
|
|
1689
2410
|
classesProp,
|
|
1690
2411
|
label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
|
|
@@ -1736,7 +2457,7 @@ function pasteStyles(args, pasteCallback) {
|
|
|
1736
2457
|
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
1737
2458
|
|
|
1738
2459
|
// src/style-commands/undoable-actions/reset-element-style.ts
|
|
1739
|
-
var
|
|
2460
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
1740
2461
|
var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
|
|
1741
2462
|
var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
1742
2463
|
var import_i18n4 = require("@wordpress/i18n");
|
|
@@ -1745,9 +2466,9 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters11.undoable)(
|
|
|
1745
2466
|
do: ({ containers }) => {
|
|
1746
2467
|
return containers.map((container) => {
|
|
1747
2468
|
const elementId = container.model.get("id");
|
|
1748
|
-
const containerStyles = (0,
|
|
2469
|
+
const containerStyles = (0, import_editor_elements9.getElementStyles)(elementId);
|
|
1749
2470
|
Object.keys(containerStyles ?? {}).forEach(
|
|
1750
|
-
(styleId) => (0,
|
|
2471
|
+
(styleId) => (0, import_editor_elements9.deleteElementStyle)(elementId, styleId)
|
|
1751
2472
|
);
|
|
1752
2473
|
return containerStyles;
|
|
1753
2474
|
});
|
|
@@ -1763,7 +2484,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters11.undoable)(
|
|
|
1763
2484
|
Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
|
|
1764
2485
|
const [firstVariant] = style.variants;
|
|
1765
2486
|
const additionalVariants = style.variants.slice(1);
|
|
1766
|
-
(0,
|
|
2487
|
+
(0, import_editor_elements9.createElementStyle)({
|
|
1767
2488
|
elementId,
|
|
1768
2489
|
classesProp,
|
|
1769
2490
|
styleId,
|
|
@@ -1832,6 +2553,11 @@ function init() {
|
|
|
1832
2553
|
id: "classes-rename",
|
|
1833
2554
|
component: ClassesRename
|
|
1834
2555
|
});
|
|
2556
|
+
initCanvasMcp(
|
|
2557
|
+
(0, import_editor_mcp3.getMCPByDomain)("canvas", {
|
|
2558
|
+
instructions: mcpDescription
|
|
2559
|
+
})
|
|
2560
|
+
);
|
|
1835
2561
|
}
|
|
1836
2562
|
|
|
1837
2563
|
// src/sync/drag-element-from-panel.ts
|