@elementor/editor-canvas 4.2.0-beta1 → 4.2.0-beta2
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 +126 -54
- package/dist/index.mjs +91 -19
- package/package.json +20 -20
- package/src/__tests__/parse-xml.ts +2 -0
- package/src/components/__tests__/elements-overlays.test.tsx +7 -0
- package/src/components/elements-overlays.tsx +13 -10
- package/src/components/grid-outline/__tests__/grid-outline-overlay.test.tsx +13 -15
- package/src/components/grid-outline/grid-outline-overlay.tsx +3 -4
- package/src/components/outline-overlay.tsx +9 -2
- package/src/composition-builder/composition-builder.ts +12 -0
- package/src/form-structure/__tests__/form-structure-utils.test.ts +218 -0
- package/src/form-structure/enforce-form-ancestor-commands.ts +11 -4
- package/src/form-structure/utils.ts +47 -0
- package/src/mcp/tools/build-composition/tool.ts +9 -2
- package/src/types/element-overlay.ts +2 -0
- package/src/utils/__tests__/outline-offset-utils.test.ts +39 -0
- package/src/utils/outline-offset-utils.ts +11 -0
package/dist/index.js
CHANGED
|
@@ -870,7 +870,6 @@ var GridEmptyCellPositioner = ({ element }) => {
|
|
|
870
870
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
871
871
|
var React6 = __toESM(require("react"));
|
|
872
872
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
873
|
-
var import_editor_props2 = require("@elementor/editor-props");
|
|
874
873
|
var import_ui2 = require("@elementor/ui");
|
|
875
874
|
var import_react11 = require("@floating-ui/react");
|
|
876
875
|
|
|
@@ -971,6 +970,16 @@ var useHasOverlapping = () => {
|
|
|
971
970
|
return hasOverlapping;
|
|
972
971
|
};
|
|
973
972
|
|
|
973
|
+
// src/utils/outline-offset-utils.ts
|
|
974
|
+
var THIN_ELEMENT_MAX_HEIGHT_PX = 1;
|
|
975
|
+
var SMALLER_OUTLINE_OFFSET_WIDGET_TYPES = /* @__PURE__ */ new Set(["e-form-input"]);
|
|
976
|
+
function shouldUseSmallerOutlineOffset(element, widgetType) {
|
|
977
|
+
if (element.offsetHeight <= THIN_ELEMENT_MAX_HEIGHT_PX) {
|
|
978
|
+
return true;
|
|
979
|
+
}
|
|
980
|
+
return widgetType !== void 0 && SMALLER_OUTLINE_OFFSET_WIDGET_TYPES.has(widgetType);
|
|
981
|
+
}
|
|
982
|
+
|
|
974
983
|
// src/components/outline-overlay.tsx
|
|
975
984
|
var CANVAS_WRAPPER_ID = "elementor-preview-responsive-wrapper";
|
|
976
985
|
var OverlayBox = (0, import_ui.styled)(import_ui.Box, {
|
|
@@ -982,12 +991,18 @@ var OverlayBox = (0, import_ui.styled)(import_ui.Box, {
|
|
|
982
991
|
pointerEvents: "none"
|
|
983
992
|
})
|
|
984
993
|
);
|
|
985
|
-
var OutlineOverlay = ({
|
|
994
|
+
var OutlineOverlay = ({
|
|
995
|
+
element,
|
|
996
|
+
isSelected,
|
|
997
|
+
id,
|
|
998
|
+
isGlobal = false,
|
|
999
|
+
widgetType
|
|
1000
|
+
}) => {
|
|
986
1001
|
const { context, floating, isVisible } = useFloatingOnElement({ element, isSelected });
|
|
987
1002
|
const { getFloatingProps, getReferenceProps } = (0, import_react9.useInteractions)([(0, import_react9.useHover)(context)]);
|
|
988
1003
|
const hasOverlapping = useHasOverlapping();
|
|
989
1004
|
useBindReactPropsToElement(element, getReferenceProps);
|
|
990
|
-
const isSmallerOffset = element
|
|
1005
|
+
const isSmallerOffset = shouldUseSmallerOutlineOffset(element, widgetType);
|
|
991
1006
|
return isVisible && !hasOverlapping && /* @__PURE__ */ React.createElement(import_react9.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React.createElement(
|
|
992
1007
|
OverlayBox,
|
|
993
1008
|
{
|
|
@@ -1143,8 +1158,8 @@ function GridOutline({ element, tracks, width, height }) {
|
|
|
1143
1158
|
|
|
1144
1159
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
1145
1160
|
var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
1146
|
-
const
|
|
1147
|
-
const enabled =
|
|
1161
|
+
const settings = (0, import_editor_elements4.useElementEditorSettings)(id);
|
|
1162
|
+
const enabled = settings?.grid_outline;
|
|
1148
1163
|
const rect = useElementRect(element);
|
|
1149
1164
|
const tracks = useGridTracks(element, rect);
|
|
1150
1165
|
const { floating } = useFloatingOnElement({ element, isSelected });
|
|
@@ -1167,9 +1182,10 @@ var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
|
1167
1182
|
};
|
|
1168
1183
|
|
|
1169
1184
|
// src/components/elements-overlays.tsx
|
|
1185
|
+
var hasGridStyleDisplay = (element) => {
|
|
1186
|
+
return element.computedStyleMap().get("display")?.toString() === "grid";
|
|
1187
|
+
};
|
|
1170
1188
|
var ELEMENTS_DATA_ATTR = "atomic";
|
|
1171
|
-
var E_GRID_TYPE = "e-grid";
|
|
1172
|
-
var isGridElement = (element) => [element.dataset.eType, element.dataset.element_type].includes(E_GRID_TYPE);
|
|
1173
1189
|
var overlayRegistry = [
|
|
1174
1190
|
{
|
|
1175
1191
|
component: OutlineOverlay,
|
|
@@ -1177,11 +1193,11 @@ var overlayRegistry = [
|
|
|
1177
1193
|
},
|
|
1178
1194
|
{
|
|
1179
1195
|
component: GridEmptyCellPositioner,
|
|
1180
|
-
shouldRender: ({ element }) =>
|
|
1196
|
+
shouldRender: ({ element }) => hasGridStyleDisplay(element)
|
|
1181
1197
|
},
|
|
1182
1198
|
{
|
|
1183
1199
|
component: GridOutlineOverlay,
|
|
1184
|
-
shouldRender: ({
|
|
1200
|
+
shouldRender: ({ isSelected, element }) => isSelected && hasGridStyleDisplay(element)
|
|
1185
1201
|
}
|
|
1186
1202
|
];
|
|
1187
1203
|
function ElementsOverlays() {
|
|
@@ -1194,17 +1210,18 @@ function ElementsOverlays() {
|
|
|
1194
1210
|
if (!isActive) {
|
|
1195
1211
|
return null;
|
|
1196
1212
|
}
|
|
1197
|
-
return elements.map(({ id, domElement, isGlobal }) => {
|
|
1213
|
+
return elements.map(({ id, domElement, isGlobal, widgetType }) => {
|
|
1198
1214
|
const isSelected = selected.element?.id === id;
|
|
1199
1215
|
return overlayRegistry.map(
|
|
1200
|
-
({ shouldRender, component: Overlay }, index) => shouldRender({ id, element: domElement, isSelected }) && /* @__PURE__ */ React7.createElement(
|
|
1216
|
+
({ shouldRender, component: Overlay }, index) => shouldRender({ id, element: domElement, isSelected, widgetType }) && /* @__PURE__ */ React7.createElement(
|
|
1201
1217
|
Overlay,
|
|
1202
1218
|
{
|
|
1203
1219
|
key: `${id}-${index}`,
|
|
1204
1220
|
id,
|
|
1205
1221
|
element: domElement,
|
|
1206
1222
|
isSelected,
|
|
1207
|
-
isGlobal
|
|
1223
|
+
isGlobal,
|
|
1224
|
+
widgetType
|
|
1208
1225
|
}
|
|
1209
1226
|
)
|
|
1210
1227
|
);
|
|
@@ -1217,7 +1234,8 @@ function useElementsDom() {
|
|
|
1217
1234
|
return (0, import_editor_elements5.getElements)().filter((el) => isV4Element(el.view?.el?.dataset)).map((element) => ({
|
|
1218
1235
|
id: element.id,
|
|
1219
1236
|
domElement: element.view?.getDomElement?.()?.get?.(0),
|
|
1220
|
-
isGlobal: element.model.get("isGlobal") ?? false
|
|
1237
|
+
isGlobal: element.model.get("isGlobal") ?? false,
|
|
1238
|
+
widgetType: element.model.get("widgetType")
|
|
1221
1239
|
})).filter((item) => !!item.domElement);
|
|
1222
1240
|
}
|
|
1223
1241
|
);
|
|
@@ -1467,7 +1485,7 @@ var import_editor_styles = require("@elementor/editor-styles");
|
|
|
1467
1485
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
1468
1486
|
|
|
1469
1487
|
// src/renderers/create-props-resolver.ts
|
|
1470
|
-
var
|
|
1488
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
1471
1489
|
|
|
1472
1490
|
// src/renderers/multi-props.ts
|
|
1473
1491
|
var isMultiProps = (propValue) => {
|
|
@@ -1505,7 +1523,7 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1505
1523
|
if (value === null || value === void 0) {
|
|
1506
1524
|
return null;
|
|
1507
1525
|
}
|
|
1508
|
-
if (!(0,
|
|
1526
|
+
if (!(0, import_editor_props2.isTransformable)(value)) {
|
|
1509
1527
|
return value;
|
|
1510
1528
|
}
|
|
1511
1529
|
if (depth > TRANSFORM_DEPTH_LIMIT) {
|
|
@@ -1563,13 +1581,13 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1563
1581
|
}
|
|
1564
1582
|
|
|
1565
1583
|
// src/renderers/enqueue-font-from-style-prop.ts
|
|
1566
|
-
var
|
|
1584
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
1567
1585
|
var maybeEnqueueFontFromStyleProp = (propType, propValue, enqueue) => {
|
|
1568
|
-
if (!(0,
|
|
1586
|
+
if (!(0, import_editor_props3.isTransformable)(propValue) || propValue.disabled) {
|
|
1569
1587
|
return;
|
|
1570
1588
|
}
|
|
1571
1589
|
const typeKey = propType.kind === "union" ? propValue.$$type : propType.key;
|
|
1572
|
-
const propTypeUtil = (0,
|
|
1590
|
+
const propTypeUtil = (0, import_editor_props3.getPropSchemaFromCache)(typeKey);
|
|
1573
1591
|
if (!propTypeUtil || !("getEnqueueFontFamily" in propTypeUtil) || typeof propTypeUtil.getEnqueueFontFamily !== "function") {
|
|
1574
1592
|
return;
|
|
1575
1593
|
}
|
|
@@ -2030,6 +2048,46 @@ function clipboardRootsAreAtomicForms(elements) {
|
|
|
2030
2048
|
}
|
|
2031
2049
|
return elements.every((el) => getClipboardElementType(el) === FORM_ELEMENT_TYPE);
|
|
2032
2050
|
}
|
|
2051
|
+
function hasFormAncestor(node) {
|
|
2052
|
+
return node.closest(FORM_ELEMENT_TYPE) !== null;
|
|
2053
|
+
}
|
|
2054
|
+
function collectFormAncestorErrors(xml) {
|
|
2055
|
+
const errors = [];
|
|
2056
|
+
for (const node of xml.querySelectorAll("*")) {
|
|
2057
|
+
if (!FORM_FIELD_ELEMENT_TYPES.has(node.tagName.toLowerCase())) {
|
|
2058
|
+
continue;
|
|
2059
|
+
}
|
|
2060
|
+
if (hasFormAncestor(node)) {
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
const id = node.getAttribute("configuration-id");
|
|
2064
|
+
errors.push(
|
|
2065
|
+
`<${node.tagName}${id ? ` configuration-id="${id}"` : ""}> must be nested inside <e-form> (any ancestor depth is allowed).`
|
|
2066
|
+
);
|
|
2067
|
+
}
|
|
2068
|
+
return errors;
|
|
2069
|
+
}
|
|
2070
|
+
function collectSubmitButtonErrors(xml) {
|
|
2071
|
+
const errors = [];
|
|
2072
|
+
for (const form of xml.querySelectorAll("e-form")) {
|
|
2073
|
+
const submitButtons = form.querySelectorAll("e-form-submit-button");
|
|
2074
|
+
if (submitButtons.length === 0) {
|
|
2075
|
+
errors.push(`<e-form> has no <e-form-submit-button>.`);
|
|
2076
|
+
} else if (submitButtons.length > 1) {
|
|
2077
|
+
errors.push(`<e-form> has ${submitButtons.length} submit buttons \u2014 only 1 is allowed.`);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
return errors;
|
|
2081
|
+
}
|
|
2082
|
+
function collectEmptyMessageErrors(xml) {
|
|
2083
|
+
const errors = [];
|
|
2084
|
+
for (const node of xml.querySelectorAll("e-form-success-message, e-form-error-message")) {
|
|
2085
|
+
if (node.children.length === 0) {
|
|
2086
|
+
errors.push(`<${node.tagName}> must have at least one child element (e.g. <e-atomic-paragraph>).`);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
return errors;
|
|
2090
|
+
}
|
|
2033
2091
|
|
|
2034
2092
|
// src/form-structure/enforce-form-ancestor-commands.ts
|
|
2035
2093
|
var FORM_FIELDS_OUTSIDE_ALERT = {
|
|
@@ -2056,7 +2114,8 @@ function blockFormFieldCreate(args) {
|
|
|
2056
2114
|
if (!elementType || !FORM_FIELD_ELEMENT_TYPES.has(elementType)) {
|
|
2057
2115
|
return false;
|
|
2058
2116
|
}
|
|
2059
|
-
|
|
2117
|
+
const containers = args.containers ?? [args.container];
|
|
2118
|
+
if (containers.some((container) => !isWithinForm(container))) {
|
|
2060
2119
|
handleBlockedFormField();
|
|
2061
2120
|
return true;
|
|
2062
2121
|
}
|
|
@@ -2064,10 +2123,10 @@ function blockFormFieldCreate(args) {
|
|
|
2064
2123
|
}
|
|
2065
2124
|
function blockFormFieldMove(args) {
|
|
2066
2125
|
const { containers = [args.container], target } = args;
|
|
2067
|
-
const
|
|
2068
|
-
(container) => container ? hasElementTypes(container, FORM_FIELD_ELEMENT_TYPES) : false
|
|
2126
|
+
const hasLooseFormFields = containers.some(
|
|
2127
|
+
(container) => container ? !hasElementType(container, FORM_ELEMENT_TYPE) && hasElementTypes(container, FORM_FIELD_ELEMENT_TYPES) : false
|
|
2069
2128
|
);
|
|
2070
|
-
if (
|
|
2129
|
+
if (hasLooseFormFields && !isWithinForm(target) && !movedContainersIncludeAtomicFormRoot(containers)) {
|
|
2071
2130
|
handleBlockedFormField();
|
|
2072
2131
|
return true;
|
|
2073
2132
|
}
|
|
@@ -3425,7 +3484,7 @@ var import_client = require("react-dom/client");
|
|
|
3425
3484
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
3426
3485
|
var React11 = __toESM(require("react"));
|
|
3427
3486
|
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3428
|
-
var
|
|
3487
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
3429
3488
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
3430
3489
|
var import_i18n3 = require("@wordpress/i18n");
|
|
3431
3490
|
|
|
@@ -3702,11 +3761,11 @@ var InlineEditingToolbar = ({ anchor, editor, id }) => {
|
|
|
3702
3761
|
};
|
|
3703
3762
|
|
|
3704
3763
|
// src/legacy/replacements/inline-editing/inline-editing-eligibility.ts
|
|
3705
|
-
var
|
|
3764
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
3706
3765
|
var hasKey = (propType) => {
|
|
3707
3766
|
return "key" in propType;
|
|
3708
3767
|
};
|
|
3709
|
-
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([
|
|
3768
|
+
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([import_editor_props4.htmlV3PropTypeUtil.key, import_editor_props4.stringPropTypeUtil.key]);
|
|
3710
3769
|
var isCoreTextPropTypeKey = (key) => {
|
|
3711
3770
|
return TEXT_PROP_TYPE_KEYS.has(key);
|
|
3712
3771
|
};
|
|
@@ -3726,7 +3785,7 @@ var isInlineEditingAllowed = ({ rawValue, propTypeFromSchema }) => {
|
|
|
3726
3785
|
if (rawValue === null || rawValue === void 0) {
|
|
3727
3786
|
return isAllowedBySchema(propTypeFromSchema);
|
|
3728
3787
|
}
|
|
3729
|
-
return
|
|
3788
|
+
return import_editor_props4.htmlV3PropTypeUtil.isValid(rawValue) || import_editor_props4.stringPropTypeUtil.isValid(rawValue);
|
|
3730
3789
|
};
|
|
3731
3790
|
|
|
3732
3791
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
@@ -3811,15 +3870,15 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3811
3870
|
}
|
|
3812
3871
|
getExtractedContentValue() {
|
|
3813
3872
|
const propValue = this.getInlineEditablePropValue();
|
|
3814
|
-
const extracted =
|
|
3815
|
-
return
|
|
3873
|
+
const extracted = import_editor_props5.htmlV3PropTypeUtil.extract(propValue);
|
|
3874
|
+
return import_editor_props5.stringPropTypeUtil.extract(extracted?.content ?? null) ?? "";
|
|
3816
3875
|
}
|
|
3817
3876
|
setContentValue(value) {
|
|
3818
3877
|
const settingKey = this.getInlineEditablePropertyName();
|
|
3819
3878
|
const html = value || "";
|
|
3820
|
-
const parsed = (0,
|
|
3821
|
-
const valueToSave =
|
|
3822
|
-
content: parsed.content ?
|
|
3879
|
+
const parsed = (0, import_editor_props5.parseHtmlChildren)(html);
|
|
3880
|
+
const valueToSave = import_editor_props5.htmlV3PropTypeUtil.create({
|
|
3881
|
+
content: parsed.content ? import_editor_props5.stringPropTypeUtil.create(parsed.content) : null,
|
|
3823
3882
|
children: parsed.children
|
|
3824
3883
|
});
|
|
3825
3884
|
(0, import_editor_v1_adapters13.undoable)(
|
|
@@ -3850,7 +3909,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3850
3909
|
return null;
|
|
3851
3910
|
}
|
|
3852
3911
|
if (propType.kind === "union") {
|
|
3853
|
-
const textKeys = [
|
|
3912
|
+
const textKeys = [import_editor_props5.htmlV3PropTypeUtil.key, import_editor_props5.stringPropTypeUtil.key];
|
|
3854
3913
|
for (const key of textKeys) {
|
|
3855
3914
|
if (propType.prop_types[key]) {
|
|
3856
3915
|
return key;
|
|
@@ -3879,7 +3938,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3879
3938
|
getExpectedTag() {
|
|
3880
3939
|
const tagPropType = this.getTagPropType();
|
|
3881
3940
|
const tagSettingKey = "tag";
|
|
3882
|
-
return
|
|
3941
|
+
return import_editor_props5.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props5.stringPropTypeUtil.extract(tagPropType?.default ?? null) ?? null;
|
|
3883
3942
|
}
|
|
3884
3943
|
getTagPropType() {
|
|
3885
3944
|
const propsSchema = (0, import_editor_elements9.getElementType)(this.type)?.propsSchema;
|
|
@@ -4106,7 +4165,7 @@ function createNestedTemplatedType(type, renderer, element) {
|
|
|
4106
4165
|
}
|
|
4107
4166
|
|
|
4108
4167
|
// src/legacy/tabs-model-extensions.ts
|
|
4109
|
-
var
|
|
4168
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
4110
4169
|
var tabModelExtensions = {
|
|
4111
4170
|
modifyDefaultChildren(elements) {
|
|
4112
4171
|
if (!Array.isArray(elements) || elements.length === 0) {
|
|
@@ -4122,8 +4181,8 @@ var tabModelExtensions = {
|
|
|
4122
4181
|
...paragraphElement,
|
|
4123
4182
|
settings: {
|
|
4124
4183
|
...paragraphElement.settings,
|
|
4125
|
-
paragraph:
|
|
4126
|
-
content:
|
|
4184
|
+
paragraph: import_editor_props6.htmlV3PropTypeUtil.create({
|
|
4185
|
+
content: import_editor_props6.stringPropTypeUtil.create(`Tab ${position}`),
|
|
4127
4186
|
children: []
|
|
4128
4187
|
})
|
|
4129
4188
|
}
|
|
@@ -4136,7 +4195,7 @@ function initTabsModelExtensions() {
|
|
|
4136
4195
|
}
|
|
4137
4196
|
|
|
4138
4197
|
// src/mcp/canvas-mcp.ts
|
|
4139
|
-
var
|
|
4198
|
+
var import_editor_props11 = require("@elementor/editor-props");
|
|
4140
4199
|
|
|
4141
4200
|
// src/mcp/resources/available-widgets-resource.ts
|
|
4142
4201
|
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
@@ -4288,7 +4347,7 @@ function extractElementData(element) {
|
|
|
4288
4347
|
}
|
|
4289
4348
|
|
|
4290
4349
|
// src/mcp/resources/dynamic-tags-resource.ts
|
|
4291
|
-
var
|
|
4350
|
+
var import_editor_props7 = require("@elementor/editor-props");
|
|
4292
4351
|
|
|
4293
4352
|
// src/mcp/utils/resolve-dynamic-tag.ts
|
|
4294
4353
|
var import_editor_v1_adapters17 = require("@elementor/editor-v1-adapters");
|
|
@@ -4356,7 +4415,7 @@ var defaultSettingValue = (propType) => {
|
|
|
4356
4415
|
var DYNAMIC_TAGS_URI = "elementor://dynamic-tags";
|
|
4357
4416
|
var settingsSchema = (propsSchema) => {
|
|
4358
4417
|
return Object.fromEntries(
|
|
4359
|
-
Object.entries(propsSchema ?? {}).filter(([key]) => !OMITTED_DYNAMIC_SETTING_KEYS.includes(key)).map(([key, propType]) => [key,
|
|
4418
|
+
Object.entries(propsSchema ?? {}).filter(([key]) => !OMITTED_DYNAMIC_SETTING_KEYS.includes(key)).map(([key, propType]) => [key, import_editor_props7.Schema.propTypeToJsonSchema(propType)])
|
|
4360
4419
|
);
|
|
4361
4420
|
};
|
|
4362
4421
|
var buildDynamicTagsList = () => {
|
|
@@ -4713,7 +4772,7 @@ var import_editor_elements15 = require("@elementor/editor-elements");
|
|
|
4713
4772
|
|
|
4714
4773
|
// src/mcp/utils/do-update-element-property.ts
|
|
4715
4774
|
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4716
|
-
var
|
|
4775
|
+
var import_editor_props8 = require("@elementor/editor-props");
|
|
4717
4776
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
4718
4777
|
var import_editor_v1_adapters21 = require("@elementor/editor-v1-adapters");
|
|
4719
4778
|
|
|
@@ -4790,7 +4849,7 @@ var LOCAL_STYLE_META = {
|
|
|
4790
4849
|
};
|
|
4791
4850
|
function resolvePropValue(value, forceKey) {
|
|
4792
4851
|
const Utils = window.elementorV2.editorVariables.Utils;
|
|
4793
|
-
return
|
|
4852
|
+
return import_editor_props8.Schema.adjustLlmPropValueSchema(value, {
|
|
4794
4853
|
forceKey,
|
|
4795
4854
|
transformers: {
|
|
4796
4855
|
...Utils.globalVariablesLLMResolvers,
|
|
@@ -4849,7 +4908,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4849
4908
|
}
|
|
4850
4909
|
if (propertyRawSchema.kind === "plain") {
|
|
4851
4910
|
if (typeof propertyMapValue[stylePropName] !== "object") {
|
|
4852
|
-
const propUtil = (0,
|
|
4911
|
+
const propUtil = (0, import_editor_props8.getPropSchemaFromCache)(propertyRawSchema.key);
|
|
4853
4912
|
if (propUtil) {
|
|
4854
4913
|
const plainValue = propUtil.create(propertyMapValue[stylePropName]);
|
|
4855
4914
|
propertyMapValue[stylePropName] = plainValue;
|
|
@@ -4902,7 +4961,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4902
4961
|
}
|
|
4903
4962
|
const propKey = elementPropSchema[propertyName].key;
|
|
4904
4963
|
const value = resolvePropValue(propertyValue, propKey);
|
|
4905
|
-
const { valid, jsonSchema } =
|
|
4964
|
+
const { valid, jsonSchema } = import_editor_props8.Schema.validatePropValue(elementPropSchema[propertyName], propertyValue);
|
|
4906
4965
|
if (!valid) {
|
|
4907
4966
|
throw new Error(
|
|
4908
4967
|
`Invalid PropValue for elementId: ${elementId}. PropKey: ${propKey}, PropValue: ${JSON.stringify(
|
|
@@ -5173,6 +5232,11 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
5173
5232
|
throw new Error(`Invalid element structure:
|
|
5174
5233
|
${childTypeErrors.join("\n")}`);
|
|
5175
5234
|
}
|
|
5235
|
+
const formErrors = [
|
|
5236
|
+
...collectFormAncestorErrors(this.xml),
|
|
5237
|
+
...collectSubmitButtonErrors(this.xml),
|
|
5238
|
+
...collectEmptyMessageErrors(this.xml)
|
|
5239
|
+
];
|
|
5176
5240
|
const children = Array.from(this.xml.children);
|
|
5177
5241
|
for (const childNode of children) {
|
|
5178
5242
|
const modelTree = this.buildModelTree(childNode, widgetsCache);
|
|
@@ -5207,6 +5271,7 @@ ${childTypeErrors.join("\n")}`);
|
|
|
5207
5271
|
return {
|
|
5208
5272
|
configErrors,
|
|
5209
5273
|
styleErrors,
|
|
5274
|
+
formErrors,
|
|
5210
5275
|
rootContainers: [...this.rootContainers]
|
|
5211
5276
|
};
|
|
5212
5277
|
}
|
|
@@ -5517,7 +5582,11 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5517
5582
|
compositionBuilder.setElementConfig(elementConfig);
|
|
5518
5583
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
5519
5584
|
compositionBuilder.setCustomCSS(customCSS);
|
|
5520
|
-
const {
|
|
5585
|
+
const {
|
|
5586
|
+
configErrors,
|
|
5587
|
+
formErrors,
|
|
5588
|
+
rootContainers: generatedRootContainers
|
|
5589
|
+
} = await compositionBuilder.build(targetContainer);
|
|
5521
5590
|
rootContainers.push(...generatedRootContainers);
|
|
5522
5591
|
generatedXML = new XMLSerializer().serializeToString(compositionBuilder.getXML());
|
|
5523
5592
|
rootContainers.forEach((container) => {
|
|
@@ -5532,6 +5601,9 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5532
5601
|
if (configErrors.length) {
|
|
5533
5602
|
errors.push(...configErrors.map((msg) => new Error(msg)));
|
|
5534
5603
|
}
|
|
5604
|
+
if (formErrors.length) {
|
|
5605
|
+
errors.push(...formErrors.map((msg) => new Error(msg)));
|
|
5606
|
+
}
|
|
5535
5607
|
} catch (error) {
|
|
5536
5608
|
errors.push(error);
|
|
5537
5609
|
}
|
|
@@ -5647,7 +5719,7 @@ function onElementAdded(element) {
|
|
|
5647
5719
|
// src/mcp/tools/configure-element/tool.ts
|
|
5648
5720
|
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
5649
5721
|
var import_editor_mcp5 = require("@elementor/editor-mcp");
|
|
5650
|
-
var
|
|
5722
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
5651
5723
|
|
|
5652
5724
|
// src/mcp/tools/configure-element/prompt.ts
|
|
5653
5725
|
var import_editor_mcp4 = require("@elementor/editor-mcp");
|
|
@@ -5836,7 +5908,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
5836
5908
|
const propertiesToUpdate = resolveCanonicalPropKeys(elementType, propertiesToChange);
|
|
5837
5909
|
const toUpdate = Object.entries(propertiesToUpdate);
|
|
5838
5910
|
for (const [propertyName, propertyValue] of toUpdate) {
|
|
5839
|
-
if (!
|
|
5911
|
+
if (!import_editor_props9.Schema.isPropKeyConfigurable(propertyName)) {
|
|
5840
5912
|
throw new Error(`Not allowed to update ${propertyName}`);
|
|
5841
5913
|
}
|
|
5842
5914
|
try {
|
|
@@ -5913,7 +5985,7 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5913
5985
|
|
|
5914
5986
|
// src/mcp/tools/get-element-config/tool.ts
|
|
5915
5987
|
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5916
|
-
var
|
|
5988
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
5917
5989
|
var import_schema5 = require("@elementor/schema");
|
|
5918
5990
|
var schema = {
|
|
5919
5991
|
elementId: import_schema5.z.string()
|
|
@@ -5970,7 +6042,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5970
6042
|
}
|
|
5971
6043
|
const propValues = {};
|
|
5972
6044
|
const stylePropValues = {};
|
|
5973
|
-
|
|
6045
|
+
import_editor_props10.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
5974
6046
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
5975
6047
|
});
|
|
5976
6048
|
const elementStyles = (0, import_editor_elements18.getElementStyles)(elementId) || {};
|
|
@@ -6006,7 +6078,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
6006
6078
|
|
|
6007
6079
|
// src/mcp/canvas-mcp.ts
|
|
6008
6080
|
var initCanvasMcp = (reg) => {
|
|
6009
|
-
|
|
6081
|
+
import_editor_props11.Schema.setDynamicTagNamesResolver(getDynamicTagNamesByCategories);
|
|
6010
6082
|
initWidgetsSchemaResource(reg);
|
|
6011
6083
|
initAvailableWidgetsResource(reg);
|
|
6012
6084
|
initDocumentStructureResource(reg);
|
|
@@ -6213,12 +6285,12 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
6213
6285
|
|
|
6214
6286
|
// src/style-commands/paste-style.ts
|
|
6215
6287
|
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
6216
|
-
var
|
|
6288
|
+
var import_editor_props13 = require("@elementor/editor-props");
|
|
6217
6289
|
var import_editor_v1_adapters24 = require("@elementor/editor-v1-adapters");
|
|
6218
6290
|
|
|
6219
6291
|
// src/utils/command-utils.ts
|
|
6220
6292
|
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
6221
|
-
var
|
|
6293
|
+
var import_editor_props12 = require("@elementor/editor-props");
|
|
6222
6294
|
var import_i18n5 = require("@wordpress/i18n");
|
|
6223
6295
|
function hasAtomicWidgets(args) {
|
|
6224
6296
|
const { containers = [args.container] } = args;
|
|
@@ -6236,7 +6308,7 @@ function getClassesProp(container) {
|
|
|
6236
6308
|
return null;
|
|
6237
6309
|
}
|
|
6238
6310
|
const [propKey] = Object.entries(propsSchema).find(
|
|
6239
|
-
([, propType]) => propType.kind === "plain" && propType.key ===
|
|
6311
|
+
([, propType]) => propType.kind === "plain" && propType.key === import_editor_props12.CLASSES_PROP_KEY
|
|
6240
6312
|
) ?? [];
|
|
6241
6313
|
return propKey ?? null;
|
|
6242
6314
|
}
|
|
@@ -6385,8 +6457,8 @@ function pasteClasses(containers, classes) {
|
|
|
6385
6457
|
return;
|
|
6386
6458
|
}
|
|
6387
6459
|
const classesSetting = (0, import_editor_elements22.getElementSetting)(container.id, classesProp);
|
|
6388
|
-
const currentClasses =
|
|
6389
|
-
const newClasses =
|
|
6460
|
+
const currentClasses = import_editor_props13.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
6461
|
+
const newClasses = import_editor_props13.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
6390
6462
|
(0, import_editor_elements22.updateElementSettings)({
|
|
6391
6463
|
id: container.id,
|
|
6392
6464
|
props: { [classesProp]: newClasses }
|