@elementor/editor-canvas 4.0.0-573 → 4.0.0-597

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 CHANGED
@@ -1027,7 +1027,13 @@ var import_i18n = require("@wordpress/i18n");
1027
1027
  // src/form-structure/utils.ts
1028
1028
  var import_editor_elements3 = require("@elementor/editor-elements");
1029
1029
  var FORM_ELEMENT_TYPE = "e-form";
1030
- var FORM_FIELD_ELEMENT_TYPES = /* @__PURE__ */ new Set(["e-form-input", "e-form-textarea", "e-form-label"]);
1030
+ var FORM_FIELD_ELEMENT_TYPES = /* @__PURE__ */ new Set([
1031
+ "e-form-input",
1032
+ "e-form-textarea",
1033
+ "e-form-label",
1034
+ "e-form-checkbox",
1035
+ "e-form-submit-button"
1036
+ ]);
1031
1037
  function getArgsElementType(args) {
1032
1038
  return args.model?.widgetType || args.model?.elType;
1033
1039
  }
@@ -1243,6 +1249,11 @@ var htmlV2Transformer = createTransformer((value) => {
1243
1249
  return value?.content ?? "";
1244
1250
  });
1245
1251
 
1252
+ // src/transformers/settings/html-v3-transformer.ts
1253
+ var htmlV3Transformer = createTransformer((value) => {
1254
+ return value?.content ?? "";
1255
+ });
1256
+
1246
1257
  // src/transformers/settings/link-transformer.ts
1247
1258
  var linkTransformer = createTransformer(({ destination, isTargetBlank, tag }) => {
1248
1259
  return {
@@ -1297,7 +1308,7 @@ var plainTransformer = createTransformer((value) => {
1297
1308
 
1298
1309
  // src/init-settings-transformers.ts
1299
1310
  function initSettingsTransformers() {
1300
- settingsTransformersRegistry.register("classes", createClassesTransformer()).register("link", linkTransformer).register("query", queryTransformer).register("image", imageTransformer).register("image-src", imageSrcTransformer).register("attributes", attributesTransformer).register("date-time", dateTimeTransformer).register("html-v2", htmlV2Transformer).registerFallback(plainTransformer);
1311
+ settingsTransformersRegistry.register("classes", createClassesTransformer()).register("link", linkTransformer).register("query", queryTransformer).register("image", imageTransformer).register("image-src", imageSrcTransformer).register("attributes", attributesTransformer).register("date-time", dateTimeTransformer).register("html-v2", htmlV2Transformer).register("html-v3", htmlV3Transformer).registerFallback(plainTransformer);
1301
1312
  }
1302
1313
 
1303
1314
  // src/transformers/styles/background-color-overlay-transformer.ts
@@ -2206,67 +2217,130 @@ var ReplacementBase = class {
2206
2217
 
2207
2218
  // src/legacy/replacements/inline-editing/canvas-inline-editor.tsx
2208
2219
  var React5 = __toESM(require("react"));
2209
- var import_react11 = require("react");
2220
+ var import_react12 = require("react");
2210
2221
  var import_editor_controls2 = require("@elementor/editor-controls");
2211
2222
  var import_ui4 = require("@elementor/ui");
2212
- var import_react12 = require("@floating-ui/react");
2223
+ var import_react13 = require("@floating-ui/react");
2213
2224
 
2214
2225
  // src/legacy/replacements/inline-editing/inline-editing-utils.ts
2226
+ var import_react11 = require("react");
2227
+ var TOP_BAR_SELECTOR = "#elementor-editor-wrapper-v2";
2228
+ var NAVIGATOR_SELECTOR = "#elementor-navigator";
2229
+ var EDITING_PANEL = "#elementor-panel";
2230
+ var EDITOR_ELEMENTS_OUT_OF_IFRAME = [TOP_BAR_SELECTOR, NAVIGATOR_SELECTOR, EDITING_PANEL];
2231
+ var TOOLBAR_ANCHOR_ID_PREFIX = "inline-editing-toolbar-anchor";
2232
+ var TOOLBAR_ANCHOR_STATIC_STYLES = {
2233
+ backgroundColor: "transparent",
2234
+ border: "none",
2235
+ outline: "none",
2236
+ boxShadow: "none",
2237
+ padding: "0",
2238
+ margin: "0",
2239
+ borderRadius: "0",
2240
+ overflow: "hidden",
2241
+ opacity: "0",
2242
+ pointerEvents: "none",
2243
+ position: "absolute",
2244
+ display: "block"
2245
+ };
2215
2246
  var INLINE_EDITING_PROPERTY_PER_TYPE = {
2216
2247
  "e-button": "text",
2217
2248
  "e-form-label": "text",
2218
2249
  "e-heading": "title",
2219
2250
  "e-paragraph": "paragraph"
2220
2251
  };
2221
- var calcSelectionCenterOffsets = (view) => {
2222
- const frameWindow = view.root?.defaultView;
2252
+ var getInlineEditorElement = (elementWrapper, expectedTag) => {
2253
+ return !expectedTag ? null : elementWrapper.querySelector(expectedTag);
2254
+ };
2255
+ var useOnClickOutsideIframe = (handleUnmount) => {
2256
+ const asyncUnmountInlineEditor = (0, import_react11.useCallback)(() => queueMicrotask(handleUnmount), [handleUnmount]);
2257
+ (0, import_react11.useEffect)(() => {
2258
+ EDITOR_ELEMENTS_OUT_OF_IFRAME.forEach(
2259
+ (selector) => document?.querySelector(selector)?.addEventListener("mousedown", asyncUnmountInlineEditor)
2260
+ );
2261
+ return () => EDITOR_ELEMENTS_OUT_OF_IFRAME.forEach(
2262
+ (selector) => document?.querySelector(selector)?.removeEventListener("mousedown", asyncUnmountInlineEditor)
2263
+ );
2264
+ }, []);
2265
+ };
2266
+ var useRenderToolbar = (ownerDocument, id) => {
2267
+ const [anchor, setAnchor] = (0, import_react11.useState)(null);
2268
+ const onSelectionEnd = (view) => {
2269
+ const hasSelection = !view.state.selection.empty;
2270
+ removeToolbarAnchor(ownerDocument, id);
2271
+ if (hasSelection) {
2272
+ setAnchor(createAnchorBasedOnSelection(ownerDocument, id));
2273
+ } else {
2274
+ setAnchor(null);
2275
+ }
2276
+ };
2277
+ return { onSelectionEnd, anchor };
2278
+ };
2279
+ var createAnchorBasedOnSelection = (ownerDocument, id) => {
2280
+ const frameWindow = ownerDocument.defaultView;
2223
2281
  const selection = frameWindow?.getSelection();
2224
- const editorContainer = view.dom;
2225
- if (!selection || !editorContainer) {
2282
+ if (!selection) {
2226
2283
  return null;
2227
2284
  }
2228
2285
  const range = selection.getRangeAt(0);
2229
2286
  const selectionRect = range.getBoundingClientRect();
2230
- const editorContainerRect = editorContainer.getBoundingClientRect();
2231
- if (!selectionRect || !editorContainerRect) {
2232
- return null;
2287
+ const bodyRect = ownerDocument.body.getBoundingClientRect();
2288
+ const toolbarAnchor = ownerDocument.createElement("span");
2289
+ styleToolbarAnchor(toolbarAnchor, selectionRect, bodyRect);
2290
+ toolbarAnchor.setAttribute("id", getToolbarAnchorId(id));
2291
+ ownerDocument.body.appendChild(toolbarAnchor);
2292
+ return toolbarAnchor;
2293
+ };
2294
+ var removeToolbarAnchor = (ownerDocument, id) => {
2295
+ const toolbarAnchor = getToolbarAnchor(ownerDocument, id);
2296
+ if (toolbarAnchor) {
2297
+ ownerDocument.body.removeChild(toolbarAnchor);
2233
2298
  }
2234
- const verticalOffset = selectionRect.top - editorContainerRect.top;
2235
- const selectionCenter = selectionRect?.left + selectionRect?.width / 2;
2236
- const horizontalOffset = selectionCenter - editorContainerRect.left;
2237
- return { left: horizontalOffset, top: verticalOffset };
2238
2299
  };
2239
- var getComputedStyle = (styles, offsets) => {
2240
- const transform = extractTransformValue(styles);
2241
- return transform ? {
2242
- ...styles,
2243
- marginLeft: `${offsets.left}px`,
2244
- marginTop: `${offsets.top}px`,
2245
- pointerEvents: "none"
2246
- } : {
2247
- display: "none"
2248
- };
2300
+ var getToolbarAnchorId = (id) => `${TOOLBAR_ANCHOR_ID_PREFIX}-${id}`;
2301
+ var getToolbarAnchor = (ownerDocument, id) => ownerDocument.getElementById(getToolbarAnchorId(id));
2302
+ var styleToolbarAnchor = (anchor, selectionRect, bodyRect) => {
2303
+ const { width, height } = selectionRect;
2304
+ Object.assign(anchor.style, {
2305
+ ...TOOLBAR_ANCHOR_STATIC_STYLES,
2306
+ top: `${selectionRect.top - bodyRect.top}px`,
2307
+ left: `${selectionRect.left - bodyRect.left}px`,
2308
+ width: `${width}px`,
2309
+ height: `${height}px`
2310
+ });
2249
2311
  };
2250
- var extractTransformValue = (styles) => {
2251
- const translateRegex = /translate\([^)]*\)\s?/g;
2252
- const numericValuesRegex = /(-?\d+\.?\d*)/g;
2253
- const translateValue = styles?.transform?.match(translateRegex)?.[0];
2254
- const values = translateValue?.match(numericValuesRegex);
2255
- if (!translateValue || !values) {
2256
- return null;
2257
- }
2258
- const [numericX, numericY] = values.map(Number);
2259
- if (!numericX || !numericY) {
2260
- return null;
2312
+ var horizontalShifterMiddleware = {
2313
+ name: "horizontalShifter",
2314
+ fn(state) {
2315
+ const {
2316
+ x: left,
2317
+ y: top,
2318
+ elements: { reference: anchor, floating }
2319
+ } = state;
2320
+ const newState = {
2321
+ ...state,
2322
+ x: left,
2323
+ y: top
2324
+ };
2325
+ const isLeftOverflown = left < 0;
2326
+ if (isLeftOverflown) {
2327
+ newState.x = 0;
2328
+ return newState;
2329
+ }
2330
+ const anchorRect = anchor.getBoundingClientRect();
2331
+ const right = left + floating.offsetWidth;
2332
+ const documentWidth = anchor.ownerDocument.body.offsetWidth;
2333
+ const isRightOverflown = right > documentWidth && anchorRect.right < right;
2334
+ if (isRightOverflown) {
2335
+ const diff = right - documentWidth;
2336
+ newState.x = left - diff;
2337
+ return newState;
2338
+ }
2339
+ return newState;
2261
2340
  }
2262
- return styles.transform;
2263
2341
  };
2264
2342
 
2265
2343
  // src/legacy/replacements/inline-editing/canvas-inline-editor.tsx
2266
- var TOP_BAR_SELECTOR = "#elementor-editor-wrapper-v2";
2267
- var NAVIGATOR_SELECTOR = "#elementor-navigator";
2268
- var EDITING_PANEL = "#elementor-panel";
2269
- var EDITOR_ELEMENTS_OUT_OF_IFRAME = [TOP_BAR_SELECTOR, NAVIGATOR_SELECTOR, EDITING_PANEL];
2270
2344
  var EDITOR_WRAPPER_SELECTOR = "inline-editor-wrapper";
2271
2345
  var CanvasInlineEditor = ({
2272
2346
  elementClasses,
@@ -2275,23 +2349,23 @@ var CanvasInlineEditor = ({
2275
2349
  rootElement,
2276
2350
  id,
2277
2351
  setValue,
2278
- onBlur
2352
+ ...props
2279
2353
  }) => {
2280
- const [selectionOffsets, setSelectionOffsets] = (0, import_react11.useState)(null);
2281
- const [editor, setEditor] = (0, import_react11.useState)(null);
2282
- const onSelectionEnd = (view) => {
2283
- const hasSelection = !view.state.selection.empty;
2284
- setSelectionOffsets(hasSelection ? calcSelectionCenterOffsets(view) : null);
2354
+ const [editor, setEditor] = (0, import_react12.useState)(null);
2355
+ const { onSelectionEnd, anchor: toolbarAnchor } = useRenderToolbar(rootElement.ownerDocument, id);
2356
+ const onBlur = () => {
2357
+ removeToolbarAnchor(rootElement.ownerDocument, id);
2358
+ props.onBlur();
2285
2359
  };
2286
2360
  useOnClickOutsideIframe(onBlur);
2287
2361
  return /* @__PURE__ */ React5.createElement(import_ui4.ThemeProvider, null, /* @__PURE__ */ React5.createElement(InlineEditingOverlay, { expectedTag, rootElement, id }), /* @__PURE__ */ React5.createElement("style", null, `
2288
2362
  .ProseMirror > * {
2289
2363
  height: 100%;
2290
2364
  }
2291
- .${EDITOR_WRAPPER_SELECTOR} .ProseMirror > button[contenteditable="true"] {
2292
- height: auto;
2293
- cursor: text;
2294
- }
2365
+ .${EDITOR_WRAPPER_SELECTOR} .ProseMirror > button[contenteditable="true"] {
2366
+ height: auto;
2367
+ cursor: text;
2368
+ }
2295
2369
  `), /* @__PURE__ */ React5.createElement(
2296
2370
  import_editor_controls2.InlineEditor,
2297
2371
  {
@@ -2307,19 +2381,9 @@ var CanvasInlineEditor = ({
2307
2381
  onBlur,
2308
2382
  autofocus: true,
2309
2383
  expectedTag,
2310
- wrapperClassName: EDITOR_WRAPPER_SELECTOR,
2311
2384
  onSelectionEnd
2312
2385
  }
2313
- ), selectionOffsets && editor && /* @__PURE__ */ React5.createElement(
2314
- InlineEditingToolbarWrapper,
2315
- {
2316
- expectedTag,
2317
- editor,
2318
- rootElement,
2319
- id,
2320
- selectionOffsets
2321
- }
2322
- ));
2386
+ ), toolbarAnchor && editor && /* @__PURE__ */ React5.createElement(InlineEditingToolbar, { anchor: toolbarAnchor, editor, id }));
2323
2387
  };
2324
2388
  var InlineEditingOverlay = ({
2325
2389
  expectedTag,
@@ -2327,84 +2391,25 @@ var InlineEditingOverlay = ({
2327
2391
  id
2328
2392
  }) => {
2329
2393
  const inlineEditedElement = getInlineEditorElement(rootElement, expectedTag);
2330
- const [overlayRefElement, setOverlayElement] = (0, import_react11.useState)(inlineEditedElement);
2331
- (0, import_react11.useEffect)(() => {
2394
+ const [overlayRefElement, setOverlayElement] = (0, import_react12.useState)(inlineEditedElement);
2395
+ (0, import_react12.useEffect)(() => {
2332
2396
  setOverlayElement(getInlineEditorElement(rootElement, expectedTag));
2333
2397
  }, [expectedTag, rootElement]);
2334
2398
  return overlayRefElement ? /* @__PURE__ */ React5.createElement(OutlineOverlay, { element: overlayRefElement, id, isSelected: true }) : null;
2335
2399
  };
2336
- var InlineEditingToolbarWrapper = ({
2337
- expectedTag,
2338
- editor,
2339
- rootElement,
2340
- id,
2341
- selectionOffsets
2342
- }) => {
2343
- const [element, setElement] = (0, import_react11.useState)(null);
2344
- (0, import_react11.useEffect)(() => {
2345
- setElement(getInlineEditorElement(rootElement, expectedTag));
2346
- }, [expectedTag, rootElement]);
2347
- return element ? /* @__PURE__ */ React5.createElement(InlineEditingToolbar, { element, editor, id, selectionOffsets }) : null;
2348
- };
2349
- var InlineEditingToolbar = ({
2350
- element,
2351
- editor,
2352
- id,
2353
- selectionOffsets
2354
- }) => {
2355
- const { floating } = useFloatingOnElement({
2356
- element,
2357
- isSelected: true
2400
+ var InlineEditingToolbar = ({ anchor, editor, id }) => {
2401
+ const { refs, floatingStyles } = (0, import_react13.useFloating)({
2402
+ placement: "top",
2403
+ strategy: "fixed",
2404
+ transform: false,
2405
+ whileElementsMounted: import_react13.autoUpdate,
2406
+ middleware: [horizontalShifterMiddleware, (0, import_react13.flip)()]
2358
2407
  });
2359
- const { getFloatingProps, getReferenceProps } = (0, import_react12.useInteractions)();
2360
- const style = getComputedStyle(floating.styles, selectionOffsets);
2361
- useBindReactPropsToElement(element, getReferenceProps);
2362
- return /* @__PURE__ */ React5.createElement(import_react12.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React5.createElement(
2363
- import_ui4.Box,
2364
- {
2365
- ref: floating.setRef,
2366
- style: {
2367
- ...floating.styles,
2368
- pointerEvents: "none"
2369
- },
2370
- role: "presentation",
2371
- ...getFloatingProps({ style })
2372
- },
2373
- floating.styles.transform && /* @__PURE__ */ React5.createElement(
2374
- import_ui4.Box,
2375
- {
2376
- sx: {
2377
- position: "relative",
2378
- transform: "translateY(-100%)",
2379
- height: "max-content"
2380
- }
2381
- },
2382
- /* @__PURE__ */ React5.createElement(
2383
- import_editor_controls2.InlineEditorToolbar,
2384
- {
2385
- editor,
2386
- elementId: id,
2387
- sx: {
2388
- transform: "translateX(-50%)"
2389
- }
2390
- }
2391
- )
2392
- )
2393
- ));
2394
- };
2395
- var getInlineEditorElement = (elementWrapper, expectedTag) => {
2396
- return !expectedTag ? null : elementWrapper.querySelector(expectedTag);
2397
- };
2398
- var useOnClickOutsideIframe = (handleUnmount) => {
2399
- const asyncUnmountInlineEditor = React5.useCallback(() => queueMicrotask(handleUnmount), [handleUnmount]);
2400
- (0, import_react11.useEffect)(() => {
2401
- EDITOR_ELEMENTS_OUT_OF_IFRAME.forEach(
2402
- (selector) => document?.querySelector(selector)?.addEventListener("mousedown", asyncUnmountInlineEditor)
2403
- );
2404
- return () => EDITOR_ELEMENTS_OUT_OF_IFRAME.forEach(
2405
- (selector) => document?.querySelector(selector)?.removeEventListener("mousedown", asyncUnmountInlineEditor)
2406
- );
2407
- }, []);
2408
+ (0, import_react12.useLayoutEffect)(() => {
2409
+ refs.setReference(anchor);
2410
+ return () => refs.setReference(null);
2411
+ }, [anchor, refs]);
2412
+ return /* @__PURE__ */ React5.createElement(import_react13.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React5.createElement(import_ui4.Box, { ref: refs.setFloating, role: "presentation", style: { ...floatingStyles, pointerEvents: "none" } }, /* @__PURE__ */ React5.createElement(import_editor_controls2.InlineEditorToolbar, { editor, elementId: id })));
2408
2413
  };
2409
2414
 
2410
2415
  // src/legacy/replacements/inline-editing/inline-editing-eligibility.ts
@@ -2412,7 +2417,7 @@ var import_editor_props3 = require("@elementor/editor-props");
2412
2417
  var hasKey = (propType) => {
2413
2418
  return "key" in propType;
2414
2419
  };
2415
- var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([import_editor_props3.htmlV2PropTypeUtil.key, import_editor_props3.stringPropTypeUtil.key]);
2420
+ var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([import_editor_props3.htmlV3PropTypeUtil.key, import_editor_props3.stringPropTypeUtil.key]);
2416
2421
  var isCoreTextPropTypeKey = (key) => {
2417
2422
  return TEXT_PROP_TYPE_KEYS.has(key);
2418
2423
  };
@@ -2432,7 +2437,7 @@ var isInlineEditingAllowed = ({ rawValue, propTypeFromSchema }) => {
2432
2437
  if (rawValue === null || rawValue === void 0) {
2433
2438
  return isAllowedBySchema(propTypeFromSchema);
2434
2439
  }
2435
- return import_editor_props3.htmlV2PropTypeUtil.isValid(rawValue) || import_editor_props3.stringPropTypeUtil.isValid(rawValue);
2440
+ return import_editor_props3.htmlV3PropTypeUtil.isValid(rawValue) || import_editor_props3.stringPropTypeUtil.isValid(rawValue);
2436
2441
  };
2437
2442
 
2438
2443
  // src/legacy/replacements/inline-editing/inline-editing-elements.tsx
@@ -2517,14 +2522,15 @@ var InlineEditingReplacement = class extends ReplacementBase {
2517
2522
  }
2518
2523
  getExtractedContentValue() {
2519
2524
  const propValue = this.getInlineEditablePropValue();
2520
- return import_editor_props4.htmlV2PropTypeUtil.extract(propValue)?.content ?? "";
2525
+ const extracted = import_editor_props4.htmlV3PropTypeUtil.extract(propValue);
2526
+ return import_editor_props4.stringPropTypeUtil.extract(extracted?.content ?? null) ?? "";
2521
2527
  }
2522
2528
  setContentValue(value) {
2523
2529
  const settingKey = this.getInlineEditablePropertyName();
2524
2530
  const html = value || "";
2525
2531
  const parsed = (0, import_editor_props4.parseHtmlChildren)(html);
2526
- const valueToSave = import_editor_props4.htmlV2PropTypeUtil.create({
2527
- content: parsed.content || null,
2532
+ const valueToSave = import_editor_props4.htmlV3PropTypeUtil.create({
2533
+ content: parsed.content ? import_editor_props4.stringPropTypeUtil.create(parsed.content) : null,
2528
2534
  children: parsed.children
2529
2535
  });
2530
2536
  (0, import_editor_v1_adapters11.undoable)(
@@ -2555,7 +2561,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
2555
2561
  return null;
2556
2562
  }
2557
2563
  if (propType.kind === "union") {
2558
- const textKeys = [import_editor_props4.htmlV2PropTypeUtil.key, import_editor_props4.stringPropTypeUtil.key];
2564
+ const textKeys = [import_editor_props4.htmlV3PropTypeUtil.key, import_editor_props4.stringPropTypeUtil.key];
2559
2565
  for (const key of textKeys) {
2560
2566
  if (propType.prop_types[key]) {
2561
2567
  return key;
@@ -2796,7 +2802,10 @@ var tabModelExtensions = {
2796
2802
  ...paragraphElement,
2797
2803
  settings: {
2798
2804
  ...paragraphElement.settings,
2799
- paragraph: import_editor_props5.htmlV2PropTypeUtil.create({ content: `Tab ${position}`, children: [] })
2805
+ paragraph: import_editor_props5.htmlV3PropTypeUtil.create({
2806
+ content: import_editor_props5.stringPropTypeUtil.create(`Tab ${position}`),
2807
+ children: []
2808
+ })
2800
2809
  }
2801
2810
  };
2802
2811
  return [updatedParagraph, ...elements.slice(1)];
@@ -3449,6 +3458,13 @@ var inputSchema = {
3449
3458
  `A record mapping element IDs to their styles configuration objects. Use the actual styles schema from [${STYLE_SCHEMA_URI}].`
3450
3459
  ).default({})
3451
3460
  };
3461
+ var outputSchema = {
3462
+ errors: import_schema.z.string().describe("Error message if the composition building failed").optional(),
3463
+ xmlStructure: import_schema.z.string().describe(
3464
+ "The built XML structure as a string. Must use this XML after completion of building the composition, it contains real IDs."
3465
+ ).optional(),
3466
+ llm_instructions: import_schema.z.string().describe("Instructions what to do next, Important to follow these instructions!").optional()
3467
+ };
3452
3468
 
3453
3469
  // src/mcp/tools/build-composition/tool.ts
3454
3470
  var initBuildCompositionsTool = (reg) => {
@@ -3464,7 +3480,7 @@ var initBuildCompositionsTool = (reg) => {
3464
3480
  { description: "Global Variables", uri: "elementor://global-variables" },
3465
3481
  { description: "Styles best practices", uri: BEST_PRACTICES_URI }
3466
3482
  ],
3467
- // outputSchema: '',
3483
+ outputSchema,
3468
3484
  modelPreferences: {
3469
3485
  hints: [{ name: "claude-sonnet-4-5" }]
3470
3486
  },
@@ -3546,10 +3562,10 @@ ${errorMessages.join(
3546
3562
  Now that you have these errors, fix them and try again. Errors regarding configuration objects, please check against the PropType schemas`;
3547
3563
  throw new Error(errorText);
3548
3564
  }
3549
- if (errors.length) {
3550
- throw new Error(errors.map((e) => typeof e === "string" ? e : e.message).join("\n"));
3551
- }
3552
- return `The composition was built successfully with element IDs embedded in the XML.
3565
+ return {
3566
+ xmlStructure: generatedXML,
3567
+ errors: errors?.length ? errors.map((e) => typeof e === "string" ? e : e.message).join("\n\n") : void 0,
3568
+ llm_instructions: `The composition was built successfully with element IDs embedded in the XML.
3553
3569
 
3554
3570
  **CRITICAL NEXT STEPS** (Follow in order):
3555
3571
  1. **Apply Global Classes**: Use "apply-global-class" tool to apply the global classes you created BEFORE building this composition
@@ -3559,10 +3575,8 @@ Now that you have these errors, fix them and try again. Errors regarding configu
3559
3575
  2. **Fine-tune if needed**: Use "configure-element" tool only for element-specific adjustments that don't warrant global classes
3560
3576
 
3561
3577
  Remember: Global classes ensure design consistency and reusability. Don't skip applying them!
3562
-
3563
- Updated XML structure:
3564
- ${generatedXML}
3565
- `;
3578
+ `
3579
+ };
3566
3580
  }
3567
3581
  });
3568
3582
  };
@@ -3681,7 +3695,7 @@ var inputSchema2 = {
3681
3695
  elementType: import_schema3.z.string().describe("The type of the element to retreive the schema"),
3682
3696
  elementId: import_schema3.z.string().describe("The unique id of the element to configure")
3683
3697
  };
3684
- var outputSchema = {
3698
+ var outputSchema2 = {
3685
3699
  success: import_schema3.z.boolean().describe(
3686
3700
  "Whether the configuration change was successful, only if propertyName and propertyValue are provided"
3687
3701
  )
@@ -3694,7 +3708,7 @@ var initConfigureElementTool = (reg) => {
3694
3708
  name: "configure-element",
3695
3709
  description: configureElementToolPrompt,
3696
3710
  schema: inputSchema2,
3697
- outputSchema,
3711
+ outputSchema: outputSchema2,
3698
3712
  requiredResources: [
3699
3713
  { description: "Widgets schema", uri: WIDGET_SCHEMA_URI },
3700
3714
  { description: "Styles schema", uri: STYLE_SCHEMA_URI }
@@ -3792,7 +3806,7 @@ var import_schema5 = require("@elementor/schema");
3792
3806
  var schema = {
3793
3807
  elementId: import_schema5.z.string()
3794
3808
  };
3795
- var outputSchema2 = {
3809
+ var outputSchema3 = {
3796
3810
  properties: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
3797
3811
  style: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
3798
3812
  childElements: import_schema5.z.array(
@@ -3819,7 +3833,7 @@ var initGetElementConfigTool = (reg) => {
3819
3833
  name: "get-element-configuration-values",
3820
3834
  description: "Retrieve the element's configuration PropValues for a specific element by unique ID.",
3821
3835
  schema,
3822
- outputSchema: outputSchema2,
3836
+ outputSchema: outputSchema3,
3823
3837
  modelPreferences: {
3824
3838
  intelligencePriority: 0.6,
3825
3839
  speedPriority: 0.9