@elementor/editor-components 3.35.0-332 → 3.35.0-334
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 +87 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/components/overridable-props/overridable-prop-control.tsx +16 -13
- package/src/components/overridable-props/overridable-prop-indicator.tsx +17 -12
- package/src/create-component-type.ts +75 -17
- package/src/provider/overridable-prop-context.tsx +16 -0
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
// src/init.ts
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
39
|
var import_editor_canvas6 = require("@elementor/editor-canvas");
|
|
40
|
-
var
|
|
40
|
+
var import_editor_documents10 = require("@elementor/editor-documents");
|
|
41
41
|
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
42
42
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
43
43
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
@@ -556,6 +556,21 @@ var onElementDrop = (_args, element) => {
|
|
|
556
556
|
|
|
557
557
|
// src/create-component-type.ts
|
|
558
558
|
var TYPE = "e-component";
|
|
559
|
+
var updateGroups = (groups, config) => {
|
|
560
|
+
const disableMap = new Map(Object.entries(config.disable ?? {}));
|
|
561
|
+
const addMap = new Map(Object.entries(config.add ?? {}));
|
|
562
|
+
return groups.map((group) => {
|
|
563
|
+
const disabledActions = disableMap.get(group.name) ?? [];
|
|
564
|
+
const addConfig = addMap.get(group.name);
|
|
565
|
+
const updatedActions = group.actions.map(
|
|
566
|
+
(action) => disabledActions.includes(action.name) ? { ...action, isEnabled: () => false } : action
|
|
567
|
+
);
|
|
568
|
+
if (addConfig) {
|
|
569
|
+
updatedActions.splice(addConfig.index, 0, addConfig.action);
|
|
570
|
+
}
|
|
571
|
+
return { ...group, actions: updatedActions };
|
|
572
|
+
});
|
|
573
|
+
};
|
|
559
574
|
function createComponentType(options) {
|
|
560
575
|
const legacyWindow = window;
|
|
561
576
|
return class extends legacyWindow.elementor.modules.elements.types.Widget {
|
|
@@ -563,7 +578,7 @@ function createComponentType(options) {
|
|
|
563
578
|
return options.type;
|
|
564
579
|
}
|
|
565
580
|
getView() {
|
|
566
|
-
return createComponentView(options);
|
|
581
|
+
return createComponentView({ ...options });
|
|
567
582
|
}
|
|
568
583
|
};
|
|
569
584
|
}
|
|
@@ -606,21 +621,32 @@ function createComponentView(options) {
|
|
|
606
621
|
if (!componentId) {
|
|
607
622
|
return filteredGroups;
|
|
608
623
|
}
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
624
|
+
const newGroups = updateGroups(
|
|
625
|
+
filteredGroups,
|
|
626
|
+
this._getContextMenuConfig()
|
|
627
|
+
);
|
|
628
|
+
return newGroups;
|
|
629
|
+
}
|
|
630
|
+
_getContextMenuConfig() {
|
|
631
|
+
const legacyWindow = this.legacyWindow || window;
|
|
632
|
+
const elementorWithConfig = legacyWindow.elementor;
|
|
633
|
+
const isAdministrator = elementorWithConfig.config?.user?.is_administrator ?? false;
|
|
634
|
+
const addedGroup = {
|
|
635
|
+
general: {
|
|
636
|
+
index: 1,
|
|
637
|
+
action: {
|
|
638
|
+
name: "edit component",
|
|
639
|
+
icon: "eicon-edit",
|
|
640
|
+
title: () => (0, import_i18n4.__)("Edit Component", "elementor"),
|
|
641
|
+
isEnabled: () => true,
|
|
642
|
+
callback: (_, eventData) => this.editComponent(eventData)
|
|
643
|
+
}
|
|
621
644
|
}
|
|
622
|
-
|
|
623
|
-
|
|
645
|
+
};
|
|
646
|
+
const disabledGroup = {
|
|
647
|
+
clipboard: ["pasteStyle", "resetStyle"]
|
|
648
|
+
};
|
|
649
|
+
return { add: isAdministrator ? addedGroup : {}, disable: disabledGroup };
|
|
624
650
|
}
|
|
625
651
|
async switchDocument() {
|
|
626
652
|
const { isAllowedToSwitchDocument, lockedBy } = await apiClient.getComponentLockStatus(
|
|
@@ -1635,7 +1661,7 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
1635
1661
|
};
|
|
1636
1662
|
|
|
1637
1663
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
1638
|
-
var
|
|
1664
|
+
var React14 = __toESM(require("react"));
|
|
1639
1665
|
var import_editor_controls = require("@elementor/editor-controls");
|
|
1640
1666
|
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
1641
1667
|
var import_store29 = require("@elementor/store");
|
|
@@ -1654,6 +1680,15 @@ var componentOverridablePropTypeUtil = (0, import_editor_props.createPropUtils)(
|
|
|
1654
1680
|
})
|
|
1655
1681
|
);
|
|
1656
1682
|
|
|
1683
|
+
// src/provider/overridable-prop-context.tsx
|
|
1684
|
+
var React13 = __toESM(require("react"));
|
|
1685
|
+
var import_react9 = require("react");
|
|
1686
|
+
var OverridablePropContext = (0, import_react9.createContext)(null);
|
|
1687
|
+
function OverridablePropProvider({ children, ...props }) {
|
|
1688
|
+
return /* @__PURE__ */ React13.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
1689
|
+
}
|
|
1690
|
+
var useOverridablePropValue = () => (0, import_react9.useContext)(OverridablePropContext)?.value;
|
|
1691
|
+
|
|
1657
1692
|
// src/store/actions/update-overridable-prop-origin-value.ts
|
|
1658
1693
|
var import_store27 = require("@elementor/store");
|
|
1659
1694
|
function updateOverridablePropOriginValue(componentId, propValue) {
|
|
@@ -1711,7 +1746,7 @@ function OverridablePropControl({
|
|
|
1711
1746
|
}
|
|
1712
1747
|
});
|
|
1713
1748
|
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
1714
|
-
return /* @__PURE__ */
|
|
1749
|
+
return /* @__PURE__ */ React14.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React14.createElement(
|
|
1715
1750
|
import_editor_controls.PropProvider,
|
|
1716
1751
|
{
|
|
1717
1752
|
...propContext,
|
|
@@ -1720,14 +1755,13 @@ function OverridablePropControl({
|
|
|
1720
1755
|
value: { [bind]: value.origin_value },
|
|
1721
1756
|
placeholder: objectPlaceholder
|
|
1722
1757
|
},
|
|
1723
|
-
/* @__PURE__ */
|
|
1724
|
-
);
|
|
1758
|
+
/* @__PURE__ */ React14.createElement(import_editor_controls.PropKeyProvider, { bind }, /* @__PURE__ */ React14.createElement(import_editor_controls.ControlReplacementsProvider, { replacements: [] }, /* @__PURE__ */ React14.createElement(OriginalControl, { ...props })))
|
|
1759
|
+
));
|
|
1725
1760
|
}
|
|
1726
1761
|
|
|
1727
1762
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
1728
|
-
var
|
|
1763
|
+
var React17 = __toESM(require("react"));
|
|
1729
1764
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1730
|
-
var import_editor_documents9 = require("@elementor/editor-documents");
|
|
1731
1765
|
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
1732
1766
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1733
1767
|
var import_store35 = require("@elementor/store");
|
|
@@ -1877,8 +1911,8 @@ function removeProps({
|
|
|
1877
1911
|
}
|
|
1878
1912
|
|
|
1879
1913
|
// src/components/overridable-props/indicator.tsx
|
|
1880
|
-
var
|
|
1881
|
-
var
|
|
1914
|
+
var React15 = __toESM(require("react"));
|
|
1915
|
+
var import_react10 = require("react");
|
|
1882
1916
|
var import_icons8 = require("@elementor/icons");
|
|
1883
1917
|
var import_ui9 = require("@elementor/ui");
|
|
1884
1918
|
var import_i18n12 = require("@wordpress/i18n");
|
|
@@ -1937,32 +1971,32 @@ var Content = (0, import_ui9.styled)(import_ui9.Box)`
|
|
|
1937
1971
|
}
|
|
1938
1972
|
}
|
|
1939
1973
|
`;
|
|
1940
|
-
var Indicator = (0,
|
|
1974
|
+
var Indicator = (0, import_react10.forwardRef)(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React15.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React15.createElement(
|
|
1941
1975
|
IconContainer,
|
|
1942
1976
|
{
|
|
1943
1977
|
className: "icon",
|
|
1944
1978
|
"aria-label": isOverridable ? (0, import_i18n12.__)("Overridable property", "elementor") : (0, import_i18n12.__)("Make prop overridable", "elementor")
|
|
1945
1979
|
},
|
|
1946
|
-
isOverridable ? /* @__PURE__ */
|
|
1980
|
+
isOverridable ? /* @__PURE__ */ React15.createElement(import_icons8.CheckIcon, { fontSize: SIZE }) : /* @__PURE__ */ React15.createElement(import_icons8.PlusIcon, { fontSize: SIZE })
|
|
1947
1981
|
)));
|
|
1948
1982
|
|
|
1949
1983
|
// src/components/overridable-props/overridable-prop-form.tsx
|
|
1950
|
-
var
|
|
1951
|
-
var
|
|
1984
|
+
var React16 = __toESM(require("react"));
|
|
1985
|
+
var import_react11 = require("react");
|
|
1952
1986
|
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
1953
1987
|
var import_ui10 = require("@elementor/ui");
|
|
1954
1988
|
var import_i18n13 = require("@wordpress/i18n");
|
|
1955
1989
|
var SIZE2 = "tiny";
|
|
1956
1990
|
var DEFAULT_GROUP = { value: null, label: (0, import_i18n13.__)("Default", "elementor") };
|
|
1957
1991
|
function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
1958
|
-
const [propLabel, setPropLabel] = (0,
|
|
1959
|
-
const [group, setGroup] = (0,
|
|
1992
|
+
const [propLabel, setPropLabel] = (0, import_react11.useState)(currentValue?.label ?? null);
|
|
1993
|
+
const [group, setGroup] = (0, import_react11.useState)(currentValue?.groupId ?? groups?.[0]?.value ?? null);
|
|
1960
1994
|
const name = (0, import_i18n13.__)("Name", "elementor");
|
|
1961
1995
|
const groupName = (0, import_i18n13.__)("Group Name", "elementor");
|
|
1962
1996
|
const isCreate = currentValue === void 0;
|
|
1963
1997
|
const title = isCreate ? (0, import_i18n13.__)("Create new property", "elementor") : (0, import_i18n13.__)("Update property", "elementor");
|
|
1964
1998
|
const ctaLabel = isCreate ? (0, import_i18n13.__)("Create", "elementor") : (0, import_i18n13.__)("Update", "elementor");
|
|
1965
|
-
return /* @__PURE__ */
|
|
1999
|
+
return /* @__PURE__ */ React16.createElement(import_editor_ui5.Form, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React16.createElement(import_ui10.Stack, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React16.createElement(
|
|
1966
2000
|
import_ui10.Stack,
|
|
1967
2001
|
{
|
|
1968
2002
|
direction: "row",
|
|
@@ -1971,8 +2005,8 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
1971
2005
|
px: 1.5,
|
|
1972
2006
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
1973
2007
|
},
|
|
1974
|
-
/* @__PURE__ */
|
|
1975
|
-
), /* @__PURE__ */
|
|
2008
|
+
/* @__PURE__ */ React16.createElement(import_ui10.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
2009
|
+
), /* @__PURE__ */ React16.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React16.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(import_ui10.FormLabel, { size: "tiny" }, name)), /* @__PURE__ */ React16.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(
|
|
1976
2010
|
import_ui10.TextField,
|
|
1977
2011
|
{
|
|
1978
2012
|
name,
|
|
@@ -1982,7 +2016,7 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
1982
2016
|
value: propLabel ?? "",
|
|
1983
2017
|
onChange: (e) => setPropLabel(e.target.value)
|
|
1984
2018
|
}
|
|
1985
|
-
))), /* @__PURE__ */
|
|
2019
|
+
))), /* @__PURE__ */ React16.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React16.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(import_ui10.FormLabel, { size: "tiny" }, groupName)), /* @__PURE__ */ React16.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(
|
|
1986
2020
|
import_ui10.Select,
|
|
1987
2021
|
{
|
|
1988
2022
|
name: groupName,
|
|
@@ -1999,8 +2033,8 @@ function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
|
1999
2033
|
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
2000
2034
|
}
|
|
2001
2035
|
},
|
|
2002
|
-
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */
|
|
2003
|
-
))), /* @__PURE__ */
|
|
2036
|
+
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React16.createElement(import_editor_ui5.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
2037
|
+
))), /* @__PURE__ */ React16.createElement(import_ui10.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React16.createElement(import_ui10.Button, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
2004
2038
|
}
|
|
2005
2039
|
|
|
2006
2040
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
@@ -2020,15 +2054,12 @@ function getOverridableProp({
|
|
|
2020
2054
|
var FORBIDDEN_KEYS = ["_cssid", "attributes"];
|
|
2021
2055
|
function OverridablePropIndicator() {
|
|
2022
2056
|
const { bind } = (0, import_editor_controls2.useBoundProp)();
|
|
2023
|
-
const
|
|
2024
|
-
if (
|
|
2025
|
-
return null;
|
|
2026
|
-
}
|
|
2027
|
-
if (!isPropAllowed(bind)) {
|
|
2057
|
+
const componentId = selectCurrentComponentId((0, import_store35.__getState)());
|
|
2058
|
+
if (!isPropAllowed(bind) || !componentId) {
|
|
2028
2059
|
return null;
|
|
2029
2060
|
}
|
|
2030
|
-
const overridableProps = selectOverridableProps((0, import_store35.__getState)(),
|
|
2031
|
-
return /* @__PURE__ */
|
|
2061
|
+
const overridableProps = selectOverridableProps((0, import_store35.__getState)(), componentId);
|
|
2062
|
+
return /* @__PURE__ */ React17.createElement(Content2, { componentId, overridableProps });
|
|
2032
2063
|
}
|
|
2033
2064
|
function Content2({ componentId, overridableProps }) {
|
|
2034
2065
|
const {
|
|
@@ -2036,7 +2067,11 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2036
2067
|
elementType
|
|
2037
2068
|
} = (0, import_editor_editing_panel2.useElement)();
|
|
2038
2069
|
const { value, bind, propType } = (0, import_editor_controls2.useBoundProp)();
|
|
2039
|
-
const
|
|
2070
|
+
const contextOverridableValue = useOverridablePropValue();
|
|
2071
|
+
const { value: boundPropOverridableValue, setValue: setOverridableValue } = (0, import_editor_controls2.useBoundProp)(
|
|
2072
|
+
componentOverridablePropTypeUtil
|
|
2073
|
+
);
|
|
2074
|
+
const overridableValue = boundPropOverridableValue ?? contextOverridableValue;
|
|
2040
2075
|
const popupState = (0, import_ui11.usePopupState)({
|
|
2041
2076
|
variant: "popover"
|
|
2042
2077
|
});
|
|
@@ -2065,7 +2100,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2065
2100
|
popupState.close();
|
|
2066
2101
|
};
|
|
2067
2102
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
2068
|
-
return /* @__PURE__ */
|
|
2103
|
+
return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(import_ui11.Tooltip, { placement: "top", title: (0, import_i18n14.__)("Override Property", "elementor") }, /* @__PURE__ */ React17.createElement(Indicator, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React17.createElement(
|
|
2069
2104
|
import_ui11.Popover,
|
|
2070
2105
|
{
|
|
2071
2106
|
disableScrollLock: true,
|
|
@@ -2082,7 +2117,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2082
2117
|
},
|
|
2083
2118
|
...popoverProps
|
|
2084
2119
|
},
|
|
2085
|
-
/* @__PURE__ */
|
|
2120
|
+
/* @__PURE__ */ React17.createElement(
|
|
2086
2121
|
OverridablePropForm,
|
|
2087
2122
|
{
|
|
2088
2123
|
onSubmit: handleSubmit,
|
|
@@ -2184,10 +2219,10 @@ function initMcp() {
|
|
|
2184
2219
|
}
|
|
2185
2220
|
|
|
2186
2221
|
// src/populate-store.ts
|
|
2187
|
-
var
|
|
2222
|
+
var import_react12 = require("react");
|
|
2188
2223
|
var import_store37 = require("@elementor/store");
|
|
2189
2224
|
function PopulateStore() {
|
|
2190
|
-
(0,
|
|
2225
|
+
(0, import_react12.useEffect)(() => {
|
|
2191
2226
|
(0, import_store37.__dispatch)(loadComponents());
|
|
2192
2227
|
}, []);
|
|
2193
2228
|
return null;
|
|
@@ -2351,14 +2386,14 @@ var updateArchivedComponentBeforeSave = async () => {
|
|
|
2351
2386
|
};
|
|
2352
2387
|
|
|
2353
2388
|
// src/sync/update-components-before-save.ts
|
|
2354
|
-
var
|
|
2389
|
+
var import_editor_documents9 = require("@elementor/editor-documents");
|
|
2355
2390
|
async function updateComponentsBeforeSave({ status, elements }) {
|
|
2356
2391
|
if (status !== "publish") {
|
|
2357
2392
|
return;
|
|
2358
2393
|
}
|
|
2359
2394
|
const componentIds = await getComponentIds(elements);
|
|
2360
2395
|
const componentDocumentData = await Promise.all(componentIds.map(getComponentDocumentData));
|
|
2361
|
-
const draftIds = componentDocumentData.filter((document) => !!document).filter(
|
|
2396
|
+
const draftIds = componentDocumentData.filter((document) => !!document).filter(import_editor_documents9.isDocumentDirty).map((document) => document.id);
|
|
2362
2397
|
if (draftIds.length === 0) {
|
|
2363
2398
|
return;
|
|
2364
2399
|
}
|
|
@@ -2386,7 +2421,7 @@ function init() {
|
|
|
2386
2421
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
2387
2422
|
);
|
|
2388
2423
|
(0, import_editor_v1_adapters7.registerDataHook)("dependency", "editor/documents/close", (args) => {
|
|
2389
|
-
const document = (0,
|
|
2424
|
+
const document = (0, import_editor_documents10.getV1CurrentDocument)();
|
|
2390
2425
|
if (document.config.type === COMPONENT_DOCUMENT_TYPE) {
|
|
2391
2426
|
args.mode = "autosave";
|
|
2392
2427
|
}
|
|
@@ -2416,7 +2451,7 @@ function init() {
|
|
|
2416
2451
|
component: ComponentPanelHeader
|
|
2417
2452
|
});
|
|
2418
2453
|
(0, import_editor_v1_adapters7.registerDataHook)("after", "editor/documents/attach-preview", async () => {
|
|
2419
|
-
const { id, config } = (0,
|
|
2454
|
+
const { id, config } = (0, import_editor_documents10.getV1CurrentDocument)();
|
|
2420
2455
|
if (id) {
|
|
2421
2456
|
removeComponentStyles(id);
|
|
2422
2457
|
}
|