@elementor/editor-components 4.0.0-496 → 4.0.0-497
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 +43 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/mcp/save-as-component-tool.ts +48 -18
package/dist/index.js
CHANGED
|
@@ -4555,12 +4555,14 @@ var InputSchema = {
|
|
|
4555
4555
|
),
|
|
4556
4556
|
label: import_schema6.z.string().describe(
|
|
4557
4557
|
'A unique, user-friendly display name for this property (e.g., "Hero Headline", "CTA Button Text"). Must be unique within the same component.'
|
|
4558
|
-
)
|
|
4558
|
+
),
|
|
4559
|
+
group: import_schema6.z.string().optional().describe("Non unique, optional property grouping")
|
|
4559
4560
|
})
|
|
4560
4561
|
)
|
|
4561
4562
|
}).optional().describe(
|
|
4562
4563
|
'Overridable properties configuration. Specify which CHILD element properties can be customized. Only elementId and propKey are required; To get the available propKeys for a child element you must use the "get-element-type-config" tool.'
|
|
4563
|
-
)
|
|
4564
|
+
),
|
|
4565
|
+
groups: import_schema6.z.array(import_schema6.z.string()).describe("Property Groups, by order, unique values").optional()
|
|
4564
4566
|
};
|
|
4565
4567
|
var OutputSchema = {
|
|
4566
4568
|
message: import_schema6.z.string().optional().describe("Additional information about the operation result"),
|
|
@@ -4572,7 +4574,12 @@ var ERROR_MESSAGES3 = {
|
|
|
4572
4574
|
ELEMENT_IS_LOCKED: "Cannot save a locked element as a component."
|
|
4573
4575
|
};
|
|
4574
4576
|
var handleSaveAsComponent = async (params) => {
|
|
4575
|
-
const {
|
|
4577
|
+
const {
|
|
4578
|
+
groups = [],
|
|
4579
|
+
element_id: elementId,
|
|
4580
|
+
component_name: componentName,
|
|
4581
|
+
overridable_props: overridablePropsInput
|
|
4582
|
+
} = params;
|
|
4576
4583
|
const validElementTypes = getValidElementTypes();
|
|
4577
4584
|
const container = (0, import_editor_elements18.getContainer)(elementId);
|
|
4578
4585
|
if (!container) {
|
|
@@ -4586,7 +4593,13 @@ var handleSaveAsComponent = async (params) => {
|
|
|
4586
4593
|
if (element?.isLocked) {
|
|
4587
4594
|
throw new Error(ERROR_MESSAGES3.ELEMENT_IS_LOCKED);
|
|
4588
4595
|
}
|
|
4589
|
-
const
|
|
4596
|
+
const groupsWithDefaultGroup = groups.indexOf("Default") >= 0 ? [...groups] : ["Default", ...groups];
|
|
4597
|
+
const propertyGroups = groupsWithDefaultGroup.map((groupName) => ({
|
|
4598
|
+
id: (0, import_utils9.generateUniqueId)("group"),
|
|
4599
|
+
label: groupName,
|
|
4600
|
+
props: []
|
|
4601
|
+
}));
|
|
4602
|
+
const overridableProps = overridablePropsInput ? enrichOverridableProps(overridablePropsInput, element, propertyGroups) : void 0;
|
|
4590
4603
|
if (overridableProps) {
|
|
4591
4604
|
updateElementDataWithOverridableProps(element, overridableProps);
|
|
4592
4605
|
}
|
|
@@ -4617,11 +4630,17 @@ var handleSaveAsComponent = async (params) => {
|
|
|
4617
4630
|
component_uid: uid
|
|
4618
4631
|
};
|
|
4619
4632
|
};
|
|
4620
|
-
function enrichOverridableProps(input, rootElement) {
|
|
4633
|
+
function enrichOverridableProps(input, rootElement, propertGroups) {
|
|
4621
4634
|
const enrichedProps = {};
|
|
4622
|
-
const
|
|
4635
|
+
const enrichedGroups = {};
|
|
4636
|
+
const defaultGroup = propertGroups.find((g) => g.label === "Default");
|
|
4637
|
+
if (!defaultGroup) {
|
|
4638
|
+
throw new Error("Internal mcp error: could not generate default group");
|
|
4639
|
+
}
|
|
4623
4640
|
Object.entries(input.props).forEach(([, prop]) => {
|
|
4624
|
-
const { elementId, propKey, label } = prop;
|
|
4641
|
+
const { elementId, propKey, label, group = "Default" } = prop;
|
|
4642
|
+
const targetGroup = propertGroups.find((g) => g.label === group) || defaultGroup;
|
|
4643
|
+
const targetGroupId = targetGroup.id;
|
|
4625
4644
|
const element = findElementById(rootElement, elementId);
|
|
4626
4645
|
if (!element) {
|
|
4627
4646
|
throw new Error(`Element with ID "${elementId}" not found in component`);
|
|
@@ -4642,6 +4661,14 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
4642
4661
|
}
|
|
4643
4662
|
const overrideKey = (0, import_utils9.generateUniqueId)("prop");
|
|
4644
4663
|
const originValue = element.settings?.[propKey] ? element.settings[propKey] : elementType.propsSchema[propKey].default ?? null;
|
|
4664
|
+
if (!enrichedGroups[targetGroupId]) {
|
|
4665
|
+
enrichedGroups[targetGroupId] = {
|
|
4666
|
+
id: targetGroupId,
|
|
4667
|
+
label: targetGroup.label,
|
|
4668
|
+
props: []
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
enrichedGroups[targetGroupId].props.push(overrideKey);
|
|
4645
4672
|
enrichedProps[overrideKey] = {
|
|
4646
4673
|
overrideKey,
|
|
4647
4674
|
label,
|
|
@@ -4650,20 +4677,14 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
4650
4677
|
elType,
|
|
4651
4678
|
widgetType,
|
|
4652
4679
|
originValue,
|
|
4653
|
-
groupId:
|
|
4680
|
+
groupId: targetGroupId
|
|
4654
4681
|
};
|
|
4655
4682
|
});
|
|
4656
4683
|
return {
|
|
4657
4684
|
props: enrichedProps,
|
|
4658
4685
|
groups: {
|
|
4659
|
-
items:
|
|
4660
|
-
|
|
4661
|
-
id: defaultGroupId,
|
|
4662
|
-
label: "Default",
|
|
4663
|
-
props: Object.keys(enrichedProps)
|
|
4664
|
-
}
|
|
4665
|
-
},
|
|
4666
|
-
order: [defaultGroupId]
|
|
4686
|
+
items: enrichedGroups,
|
|
4687
|
+
order: [defaultGroup.id]
|
|
4667
4688
|
}
|
|
4668
4689
|
};
|
|
4669
4690
|
}
|
|
@@ -4828,17 +4849,20 @@ Component with overridable properties:
|
|
|
4828
4849
|
"heading-text": {
|
|
4829
4850
|
"elementId": "heading-123",
|
|
4830
4851
|
"propKey": "text",
|
|
4831
|
-
"label": "Card Title"
|
|
4852
|
+
"label": "Card Title",
|
|
4853
|
+
"group": "Content"
|
|
4832
4854
|
},
|
|
4833
4855
|
"button-text": {
|
|
4834
4856
|
"elementId": "button-456",
|
|
4835
4857
|
"propKey": "text",
|
|
4836
|
-
"label": "Button Text"
|
|
4858
|
+
"label": "Button Text",
|
|
4859
|
+
"group": "Content"
|
|
4837
4860
|
},
|
|
4838
4861
|
"button-link": {
|
|
4839
4862
|
"elementId": "button-456",
|
|
4840
4863
|
"propKey": "url",
|
|
4841
|
-
"label": "Button Link"
|
|
4864
|
+
"label": "Button Link",
|
|
4865
|
+
"group": "Settings"
|
|
4842
4866
|
}
|
|
4843
4867
|
}
|
|
4844
4868
|
}
|