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

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
@@ -1238,6 +1238,11 @@ var dateTimeTransformer = createTransformer((values) => {
1238
1238
  }).join(" ");
1239
1239
  });
1240
1240
 
1241
+ // src/transformers/settings/html-v2-transformer.ts
1242
+ var htmlV2Transformer = createTransformer((value) => {
1243
+ return value?.content ?? "";
1244
+ });
1245
+
1241
1246
  // src/transformers/settings/link-transformer.ts
1242
1247
  var linkTransformer = createTransformer(({ destination, isTargetBlank, tag }) => {
1243
1248
  return {
@@ -1292,7 +1297,7 @@ var plainTransformer = createTransformer((value) => {
1292
1297
 
1293
1298
  // src/init-settings-transformers.ts
1294
1299
  function initSettingsTransformers() {
1295
- settingsTransformersRegistry.register("classes", createClassesTransformer()).register("link", linkTransformer).register("query", queryTransformer).register("image", imageTransformer).register("image-src", imageSrcTransformer).register("attributes", attributesTransformer).register("date-time", dateTimeTransformer).registerFallback(plainTransformer);
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);
1296
1301
  }
1297
1302
 
1298
1303
  // src/transformers/styles/background-color-overlay-transformer.ts
@@ -1780,46 +1785,21 @@ function createAfterRender(view) {
1780
1785
  view.isRendered = true;
1781
1786
  view.triggerMethod("render", view);
1782
1787
  }
1783
- async function renderTwigTemplate({
1784
- view,
1785
- signal,
1786
- resolveProps,
1787
- templateKey,
1788
- baseStylesDictionary,
1789
- type,
1790
- renderer,
1791
- buildContext,
1792
- attachContent
1793
- }) {
1794
- view.triggerMethod("before:render:template");
1795
- if (signal.aborted) {
1796
- return;
1797
- }
1798
- const settings = view.model.get("settings").toJSON();
1799
- const resolvedSettings = await resolveProps({
1800
- props: settings,
1801
- signal,
1802
- renderContext: view.getResolverRenderContext?.()
1788
+ function rerenderExistingChildren(view) {
1789
+ view.children?.each((childView) => {
1790
+ childView.render();
1803
1791
  });
1804
- if (signal.aborted) {
1805
- return;
1806
- }
1807
- let context = {
1808
- id: view.model.get("id"),
1809
- type,
1810
- settings: resolvedSettings,
1811
- base_styles: baseStylesDictionary
1812
- };
1813
- if (buildContext) {
1814
- context = buildContext(context);
1815
- }
1816
- const html = await renderer.render(templateKey, context);
1817
- if (signal.aborted) {
1818
- return;
1792
+ }
1793
+ async function waitForChildrenToComplete(view) {
1794
+ const promises = [];
1795
+ view.children?.each((childView) => {
1796
+ if (childView._currentRenderPromise) {
1797
+ promises.push(childView._currentRenderPromise);
1798
+ }
1799
+ });
1800
+ if (promises.length > 0) {
1801
+ await Promise.all(promises);
1819
1802
  }
1820
- attachContent(html);
1821
- view.bindUIElements();
1822
- view.triggerMethod("render:template");
1823
1803
  }
1824
1804
 
1825
1805
  // src/legacy/create-templated-element-type.ts
@@ -1838,10 +1818,9 @@ function createTemplatedElementView({
1838
1818
  element
1839
1819
  });
1840
1820
  return class extends BaseView {
1841
- #abortController = null;
1842
- #childrenRenderPromises = [];
1843
- #lastResolvedSettingsHash = null;
1844
- #domUpdateWasSkipped = false;
1821
+ _abortController = null;
1822
+ _lastResolvedSettingsHash = null;
1823
+ _domUpdateWasSkipped = false;
1845
1824
  getTemplateType() {
1846
1825
  return "twig";
1847
1826
  }
@@ -1858,48 +1837,29 @@ function createTemplatedElementView({
1858
1837
  return this._parent?.getResolverRenderContext?.();
1859
1838
  }
1860
1839
  invalidateRenderCache() {
1861
- this.#lastResolvedSettingsHash = null;
1840
+ this._lastResolvedSettingsHash = null;
1862
1841
  }
1863
1842
  render() {
1864
- this.#abortController?.abort();
1865
- this.#abortController = new AbortController();
1866
- const process = signalizedProcess(this.#abortController.signal).then(() => this._beforeRender()).then(() => this._renderTemplate()).then(() => this._renderChildren()).then(() => this._afterRender());
1843
+ this._abortController?.abort();
1844
+ this._abortController = new AbortController();
1845
+ const process = signalizedProcess(this._abortController.signal).then(() => this._beforeRender()).then(() => this._renderTemplate()).then(() => this._renderChildren()).then(() => this._afterRender());
1867
1846
  this._currentRenderPromise = process.execute();
1868
1847
  return this._currentRenderPromise;
1869
1848
  }
1870
1849
  async _renderChildren() {
1871
- this.#childrenRenderPromises = [];
1872
- if (this.#shouldReuseChildren()) {
1873
- this.#rerenderExistingChildren();
1850
+ if (this._shouldReuseChildren()) {
1851
+ rerenderExistingChildren(this);
1874
1852
  } else {
1875
1853
  super._renderChildren();
1876
1854
  }
1877
- this.#collectChildrenRenderPromises();
1878
- await this._waitForChildrenToComplete();
1855
+ await waitForChildrenToComplete(this);
1879
1856
  }
1880
- #shouldReuseChildren() {
1881
- return this.#domUpdateWasSkipped && this.children?.length > 0;
1882
- }
1883
- #rerenderExistingChildren() {
1884
- this.children?.each((childView) => {
1885
- childView.render();
1886
- });
1887
- }
1888
- #collectChildrenRenderPromises() {
1889
- this.children?.each((childView) => {
1890
- if (childView._currentRenderPromise) {
1891
- this.#childrenRenderPromises.push(childView._currentRenderPromise);
1892
- }
1893
- });
1894
- }
1895
- async _waitForChildrenToComplete() {
1896
- if (this.#childrenRenderPromises.length > 0) {
1897
- await Promise.all(this.#childrenRenderPromises);
1898
- }
1857
+ _shouldReuseChildren() {
1858
+ return this._domUpdateWasSkipped && this.children?.length > 0;
1899
1859
  }
1900
1860
  async _renderTemplate() {
1901
1861
  this.triggerMethod("before:render:template");
1902
- const process = signalizedProcess(this.#abortController?.signal).then((_, signal) => {
1862
+ const process = signalizedProcess(this._abortController?.signal).then((_, signal) => {
1903
1863
  const settings = this.model.get("settings").toJSON();
1904
1864
  return resolveProps({
1905
1865
  props: settings,
@@ -1910,13 +1870,13 @@ function createTemplatedElementView({
1910
1870
  return this.afterSettingsResolve(settings);
1911
1871
  }).then(async (settings) => {
1912
1872
  const settingsHash = JSON.stringify(settings);
1913
- const settingsChanged = settingsHash !== this.#lastResolvedSettingsHash;
1873
+ const settingsChanged = settingsHash !== this._lastResolvedSettingsHash;
1914
1874
  if (!settingsChanged && this.isRendered) {
1915
- this.#domUpdateWasSkipped = true;
1875
+ this._domUpdateWasSkipped = true;
1916
1876
  return null;
1917
1877
  }
1918
- this.#domUpdateWasSkipped = false;
1919
- this.#lastResolvedSettingsHash = settingsHash;
1878
+ this._domUpdateWasSkipped = false;
1879
+ this._lastResolvedSettingsHash = settingsHash;
1920
1880
  const context = {
1921
1881
  id: this.model.get("id"),
1922
1882
  type,
@@ -2013,10 +1973,15 @@ function createNestedTemplatedElementView({
2013
1973
  const parentOpenEditingPanel = AtomicElementBaseView.prototype._openEditingPanel;
2014
1974
  return AtomicElementBaseView.extend({
2015
1975
  _abortController: null,
1976
+ _lastResolvedSettingsHash: null,
1977
+ _domUpdateWasSkipped: false,
2016
1978
  template: false,
2017
1979
  getTemplateType() {
2018
1980
  return "twig";
2019
1981
  },
1982
+ invalidateRenderCache() {
1983
+ this._lastResolvedSettingsHash = null;
1984
+ },
2020
1985
  render() {
2021
1986
  this._abortController?.abort();
2022
1987
  this._abortController = new AbortController();
@@ -2041,21 +2006,47 @@ function createNestedTemplatedElementView({
2041
2006
  },
2042
2007
  async _renderTemplate() {
2043
2008
  const model = this.model;
2044
- await renderTwigTemplate({
2045
- view: this,
2046
- signal: this._abortController?.signal,
2047
- resolveProps,
2048
- templateKey,
2049
- baseStylesDictionary,
2050
- type,
2051
- renderer,
2052
- buildContext: (context) => ({
2053
- ...context,
2009
+ this.triggerMethod("before:render:template");
2010
+ const process = signalizedProcess(this._abortController?.signal).then((_, signal) => {
2011
+ const settings = model.get("settings").toJSON();
2012
+ return resolveProps({
2013
+ props: settings,
2014
+ signal,
2015
+ renderContext: this.getResolverRenderContext?.()
2016
+ });
2017
+ }).then(async (settings) => {
2018
+ const settingsHash = JSON.stringify(settings);
2019
+ const settingsChanged = settingsHash !== this._lastResolvedSettingsHash;
2020
+ if (!settingsChanged && this.isRendered) {
2021
+ this._domUpdateWasSkipped = true;
2022
+ return null;
2023
+ }
2024
+ this._domUpdateWasSkipped = false;
2025
+ this._lastResolvedSettingsHash = settingsHash;
2026
+ const context = {
2027
+ id: model.get("id"),
2028
+ type,
2029
+ settings,
2030
+ base_styles: baseStylesDictionary,
2054
2031
  editor_attributes: buildEditorAttributes(model),
2055
2032
  editor_classes: buildEditorClasses(model)
2056
- }),
2057
- attachContent: (html) => this._attachTwigContent(html)
2033
+ };
2034
+ return renderer.render(templateKey, context);
2035
+ }).then((html) => {
2036
+ if (html === null) {
2037
+ return;
2038
+ }
2039
+ this._attachTwigContent(html);
2058
2040
  });
2041
+ await process.execute();
2042
+ this.bindUIElements();
2043
+ this.triggerMethod("render:template");
2044
+ },
2045
+ getRenderContext() {
2046
+ return this._parent?.getRenderContext?.();
2047
+ },
2048
+ getResolverRenderContext() {
2049
+ return this._parent?.getResolverRenderContext?.();
2059
2050
  },
2060
2051
  getChildType() {
2061
2052
  const allowedTypes = element.allowed_child_types ?? [];
@@ -2080,16 +2071,17 @@ function createNestedTemplatedElementView({
2080
2071
  oldEl.innerHTML = overlayHTML + newEl.innerHTML;
2081
2072
  },
2082
2073
  async _renderChildren() {
2083
- parentRenderChildren.call(this);
2084
- const renderPromises = [];
2085
- this.children.each((childView) => {
2086
- if (childView._currentRenderPromise) {
2087
- renderPromises.push(childView._currentRenderPromise);
2088
- }
2089
- });
2090
- await Promise.all(renderPromises);
2074
+ if (this._shouldReuseChildren()) {
2075
+ rerenderExistingChildren(this);
2076
+ } else {
2077
+ parentRenderChildren.call(this);
2078
+ }
2079
+ await waitForChildrenToComplete(this);
2091
2080
  this._removeChildrenPlaceholder();
2092
2081
  },
2082
+ _shouldReuseChildren() {
2083
+ return this._domUpdateWasSkipped && this.children?.length > 0;
2084
+ },
2093
2085
  _removeChildrenPlaceholder() {
2094
2086
  const el = this.$el.get(0);
2095
2087
  if (!el) {
@@ -2293,9 +2285,6 @@ var CanvasInlineEditor = ({
2293
2285
  };
2294
2286
  useOnClickOutsideIframe(onBlur);
2295
2287
  return /* @__PURE__ */ React5.createElement(import_ui4.ThemeProvider, null, /* @__PURE__ */ React5.createElement(InlineEditingOverlay, { expectedTag, rootElement, id }), /* @__PURE__ */ React5.createElement("style", null, `
2296
- .${EDITOR_WRAPPER_SELECTOR}, .${EDITOR_WRAPPER_SELECTOR} > * {
2297
- height: 100%;
2298
- }
2299
2288
  .ProseMirror > * {
2300
2289
  height: 100%;
2301
2290
  }
@@ -2423,8 +2412,9 @@ var import_editor_props3 = require("@elementor/editor-props");
2423
2412
  var hasKey = (propType) => {
2424
2413
  return "key" in propType;
2425
2414
  };
2415
+ var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([import_editor_props3.htmlV2PropTypeUtil.key, import_editor_props3.stringPropTypeUtil.key]);
2426
2416
  var isCoreTextPropTypeKey = (key) => {
2427
- return key === import_editor_props3.htmlPropTypeUtil.key || key === import_editor_props3.stringPropTypeUtil.key;
2417
+ return TEXT_PROP_TYPE_KEYS.has(key);
2428
2418
  };
2429
2419
  var isAllowedBySchema = (propTypeFromSchema) => {
2430
2420
  if (!propTypeFromSchema) {
@@ -2436,15 +2426,13 @@ var isAllowedBySchema = (propTypeFromSchema) => {
2436
2426
  if (propTypeFromSchema.kind !== "union") {
2437
2427
  return false;
2438
2428
  }
2439
- return Boolean(
2440
- propTypeFromSchema.prop_types[import_editor_props3.htmlPropTypeUtil.key] || propTypeFromSchema.prop_types[import_editor_props3.stringPropTypeUtil.key]
2441
- );
2429
+ return [...TEXT_PROP_TYPE_KEYS].some((key) => propTypeFromSchema.prop_types[key]);
2442
2430
  };
2443
2431
  var isInlineEditingAllowed = ({ rawValue, propTypeFromSchema }) => {
2444
2432
  if (rawValue === null || rawValue === void 0) {
2445
2433
  return isAllowedBySchema(propTypeFromSchema);
2446
2434
  }
2447
- return import_editor_props3.htmlPropTypeUtil.isValid(rawValue) || import_editor_props3.stringPropTypeUtil.isValid(rawValue);
2435
+ return import_editor_props3.htmlV2PropTypeUtil.isValid(rawValue) || import_editor_props3.stringPropTypeUtil.isValid(rawValue);
2448
2436
  };
2449
2437
 
2450
2438
  // src/legacy/replacements/inline-editing/inline-editing-elements.tsx
@@ -2529,11 +2517,16 @@ var InlineEditingReplacement = class extends ReplacementBase {
2529
2517
  }
2530
2518
  getExtractedContentValue() {
2531
2519
  const propValue = this.getInlineEditablePropValue();
2532
- return import_editor_props4.htmlPropTypeUtil.extract(propValue) ?? "";
2520
+ return import_editor_props4.htmlV2PropTypeUtil.extract(propValue)?.content ?? "";
2533
2521
  }
2534
2522
  setContentValue(value) {
2535
2523
  const settingKey = this.getInlineEditablePropertyName();
2536
- const valueToSave = import_editor_props4.htmlPropTypeUtil.create(value || "");
2524
+ const html = value || "";
2525
+ const parsed = (0, import_editor_props4.parseHtmlChildren)(html);
2526
+ const valueToSave = import_editor_props4.htmlV2PropTypeUtil.create({
2527
+ content: parsed.content || null,
2528
+ children: parsed.children
2529
+ });
2537
2530
  (0, import_editor_v1_adapters11.undoable)(
2538
2531
  {
2539
2532
  do: () => {
@@ -2562,11 +2555,11 @@ var InlineEditingReplacement = class extends ReplacementBase {
2562
2555
  return null;
2563
2556
  }
2564
2557
  if (propType.kind === "union") {
2565
- if (propType.prop_types[import_editor_props4.htmlPropTypeUtil.key]) {
2566
- return import_editor_props4.htmlPropTypeUtil.key;
2567
- }
2568
- if (propType.prop_types[import_editor_props4.stringPropTypeUtil.key]) {
2569
- return import_editor_props4.stringPropTypeUtil.key;
2558
+ const textKeys = [import_editor_props4.htmlV2PropTypeUtil.key, import_editor_props4.stringPropTypeUtil.key];
2559
+ for (const key of textKeys) {
2560
+ if (propType.prop_types[key]) {
2561
+ return key;
2562
+ }
2570
2563
  }
2571
2564
  return null;
2572
2565
  }
@@ -2803,7 +2796,7 @@ var tabModelExtensions = {
2803
2796
  ...paragraphElement,
2804
2797
  settings: {
2805
2798
  ...paragraphElement.settings,
2806
- paragraph: import_editor_props5.htmlPropTypeUtil.create(`Tab ${position}`)
2799
+ paragraph: import_editor_props5.htmlV2PropTypeUtil.create({ content: `Tab ${position}`, children: [] })
2807
2800
  }
2808
2801
  };
2809
2802
  return [updatedParagraph, ...elements.slice(1)];
@@ -3456,13 +3449,6 @@ var inputSchema = {
3456
3449
  `A record mapping element IDs to their styles configuration objects. Use the actual styles schema from [${STYLE_SCHEMA_URI}].`
3457
3450
  ).default({})
3458
3451
  };
3459
- var outputSchema = {
3460
- errors: import_schema.z.string().describe("Error message if the composition building failed").optional(),
3461
- xmlStructure: import_schema.z.string().describe(
3462
- "The built XML structure as a string. Must use this XML after completion of building the composition, it contains real IDs."
3463
- ).optional(),
3464
- llm_instructions: import_schema.z.string().describe("Instructions what to do next, Important to follow these instructions!")
3465
- };
3466
3452
 
3467
3453
  // src/mcp/tools/build-composition/tool.ts
3468
3454
  var initBuildCompositionsTool = (reg) => {
@@ -3478,7 +3464,7 @@ var initBuildCompositionsTool = (reg) => {
3478
3464
  { description: "Global Variables", uri: "elementor://global-variables" },
3479
3465
  { description: "Styles best practices", uri: BEST_PRACTICES_URI }
3480
3466
  ],
3481
- outputSchema,
3467
+ // outputSchema: '',
3482
3468
  modelPreferences: {
3483
3469
  hints: [{ name: "claude-sonnet-4-5" }]
3484
3470
  },
@@ -3560,10 +3546,10 @@ ${errorMessages.join(
3560
3546
  Now that you have these errors, fix them and try again. Errors regarding configuration objects, please check against the PropType schemas`;
3561
3547
  throw new Error(errorText);
3562
3548
  }
3563
- return {
3564
- xmlStructure: generatedXML,
3565
- errors: errors?.length ? errors.map((e) => typeof e === "string" ? e : e.message).join("\n\n") : void 0,
3566
- llm_instructions: `The composition was built successfully with element IDs embedded in the XML.
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.
3567
3553
 
3568
3554
  **CRITICAL NEXT STEPS** (Follow in order):
3569
3555
  1. **Apply Global Classes**: Use "apply-global-class" tool to apply the global classes you created BEFORE building this composition
@@ -3573,8 +3559,10 @@ Now that you have these errors, fix them and try again. Errors regarding configu
3573
3559
  2. **Fine-tune if needed**: Use "configure-element" tool only for element-specific adjustments that don't warrant global classes
3574
3560
 
3575
3561
  Remember: Global classes ensure design consistency and reusability. Don't skip applying them!
3576
- `
3577
- };
3562
+
3563
+ Updated XML structure:
3564
+ ${generatedXML}
3565
+ `;
3578
3566
  }
3579
3567
  });
3580
3568
  };
@@ -3693,7 +3681,7 @@ var inputSchema2 = {
3693
3681
  elementType: import_schema3.z.string().describe("The type of the element to retreive the schema"),
3694
3682
  elementId: import_schema3.z.string().describe("The unique id of the element to configure")
3695
3683
  };
3696
- var outputSchema2 = {
3684
+ var outputSchema = {
3697
3685
  success: import_schema3.z.boolean().describe(
3698
3686
  "Whether the configuration change was successful, only if propertyName and propertyValue are provided"
3699
3687
  )
@@ -3706,7 +3694,7 @@ var initConfigureElementTool = (reg) => {
3706
3694
  name: "configure-element",
3707
3695
  description: configureElementToolPrompt,
3708
3696
  schema: inputSchema2,
3709
- outputSchema: outputSchema2,
3697
+ outputSchema,
3710
3698
  requiredResources: [
3711
3699
  { description: "Widgets schema", uri: WIDGET_SCHEMA_URI },
3712
3700
  { description: "Styles schema", uri: STYLE_SCHEMA_URI }
@@ -3804,7 +3792,7 @@ var import_schema5 = require("@elementor/schema");
3804
3792
  var schema = {
3805
3793
  elementId: import_schema5.z.string()
3806
3794
  };
3807
- var outputSchema3 = {
3795
+ var outputSchema2 = {
3808
3796
  properties: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping PropTypes to their corresponding PropValues"),
3809
3797
  style: import_schema5.z.record(import_schema5.z.string(), import_schema5.z.any()).describe("A record mapping StyleSchema properties to their corresponding PropValues"),
3810
3798
  childElements: import_schema5.z.array(
@@ -3831,7 +3819,7 @@ var initGetElementConfigTool = (reg) => {
3831
3819
  name: "get-element-configuration-values",
3832
3820
  description: "Retrieve the element's configuration PropValues for a specific element by unique ID.",
3833
3821
  schema,
3834
- outputSchema: outputSchema3,
3822
+ outputSchema: outputSchema2,
3835
3823
  modelPreferences: {
3836
3824
  intelligencePriority: 0.6,
3837
3825
  speedPriority: 0.9