@elementor/editor-canvas 3.35.0-359 → 3.35.0-360

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
@@ -281,8 +281,8 @@ var subscribeToStylesRepository = () => {
281
281
  });
282
282
  };
283
283
  var renameClass = (oldClassName, newClassName) => {
284
- Object.values((0, import_editor_documents.getV1DocumentsManager)().documents).forEach((document2) => {
285
- const container = document2.container;
284
+ Object.values((0, import_editor_documents.getV1DocumentsManager)().documents).forEach((document) => {
285
+ const container = document.container;
286
286
  container.view?.el?.querySelectorAll(`.elementor .${oldClassName}`).forEach((element) => {
287
287
  element.classList.replace(oldClassName, newClassName);
288
288
  });
@@ -613,14 +613,14 @@ function useDocumentsCssLinks() {
613
613
  }));
614
614
  });
615
615
  }
616
- function getDocumentsIdsInCanvas(document2) {
617
- return [...document2.body.querySelectorAll(`[${DOCUMENT_WRAPPER_ATTR}]`) ?? []].map(
616
+ function getDocumentsIdsInCanvas(document) {
617
+ return [...document.body.querySelectorAll(`[${DOCUMENT_WRAPPER_ATTR}]`) ?? []].map(
618
618
  (el) => el.getAttribute(DOCUMENT_WRAPPER_ATTR) || ""
619
619
  );
620
620
  }
621
- function getDocumentsCssLinks(document2) {
621
+ function getDocumentsCssLinks(document) {
622
622
  return [
623
- ...document2.head.querySelectorAll(
623
+ ...document.head.querySelectorAll(
624
624
  `link[rel="stylesheet"][id^=${CSS_LINK_ID_PREFIX}][id$=${CSS_LINK_ID_SUFFIX}]`
625
625
  ) ?? []
626
626
  ];
@@ -1455,7 +1455,7 @@ function initStyleTransformers() {
1455
1455
  }
1456
1456
 
1457
1457
  // src/legacy/init-legacy-views.ts
1458
- var import_editor_elements5 = require("@elementor/editor-elements");
1458
+ var import_editor_elements4 = require("@elementor/editor-elements");
1459
1459
  var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
1460
1460
 
1461
1461
  // src/renderers/create-dom-renderer.ts
@@ -1503,98 +1503,6 @@ function escapeURL(value) {
1503
1503
  }
1504
1504
  }
1505
1505
 
1506
- // src/utils/inline-editing-utils.ts
1507
- var import_editor_elements3 = require("@elementor/editor-elements");
1508
- var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
1509
- var WIDGET_PROPERTY_MAP = {
1510
- "e-heading": "title",
1511
- "e-paragraph": "paragraph"
1512
- };
1513
- var EXPERIMENT_KEY = "v4-inline-text-editing";
1514
- var legacyWindow = window;
1515
- var shouldRenderInlineEditingView = (elementType) => {
1516
- return elementType in WIDGET_PROPERTY_MAP && (0, import_editor_v1_adapters8.isExperimentActive)(EXPERIMENT_KEY);
1517
- };
1518
- var getWidgetType = (container) => {
1519
- return container?.model?.get("widgetType") ?? container?.model?.get("elType") ?? null;
1520
- };
1521
- var getHtmlPropertyName = (container) => {
1522
- const widgetType = getWidgetType(container);
1523
- if (!widgetType) {
1524
- return "";
1525
- }
1526
- const propsSchema = (0, import_editor_elements3.getElementType)(widgetType)?.propsSchema;
1527
- if (WIDGET_PROPERTY_MAP[widgetType]) {
1528
- return WIDGET_PROPERTY_MAP[widgetType];
1529
- }
1530
- if (!propsSchema) {
1531
- return "";
1532
- }
1533
- const entry = Object.entries(propsSchema).find(([, propType]) => {
1534
- switch (propType.kind) {
1535
- case "union":
1536
- return propType.prop_types.html;
1537
- case "object":
1538
- return propType.shape.html;
1539
- case "array":
1540
- return "key" in propType.item_prop_type && propType.item_prop_type.key === "html";
1541
- }
1542
- return propType.key === "html";
1543
- });
1544
- return entry?.[0] ?? "";
1545
- };
1546
- var getHtmlPropType = (container) => {
1547
- const widgetType = getWidgetType(container);
1548
- if (!widgetType) {
1549
- return null;
1550
- }
1551
- const propsSchema = (0, import_editor_elements3.getElementType)(widgetType)?.propsSchema;
1552
- const propertyName = getHtmlPropertyName(container) ?? null;
1553
- return propsSchema?.[propertyName] ?? null;
1554
- };
1555
- var getInlineEditablePropertyName = (container) => {
1556
- return getHtmlPropertyName(container) ?? "";
1557
- };
1558
- var getBlockedValue = (value, tag) => {
1559
- if (!value) {
1560
- return "";
1561
- }
1562
- if (!tag) {
1563
- return value;
1564
- }
1565
- const pseudoElement = document.createElement("div");
1566
- pseudoElement.innerHTML = value;
1567
- if (!pseudoElement?.children.length) {
1568
- return `<${tag}>${value}</${tag}>`;
1569
- }
1570
- const firstChild = pseudoElement.children[0];
1571
- const lastChild = Array.from(pseudoElement.children).slice(-1)[0];
1572
- if (firstChild === lastChild && pseudoElement.textContent === firstChild.textContent) {
1573
- return compareTag(firstChild, tag) ? value : `<${tag}>${firstChild.innerHTML}</${tag}>`;
1574
- }
1575
- if (!value.startsWith(`<${tag}`) || !value.endsWith(`</${tag}>`)) {
1576
- return `<${tag}>${value}</${tag}>`;
1577
- }
1578
- if (firstChild !== lastChild || !compareTag(firstChild, tag)) {
1579
- return `<${tag}>${value}</${tag}>`;
1580
- }
1581
- return value;
1582
- };
1583
- var compareTag = (el, tag) => {
1584
- return el.tagName.toUpperCase() === tag.toUpperCase();
1585
- };
1586
- var getInitialPopoverPosition = () => {
1587
- const positionFallback = { left: 0, top: 0 };
1588
- const iFrameElement = legacyWindow?.elementor?.$preview?.get(0);
1589
- const iFramePosition = iFrameElement?.getBoundingClientRect() ?? positionFallback;
1590
- const previewElement = legacyWindow?.elementor?.$previewWrapper?.get(0);
1591
- const previewPosition = previewElement ? { left: previewElement.scrollLeft, top: previewElement.scrollTop } : positionFallback;
1592
- return {
1593
- left: iFramePosition.left + previewPosition.left,
1594
- top: iFramePosition.top + previewPosition.top
1595
- };
1596
- };
1597
-
1598
1506
  // src/legacy/create-element-type.ts
1599
1507
  function createElementType(type) {
1600
1508
  const legacyWindow2 = window;
@@ -1671,34 +1579,7 @@ function createElementViewClassDeclaration() {
1671
1579
  };
1672
1580
  }
1673
1581
 
1674
- // src/legacy/create-inline-editing-element-type.tsx
1675
- var React5 = __toESM(require("react"));
1676
- var import_client = require("react-dom/client");
1677
- var import_editor_controls2 = require("@elementor/editor-controls");
1678
- var import_editor_elements4 = require("@elementor/editor-elements");
1679
- var import_editor_props3 = require("@elementor/editor-props");
1680
- var import_editor_ui = require("@elementor/editor-ui");
1681
-
1682
1582
  // src/legacy/create-templated-element-type.ts
1683
- function createTemplatedElementType({
1684
- type,
1685
- renderer,
1686
- element
1687
- }) {
1688
- const legacyWindow2 = window;
1689
- return class extends legacyWindow2.elementor.modules.elements.types.Widget {
1690
- getType() {
1691
- return type;
1692
- }
1693
- getView() {
1694
- return createTemplatedElementView({
1695
- type,
1696
- renderer,
1697
- element
1698
- });
1699
- }
1700
- };
1701
- }
1702
1583
  function canBeTemplated(element) {
1703
1584
  return !!(element.atomic_props_schema && element.twig_templates && element.twig_main_template && element.base_styles_dictionary);
1704
1585
  }
@@ -1730,9 +1611,9 @@ function createTemplatedElementView({
1730
1611
  render() {
1731
1612
  this.#abortController?.abort();
1732
1613
  this.#abortController = new AbortController();
1733
- const process = signalizedProcess(this.#abortController.signal).then(() => this.#beforeRender()).then(() => this._renderTemplate()).then(() => {
1614
+ const process = signalizedProcess(this.#abortController.signal).then(() => this._beforeRender()).then(() => this._renderTemplate()).then(() => {
1734
1615
  this._renderChildren();
1735
- this.#afterRender();
1616
+ this._afterRender();
1736
1617
  });
1737
1618
  return process.execute();
1738
1619
  }
@@ -1763,13 +1644,13 @@ function createTemplatedElementView({
1763
1644
  afterSettingsResolve(settings) {
1764
1645
  return settings;
1765
1646
  }
1766
- #beforeRender() {
1647
+ _beforeRender() {
1767
1648
  this._ensureViewIsIntact();
1768
1649
  this._isRendering = true;
1769
1650
  this.resetChildViewContainer();
1770
1651
  this.triggerMethod("before:render", this);
1771
1652
  }
1772
- #afterRender() {
1653
+ _afterRender() {
1773
1654
  this._isRendering = false;
1774
1655
  this.isRendered = true;
1775
1656
  this.triggerMethod("render", this);
@@ -1777,141 +1658,262 @@ function createTemplatedElementView({
1777
1658
  };
1778
1659
  }
1779
1660
 
1780
- // src/legacy/create-inline-editing-element-type.tsx
1781
- function createInlineEditingElementType({
1782
- type,
1783
- renderer,
1784
- element
1785
- }) {
1786
- return class extends legacyWindow.elementor.modules.elements.types.Widget {
1787
- getType() {
1788
- return type;
1789
- }
1790
- getView() {
1791
- return createInlineEditingElementView({
1792
- type,
1793
- renderer,
1794
- element
1795
- });
1796
- }
1661
+ // src/legacy/replacements/inline-editing/inline-editing-elements.tsx
1662
+ var React5 = __toESM(require("react"));
1663
+ var import_client = require("react-dom/client");
1664
+ var import_editor_controls2 = require("@elementor/editor-controls");
1665
+ var import_editor_elements3 = require("@elementor/editor-elements");
1666
+ var import_editor_props3 = require("@elementor/editor-props");
1667
+ var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
1668
+ var import_ui4 = require("@elementor/ui");
1669
+
1670
+ // src/legacy/replacements/base.ts
1671
+ var ReplacementBase = class {
1672
+ getSetting;
1673
+ setSetting;
1674
+ element;
1675
+ type;
1676
+ id;
1677
+ refreshView;
1678
+ constructor(settings) {
1679
+ this.getSetting = settings.getSetting;
1680
+ this.setSetting = settings.setSetting;
1681
+ this.element = settings.element;
1682
+ this.type = settings.type;
1683
+ this.id = settings.id;
1684
+ this.refreshView = settings.refreshView;
1685
+ }
1686
+ static getTypes() {
1687
+ return null;
1688
+ }
1689
+ render() {
1690
+ }
1691
+ onDestroy() {
1692
+ }
1693
+ _beforeRender() {
1694
+ }
1695
+ _afterRender() {
1696
+ }
1697
+ shouldRenderReplacement() {
1698
+ return true;
1699
+ }
1700
+ };
1701
+
1702
+ // src/legacy/replacements/inline-editing/inline-editing-utils.ts
1703
+ var INLINE_EDITING_PROPERTY_PER_TYPE = {
1704
+ "e-heading": "title",
1705
+ "e-paragraph": "paragraph"
1706
+ };
1707
+ var legacyWindow = window;
1708
+ var getInitialPopoverPosition = () => {
1709
+ const positionFallback = { left: 0, top: 0 };
1710
+ const iFrameElement = legacyWindow?.elementor?.$preview?.get(0);
1711
+ const iFramePosition = iFrameElement?.getBoundingClientRect() ?? positionFallback;
1712
+ const previewElement = legacyWindow?.elementor?.$previewWrapper?.get(0);
1713
+ const previewPosition = previewElement ? { left: previewElement.scrollLeft, top: previewElement.scrollTop } : positionFallback;
1714
+ return {
1715
+ left: iFramePosition.left + previewPosition.left,
1716
+ top: iFramePosition.top + previewPosition.top
1797
1717
  };
1798
- }
1799
- function createInlineEditingElementView({
1800
- type,
1801
- renderer,
1802
- element
1803
- }) {
1804
- const TemplatedView = createTemplatedElementView({ type, renderer, element });
1805
- Object.entries(element.twig_templates).forEach(([key, template]) => {
1806
- renderer.register(key, template);
1807
- });
1808
- return class extends TemplatedView {
1809
- inlineEditorRoot = null;
1810
- handlerAttached = false;
1811
- render() {
1812
- if (this.inlineEditorRoot) {
1813
- this.resetInlineEditorRoot();
1814
- }
1815
- if (!this.isValueDynamic() && !this.handlerAttached) {
1816
- this.$el.on("dblclick", "*", this.handleRenderInlineEditor.bind(this));
1817
- this.handlerAttached = true;
1818
- }
1819
- TemplatedView.prototype.render.apply(this);
1820
- }
1821
- handleRenderInlineEditor(event) {
1822
- event.stopPropagation();
1823
- this.$el.off("dblclick", "*");
1824
- this.handlerAttached = false;
1825
- if (!this.isValueDynamic()) {
1826
- this.renderInlineEditor();
1827
- }
1718
+ };
1719
+
1720
+ // src/legacy/replacements/inline-editing/inline-editing-elements.tsx
1721
+ var EXPERIMENT_KEY = "v4-inline-text-editing";
1722
+ var InlineEditingReplacement = class extends ReplacementBase {
1723
+ inlineEditorRoot = null;
1724
+ handlerAttached = false;
1725
+ getReplacementKey() {
1726
+ return "inline-editing";
1727
+ }
1728
+ static getTypes() {
1729
+ return Object.keys(INLINE_EDITING_PROPERTY_PER_TYPE);
1730
+ }
1731
+ isEditingModeActive() {
1732
+ return !!this.inlineEditorRoot;
1733
+ }
1734
+ shouldRenderReplacement() {
1735
+ return (0, import_editor_v1_adapters8.isExperimentActive)(EXPERIMENT_KEY) && this.isEditingModeActive() && !this.isValueDynamic();
1736
+ }
1737
+ handleRenderInlineEditor = (event) => {
1738
+ event.stopPropagation();
1739
+ if (!this.isValueDynamic()) {
1740
+ this.renderInlineEditor();
1828
1741
  }
1829
- handleUnmountInlineEditor(event) {
1830
- event.stopPropagation();
1831
- this.unmountInlineEditor();
1742
+ };
1743
+ handleUnmountInlineEditor = (event) => {
1744
+ event.stopPropagation();
1745
+ this.unmountInlineEditor();
1746
+ };
1747
+ onDestroy() {
1748
+ this.resetInlineEditorRoot();
1749
+ }
1750
+ _beforeRender() {
1751
+ this.resetInlineEditorRoot();
1752
+ }
1753
+ _afterRender() {
1754
+ if (!this.isValueDynamic() && !this.handlerAttached) {
1755
+ this.element.addEventListener("dblclick", this.handleRenderInlineEditor);
1756
+ this.handlerAttached = true;
1757
+ }
1758
+ }
1759
+ resetInlineEditorRoot() {
1760
+ this.element.removeEventListener("dblclick", this.handleRenderInlineEditor);
1761
+ this.handlerAttached = false;
1762
+ this.inlineEditorRoot?.unmount?.();
1763
+ this.inlineEditorRoot = null;
1764
+ }
1765
+ unmountInlineEditor() {
1766
+ this.resetInlineEditorRoot();
1767
+ this.refreshView();
1768
+ }
1769
+ isValueDynamic() {
1770
+ const settingKey = this.getInlineEditablePropertyName();
1771
+ const propValue = this.getSetting(settingKey);
1772
+ return propValue?.$$type === "dynamic";
1773
+ }
1774
+ getInlineEditablePropertyName() {
1775
+ return INLINE_EDITING_PROPERTY_PER_TYPE[this.type] ?? "";
1776
+ }
1777
+ getHtmlPropType() {
1778
+ const propSchema = (0, import_editor_elements3.getElementType)(this.type)?.propsSchema;
1779
+ const propertyName = this.getInlineEditablePropertyName();
1780
+ return propSchema?.[propertyName] ?? null;
1781
+ }
1782
+ getContentValue() {
1783
+ const prop = this.getHtmlPropType();
1784
+ const defaultValue = prop?.default?.value ?? "";
1785
+ const settingKey = this.getInlineEditablePropertyName();
1786
+ return import_editor_props3.htmlPropTypeUtil.extract(this.getSetting(settingKey) ?? null) ?? import_editor_props3.htmlPropTypeUtil.extract(prop?.default ?? null) ?? defaultValue ?? "";
1787
+ }
1788
+ setContentValue(value) {
1789
+ const settingKey = this.getInlineEditablePropertyName();
1790
+ const valueToSave = value ? import_editor_props3.htmlPropTypeUtil.create(value) : null;
1791
+ this.setSetting(settingKey, valueToSave);
1792
+ }
1793
+ getExpectedTag() {
1794
+ const propsSchema = (0, import_editor_elements3.getElementType)(this.type)?.propsSchema;
1795
+ if (!propsSchema?.tag) {
1796
+ return null;
1832
1797
  }
1833
- onDestroy(...args) {
1798
+ const tagSettingKey = "tag";
1799
+ return import_editor_props3.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props3.stringPropTypeUtil.extract(propsSchema.tag.default ?? null) ?? null;
1800
+ }
1801
+ renderInlineEditor() {
1802
+ const propValue = this.getContentValue();
1803
+ const classes = (this.element.children?.[0]?.classList.toString() ?? "") + " strip-styles";
1804
+ const expectedTag = this.getExpectedTag();
1805
+ this.element.innerHTML = "";
1806
+ if (this.inlineEditorRoot) {
1834
1807
  this.resetInlineEditorRoot();
1835
- TemplatedView.prototype.onDestroy.apply(this, args);
1836
1808
  }
1837
- resetInlineEditorRoot() {
1838
- this.$el.off("dblclick", "*");
1839
- this.handlerAttached = false;
1840
- this.inlineEditorRoot?.unmount?.();
1841
- this.inlineEditorRoot = null;
1809
+ this.inlineEditorRoot = (0, import_client.createRoot)(this.element);
1810
+ this.inlineEditorRoot.render(
1811
+ /* @__PURE__ */ React5.createElement(import_ui4.ThemeProvider, null, /* @__PURE__ */ React5.createElement(
1812
+ import_editor_controls2.InlineEditor,
1813
+ {
1814
+ attributes: { class: classes },
1815
+ value: propValue,
1816
+ setValue: this.setContentValue.bind(this),
1817
+ onBlur: this.handleUnmountInlineEditor.bind(this),
1818
+ autofocus: true,
1819
+ showToolbar: true,
1820
+ getInitialPopoverPosition,
1821
+ expectedTag
1822
+ }
1823
+ ))
1824
+ );
1825
+ }
1826
+ };
1827
+
1828
+ // src/legacy/replacements/manager.ts
1829
+ var replacements = /* @__PURE__ */ new Map();
1830
+ var initViewReplacements = () => {
1831
+ registerReplacement(InlineEditingReplacement);
1832
+ };
1833
+ var registerReplacement = (replacement) => {
1834
+ const types = replacement.getTypes();
1835
+ if (!types) {
1836
+ return;
1837
+ }
1838
+ types.forEach((type) => {
1839
+ replacements.set(type, replacement);
1840
+ });
1841
+ };
1842
+ var getReplacement = (type) => {
1843
+ return replacements.get(type) ?? null;
1844
+ };
1845
+ var createViewWithReplacements = (options) => {
1846
+ const TemplatedView = createTemplatedElementView(options);
1847
+ return class extends TemplatedView {
1848
+ #replacement = null;
1849
+ #config;
1850
+ constructor(...args) {
1851
+ super(...args);
1852
+ const settings = this.model.get("settings");
1853
+ this.#config = {
1854
+ getSetting: settings.get.bind(settings),
1855
+ setSetting: settings.set.bind(settings),
1856
+ element: this.el,
1857
+ type: this?.model?.get("widgetType") ?? this.container?.model?.get("elType") ?? null,
1858
+ id: this?.model?.get("id") ?? null,
1859
+ refreshView: this.render.bind(this)
1860
+ };
1842
1861
  }
1843
- unmountInlineEditor() {
1844
- this.resetInlineEditorRoot();
1862
+ refreshView() {
1845
1863
  this.render();
1846
1864
  }
1847
- isValueDynamic() {
1848
- const settingKey = getInlineEditablePropertyName(this.container);
1849
- const propValue = this.model.get("settings")?.get(settingKey);
1850
- return propValue?.$$type === "dynamic";
1851
- }
1852
- getContentValue() {
1853
- const prop = getHtmlPropType(this.container);
1854
- const defaultValue = prop?.default?.value ?? "";
1855
- const settingKey = getInlineEditablePropertyName(this.container);
1856
- return import_editor_props3.htmlPropTypeUtil.extract(this.model.get("settings")?.get(settingKey) ?? null) ?? import_editor_props3.htmlPropTypeUtil.extract(prop?.default ?? null) ?? defaultValue ?? "";
1857
- }
1858
- setContentValue(value) {
1859
- const settingKey = getInlineEditablePropertyName(this.container);
1860
- const valueToSave = value ? import_editor_props3.htmlPropTypeUtil.create(value) : null;
1861
- this.model.get("settings")?.set(settingKey, valueToSave);
1862
- }
1863
- getExpectedTag() {
1864
- const widgetType = getWidgetType(this.container);
1865
- if (!widgetType) {
1866
- return null;
1865
+ render() {
1866
+ const config = this.#config;
1867
+ const widgetType = config.type;
1868
+ const ReplacementClass = widgetType ? getReplacement(widgetType) : null;
1869
+ if (ReplacementClass && !this.#replacement) {
1870
+ this.#replacement = new ReplacementClass(config);
1867
1871
  }
1868
- const propsSchema = (0, import_editor_elements4.getElementType)(widgetType)?.propsSchema;
1869
- if (!propsSchema?.tag) {
1870
- return null;
1872
+ if (!this.#replacement?.shouldRenderReplacement()) {
1873
+ return TemplatedView.prototype.render.apply(this);
1871
1874
  }
1872
- return import_editor_props3.stringPropTypeUtil.extract(this.model.get("settings").get("tag") ?? null) ?? import_editor_props3.stringPropTypeUtil.extract(propsSchema.tag.default ?? null) ?? null;
1873
- }
1874
- ensureProperValue() {
1875
- const actualValue = this.getContentValue();
1876
- const tagSettings = this.getExpectedTag();
1877
- const wrappedValue = getBlockedValue(actualValue, tagSettings);
1878
- if (actualValue !== wrappedValue) {
1879
- this.setContentValue(wrappedValue);
1875
+ this.#replacement.render();
1876
+ }
1877
+ onDestroy() {
1878
+ if (this.#replacement) {
1879
+ this.#replacement.onDestroy();
1880
+ this.#replacement = null;
1880
1881
  }
1882
+ TemplatedView.prototype.onDestroy.apply(this);
1881
1883
  }
1882
- renderInlineEditor() {
1883
- this.ensureProperValue();
1884
- const propValue = this.getContentValue();
1885
- const settingKey = getInlineEditablePropertyName(this.container);
1886
- const classes = (this.el?.children?.[0]?.classList.toString() ?? "") + " strip-styles";
1887
- const expectedTag = this.getExpectedTag();
1888
- const setValue = (value) => {
1889
- const valueToSave = value ? import_editor_props3.htmlPropTypeUtil.create(value) : null;
1890
- this.model.get("settings")?.set(settingKey, valueToSave);
1891
- };
1892
- this.$el.html("");
1893
- if (this.inlineEditorRoot) {
1894
- this.resetInlineEditorRoot();
1884
+ _afterRender() {
1885
+ if (this.#replacement) {
1886
+ this.#replacement._afterRender();
1895
1887
  }
1896
- this.inlineEditorRoot = (0, import_client.createRoot)(this.el);
1897
- this.inlineEditorRoot.render(
1898
- /* @__PURE__ */ React5.createElement(import_editor_ui.ThemeProvider, null, /* @__PURE__ */ React5.createElement(
1899
- import_editor_controls2.InlineEditor,
1900
- {
1901
- attributes: { class: classes },
1902
- value: propValue,
1903
- setValue,
1904
- onBlur: this.handleUnmountInlineEditor.bind(this),
1905
- autofocus: true,
1906
- showToolbar: true,
1907
- getInitialPopoverPosition,
1908
- expectedTag
1909
- }
1910
- ))
1911
- );
1888
+ TemplatedView.prototype._afterRender.apply(this);
1889
+ }
1890
+ _beforeRender() {
1891
+ if (this.#replacement) {
1892
+ this.#replacement._beforeRender();
1893
+ }
1894
+ TemplatedView.prototype._beforeRender.apply(this);
1912
1895
  }
1913
1896
  };
1914
- }
1897
+ };
1898
+ var createTemplatedElementTypeWithReplacements = ({
1899
+ type,
1900
+ renderer,
1901
+ element
1902
+ }) => {
1903
+ const legacyWindow2 = window;
1904
+ return class extends legacyWindow2.elementor.modules.elements.types.Widget {
1905
+ getType() {
1906
+ return type;
1907
+ }
1908
+ getView() {
1909
+ return createViewWithReplacements({
1910
+ type,
1911
+ renderer,
1912
+ element
1913
+ });
1914
+ }
1915
+ };
1916
+ };
1915
1917
 
1916
1918
  // src/legacy/init-legacy-views.ts
1917
1919
  var elementsLegacyTypes = {};
@@ -1920,7 +1922,7 @@ function registerElementType(type, elementTypeGenerator) {
1920
1922
  }
1921
1923
  function initLegacyViews() {
1922
1924
  (0, import_editor_v1_adapters9.__privateListenTo)((0, import_editor_v1_adapters9.v1ReadyEvent)(), () => {
1923
- const config = (0, import_editor_elements5.getWidgetsCache)() ?? {};
1925
+ const config = (0, import_editor_elements4.getWidgetsCache)() ?? {};
1924
1926
  const legacyWindow2 = window;
1925
1927
  const renderer = createDomRenderer();
1926
1928
  Object.entries(config).forEach(([type, element]) => {
@@ -1931,7 +1933,7 @@ function initLegacyViews() {
1931
1933
  if (!!elementsLegacyTypes[type] && canBeTemplated(element)) {
1932
1934
  ElementType = elementsLegacyTypes[type]({ type, renderer, element });
1933
1935
  } else if (canBeTemplated(element)) {
1934
- ElementType = shouldRenderInlineEditingView(type) ? createInlineEditingElementType({ type, renderer, element }) : createTemplatedElementType({ type, renderer, element });
1936
+ ElementType = createTemplatedElementTypeWithReplacements({ type, renderer, element });
1935
1937
  } else {
1936
1938
  ElementType = createElementType(type);
1937
1939
  }
@@ -1980,18 +1982,18 @@ var initDocumentStructureResource = (reg) => {
1980
1982
  };
1981
1983
  function getDocumentStructure() {
1982
1984
  const extendedWindow = window;
1983
- const document2 = extendedWindow.elementor?.documents?.getCurrent?.();
1984
- if (!document2) {
1985
+ const document = extendedWindow.elementor?.documents?.getCurrent?.();
1986
+ if (!document) {
1985
1987
  return { error: "No active document found" };
1986
1988
  }
1987
- const containers = document2.container?.children || [];
1989
+ const containers = document.container?.children || [];
1988
1990
  const elements = containers.map(
1989
1991
  (container) => extractElementData(container)
1990
1992
  );
1991
1993
  return {
1992
- documentId: document2.id,
1993
- documentType: document2.config.type,
1994
- title: document2.config.settings?.post_title || "Untitled",
1994
+ documentId: document.id,
1995
+ documentType: document.config.type,
1996
+ title: document.config.settings?.post_title || "Untitled",
1995
1997
  elements: elements.filter((el) => el !== null)
1996
1998
  };
1997
1999
  }
@@ -2016,10 +2018,10 @@ function extractElementData(element) {
2016
2018
  }
2017
2019
 
2018
2020
  // src/mcp/tools/build-composition/tool.ts
2019
- var import_editor_elements8 = require("@elementor/editor-elements");
2021
+ var import_editor_elements7 = require("@elementor/editor-elements");
2020
2022
 
2021
2023
  // src/mcp/utils/do-update-element-property.ts
2022
- var import_editor_elements6 = require("@elementor/editor-elements");
2024
+ var import_editor_elements5 = require("@elementor/editor-elements");
2023
2025
  var import_editor_props4 = require("@elementor/editor-props");
2024
2026
  var import_editor_styles5 = require("@elementor/editor-styles");
2025
2027
  function resolvePropValue(value, forceKey) {
@@ -2028,7 +2030,7 @@ function resolvePropValue(value, forceKey) {
2028
2030
  var doUpdateElementProperty = (params) => {
2029
2031
  const { elementId, propertyName, propertyValue, elementType } = params;
2030
2032
  if (propertyName === "_styles") {
2031
- const elementStyles = (0, import_editor_elements6.getElementStyles)(elementId) || {};
2033
+ const elementStyles = (0, import_editor_elements5.getElementStyles)(elementId) || {};
2032
2034
  const propertyMapValue = propertyValue;
2033
2035
  const styleSchema = (0, import_editor_styles5.getStylesSchema)();
2034
2036
  const transformedStyleValues = Object.fromEntries(
@@ -2076,7 +2078,7 @@ var doUpdateElementProperty = (params) => {
2076
2078
  delete transformedStyleValues.custom_css;
2077
2079
  const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
2078
2080
  if (!localStyle) {
2079
- (0, import_editor_elements6.createElementStyle)({
2081
+ (0, import_editor_elements5.createElementStyle)({
2080
2082
  elementId,
2081
2083
  ...typeof customCss !== "undefined" ? { custom_css: customCss } : {},
2082
2084
  classesProp: "classes",
@@ -2090,7 +2092,7 @@ var doUpdateElementProperty = (params) => {
2090
2092
  }
2091
2093
  });
2092
2094
  } else {
2093
- (0, import_editor_elements6.updateElementStyle)({
2095
+ (0, import_editor_elements5.updateElementStyle)({
2094
2096
  elementId,
2095
2097
  styleId: localStyle.id,
2096
2098
  meta: {
@@ -2105,7 +2107,7 @@ var doUpdateElementProperty = (params) => {
2105
2107
  }
2106
2108
  return;
2107
2109
  }
2108
- const elementPropSchema = (0, import_editor_elements6.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
2110
+ const elementPropSchema = (0, import_editor_elements5.getWidgetsCache)()?.[elementType]?.atomic_props_schema;
2109
2111
  if (!elementPropSchema) {
2110
2112
  throw new Error(`No prop schema found for element type: ${elementType}`);
2111
2113
  }
@@ -2119,7 +2121,7 @@ var doUpdateElementProperty = (params) => {
2119
2121
  }
2120
2122
  const propKey = elementPropSchema[propertyName].key;
2121
2123
  const value = resolvePropValue(propertyValue, propKey);
2122
- (0, import_editor_elements6.updateElementSettings)({
2124
+ (0, import_editor_elements5.updateElementSettings)({
2123
2125
  id: elementId,
2124
2126
  props: {
2125
2127
  [propertyName]: value
@@ -2129,7 +2131,7 @@ var doUpdateElementProperty = (params) => {
2129
2131
  };
2130
2132
 
2131
2133
  // src/mcp/utils/validate-input.ts
2132
- var import_editor_elements7 = require("@elementor/editor-elements");
2134
+ var import_editor_elements6 = require("@elementor/editor-elements");
2133
2135
  var import_editor_props5 = require("@elementor/editor-props");
2134
2136
  var import_editor_styles6 = require("@elementor/editor-styles");
2135
2137
  var _widgetsSchema = null;
@@ -2137,7 +2139,7 @@ var validateInput = {
2137
2139
  get widgetsSchema() {
2138
2140
  if (!_widgetsSchema) {
2139
2141
  const schema2 = {};
2140
- const cache = (0, import_editor_elements7.getWidgetsCache)();
2142
+ const cache = (0, import_editor_elements6.getWidgetsCache)();
2141
2143
  if (!cache) {
2142
2144
  return {};
2143
2145
  }
@@ -2593,8 +2595,8 @@ var initBuildCompositionsTool = (reg) => {
2593
2595
  const errors = [];
2594
2596
  const softErrors = [];
2595
2597
  const rootContainers = [];
2596
- const widgetsCache = (0, import_editor_elements8.getWidgetsCache)() || {};
2597
- const documentContainer = (0, import_editor_elements8.getContainer)("document");
2598
+ const widgetsCache = (0, import_editor_elements7.getWidgetsCache)() || {};
2599
+ const documentContainer = (0, import_editor_elements7.getContainer)("document");
2598
2600
  try {
2599
2601
  const parser = new DOMParser();
2600
2602
  xml = parser.parseFromString(xmlStructure, "application/xml");
@@ -2615,19 +2617,19 @@ var initBuildCompositionsTool = (reg) => {
2615
2617
  if (!targetContainerId) {
2616
2618
  targetContainerId = containerElement.id;
2617
2619
  }
2618
- const newElement = isContainer ? (0, import_editor_elements8.createElement)({
2620
+ const newElement = isContainer ? (0, import_editor_elements7.createElement)({
2619
2621
  containerId: targetContainerId,
2620
2622
  model: {
2621
2623
  elType: elementTag,
2622
- id: (0, import_editor_elements8.generateElementId)()
2624
+ id: (0, import_editor_elements7.generateElementId)()
2623
2625
  },
2624
2626
  options: { useHistory: false }
2625
- }) : (0, import_editor_elements8.createElement)({
2627
+ }) : (0, import_editor_elements7.createElement)({
2626
2628
  containerId: targetContainerId,
2627
2629
  model: {
2628
2630
  elType: "widget",
2629
2631
  widgetType: elementTag,
2630
- id: (0, import_editor_elements8.generateElementId)()
2632
+ id: (0, import_editor_elements7.generateElementId)()
2631
2633
  },
2632
2634
  options: { useHistory: false }
2633
2635
  });
@@ -2689,7 +2691,7 @@ var initBuildCompositionsTool = (reg) => {
2689
2691
  }
2690
2692
  if (errors.length) {
2691
2693
  rootContainers.forEach((rootContainer) => {
2692
- (0, import_editor_elements8.deleteElement)({
2694
+ (0, import_editor_elements7.deleteElement)({
2693
2695
  elementId: rootContainer.id,
2694
2696
  options: { useHistory: false }
2695
2697
  });
@@ -2935,7 +2937,7 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
2935
2937
  }
2936
2938
 
2937
2939
  // src/mcp/tools/get-element-config/tool.ts
2938
- var import_editor_elements9 = require("@elementor/editor-elements");
2940
+ var import_editor_elements8 = require("@elementor/editor-elements");
2939
2941
  var import_editor_props6 = require("@elementor/editor-props");
2940
2942
  var import_schema5 = require("@elementor/schema");
2941
2943
  var schema = {
@@ -2970,12 +2972,12 @@ var initGetElementConfigTool = (reg) => {
2970
2972
  schema,
2971
2973
  outputSchema: outputSchema3,
2972
2974
  handler: async ({ elementId }) => {
2973
- const element = (0, import_editor_elements9.getContainer)(elementId);
2975
+ const element = (0, import_editor_elements8.getContainer)(elementId);
2974
2976
  if (!element) {
2975
2977
  throw new Error(`Element with ID ${elementId} not found.`);
2976
2978
  }
2977
2979
  const elementRawSettings = element.settings;
2978
- const propSchema = (0, import_editor_elements9.getWidgetsCache)()?.[element.model.get("widgetType") || element.model.get("elType") || ""]?.atomic_props_schema;
2980
+ const propSchema = (0, import_editor_elements8.getWidgetsCache)()?.[element.model.get("widgetType") || element.model.get("elType") || ""]?.atomic_props_schema;
2979
2981
  if (!elementRawSettings || !propSchema) {
2980
2982
  throw new Error(`No settings or prop schema found for element ID: ${elementId}`);
2981
2983
  }
@@ -2984,7 +2986,7 @@ var initGetElementConfigTool = (reg) => {
2984
2986
  import_editor_props6.Schema.configurableKeys(propSchema).forEach((key) => {
2985
2987
  propValues[key] = structuredClone(elementRawSettings.get(key));
2986
2988
  });
2987
- const elementStyles = (0, import_editor_elements9.getElementStyles)(elementId) || {};
2989
+ const elementStyles = (0, import_editor_elements8.getElementStyles)(elementId) || {};
2988
2990
  const localStyle = Object.values(elementStyles).find((style) => style.label === "local");
2989
2991
  if (localStyle) {
2990
2992
  const defaultVariant = localStyle.variants.find(
@@ -3156,7 +3158,7 @@ An Example scenario of creating fully styled composition:
3156
3158
  `;
3157
3159
 
3158
3160
  // src/prevent-link-in-link-commands.ts
3159
- var import_editor_elements10 = require("@elementor/editor-elements");
3161
+ var import_editor_elements9 = require("@elementor/editor-elements");
3160
3162
  var import_editor_notifications = require("@elementor/editor-notifications");
3161
3163
  var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
3162
3164
  var import_i18n = require("@wordpress/i18n");
@@ -3227,13 +3229,13 @@ function shouldBlock(sourceElements, targetElements) {
3227
3229
  return false;
3228
3230
  }
3229
3231
  const isSourceContainsAnAnchor = sourceElements.some((src) => {
3230
- return src?.id ? (0, import_editor_elements10.isElementAnchored)(src.id) || !!(0, import_editor_elements10.getAnchoredDescendantId)(src.id) : false;
3232
+ return src?.id ? (0, import_editor_elements9.isElementAnchored)(src.id) || !!(0, import_editor_elements9.getAnchoredDescendantId)(src.id) : false;
3231
3233
  });
3232
3234
  if (!isSourceContainsAnAnchor) {
3233
3235
  return false;
3234
3236
  }
3235
3237
  const isTargetContainsAnAnchor = targetElements.some((target) => {
3236
- return target?.id ? (0, import_editor_elements10.isElementAnchored)(target.id) || !!(0, import_editor_elements10.getAnchoredAncestorId)(target.id) : false;
3238
+ return target?.id ? (0, import_editor_elements9.isElementAnchored)(target.id) || !!(0, import_editor_elements9.getAnchoredAncestorId)(target.id) : false;
3237
3239
  });
3238
3240
  return isTargetContainsAnAnchor;
3239
3241
  }
@@ -3242,13 +3244,13 @@ function shouldBlock(sourceElements, targetElements) {
3242
3244
  var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
3243
3245
 
3244
3246
  // src/style-commands/undoable-actions/paste-element-style.ts
3245
- var import_editor_elements12 = require("@elementor/editor-elements");
3247
+ var import_editor_elements11 = require("@elementor/editor-elements");
3246
3248
  var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
3247
3249
  var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
3248
3250
  var import_i18n3 = require("@wordpress/i18n");
3249
3251
 
3250
3252
  // src/style-commands/utils.ts
3251
- var import_editor_elements11 = require("@elementor/editor-elements");
3253
+ var import_editor_elements10 = require("@elementor/editor-elements");
3252
3254
  var import_editor_props7 = require("@elementor/editor-props");
3253
3255
  var import_i18n2 = require("@wordpress/i18n");
3254
3256
  function hasAtomicWidgets(args) {
@@ -3273,7 +3275,7 @@ function getClassesProp(container) {
3273
3275
  }
3274
3276
  function getContainerSchema(container) {
3275
3277
  const type = container?.model.get("widgetType") || container?.model.get("elType");
3276
- const widgetsCache = (0, import_editor_elements11.getWidgetsCache)();
3278
+ const widgetsCache = (0, import_editor_elements10.getWidgetsCache)();
3277
3279
  const elementType = widgetsCache?.[type];
3278
3280
  return elementType?.atomic_props_schema ?? null;
3279
3281
  }
@@ -3286,7 +3288,7 @@ function getClipboardElements(storageKey = "clipboard") {
3286
3288
  }
3287
3289
  }
3288
3290
  function getTitleForContainers(containers) {
3289
- return containers.length > 1 ? (0, import_i18n2.__)("Elements", "elementor") : (0, import_editor_elements11.getElementLabel)(containers[0].id);
3291
+ return containers.length > 1 ? (0, import_i18n2.__)("Elements", "elementor") : (0, import_editor_elements10.getElementLabel)(containers[0].id);
3290
3292
  }
3291
3293
 
3292
3294
  // src/style-commands/undoable-actions/paste-element-style.ts
@@ -3299,7 +3301,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters12.undoable)(
3299
3301
  if (!classesProp) {
3300
3302
  return null;
3301
3303
  }
3302
- const originalStyles = (0, import_editor_elements12.getElementStyles)(container.id);
3304
+ const originalStyles = (0, import_editor_elements11.getElementStyles)(container.id);
3303
3305
  const [styleId, styleDef] = Object.entries(originalStyles ?? {})[0] ?? [];
3304
3306
  const originalStyle = Object.keys(styleDef ?? {}).length ? styleDef : null;
3305
3307
  const revertData = {
@@ -3308,7 +3310,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters12.undoable)(
3308
3310
  };
3309
3311
  if (styleId) {
3310
3312
  newStyle.variants.forEach(({ meta, props, custom_css: customCss }) => {
3311
- (0, import_editor_elements12.updateElementStyle)({
3313
+ (0, import_editor_elements11.updateElementStyle)({
3312
3314
  elementId,
3313
3315
  styleId,
3314
3316
  meta,
@@ -3319,7 +3321,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters12.undoable)(
3319
3321
  } else {
3320
3322
  const [firstVariant] = newStyle.variants;
3321
3323
  const additionalVariants = newStyle.variants.slice(1);
3322
- revertData.styleId = (0, import_editor_elements12.createElementStyle)({
3324
+ revertData.styleId = (0, import_editor_elements11.createElementStyle)({
3323
3325
  elementId,
3324
3326
  classesProp,
3325
3327
  label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
@@ -3337,7 +3339,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters12.undoable)(
3337
3339
  return;
3338
3340
  }
3339
3341
  if (!revertData.originalStyle) {
3340
- (0, import_editor_elements12.deleteElementStyle)(container.id, revertData.styleId);
3342
+ (0, import_editor_elements11.deleteElementStyle)(container.id, revertData.styleId);
3341
3343
  return;
3342
3344
  }
3343
3345
  const classesProp = getClassesProp(container);
@@ -3346,7 +3348,7 @@ var undoablePasteElementStyle = () => (0, import_editor_v1_adapters12.undoable)(
3346
3348
  }
3347
3349
  const [firstVariant] = revertData.originalStyle.variants;
3348
3350
  const additionalVariants = revertData.originalStyle.variants.slice(1);
3349
- (0, import_editor_elements12.createElementStyle)({
3351
+ (0, import_editor_elements11.createElementStyle)({
3350
3352
  elementId: container.id,
3351
3353
  classesProp,
3352
3354
  label: import_editor_styles_repository4.ELEMENTS_STYLES_RESERVED_LABEL,
@@ -3398,7 +3400,7 @@ function pasteStyles(args, pasteCallback) {
3398
3400
  var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
3399
3401
 
3400
3402
  // src/style-commands/undoable-actions/reset-element-style.ts
3401
- var import_editor_elements13 = require("@elementor/editor-elements");
3403
+ var import_editor_elements12 = require("@elementor/editor-elements");
3402
3404
  var import_editor_styles_repository5 = require("@elementor/editor-styles-repository");
3403
3405
  var import_editor_v1_adapters14 = require("@elementor/editor-v1-adapters");
3404
3406
  var import_i18n4 = require("@wordpress/i18n");
@@ -3407,9 +3409,9 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters14.undoable)(
3407
3409
  do: ({ containers }) => {
3408
3410
  return containers.map((container) => {
3409
3411
  const elementId = container.model.get("id");
3410
- const containerStyles = (0, import_editor_elements13.getElementStyles)(elementId);
3412
+ const containerStyles = (0, import_editor_elements12.getElementStyles)(elementId);
3411
3413
  Object.keys(containerStyles ?? {}).forEach(
3412
- (styleId) => (0, import_editor_elements13.deleteElementStyle)(elementId, styleId)
3414
+ (styleId) => (0, import_editor_elements12.deleteElementStyle)(elementId, styleId)
3413
3415
  );
3414
3416
  return containerStyles;
3415
3417
  });
@@ -3425,7 +3427,7 @@ var undoableResetElementStyle = () => (0, import_editor_v1_adapters14.undoable)(
3425
3427
  Object.entries(containerStyles ?? {}).forEach(([styleId, style]) => {
3426
3428
  const [firstVariant] = style.variants;
3427
3429
  const additionalVariants = style.variants.slice(1);
3428
- (0, import_editor_elements13.createElementStyle)({
3430
+ (0, import_editor_elements12.createElementStyle)({
3429
3431
  elementId,
3430
3432
  classesProp,
3431
3433
  styleId,
@@ -3475,6 +3477,7 @@ function init() {
3475
3477
  initStyleTransformers();
3476
3478
  initStyleCommands();
3477
3479
  initLinkInLinkPrevention();
3480
+ initViewReplacements();
3478
3481
  initLegacyViews();
3479
3482
  initSettingsTransformers();
3480
3483
  (0, import_editor_interactions2.init)();