@elementor/editor-canvas 3.35.0-358 → 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.d.mts +47 -2
- package/dist/index.d.ts +47 -2
- package/dist/index.js +303 -304
- package/dist/index.mjs +274 -278
- package/package.json +18 -18
- package/src/components/__tests__/elements-overlays.test.tsx +0 -3
- package/src/index.ts +1 -0
- package/src/init.tsx +3 -0
- package/src/legacy/create-templated-element-type.ts +4 -4
- package/src/legacy/init-legacy-views.ts +3 -10
- package/src/legacy/replacements/base.ts +35 -0
- package/src/legacy/replacements/inline-editing/inline-editing-elements.tsx +161 -0
- package/src/legacy/replacements/inline-editing/inline-editing-utils.ts +31 -0
- package/src/legacy/replacements/manager.ts +119 -0
- package/src/legacy/types.ts +14 -1
- package/src/renderers/__tests__/__snapshots__/create-styles-renderer.test.ts.snap +1 -1
- package/src/renderers/create-styles-renderer.ts +5 -15
- package/src/legacy/create-inline-editing-element-type.tsx +0 -199
- package/src/utils/__tests__/inline-editing.test.ts +0 -553
- package/src/utils/inline-editing-utils.ts +0 -138
package/dist/index.mjs
CHANGED
|
@@ -230,8 +230,8 @@ var subscribeToStylesRepository = () => {
|
|
|
230
230
|
});
|
|
231
231
|
};
|
|
232
232
|
var renameClass = (oldClassName, newClassName) => {
|
|
233
|
-
Object.values(getV1DocumentsManager().documents).forEach((
|
|
234
|
-
const container =
|
|
233
|
+
Object.values(getV1DocumentsManager().documents).forEach((document) => {
|
|
234
|
+
const container = document.container;
|
|
235
235
|
container.view?.el?.querySelectorAll(`.elementor .${oldClassName}`).forEach((element) => {
|
|
236
236
|
element.classList.replace(oldClassName, newClassName);
|
|
237
237
|
});
|
|
@@ -567,14 +567,14 @@ function useDocumentsCssLinks() {
|
|
|
567
567
|
}));
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
|
-
function getDocumentsIdsInCanvas(
|
|
571
|
-
return [...
|
|
570
|
+
function getDocumentsIdsInCanvas(document) {
|
|
571
|
+
return [...document.body.querySelectorAll(`[${DOCUMENT_WRAPPER_ATTR}]`) ?? []].map(
|
|
572
572
|
(el) => el.getAttribute(DOCUMENT_WRAPPER_ATTR) || ""
|
|
573
573
|
);
|
|
574
574
|
}
|
|
575
|
-
function getDocumentsCssLinks(
|
|
575
|
+
function getDocumentsCssLinks(document) {
|
|
576
576
|
return [
|
|
577
|
-
...
|
|
577
|
+
...document.head.querySelectorAll(
|
|
578
578
|
`link[rel="stylesheet"][id^=${CSS_LINK_ID_PREFIX}][id$=${CSS_LINK_ID_SUFFIX}]`
|
|
579
579
|
) ?? []
|
|
580
580
|
];
|
|
@@ -587,7 +587,7 @@ function getLinkAttrs(el) {
|
|
|
587
587
|
// src/hooks/use-style-items.ts
|
|
588
588
|
import { useEffect as useEffect6, useMemo as useMemo4, useState as useState3 } from "react";
|
|
589
589
|
import { getBreakpoints } from "@elementor/editor-responsive";
|
|
590
|
-
import { isClassState
|
|
590
|
+
import { isClassState } from "@elementor/editor-styles";
|
|
591
591
|
import { stylesRepository as stylesRepository2 } from "@elementor/editor-styles-repository";
|
|
592
592
|
import { registerDataHook as registerDataHook2 } from "@elementor/editor-v1-adapters";
|
|
593
593
|
|
|
@@ -774,8 +774,7 @@ import { useBreakpointsMap } from "@elementor/editor-responsive";
|
|
|
774
774
|
|
|
775
775
|
// src/renderers/create-styles-renderer.ts
|
|
776
776
|
import {
|
|
777
|
-
|
|
778
|
-
isPseudoState
|
|
777
|
+
getSelectorWithState
|
|
779
778
|
} from "@elementor/editor-styles";
|
|
780
779
|
import { decodeString } from "@elementor/utils";
|
|
781
780
|
|
|
@@ -824,16 +823,8 @@ function createStyleWrapper(value = "", wrapper) {
|
|
|
824
823
|
},
|
|
825
824
|
withPrefix: (prefix) => createStyleWrapper([prefix, value].filter(Boolean).join(" "), wrapper),
|
|
826
825
|
withState: (state) => {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
if (isClassState(state)) {
|
|
831
|
-
return createStyleWrapper(`${value}.${state}`, wrapper);
|
|
832
|
-
}
|
|
833
|
-
if (isPseudoState(state)) {
|
|
834
|
-
return createStyleWrapper(`${value}:${state}`, wrapper);
|
|
835
|
-
}
|
|
836
|
-
throw new UnknownStyleStateError({ context: { state } });
|
|
826
|
+
const selector = getSelectorWithState(value, state);
|
|
827
|
+
return createStyleWrapper(selector, wrapper);
|
|
837
828
|
},
|
|
838
829
|
withMediaQuery: (breakpoint) => {
|
|
839
830
|
if (!breakpoint?.type) {
|
|
@@ -927,10 +918,10 @@ function sortByBreakpoint(breakpointsOrder) {
|
|
|
927
918
|
return ({ breakpoint: breakpointA }, { breakpoint: breakpointB }) => breakpointsOrder.indexOf(breakpointA) - breakpointsOrder.indexOf(breakpointB);
|
|
928
919
|
}
|
|
929
920
|
function sortByStateType({ state: stateA }, { state: stateB }) {
|
|
930
|
-
if (
|
|
921
|
+
if (isClassState(stateA) && !isClassState(stateB)) {
|
|
931
922
|
return -1;
|
|
932
923
|
}
|
|
933
|
-
if (!
|
|
924
|
+
if (!isClassState(stateA) && isClassState(stateB)) {
|
|
934
925
|
return 1;
|
|
935
926
|
}
|
|
936
927
|
return 0;
|
|
@@ -1471,98 +1462,6 @@ function escapeURL(value) {
|
|
|
1471
1462
|
}
|
|
1472
1463
|
}
|
|
1473
1464
|
|
|
1474
|
-
// src/utils/inline-editing-utils.ts
|
|
1475
|
-
import { getContainer, getElementType } from "@elementor/editor-elements";
|
|
1476
|
-
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
1477
|
-
var WIDGET_PROPERTY_MAP = {
|
|
1478
|
-
"e-heading": "title",
|
|
1479
|
-
"e-paragraph": "paragraph"
|
|
1480
|
-
};
|
|
1481
|
-
var EXPERIMENT_KEY = "v4-inline-text-editing";
|
|
1482
|
-
var legacyWindow = window;
|
|
1483
|
-
var shouldRenderInlineEditingView = (elementType) => {
|
|
1484
|
-
return elementType in WIDGET_PROPERTY_MAP && isExperimentActive(EXPERIMENT_KEY);
|
|
1485
|
-
};
|
|
1486
|
-
var getWidgetType = (container) => {
|
|
1487
|
-
return container?.model?.get("widgetType") ?? container?.model?.get("elType") ?? null;
|
|
1488
|
-
};
|
|
1489
|
-
var getHtmlPropertyName = (container) => {
|
|
1490
|
-
const widgetType = getWidgetType(container);
|
|
1491
|
-
if (!widgetType) {
|
|
1492
|
-
return "";
|
|
1493
|
-
}
|
|
1494
|
-
const propsSchema = getElementType(widgetType)?.propsSchema;
|
|
1495
|
-
if (WIDGET_PROPERTY_MAP[widgetType]) {
|
|
1496
|
-
return WIDGET_PROPERTY_MAP[widgetType];
|
|
1497
|
-
}
|
|
1498
|
-
if (!propsSchema) {
|
|
1499
|
-
return "";
|
|
1500
|
-
}
|
|
1501
|
-
const entry = Object.entries(propsSchema).find(([, propType]) => {
|
|
1502
|
-
switch (propType.kind) {
|
|
1503
|
-
case "union":
|
|
1504
|
-
return propType.prop_types.html;
|
|
1505
|
-
case "object":
|
|
1506
|
-
return propType.shape.html;
|
|
1507
|
-
case "array":
|
|
1508
|
-
return "key" in propType.item_prop_type && propType.item_prop_type.key === "html";
|
|
1509
|
-
}
|
|
1510
|
-
return propType.key === "html";
|
|
1511
|
-
});
|
|
1512
|
-
return entry?.[0] ?? "";
|
|
1513
|
-
};
|
|
1514
|
-
var getHtmlPropType = (container) => {
|
|
1515
|
-
const widgetType = getWidgetType(container);
|
|
1516
|
-
if (!widgetType) {
|
|
1517
|
-
return null;
|
|
1518
|
-
}
|
|
1519
|
-
const propsSchema = getElementType(widgetType)?.propsSchema;
|
|
1520
|
-
const propertyName = getHtmlPropertyName(container) ?? null;
|
|
1521
|
-
return propsSchema?.[propertyName] ?? null;
|
|
1522
|
-
};
|
|
1523
|
-
var getInlineEditablePropertyName = (container) => {
|
|
1524
|
-
return getHtmlPropertyName(container) ?? "";
|
|
1525
|
-
};
|
|
1526
|
-
var getBlockedValue = (value, tag) => {
|
|
1527
|
-
if (!value) {
|
|
1528
|
-
return "";
|
|
1529
|
-
}
|
|
1530
|
-
if (!tag) {
|
|
1531
|
-
return value;
|
|
1532
|
-
}
|
|
1533
|
-
const pseudoElement = document.createElement("div");
|
|
1534
|
-
pseudoElement.innerHTML = value;
|
|
1535
|
-
if (!pseudoElement?.children.length) {
|
|
1536
|
-
return `<${tag}>${value}</${tag}>`;
|
|
1537
|
-
}
|
|
1538
|
-
const firstChild = pseudoElement.children[0];
|
|
1539
|
-
const lastChild = Array.from(pseudoElement.children).slice(-1)[0];
|
|
1540
|
-
if (firstChild === lastChild && pseudoElement.textContent === firstChild.textContent) {
|
|
1541
|
-
return compareTag(firstChild, tag) ? value : `<${tag}>${firstChild.innerHTML}</${tag}>`;
|
|
1542
|
-
}
|
|
1543
|
-
if (!value.startsWith(`<${tag}`) || !value.endsWith(`</${tag}>`)) {
|
|
1544
|
-
return `<${tag}>${value}</${tag}>`;
|
|
1545
|
-
}
|
|
1546
|
-
if (firstChild !== lastChild || !compareTag(firstChild, tag)) {
|
|
1547
|
-
return `<${tag}>${value}</${tag}>`;
|
|
1548
|
-
}
|
|
1549
|
-
return value;
|
|
1550
|
-
};
|
|
1551
|
-
var compareTag = (el, tag) => {
|
|
1552
|
-
return el.tagName.toUpperCase() === tag.toUpperCase();
|
|
1553
|
-
};
|
|
1554
|
-
var getInitialPopoverPosition = () => {
|
|
1555
|
-
const positionFallback = { left: 0, top: 0 };
|
|
1556
|
-
const iFrameElement = legacyWindow?.elementor?.$preview?.get(0);
|
|
1557
|
-
const iFramePosition = iFrameElement?.getBoundingClientRect() ?? positionFallback;
|
|
1558
|
-
const previewElement = legacyWindow?.elementor?.$previewWrapper?.get(0);
|
|
1559
|
-
const previewPosition = previewElement ? { left: previewElement.scrollLeft, top: previewElement.scrollTop } : positionFallback;
|
|
1560
|
-
return {
|
|
1561
|
-
left: iFramePosition.left + previewPosition.left,
|
|
1562
|
-
top: iFramePosition.top + previewPosition.top
|
|
1563
|
-
};
|
|
1564
|
-
};
|
|
1565
|
-
|
|
1566
1465
|
// src/legacy/create-element-type.ts
|
|
1567
1466
|
function createElementType(type) {
|
|
1568
1467
|
const legacyWindow2 = window;
|
|
@@ -1639,37 +1538,7 @@ function createElementViewClassDeclaration() {
|
|
|
1639
1538
|
};
|
|
1640
1539
|
}
|
|
1641
1540
|
|
|
1642
|
-
// src/legacy/create-inline-editing-element-type.tsx
|
|
1643
|
-
import * as React5 from "react";
|
|
1644
|
-
import { createRoot } from "react-dom/client";
|
|
1645
|
-
import { InlineEditor } from "@elementor/editor-controls";
|
|
1646
|
-
import { getElementType as getElementType2 } from "@elementor/editor-elements";
|
|
1647
|
-
import {
|
|
1648
|
-
htmlPropTypeUtil,
|
|
1649
|
-
stringPropTypeUtil
|
|
1650
|
-
} from "@elementor/editor-props";
|
|
1651
|
-
import { ThemeProvider } from "@elementor/editor-ui";
|
|
1652
|
-
|
|
1653
1541
|
// src/legacy/create-templated-element-type.ts
|
|
1654
|
-
function createTemplatedElementType({
|
|
1655
|
-
type,
|
|
1656
|
-
renderer,
|
|
1657
|
-
element
|
|
1658
|
-
}) {
|
|
1659
|
-
const legacyWindow2 = window;
|
|
1660
|
-
return class extends legacyWindow2.elementor.modules.elements.types.Widget {
|
|
1661
|
-
getType() {
|
|
1662
|
-
return type;
|
|
1663
|
-
}
|
|
1664
|
-
getView() {
|
|
1665
|
-
return createTemplatedElementView({
|
|
1666
|
-
type,
|
|
1667
|
-
renderer,
|
|
1668
|
-
element
|
|
1669
|
-
});
|
|
1670
|
-
}
|
|
1671
|
-
};
|
|
1672
|
-
}
|
|
1673
1542
|
function canBeTemplated(element) {
|
|
1674
1543
|
return !!(element.atomic_props_schema && element.twig_templates && element.twig_main_template && element.base_styles_dictionary);
|
|
1675
1544
|
}
|
|
@@ -1701,9 +1570,9 @@ function createTemplatedElementView({
|
|
|
1701
1570
|
render() {
|
|
1702
1571
|
this.#abortController?.abort();
|
|
1703
1572
|
this.#abortController = new AbortController();
|
|
1704
|
-
const process = signalizedProcess(this.#abortController.signal).then(() => this
|
|
1573
|
+
const process = signalizedProcess(this.#abortController.signal).then(() => this._beforeRender()).then(() => this._renderTemplate()).then(() => {
|
|
1705
1574
|
this._renderChildren();
|
|
1706
|
-
this
|
|
1575
|
+
this._afterRender();
|
|
1707
1576
|
});
|
|
1708
1577
|
return process.execute();
|
|
1709
1578
|
}
|
|
@@ -1734,13 +1603,13 @@ function createTemplatedElementView({
|
|
|
1734
1603
|
afterSettingsResolve(settings) {
|
|
1735
1604
|
return settings;
|
|
1736
1605
|
}
|
|
1737
|
-
|
|
1606
|
+
_beforeRender() {
|
|
1738
1607
|
this._ensureViewIsIntact();
|
|
1739
1608
|
this._isRendering = true;
|
|
1740
1609
|
this.resetChildViewContainer();
|
|
1741
1610
|
this.triggerMethod("before:render", this);
|
|
1742
1611
|
}
|
|
1743
|
-
|
|
1612
|
+
_afterRender() {
|
|
1744
1613
|
this._isRendering = false;
|
|
1745
1614
|
this.isRendered = true;
|
|
1746
1615
|
this.triggerMethod("render", this);
|
|
@@ -1748,141 +1617,265 @@ function createTemplatedElementView({
|
|
|
1748
1617
|
};
|
|
1749
1618
|
}
|
|
1750
1619
|
|
|
1751
|
-
// src/legacy/
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1620
|
+
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
1621
|
+
import * as React5 from "react";
|
|
1622
|
+
import { createRoot } from "react-dom/client";
|
|
1623
|
+
import { InlineEditor } from "@elementor/editor-controls";
|
|
1624
|
+
import { getElementType } from "@elementor/editor-elements";
|
|
1625
|
+
import {
|
|
1626
|
+
htmlPropTypeUtil,
|
|
1627
|
+
stringPropTypeUtil
|
|
1628
|
+
} from "@elementor/editor-props";
|
|
1629
|
+
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
1630
|
+
import { ThemeProvider } from "@elementor/ui";
|
|
1631
|
+
|
|
1632
|
+
// src/legacy/replacements/base.ts
|
|
1633
|
+
var ReplacementBase = class {
|
|
1634
|
+
getSetting;
|
|
1635
|
+
setSetting;
|
|
1636
|
+
element;
|
|
1637
|
+
type;
|
|
1638
|
+
id;
|
|
1639
|
+
refreshView;
|
|
1640
|
+
constructor(settings) {
|
|
1641
|
+
this.getSetting = settings.getSetting;
|
|
1642
|
+
this.setSetting = settings.setSetting;
|
|
1643
|
+
this.element = settings.element;
|
|
1644
|
+
this.type = settings.type;
|
|
1645
|
+
this.id = settings.id;
|
|
1646
|
+
this.refreshView = settings.refreshView;
|
|
1647
|
+
}
|
|
1648
|
+
static getTypes() {
|
|
1649
|
+
return null;
|
|
1650
|
+
}
|
|
1651
|
+
render() {
|
|
1652
|
+
}
|
|
1653
|
+
onDestroy() {
|
|
1654
|
+
}
|
|
1655
|
+
_beforeRender() {
|
|
1656
|
+
}
|
|
1657
|
+
_afterRender() {
|
|
1658
|
+
}
|
|
1659
|
+
shouldRenderReplacement() {
|
|
1660
|
+
return true;
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
|
|
1664
|
+
// src/legacy/replacements/inline-editing/inline-editing-utils.ts
|
|
1665
|
+
var INLINE_EDITING_PROPERTY_PER_TYPE = {
|
|
1666
|
+
"e-heading": "title",
|
|
1667
|
+
"e-paragraph": "paragraph"
|
|
1668
|
+
};
|
|
1669
|
+
var legacyWindow = window;
|
|
1670
|
+
var getInitialPopoverPosition = () => {
|
|
1671
|
+
const positionFallback = { left: 0, top: 0 };
|
|
1672
|
+
const iFrameElement = legacyWindow?.elementor?.$preview?.get(0);
|
|
1673
|
+
const iFramePosition = iFrameElement?.getBoundingClientRect() ?? positionFallback;
|
|
1674
|
+
const previewElement = legacyWindow?.elementor?.$previewWrapper?.get(0);
|
|
1675
|
+
const previewPosition = previewElement ? { left: previewElement.scrollLeft, top: previewElement.scrollTop } : positionFallback;
|
|
1676
|
+
return {
|
|
1677
|
+
left: iFramePosition.left + previewPosition.left,
|
|
1678
|
+
top: iFramePosition.top + previewPosition.top
|
|
1768
1679
|
};
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
handleRenderInlineEditor(event) {
|
|
1793
|
-
event.stopPropagation();
|
|
1794
|
-
this.$el.off("dblclick", "*");
|
|
1795
|
-
this.handlerAttached = false;
|
|
1796
|
-
if (!this.isValueDynamic()) {
|
|
1797
|
-
this.renderInlineEditor();
|
|
1798
|
-
}
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1682
|
+
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
1683
|
+
var EXPERIMENT_KEY = "v4-inline-text-editing";
|
|
1684
|
+
var InlineEditingReplacement = class extends ReplacementBase {
|
|
1685
|
+
inlineEditorRoot = null;
|
|
1686
|
+
handlerAttached = false;
|
|
1687
|
+
getReplacementKey() {
|
|
1688
|
+
return "inline-editing";
|
|
1689
|
+
}
|
|
1690
|
+
static getTypes() {
|
|
1691
|
+
return Object.keys(INLINE_EDITING_PROPERTY_PER_TYPE);
|
|
1692
|
+
}
|
|
1693
|
+
isEditingModeActive() {
|
|
1694
|
+
return !!this.inlineEditorRoot;
|
|
1695
|
+
}
|
|
1696
|
+
shouldRenderReplacement() {
|
|
1697
|
+
return isExperimentActive(EXPERIMENT_KEY) && this.isEditingModeActive() && !this.isValueDynamic();
|
|
1698
|
+
}
|
|
1699
|
+
handleRenderInlineEditor = (event) => {
|
|
1700
|
+
event.stopPropagation();
|
|
1701
|
+
if (!this.isValueDynamic()) {
|
|
1702
|
+
this.renderInlineEditor();
|
|
1799
1703
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1704
|
+
};
|
|
1705
|
+
handleUnmountInlineEditor = (event) => {
|
|
1706
|
+
event.stopPropagation();
|
|
1707
|
+
this.unmountInlineEditor();
|
|
1708
|
+
};
|
|
1709
|
+
onDestroy() {
|
|
1710
|
+
this.resetInlineEditorRoot();
|
|
1711
|
+
}
|
|
1712
|
+
_beforeRender() {
|
|
1713
|
+
this.resetInlineEditorRoot();
|
|
1714
|
+
}
|
|
1715
|
+
_afterRender() {
|
|
1716
|
+
if (!this.isValueDynamic() && !this.handlerAttached) {
|
|
1717
|
+
this.element.addEventListener("dblclick", this.handleRenderInlineEditor);
|
|
1718
|
+
this.handlerAttached = true;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
resetInlineEditorRoot() {
|
|
1722
|
+
this.element.removeEventListener("dblclick", this.handleRenderInlineEditor);
|
|
1723
|
+
this.handlerAttached = false;
|
|
1724
|
+
this.inlineEditorRoot?.unmount?.();
|
|
1725
|
+
this.inlineEditorRoot = null;
|
|
1726
|
+
}
|
|
1727
|
+
unmountInlineEditor() {
|
|
1728
|
+
this.resetInlineEditorRoot();
|
|
1729
|
+
this.refreshView();
|
|
1730
|
+
}
|
|
1731
|
+
isValueDynamic() {
|
|
1732
|
+
const settingKey = this.getInlineEditablePropertyName();
|
|
1733
|
+
const propValue = this.getSetting(settingKey);
|
|
1734
|
+
return propValue?.$$type === "dynamic";
|
|
1735
|
+
}
|
|
1736
|
+
getInlineEditablePropertyName() {
|
|
1737
|
+
return INLINE_EDITING_PROPERTY_PER_TYPE[this.type] ?? "";
|
|
1738
|
+
}
|
|
1739
|
+
getHtmlPropType() {
|
|
1740
|
+
const propSchema = getElementType(this.type)?.propsSchema;
|
|
1741
|
+
const propertyName = this.getInlineEditablePropertyName();
|
|
1742
|
+
return propSchema?.[propertyName] ?? null;
|
|
1743
|
+
}
|
|
1744
|
+
getContentValue() {
|
|
1745
|
+
const prop = this.getHtmlPropType();
|
|
1746
|
+
const defaultValue = prop?.default?.value ?? "";
|
|
1747
|
+
const settingKey = this.getInlineEditablePropertyName();
|
|
1748
|
+
return htmlPropTypeUtil.extract(this.getSetting(settingKey) ?? null) ?? htmlPropTypeUtil.extract(prop?.default ?? null) ?? defaultValue ?? "";
|
|
1749
|
+
}
|
|
1750
|
+
setContentValue(value) {
|
|
1751
|
+
const settingKey = this.getInlineEditablePropertyName();
|
|
1752
|
+
const valueToSave = value ? htmlPropTypeUtil.create(value) : null;
|
|
1753
|
+
this.setSetting(settingKey, valueToSave);
|
|
1754
|
+
}
|
|
1755
|
+
getExpectedTag() {
|
|
1756
|
+
const propsSchema = getElementType(this.type)?.propsSchema;
|
|
1757
|
+
if (!propsSchema?.tag) {
|
|
1758
|
+
return null;
|
|
1803
1759
|
}
|
|
1804
|
-
|
|
1760
|
+
const tagSettingKey = "tag";
|
|
1761
|
+
return stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? stringPropTypeUtil.extract(propsSchema.tag.default ?? null) ?? null;
|
|
1762
|
+
}
|
|
1763
|
+
renderInlineEditor() {
|
|
1764
|
+
const propValue = this.getContentValue();
|
|
1765
|
+
const classes = (this.element.children?.[0]?.classList.toString() ?? "") + " strip-styles";
|
|
1766
|
+
const expectedTag = this.getExpectedTag();
|
|
1767
|
+
this.element.innerHTML = "";
|
|
1768
|
+
if (this.inlineEditorRoot) {
|
|
1805
1769
|
this.resetInlineEditorRoot();
|
|
1806
|
-
TemplatedView.prototype.onDestroy.apply(this, args);
|
|
1807
1770
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1771
|
+
this.inlineEditorRoot = createRoot(this.element);
|
|
1772
|
+
this.inlineEditorRoot.render(
|
|
1773
|
+
/* @__PURE__ */ React5.createElement(ThemeProvider, null, /* @__PURE__ */ React5.createElement(
|
|
1774
|
+
InlineEditor,
|
|
1775
|
+
{
|
|
1776
|
+
attributes: { class: classes },
|
|
1777
|
+
value: propValue,
|
|
1778
|
+
setValue: this.setContentValue.bind(this),
|
|
1779
|
+
onBlur: this.handleUnmountInlineEditor.bind(this),
|
|
1780
|
+
autofocus: true,
|
|
1781
|
+
showToolbar: true,
|
|
1782
|
+
getInitialPopoverPosition,
|
|
1783
|
+
expectedTag
|
|
1784
|
+
}
|
|
1785
|
+
))
|
|
1786
|
+
);
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
|
|
1790
|
+
// src/legacy/replacements/manager.ts
|
|
1791
|
+
var replacements = /* @__PURE__ */ new Map();
|
|
1792
|
+
var initViewReplacements = () => {
|
|
1793
|
+
registerReplacement(InlineEditingReplacement);
|
|
1794
|
+
};
|
|
1795
|
+
var registerReplacement = (replacement) => {
|
|
1796
|
+
const types = replacement.getTypes();
|
|
1797
|
+
if (!types) {
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
types.forEach((type) => {
|
|
1801
|
+
replacements.set(type, replacement);
|
|
1802
|
+
});
|
|
1803
|
+
};
|
|
1804
|
+
var getReplacement = (type) => {
|
|
1805
|
+
return replacements.get(type) ?? null;
|
|
1806
|
+
};
|
|
1807
|
+
var createViewWithReplacements = (options) => {
|
|
1808
|
+
const TemplatedView = createTemplatedElementView(options);
|
|
1809
|
+
return class extends TemplatedView {
|
|
1810
|
+
#replacement = null;
|
|
1811
|
+
#config;
|
|
1812
|
+
constructor(...args) {
|
|
1813
|
+
super(...args);
|
|
1814
|
+
const settings = this.model.get("settings");
|
|
1815
|
+
this.#config = {
|
|
1816
|
+
getSetting: settings.get.bind(settings),
|
|
1817
|
+
setSetting: settings.set.bind(settings),
|
|
1818
|
+
element: this.el,
|
|
1819
|
+
type: this?.model?.get("widgetType") ?? this.container?.model?.get("elType") ?? null,
|
|
1820
|
+
id: this?.model?.get("id") ?? null,
|
|
1821
|
+
refreshView: this.render.bind(this)
|
|
1822
|
+
};
|
|
1813
1823
|
}
|
|
1814
|
-
|
|
1815
|
-
this.resetInlineEditorRoot();
|
|
1824
|
+
refreshView() {
|
|
1816
1825
|
this.render();
|
|
1817
1826
|
}
|
|
1818
|
-
|
|
1819
|
-
const
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
const prop = getHtmlPropType(this.container);
|
|
1825
|
-
const defaultValue = prop?.default?.value ?? "";
|
|
1826
|
-
const settingKey = getInlineEditablePropertyName(this.container);
|
|
1827
|
-
return htmlPropTypeUtil.extract(this.model.get("settings")?.get(settingKey) ?? null) ?? htmlPropTypeUtil.extract(prop?.default ?? null) ?? defaultValue ?? "";
|
|
1828
|
-
}
|
|
1829
|
-
setContentValue(value) {
|
|
1830
|
-
const settingKey = getInlineEditablePropertyName(this.container);
|
|
1831
|
-
const valueToSave = value ? htmlPropTypeUtil.create(value) : null;
|
|
1832
|
-
this.model.get("settings")?.set(settingKey, valueToSave);
|
|
1833
|
-
}
|
|
1834
|
-
getExpectedTag() {
|
|
1835
|
-
const widgetType = getWidgetType(this.container);
|
|
1836
|
-
if (!widgetType) {
|
|
1837
|
-
return null;
|
|
1827
|
+
render() {
|
|
1828
|
+
const config = this.#config;
|
|
1829
|
+
const widgetType = config.type;
|
|
1830
|
+
const ReplacementClass = widgetType ? getReplacement(widgetType) : null;
|
|
1831
|
+
if (ReplacementClass && !this.#replacement) {
|
|
1832
|
+
this.#replacement = new ReplacementClass(config);
|
|
1838
1833
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
return null;
|
|
1834
|
+
if (!this.#replacement?.shouldRenderReplacement()) {
|
|
1835
|
+
return TemplatedView.prototype.render.apply(this);
|
|
1842
1836
|
}
|
|
1843
|
-
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
if (actualValue !== wrappedValue) {
|
|
1850
|
-
this.setContentValue(wrappedValue);
|
|
1837
|
+
this.#replacement.render();
|
|
1838
|
+
}
|
|
1839
|
+
onDestroy() {
|
|
1840
|
+
if (this.#replacement) {
|
|
1841
|
+
this.#replacement.onDestroy();
|
|
1842
|
+
this.#replacement = null;
|
|
1851
1843
|
}
|
|
1844
|
+
TemplatedView.prototype.onDestroy.apply(this);
|
|
1852
1845
|
}
|
|
1853
|
-
|
|
1854
|
-
this
|
|
1855
|
-
|
|
1856
|
-
const settingKey = getInlineEditablePropertyName(this.container);
|
|
1857
|
-
const classes = (this.el?.children?.[0]?.classList.toString() ?? "") + " strip-styles";
|
|
1858
|
-
const expectedTag = this.getExpectedTag();
|
|
1859
|
-
const setValue = (value) => {
|
|
1860
|
-
const valueToSave = value ? htmlPropTypeUtil.create(value) : null;
|
|
1861
|
-
this.model.get("settings")?.set(settingKey, valueToSave);
|
|
1862
|
-
};
|
|
1863
|
-
this.$el.html("");
|
|
1864
|
-
if (this.inlineEditorRoot) {
|
|
1865
|
-
this.resetInlineEditorRoot();
|
|
1846
|
+
_afterRender() {
|
|
1847
|
+
if (this.#replacement) {
|
|
1848
|
+
this.#replacement._afterRender();
|
|
1866
1849
|
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
setValue,
|
|
1875
|
-
onBlur: this.handleUnmountInlineEditor.bind(this),
|
|
1876
|
-
autofocus: true,
|
|
1877
|
-
showToolbar: true,
|
|
1878
|
-
getInitialPopoverPosition,
|
|
1879
|
-
expectedTag
|
|
1880
|
-
}
|
|
1881
|
-
))
|
|
1882
|
-
);
|
|
1850
|
+
TemplatedView.prototype._afterRender.apply(this);
|
|
1851
|
+
}
|
|
1852
|
+
_beforeRender() {
|
|
1853
|
+
if (this.#replacement) {
|
|
1854
|
+
this.#replacement._beforeRender();
|
|
1855
|
+
}
|
|
1856
|
+
TemplatedView.prototype._beforeRender.apply(this);
|
|
1883
1857
|
}
|
|
1884
1858
|
};
|
|
1885
|
-
}
|
|
1859
|
+
};
|
|
1860
|
+
var createTemplatedElementTypeWithReplacements = ({
|
|
1861
|
+
type,
|
|
1862
|
+
renderer,
|
|
1863
|
+
element
|
|
1864
|
+
}) => {
|
|
1865
|
+
const legacyWindow2 = window;
|
|
1866
|
+
return class extends legacyWindow2.elementor.modules.elements.types.Widget {
|
|
1867
|
+
getType() {
|
|
1868
|
+
return type;
|
|
1869
|
+
}
|
|
1870
|
+
getView() {
|
|
1871
|
+
return createViewWithReplacements({
|
|
1872
|
+
type,
|
|
1873
|
+
renderer,
|
|
1874
|
+
element
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
};
|
|
1878
|
+
};
|
|
1886
1879
|
|
|
1887
1880
|
// src/legacy/init-legacy-views.ts
|
|
1888
1881
|
var elementsLegacyTypes = {};
|
|
@@ -1902,7 +1895,7 @@ function initLegacyViews() {
|
|
|
1902
1895
|
if (!!elementsLegacyTypes[type] && canBeTemplated(element)) {
|
|
1903
1896
|
ElementType = elementsLegacyTypes[type]({ type, renderer, element });
|
|
1904
1897
|
} else if (canBeTemplated(element)) {
|
|
1905
|
-
ElementType =
|
|
1898
|
+
ElementType = createTemplatedElementTypeWithReplacements({ type, renderer, element });
|
|
1906
1899
|
} else {
|
|
1907
1900
|
ElementType = createElementType(type);
|
|
1908
1901
|
}
|
|
@@ -1951,18 +1944,18 @@ var initDocumentStructureResource = (reg) => {
|
|
|
1951
1944
|
};
|
|
1952
1945
|
function getDocumentStructure() {
|
|
1953
1946
|
const extendedWindow = window;
|
|
1954
|
-
const
|
|
1955
|
-
if (!
|
|
1947
|
+
const document = extendedWindow.elementor?.documents?.getCurrent?.();
|
|
1948
|
+
if (!document) {
|
|
1956
1949
|
return { error: "No active document found" };
|
|
1957
1950
|
}
|
|
1958
|
-
const containers =
|
|
1951
|
+
const containers = document.container?.children || [];
|
|
1959
1952
|
const elements = containers.map(
|
|
1960
1953
|
(container) => extractElementData(container)
|
|
1961
1954
|
);
|
|
1962
1955
|
return {
|
|
1963
|
-
documentId:
|
|
1964
|
-
documentType:
|
|
1965
|
-
title:
|
|
1956
|
+
documentId: document.id,
|
|
1957
|
+
documentType: document.config.type,
|
|
1958
|
+
title: document.config.settings?.post_title || "Untitled",
|
|
1966
1959
|
elements: elements.filter((el) => el !== null)
|
|
1967
1960
|
};
|
|
1968
1961
|
}
|
|
@@ -1991,7 +1984,7 @@ import {
|
|
|
1991
1984
|
createElement as createElement6,
|
|
1992
1985
|
deleteElement,
|
|
1993
1986
|
generateElementId,
|
|
1994
|
-
getContainer
|
|
1987
|
+
getContainer,
|
|
1995
1988
|
getWidgetsCache as getWidgetsCache5
|
|
1996
1989
|
} from "@elementor/editor-elements";
|
|
1997
1990
|
|
|
@@ -2577,7 +2570,7 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
2577
2570
|
const softErrors = [];
|
|
2578
2571
|
const rootContainers = [];
|
|
2579
2572
|
const widgetsCache = getWidgetsCache5() || {};
|
|
2580
|
-
const documentContainer =
|
|
2573
|
+
const documentContainer = getContainer("document");
|
|
2581
2574
|
try {
|
|
2582
2575
|
const parser = new DOMParser();
|
|
2583
2576
|
xml = parser.parseFromString(xmlStructure, "application/xml");
|
|
@@ -2918,7 +2911,7 @@ Check the styles schema at the resource [${STYLE_SCHEMA_URI.replace(
|
|
|
2918
2911
|
}
|
|
2919
2912
|
|
|
2920
2913
|
// src/mcp/tools/get-element-config/tool.ts
|
|
2921
|
-
import { getContainer as
|
|
2914
|
+
import { getContainer as getContainer2, getElementStyles as getElementStyles2, getWidgetsCache as getWidgetsCache6 } from "@elementor/editor-elements";
|
|
2922
2915
|
import { Schema as Schema4 } from "@elementor/editor-props";
|
|
2923
2916
|
import { z as z3 } from "@elementor/schema";
|
|
2924
2917
|
var schema = {
|
|
@@ -2953,7 +2946,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
2953
2946
|
schema,
|
|
2954
2947
|
outputSchema: outputSchema3,
|
|
2955
2948
|
handler: async ({ elementId }) => {
|
|
2956
|
-
const element =
|
|
2949
|
+
const element = getContainer2(elementId);
|
|
2957
2950
|
if (!element) {
|
|
2958
2951
|
throw new Error(`Element with ID ${elementId} not found.`);
|
|
2959
2952
|
}
|
|
@@ -3475,6 +3468,7 @@ function init() {
|
|
|
3475
3468
|
initStyleTransformers();
|
|
3476
3469
|
initStyleCommands();
|
|
3477
3470
|
initLinkInLinkPrevention();
|
|
3471
|
+
initViewReplacements();
|
|
3478
3472
|
initLegacyViews();
|
|
3479
3473
|
initSettingsTransformers();
|
|
3480
3474
|
initInteractionsRepository();
|
|
@@ -3569,6 +3563,8 @@ export {
|
|
|
3569
3563
|
DOCUMENT_STRUCTURE_URI,
|
|
3570
3564
|
RenderContext,
|
|
3571
3565
|
STYLE_SCHEMA_URI,
|
|
3566
|
+
UnknownStyleStateError,
|
|
3567
|
+
UnknownStyleTypeError,
|
|
3572
3568
|
WIDGET_SCHEMA_URI,
|
|
3573
3569
|
createPropsResolver,
|
|
3574
3570
|
createTemplatedElementView,
|