@elementor/editor-components 3.35.0-411 → 3.35.0-412
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 +387 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +350 -132
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/api.ts +15 -1
- package/src/components/component-panel-header/component-panel-header.tsx +11 -2
- package/src/components/components-tab/components-item.tsx +119 -37
- package/src/components/components-tab/components-list.tsx +8 -1
- package/src/components/create-component-form/utils/component-form-schema.ts +9 -11
- package/src/components/create-component-form/utils/replace-element-with-component.ts +0 -1
- package/src/components/edit-component/edit-component.tsx +31 -1
- package/src/create-component-type.ts +85 -1
- package/src/store/actions/rename-component.ts +7 -0
- package/src/store/store.ts +29 -0
- package/src/sync/before-save.ts +2 -0
- package/src/sync/update-component-title-before-save.ts +18 -0
- package/src/types.ts +5 -0
- package/src/utils/component-name-validation.ts +27 -0
package/dist/index.mjs
CHANGED
|
@@ -76,6 +76,12 @@ var apiClient = {
|
|
|
76
76
|
componentIds
|
|
77
77
|
}
|
|
78
78
|
).then((res) => res.data.data),
|
|
79
|
+
updateComponentTitle: (updatedComponentNames) => httpService().post(
|
|
80
|
+
`${BASE_URL}/update-titles`,
|
|
81
|
+
{
|
|
82
|
+
components: updatedComponentNames
|
|
83
|
+
}
|
|
84
|
+
).then((res) => res.data.data),
|
|
79
85
|
validate: async (payload) => await httpService().post(`${BASE_URL}/create-validate`, payload).then((res) => res.data)
|
|
80
86
|
};
|
|
81
87
|
|
|
@@ -94,7 +100,8 @@ var initialState = {
|
|
|
94
100
|
createdThisSession: [],
|
|
95
101
|
archivedData: [],
|
|
96
102
|
path: [],
|
|
97
|
-
currentComponentId: null
|
|
103
|
+
currentComponentId: null,
|
|
104
|
+
updatedComponentNames: {}
|
|
98
105
|
};
|
|
99
106
|
var SLICE_NAME = "components";
|
|
100
107
|
var slice = createSlice({
|
|
@@ -148,6 +155,19 @@ var slice = createSlice({
|
|
|
148
155
|
return;
|
|
149
156
|
}
|
|
150
157
|
component.overridableProps = payload.overridableProps;
|
|
158
|
+
},
|
|
159
|
+
rename: (state, { payload }) => {
|
|
160
|
+
const component = state.data.find((comp) => comp.uid === payload.componentUid);
|
|
161
|
+
if (!component) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (component.id) {
|
|
165
|
+
state.updatedComponentNames[component.id] = payload.name;
|
|
166
|
+
}
|
|
167
|
+
component.name = payload.name;
|
|
168
|
+
},
|
|
169
|
+
cleanUpdatedComponentNames: (state) => {
|
|
170
|
+
state.updatedComponentNames = {};
|
|
151
171
|
}
|
|
152
172
|
},
|
|
153
173
|
extraReducers: (builder) => {
|
|
@@ -175,6 +195,7 @@ var selectComponent = (state, componentId) => state[SLICE_NAME].data.find((compo
|
|
|
175
195
|
var useComponent = (componentId) => {
|
|
176
196
|
return useSelector((state) => componentId ? selectComponent(state, componentId) : null);
|
|
177
197
|
};
|
|
198
|
+
var selectComponentByUid = (state, componentUid) => state[SLICE_NAME].data.find((component) => component.uid === componentUid) ?? state[SLICE_NAME].unpublishedData.find((component) => component.uid === componentUid);
|
|
178
199
|
var selectComponents = createSelector(
|
|
179
200
|
selectData,
|
|
180
201
|
selectUnpublishedData,
|
|
@@ -238,6 +259,13 @@ var selectArchivedComponents = createSelector(
|
|
|
238
259
|
selectArchivedData,
|
|
239
260
|
(archivedData) => archivedData
|
|
240
261
|
);
|
|
262
|
+
var selectUpdatedComponentNames = createSelector(
|
|
263
|
+
(state) => state[SLICE_NAME].updatedComponentNames,
|
|
264
|
+
(updatedComponentNames) => Object.entries(updatedComponentNames).map(([componentId, title]) => ({
|
|
265
|
+
componentId: Number(componentId),
|
|
266
|
+
title
|
|
267
|
+
}))
|
|
268
|
+
);
|
|
241
269
|
|
|
242
270
|
// src/utils/component-document-data.ts
|
|
243
271
|
import { getV1DocumentsManager } from "@elementor/editor-documents";
|
|
@@ -329,6 +357,7 @@ import * as React10 from "react";
|
|
|
329
357
|
import { useSuppressedMessage } from "@elementor/editor-current-user";
|
|
330
358
|
import { getV1DocumentsManager as getV1DocumentsManager3 } from "@elementor/editor-documents";
|
|
331
359
|
import { ArrowLeftIcon, ComponentsFilledIcon } from "@elementor/icons";
|
|
360
|
+
import { __getState as getState9 } from "@elementor/store";
|
|
332
361
|
import { Box as Box7, Divider as Divider2, IconButton as IconButton4, Stack as Stack6, Tooltip as Tooltip3, Typography as Typography6 } from "@elementor/ui";
|
|
333
362
|
import { __ as __11 } from "@wordpress/i18n";
|
|
334
363
|
|
|
@@ -1575,6 +1604,12 @@ var ComponentPanelHeader = () => {
|
|
|
1575
1604
|
));
|
|
1576
1605
|
};
|
|
1577
1606
|
function getComponentName() {
|
|
1607
|
+
const state = getState9();
|
|
1608
|
+
const path = state[SLICE_NAME].path;
|
|
1609
|
+
const { instanceTitle } = path.at(-1) ?? {};
|
|
1610
|
+
if (instanceTitle) {
|
|
1611
|
+
return instanceTitle;
|
|
1612
|
+
}
|
|
1578
1613
|
const documentsManager = getV1DocumentsManager3();
|
|
1579
1614
|
const currentDocument = documentsManager.getCurrent();
|
|
1580
1615
|
return currentDocument?.container?.settings?.get("post_title") ?? "";
|
|
@@ -1636,7 +1671,7 @@ var ComponentSearch = () => {
|
|
|
1636
1671
|
import * as React15 from "react";
|
|
1637
1672
|
import { ComponentsIcon as ComponentsIcon2, EyeIcon } from "@elementor/icons";
|
|
1638
1673
|
import { Box as Box11, Divider as Divider3, Icon, Link as Link3, List as List3, Stack as Stack10, Typography as Typography8 } from "@elementor/ui";
|
|
1639
|
-
import { __ as
|
|
1674
|
+
import { __ as __16 } from "@wordpress/i18n";
|
|
1640
1675
|
|
|
1641
1676
|
// src/hooks/use-components.ts
|
|
1642
1677
|
import { __useSelector as useSelector4 } from "@elementor/store";
|
|
@@ -1646,11 +1681,18 @@ var useComponents = () => {
|
|
|
1646
1681
|
return { components, isLoading };
|
|
1647
1682
|
};
|
|
1648
1683
|
|
|
1684
|
+
// src/store/actions/rename-component.ts
|
|
1685
|
+
import { __dispatch as dispatch8 } from "@elementor/store";
|
|
1686
|
+
var renameComponent = (componentUid, newName) => {
|
|
1687
|
+
dispatch8(slice.actions.rename({ componentUid, name: newName }));
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1649
1690
|
// src/components/components-tab/components-item.tsx
|
|
1650
1691
|
import * as React13 from "react";
|
|
1692
|
+
import { useRef as useRef4 } from "react";
|
|
1651
1693
|
import { endDragElementFromPanel, startDragElementFromPanel } from "@elementor/editor-canvas";
|
|
1652
1694
|
import { dropElement } from "@elementor/editor-elements";
|
|
1653
|
-
import { EllipsisWithTooltip, MenuListItem as MenuListItem3 } from "@elementor/editor-ui";
|
|
1695
|
+
import { EditableField as EditableField2, EllipsisWithTooltip, MenuListItem as MenuListItem3, useEditable as useEditable2, WarningInfotip } from "@elementor/editor-ui";
|
|
1654
1696
|
import { ComponentsIcon, DotsVerticalIcon as DotsVerticalIcon2 } from "@elementor/icons";
|
|
1655
1697
|
import {
|
|
1656
1698
|
bindMenu as bindMenu2,
|
|
@@ -1661,21 +1703,22 @@ import {
|
|
|
1661
1703
|
ListItemIcon,
|
|
1662
1704
|
Menu as Menu2,
|
|
1663
1705
|
Stack as Stack8,
|
|
1706
|
+
styled as styled3,
|
|
1664
1707
|
Typography as Typography7,
|
|
1665
1708
|
usePopupState as usePopupState3
|
|
1666
1709
|
} from "@elementor/ui";
|
|
1667
|
-
import { __ as
|
|
1710
|
+
import { __ as __15 } from "@wordpress/i18n";
|
|
1668
1711
|
|
|
1669
1712
|
// src/store/actions/archive-component.ts
|
|
1670
1713
|
import { setDocumentModifiedStatus as setDocumentModifiedStatus3 } from "@elementor/editor-documents";
|
|
1671
1714
|
import { __getStore as getStore } from "@elementor/store";
|
|
1672
1715
|
var archiveComponent = (componentId) => {
|
|
1673
1716
|
const store = getStore();
|
|
1674
|
-
const
|
|
1675
|
-
if (!
|
|
1717
|
+
const dispatch18 = store?.dispatch;
|
|
1718
|
+
if (!dispatch18) {
|
|
1676
1719
|
return;
|
|
1677
1720
|
}
|
|
1678
|
-
|
|
1721
|
+
dispatch18(slice.actions.archive(componentId));
|
|
1679
1722
|
setDocumentModifiedStatus3(true);
|
|
1680
1723
|
};
|
|
1681
1724
|
|
|
@@ -1687,11 +1730,12 @@ import {
|
|
|
1687
1730
|
createTemplatedElementView
|
|
1688
1731
|
} from "@elementor/editor-canvas";
|
|
1689
1732
|
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
1733
|
+
import { __getState as getState11 } from "@elementor/store";
|
|
1690
1734
|
import { __ as __13 } from "@wordpress/i18n";
|
|
1691
1735
|
|
|
1692
1736
|
// src/utils/tracking.ts
|
|
1693
1737
|
import { getMixpanel } from "@elementor/mixpanel";
|
|
1694
|
-
import { __getState as
|
|
1738
|
+
import { __getState as getState10 } from "@elementor/store";
|
|
1695
1739
|
var trackComponentEvent = ({ action, ...data }) => {
|
|
1696
1740
|
const { dispatchEvent, config } = getMixpanel();
|
|
1697
1741
|
if (!config?.names?.components?.[action]) {
|
|
@@ -1708,7 +1752,7 @@ var onElementDrop = (_args, element) => {
|
|
|
1708
1752
|
const componentName = editorSettings?.title;
|
|
1709
1753
|
const componentUID = editorSettings?.component_uid;
|
|
1710
1754
|
const instanceId = element.id;
|
|
1711
|
-
const createdThisSession = selectCreatedThisSession(
|
|
1755
|
+
const createdThisSession = selectCreatedThisSession(getState10());
|
|
1712
1756
|
const isSameSessionReuse = componentUID && createdThisSession.includes(componentUID);
|
|
1713
1757
|
const eventsManagerConfig = window.elementorCommon.eventsManager.config;
|
|
1714
1758
|
const { locations, secondaryLocations } = eventsManagerConfig;
|
|
@@ -1742,13 +1786,17 @@ var updateGroups = (groups, config) => {
|
|
|
1742
1786
|
};
|
|
1743
1787
|
function createComponentType(options) {
|
|
1744
1788
|
const legacyWindow = window;
|
|
1745
|
-
|
|
1789
|
+
const WidgetType = legacyWindow.elementor.modules.elements.types.Widget;
|
|
1790
|
+
return class extends WidgetType {
|
|
1746
1791
|
getType() {
|
|
1747
1792
|
return options.type;
|
|
1748
1793
|
}
|
|
1749
1794
|
getView() {
|
|
1750
1795
|
return createComponentView({ ...options });
|
|
1751
1796
|
}
|
|
1797
|
+
getModel() {
|
|
1798
|
+
return createComponentModel();
|
|
1799
|
+
}
|
|
1752
1800
|
};
|
|
1753
1801
|
}
|
|
1754
1802
|
function createComponentView(options) {
|
|
@@ -1878,6 +1926,49 @@ function setInactiveRecursively(model) {
|
|
|
1878
1926
|
});
|
|
1879
1927
|
}
|
|
1880
1928
|
}
|
|
1929
|
+
function createComponentModel() {
|
|
1930
|
+
const legacyWindow = window;
|
|
1931
|
+
const WidgetType = legacyWindow.elementor.modules.elements.types.Widget;
|
|
1932
|
+
const widgetTypeInstance = new WidgetType();
|
|
1933
|
+
const BaseWidgetModel = widgetTypeInstance.getModel();
|
|
1934
|
+
return BaseWidgetModel.extend({
|
|
1935
|
+
initialize(attributes, options) {
|
|
1936
|
+
BaseWidgetModel.prototype.initialize.call(this, attributes, options);
|
|
1937
|
+
const componentInstance = this.get("settings")?.get("component_instance");
|
|
1938
|
+
if (componentInstance?.value) {
|
|
1939
|
+
const componentId = componentInstance.value.component_id?.value;
|
|
1940
|
+
if (componentId && typeof componentId === "number") {
|
|
1941
|
+
this.set("componentId", componentId);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
},
|
|
1945
|
+
getTitle() {
|
|
1946
|
+
const editorSettings = this.get("editor_settings");
|
|
1947
|
+
const instanceTitle = editorSettings?.title;
|
|
1948
|
+
if (instanceTitle) {
|
|
1949
|
+
return instanceTitle;
|
|
1950
|
+
}
|
|
1951
|
+
const componentUid = editorSettings?.component_uid;
|
|
1952
|
+
if (componentUid) {
|
|
1953
|
+
const component = selectComponentByUid(getState11(), componentUid);
|
|
1954
|
+
if (component?.name) {
|
|
1955
|
+
return component.name;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return window.elementor.getElementData(this).title;
|
|
1959
|
+
},
|
|
1960
|
+
getComponentId() {
|
|
1961
|
+
return this.get("componentId") || null;
|
|
1962
|
+
},
|
|
1963
|
+
getComponentName() {
|
|
1964
|
+
return this.getTitle();
|
|
1965
|
+
},
|
|
1966
|
+
getComponentUid() {
|
|
1967
|
+
const editorSettings = this.get("editor_settings");
|
|
1968
|
+
return editorSettings?.component_uid || null;
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1881
1972
|
|
|
1882
1973
|
// src/utils/is-component-instance.ts
|
|
1883
1974
|
function isComponentInstance(elementModel) {
|
|
@@ -1911,7 +2002,7 @@ var getComponentIds = async (elements) => {
|
|
|
1911
2002
|
};
|
|
1912
2003
|
|
|
1913
2004
|
// src/store/actions/load-components-overridable-props.ts
|
|
1914
|
-
import { __dispatch as
|
|
2005
|
+
import { __dispatch as dispatch9, __getState as getState12 } from "@elementor/store";
|
|
1915
2006
|
function loadComponentsOverridableProps(componentIds) {
|
|
1916
2007
|
if (!componentIds.length) {
|
|
1917
2008
|
return;
|
|
@@ -1919,7 +2010,7 @@ function loadComponentsOverridableProps(componentIds) {
|
|
|
1919
2010
|
componentIds.forEach(loadComponentOverrides);
|
|
1920
2011
|
}
|
|
1921
2012
|
async function loadComponentOverrides(componentId) {
|
|
1922
|
-
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded(
|
|
2013
|
+
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded(getState12(), componentId);
|
|
1923
2014
|
if (isOverridablePropsLoaded) {
|
|
1924
2015
|
return;
|
|
1925
2016
|
}
|
|
@@ -1927,7 +2018,7 @@ async function loadComponentOverrides(componentId) {
|
|
|
1927
2018
|
if (!overridableProps) {
|
|
1928
2019
|
return;
|
|
1929
2020
|
}
|
|
1930
|
-
|
|
2021
|
+
dispatch9(
|
|
1931
2022
|
slice.actions.setOverridableProps({
|
|
1932
2023
|
componentId,
|
|
1933
2024
|
overridableProps
|
|
@@ -1936,12 +2027,12 @@ async function loadComponentOverrides(componentId) {
|
|
|
1936
2027
|
}
|
|
1937
2028
|
|
|
1938
2029
|
// src/store/actions/load-components-styles.ts
|
|
1939
|
-
import { __dispatch as
|
|
2030
|
+
import { __dispatch as dispatch10, __getState as getState13 } from "@elementor/store";
|
|
1940
2031
|
async function loadComponentsStyles(componentIds) {
|
|
1941
2032
|
if (!componentIds.length) {
|
|
1942
2033
|
return;
|
|
1943
2034
|
}
|
|
1944
|
-
const knownComponents = selectStyles(
|
|
2035
|
+
const knownComponents = selectStyles(getState13());
|
|
1945
2036
|
const unknownComponentIds = componentIds.filter((id2) => !knownComponents[id2]);
|
|
1946
2037
|
if (!unknownComponentIds.length) {
|
|
1947
2038
|
return;
|
|
@@ -1959,7 +2050,7 @@ function addStyles(data) {
|
|
|
1959
2050
|
const styles = Object.fromEntries(
|
|
1960
2051
|
data.map(([componentId, componentData]) => [componentId, extractStyles(componentData)])
|
|
1961
2052
|
);
|
|
1962
|
-
|
|
2053
|
+
dispatch10(slice.actions.addStyles(styles));
|
|
1963
2054
|
}
|
|
1964
2055
|
function extractStyles(element) {
|
|
1965
2056
|
return [...Object.values(element.styles ?? {}), ...(element.elements ?? []).flatMap(extractStyles)];
|
|
@@ -1984,6 +2075,52 @@ async function updateDocumentState(componentIds) {
|
|
|
1984
2075
|
}
|
|
1985
2076
|
}
|
|
1986
2077
|
|
|
2078
|
+
// src/utils/component-name-validation.ts
|
|
2079
|
+
import { __getState as getState14 } from "@elementor/store";
|
|
2080
|
+
|
|
2081
|
+
// src/components/create-component-form/utils/component-form-schema.ts
|
|
2082
|
+
import { z } from "@elementor/schema";
|
|
2083
|
+
import { __ as __14 } from "@wordpress/i18n";
|
|
2084
|
+
var MIN_NAME_LENGTH = 2;
|
|
2085
|
+
var MAX_NAME_LENGTH = 50;
|
|
2086
|
+
var baseComponentSchema = z.string().trim().max(MAX_NAME_LENGTH, __14("Component name is too long. Please keep it under 50 characters.", "elementor"));
|
|
2087
|
+
var createBaseComponentSchema = (existingNames) => {
|
|
2088
|
+
return z.object({
|
|
2089
|
+
componentName: baseComponentSchema.refine((value) => !existingNames.includes(value), {
|
|
2090
|
+
message: __14("Component name already exists", "elementor")
|
|
2091
|
+
})
|
|
2092
|
+
});
|
|
2093
|
+
};
|
|
2094
|
+
var createSubmitComponentSchema = (existingNames) => {
|
|
2095
|
+
const baseSchema = createBaseComponentSchema(existingNames);
|
|
2096
|
+
return baseSchema.extend({
|
|
2097
|
+
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
2098
|
+
message: __14("Component name is required.", "elementor")
|
|
2099
|
+
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
2100
|
+
message: __14("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
2101
|
+
})
|
|
2102
|
+
});
|
|
2103
|
+
};
|
|
2104
|
+
|
|
2105
|
+
// src/utils/component-name-validation.ts
|
|
2106
|
+
function validateComponentName(label) {
|
|
2107
|
+
const existingComponentTitles = selectComponents(getState14())?.map(({ name }) => name) ?? [];
|
|
2108
|
+
const schema = createSubmitComponentSchema(existingComponentTitles);
|
|
2109
|
+
const result = schema.safeParse({ componentName: label.toLowerCase() });
|
|
2110
|
+
if (result.success) {
|
|
2111
|
+
return {
|
|
2112
|
+
isValid: true,
|
|
2113
|
+
errorMessage: null
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
const formattedErrors = result.error.format();
|
|
2117
|
+
const errorMessage = formattedErrors.componentName?._errors[0] ?? formattedErrors._errors[0];
|
|
2118
|
+
return {
|
|
2119
|
+
isValid: false,
|
|
2120
|
+
errorMessage
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
|
|
1987
2124
|
// src/utils/get-container-for-new-element.ts
|
|
1988
2125
|
import {
|
|
1989
2126
|
getContainer as getContainer2,
|
|
@@ -2029,11 +2166,11 @@ import { replaceElement } from "@elementor/editor-elements";
|
|
|
2029
2166
|
var replaceElementWithComponent = (element, component) => {
|
|
2030
2167
|
replaceElement({
|
|
2031
2168
|
currentElement: element,
|
|
2032
|
-
newElement:
|
|
2169
|
+
newElement: createComponentModel2(component),
|
|
2033
2170
|
withHistory: false
|
|
2034
2171
|
});
|
|
2035
2172
|
};
|
|
2036
|
-
var
|
|
2173
|
+
var createComponentModel2 = (component) => {
|
|
2037
2174
|
return {
|
|
2038
2175
|
elType: "widget",
|
|
2039
2176
|
widgetType: "e-component",
|
|
@@ -2050,15 +2187,26 @@ var createComponentModel = (component) => {
|
|
|
2050
2187
|
overridable_props: component.overridableProps
|
|
2051
2188
|
},
|
|
2052
2189
|
editor_settings: {
|
|
2053
|
-
title: component.name,
|
|
2054
2190
|
component_uid: component.uid
|
|
2055
2191
|
}
|
|
2056
2192
|
};
|
|
2057
2193
|
};
|
|
2058
2194
|
|
|
2059
2195
|
// src/components/components-tab/components-item.tsx
|
|
2060
|
-
var ComponentItem = ({ component }) => {
|
|
2061
|
-
const
|
|
2196
|
+
var ComponentItem = ({ component, renameComponent: renameComponent2 }) => {
|
|
2197
|
+
const itemRef = useRef4(null);
|
|
2198
|
+
const {
|
|
2199
|
+
ref: editableRef,
|
|
2200
|
+
isEditing,
|
|
2201
|
+
openEditMode,
|
|
2202
|
+
error,
|
|
2203
|
+
getProps: getEditableProps
|
|
2204
|
+
} = useEditable2({
|
|
2205
|
+
value: component.name,
|
|
2206
|
+
onSubmit: renameComponent2,
|
|
2207
|
+
validation: validateComponentTitle
|
|
2208
|
+
});
|
|
2209
|
+
const componentModel = createComponentModel2(component);
|
|
2062
2210
|
const popupState = usePopupState3({
|
|
2063
2211
|
variant: "popover",
|
|
2064
2212
|
disableAutoFocus: true
|
|
@@ -2078,47 +2226,64 @@ var ComponentItem = ({ component }) => {
|
|
|
2078
2226
|
archiveComponent(component.id);
|
|
2079
2227
|
};
|
|
2080
2228
|
return /* @__PURE__ */ React13.createElement(Stack8, null, /* @__PURE__ */ React13.createElement(
|
|
2081
|
-
|
|
2229
|
+
WarningInfotip,
|
|
2082
2230
|
{
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
border: "solid 1px",
|
|
2089
|
-
borderColor: "divider",
|
|
2090
|
-
py: 0.5,
|
|
2091
|
-
px: 1,
|
|
2092
|
-
display: "flex",
|
|
2093
|
-
width: "100%",
|
|
2094
|
-
alignItems: "center",
|
|
2095
|
-
gap: 1
|
|
2096
|
-
}
|
|
2231
|
+
open: Boolean(error),
|
|
2232
|
+
text: error ?? "",
|
|
2233
|
+
placement: "bottom",
|
|
2234
|
+
width: itemRef.current?.getBoundingClientRect().width,
|
|
2235
|
+
offset: [0, -15]
|
|
2097
2236
|
},
|
|
2098
2237
|
/* @__PURE__ */ React13.createElement(
|
|
2099
|
-
|
|
2238
|
+
ListItemButton,
|
|
2100
2239
|
{
|
|
2101
|
-
|
|
2240
|
+
draggable: true,
|
|
2241
|
+
onDragStart: (event) => startDragElementFromPanel(componentModel, event),
|
|
2242
|
+
onDragEnd: handleDragEnd,
|
|
2243
|
+
shape: "rounded",
|
|
2244
|
+
ref: itemRef,
|
|
2102
2245
|
sx: {
|
|
2246
|
+
border: "solid 1px",
|
|
2247
|
+
borderColor: "divider",
|
|
2248
|
+
py: 0.5,
|
|
2249
|
+
px: 1,
|
|
2103
2250
|
display: "flex",
|
|
2251
|
+
width: "100%",
|
|
2104
2252
|
alignItems: "center",
|
|
2105
|
-
gap: 1
|
|
2106
|
-
minWidth: 0,
|
|
2107
|
-
flexGrow: 1
|
|
2253
|
+
gap: 1
|
|
2108
2254
|
}
|
|
2109
2255
|
},
|
|
2110
|
-
/* @__PURE__ */ React13.createElement(
|
|
2111
|
-
|
|
2112
|
-
EllipsisWithTooltip,
|
|
2256
|
+
/* @__PURE__ */ React13.createElement(
|
|
2257
|
+
Box9,
|
|
2113
2258
|
{
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2259
|
+
display: "flex",
|
|
2260
|
+
alignItems: "center",
|
|
2261
|
+
gap: 1,
|
|
2262
|
+
minWidth: 0,
|
|
2263
|
+
flexGrow: 1,
|
|
2264
|
+
onClick: handleClick
|
|
2265
|
+
},
|
|
2266
|
+
/* @__PURE__ */ React13.createElement(ListItemIcon, { size: "tiny" }, /* @__PURE__ */ React13.createElement(ComponentsIcon, { fontSize: "tiny" })),
|
|
2267
|
+
/* @__PURE__ */ React13.createElement(Indicator, { isActive: isEditing, isError: !!error }, /* @__PURE__ */ React13.createElement(Box9, { display: "flex", flex: 1, minWidth: 0, flexGrow: 1 }, isEditing ? /* @__PURE__ */ React13.createElement(
|
|
2268
|
+
EditableField2,
|
|
2269
|
+
{
|
|
2270
|
+
ref: editableRef,
|
|
2271
|
+
as: Typography7,
|
|
2272
|
+
variant: "caption",
|
|
2273
|
+
...getEditableProps()
|
|
2274
|
+
}
|
|
2275
|
+
) : /* @__PURE__ */ React13.createElement(
|
|
2276
|
+
EllipsisWithTooltip,
|
|
2277
|
+
{
|
|
2278
|
+
title: component.name,
|
|
2279
|
+
as: Typography7,
|
|
2280
|
+
variant: "caption",
|
|
2281
|
+
color: "text.primary"
|
|
2282
|
+
}
|
|
2283
|
+
)))
|
|
2284
|
+
),
|
|
2285
|
+
/* @__PURE__ */ React13.createElement(IconButton5, { size: "tiny", ...bindTrigger3(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React13.createElement(DotsVerticalIcon2, { fontSize: "tiny" }))
|
|
2286
|
+
)
|
|
2122
2287
|
), /* @__PURE__ */ React13.createElement(
|
|
2123
2288
|
Menu2,
|
|
2124
2289
|
{
|
|
@@ -2132,7 +2297,18 @@ var ComponentItem = ({ component }) => {
|
|
|
2132
2297
|
horizontal: "right"
|
|
2133
2298
|
}
|
|
2134
2299
|
},
|
|
2135
|
-
/* @__PURE__ */ React13.createElement(
|
|
2300
|
+
/* @__PURE__ */ React13.createElement(
|
|
2301
|
+
MenuListItem3,
|
|
2302
|
+
{
|
|
2303
|
+
sx: { minWidth: "160px" },
|
|
2304
|
+
onClick: () => {
|
|
2305
|
+
popupState.close();
|
|
2306
|
+
openEditMode();
|
|
2307
|
+
}
|
|
2308
|
+
},
|
|
2309
|
+
__15("Rename", "elementor")
|
|
2310
|
+
),
|
|
2311
|
+
/* @__PURE__ */ React13.createElement(MenuListItem3, { sx: { minWidth: "160px" }, onClick: handleArchiveClick }, /* @__PURE__ */ React13.createElement(Typography7, { variant: "caption", sx: { color: "error.light" } }, __15("Archive", "elementor")))
|
|
2136
2312
|
));
|
|
2137
2313
|
};
|
|
2138
2314
|
var addComponentToPage = (model) => {
|
|
@@ -2147,6 +2323,34 @@ var addComponentToPage = (model) => {
|
|
|
2147
2323
|
options: { ...options, useHistory: false, scrollIntoView: true }
|
|
2148
2324
|
});
|
|
2149
2325
|
};
|
|
2326
|
+
var validateComponentTitle = (newTitle) => {
|
|
2327
|
+
const result = validateComponentName(newTitle);
|
|
2328
|
+
if (!result.errorMessage) {
|
|
2329
|
+
return null;
|
|
2330
|
+
}
|
|
2331
|
+
return result.errorMessage;
|
|
2332
|
+
};
|
|
2333
|
+
var Indicator = styled3(Box9, {
|
|
2334
|
+
shouldForwardProp: (prop) => prop !== "isActive" && prop !== "isError"
|
|
2335
|
+
})(({ theme, isActive, isError }) => ({
|
|
2336
|
+
display: "flex",
|
|
2337
|
+
width: "100%",
|
|
2338
|
+
flexGrow: 1,
|
|
2339
|
+
borderRadius: theme.spacing(0.5),
|
|
2340
|
+
border: getIndicatorBorder({ isActive, isError, theme }),
|
|
2341
|
+
padding: `0 ${theme.spacing(1)}`,
|
|
2342
|
+
marginLeft: isActive ? theme.spacing(1) : 0,
|
|
2343
|
+
minWidth: 0
|
|
2344
|
+
}));
|
|
2345
|
+
var getIndicatorBorder = ({ isActive, isError, theme }) => {
|
|
2346
|
+
if (isError) {
|
|
2347
|
+
return `2px solid ${theme.palette.error.main}`;
|
|
2348
|
+
}
|
|
2349
|
+
if (isActive) {
|
|
2350
|
+
return `2px solid ${theme.palette.secondary.main}`;
|
|
2351
|
+
}
|
|
2352
|
+
return "none";
|
|
2353
|
+
};
|
|
2150
2354
|
|
|
2151
2355
|
// src/components/components-tab/loading-components.tsx
|
|
2152
2356
|
import * as React14 from "react";
|
|
@@ -2201,7 +2405,16 @@ function ComponentsList() {
|
|
|
2201
2405
|
}
|
|
2202
2406
|
return /* @__PURE__ */ React15.createElement(EmptyState, null);
|
|
2203
2407
|
}
|
|
2204
|
-
return /* @__PURE__ */ React15.createElement(List3, { sx: { display: "flex", flexDirection: "column", gap: 1, px: 2 } }, components.map((component) => /* @__PURE__ */ React15.createElement(
|
|
2408
|
+
return /* @__PURE__ */ React15.createElement(List3, { sx: { display: "flex", flexDirection: "column", gap: 1, px: 2 } }, components.map((component) => /* @__PURE__ */ React15.createElement(
|
|
2409
|
+
ComponentItem,
|
|
2410
|
+
{
|
|
2411
|
+
key: component.uid,
|
|
2412
|
+
component,
|
|
2413
|
+
renameComponent: (newName) => {
|
|
2414
|
+
renameComponent(component.uid, newName);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
)));
|
|
2205
2418
|
}
|
|
2206
2419
|
var EmptyState = () => {
|
|
2207
2420
|
return /* @__PURE__ */ React15.createElement(
|
|
@@ -2215,13 +2428,13 @@ var EmptyState = () => {
|
|
|
2215
2428
|
overflow: "hidden"
|
|
2216
2429
|
},
|
|
2217
2430
|
/* @__PURE__ */ React15.createElement(Icon, { fontSize: "large" }, /* @__PURE__ */ React15.createElement(EyeIcon, { fontSize: "large" })),
|
|
2218
|
-
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" },
|
|
2219
|
-
/* @__PURE__ */ React15.createElement(Typography8, { variant: "caption", align: "center", color: "text.secondary" },
|
|
2431
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, __16("Text that explains that there are no Components yet.", "elementor")),
|
|
2432
|
+
/* @__PURE__ */ React15.createElement(Typography8, { variant: "caption", align: "center", color: "text.secondary" }, __16(
|
|
2220
2433
|
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
2221
2434
|
"elementor"
|
|
2222
2435
|
)),
|
|
2223
2436
|
/* @__PURE__ */ React15.createElement(Divider3, { sx: { width: "100%" }, color: "text.secondary" }),
|
|
2224
|
-
/* @__PURE__ */ React15.createElement(Typography8, { align: "left", variant: "caption", color: "text.secondary" },
|
|
2437
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "left", variant: "caption", color: "text.secondary" }, __16("To create a component, first design it, then choose one of three options:", "elementor")),
|
|
2225
2438
|
/* @__PURE__ */ React15.createElement(
|
|
2226
2439
|
Typography8,
|
|
2227
2440
|
{
|
|
@@ -2230,9 +2443,9 @@ var EmptyState = () => {
|
|
|
2230
2443
|
color: "text.secondary",
|
|
2231
2444
|
sx: { display: "flex", flexDirection: "column" }
|
|
2232
2445
|
},
|
|
2233
|
-
/* @__PURE__ */ React15.createElement("span", null,
|
|
2234
|
-
/* @__PURE__ */ React15.createElement("span", null,
|
|
2235
|
-
/* @__PURE__ */ React15.createElement("span", null,
|
|
2446
|
+
/* @__PURE__ */ React15.createElement("span", null, __16("1. Right-click and select Create Component", "elementor")),
|
|
2447
|
+
/* @__PURE__ */ React15.createElement("span", null, __16("2. Use the component icon in the Structure panel", "elementor")),
|
|
2448
|
+
/* @__PURE__ */ React15.createElement("span", null, __16("3. Use the component icon in the Edit panel header", "elementor"))
|
|
2236
2449
|
)
|
|
2237
2450
|
);
|
|
2238
2451
|
};
|
|
@@ -2256,7 +2469,7 @@ var EmptySearchResult = () => {
|
|
|
2256
2469
|
width: "100%"
|
|
2257
2470
|
}
|
|
2258
2471
|
},
|
|
2259
|
-
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "subtitle2", color: "inherit" },
|
|
2472
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "subtitle2", color: "inherit" }, __16("Sorry, nothing matched", "elementor")),
|
|
2260
2473
|
searchValue && /* @__PURE__ */ React15.createElement(
|
|
2261
2474
|
Typography8,
|
|
2262
2475
|
{
|
|
@@ -2283,8 +2496,8 @@ var EmptySearchResult = () => {
|
|
|
2283
2496
|
/* @__PURE__ */ React15.createElement("span", null, "\u201D.")
|
|
2284
2497
|
)
|
|
2285
2498
|
),
|
|
2286
|
-
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "caption", color: "inherit" },
|
|
2287
|
-
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React15.createElement(Link3, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch },
|
|
2499
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "caption", color: "inherit" }, __16("Try something else.", "elementor")),
|
|
2500
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React15.createElement(Link3, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, __16("Clear & try again", "elementor")))
|
|
2288
2501
|
);
|
|
2289
2502
|
};
|
|
2290
2503
|
var useFilteredComponents = () => {
|
|
@@ -2309,7 +2522,7 @@ var COMPONENT_DOCUMENT_TYPE = "elementor_component";
|
|
|
2309
2522
|
|
|
2310
2523
|
// src/components/create-component-form/create-component-form.tsx
|
|
2311
2524
|
import * as React17 from "react";
|
|
2312
|
-
import { useEffect as useEffect2, useMemo as useMemo3, useRef as
|
|
2525
|
+
import { useEffect as useEffect2, useMemo as useMemo3, useRef as useRef5, useState as useState7 } from "react";
|
|
2313
2526
|
import { getElementLabel } from "@elementor/editor-elements";
|
|
2314
2527
|
import { notify as notify2 } from "@elementor/editor-notifications";
|
|
2315
2528
|
import { Form as FormElement, ThemeProvider as ThemeProvider3 } from "@elementor/editor-ui";
|
|
@@ -2323,10 +2536,10 @@ import { getAllDescendants, getElementType } from "@elementor/editor-elements";
|
|
|
2323
2536
|
import { notify } from "@elementor/editor-notifications";
|
|
2324
2537
|
import { blockCommand } from "@elementor/editor-v1-adapters";
|
|
2325
2538
|
import { __getStore as getStore2 } from "@elementor/store";
|
|
2326
|
-
import { __ as
|
|
2539
|
+
import { __ as __17 } from "@wordpress/i18n";
|
|
2327
2540
|
var NON_ATOMIC_ELEMENT_ALERT = {
|
|
2328
2541
|
type: "default",
|
|
2329
|
-
message:
|
|
2542
|
+
message: __17("This widget isn't compatible with components. Use atomic elements instead.", "elementor"),
|
|
2330
2543
|
id: "non-atomic-element-blocked"
|
|
2331
2544
|
};
|
|
2332
2545
|
function initNonAtomicNestingPrevention() {
|
|
@@ -2433,18 +2646,18 @@ function findNonAtomicElementsInElement(element) {
|
|
|
2433
2646
|
|
|
2434
2647
|
// src/store/actions/create-unpublished-component.ts
|
|
2435
2648
|
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
2436
|
-
import { __dispatch as
|
|
2649
|
+
import { __dispatch as dispatch11 } from "@elementor/store";
|
|
2437
2650
|
import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
|
|
2438
2651
|
function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
|
|
2439
2652
|
const generatedUid = uid ?? generateUniqueId3("component");
|
|
2440
2653
|
const componentBase = { uid: generatedUid, name, overridableProps };
|
|
2441
|
-
|
|
2654
|
+
dispatch11(
|
|
2442
2655
|
slice.actions.addUnpublished({
|
|
2443
2656
|
...componentBase,
|
|
2444
2657
|
elements: [element]
|
|
2445
2658
|
})
|
|
2446
2659
|
);
|
|
2447
|
-
|
|
2660
|
+
dispatch11(slice.actions.addCreatedThisSession(generatedUid));
|
|
2448
2661
|
replaceElementWithComponent(element, componentBase);
|
|
2449
2662
|
trackComponentEvent({
|
|
2450
2663
|
action: "created",
|
|
@@ -2505,32 +2718,6 @@ var validateForm = (values, schema) => {
|
|
|
2505
2718
|
return { success: false, errors };
|
|
2506
2719
|
};
|
|
2507
2720
|
|
|
2508
|
-
// src/components/create-component-form/utils/component-form-schema.ts
|
|
2509
|
-
import { z } from "@elementor/schema";
|
|
2510
|
-
import { __ as __17 } from "@wordpress/i18n";
|
|
2511
|
-
var MIN_NAME_LENGTH = 2;
|
|
2512
|
-
var MAX_NAME_LENGTH = 50;
|
|
2513
|
-
var createBaseComponentSchema = (existingNames) => {
|
|
2514
|
-
return z.object({
|
|
2515
|
-
componentName: z.string().trim().max(
|
|
2516
|
-
MAX_NAME_LENGTH,
|
|
2517
|
-
__17("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
2518
|
-
).refine((value) => !existingNames.includes(value), {
|
|
2519
|
-
message: __17("Component name already exists", "elementor")
|
|
2520
|
-
})
|
|
2521
|
-
});
|
|
2522
|
-
};
|
|
2523
|
-
var createSubmitComponentSchema = (existingNames) => {
|
|
2524
|
-
const baseSchema = createBaseComponentSchema(existingNames);
|
|
2525
|
-
return baseSchema.extend({
|
|
2526
|
-
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
2527
|
-
message: __17("Component name is required.", "elementor")
|
|
2528
|
-
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
2529
|
-
message: __17("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
2530
|
-
})
|
|
2531
|
-
});
|
|
2532
|
-
};
|
|
2533
|
-
|
|
2534
2721
|
// src/components/create-component-form/utils/get-component-event-data.ts
|
|
2535
2722
|
var getComponentEventData = (containerElement, options) => {
|
|
2536
2723
|
const { elementsCount, componentsCount } = countNestedElements(containerElement);
|
|
@@ -2565,7 +2752,7 @@ function CreateComponentForm() {
|
|
|
2565
2752
|
const [element, setElement] = useState7(null);
|
|
2566
2753
|
const [anchorPosition, setAnchorPosition] = useState7();
|
|
2567
2754
|
const [resultNotification, setResultNotification] = useState7(null);
|
|
2568
|
-
const eventData =
|
|
2755
|
+
const eventData = useRef5(null);
|
|
2569
2756
|
useEffect2(() => {
|
|
2570
2757
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
2571
2758
|
const openPopup = (event) => {
|
|
@@ -2726,12 +2913,12 @@ function updateCurrentComponent({
|
|
|
2726
2913
|
path,
|
|
2727
2914
|
currentComponentId
|
|
2728
2915
|
}) {
|
|
2729
|
-
const
|
|
2730
|
-
if (!
|
|
2916
|
+
const dispatch18 = getStore3()?.dispatch;
|
|
2917
|
+
if (!dispatch18) {
|
|
2731
2918
|
return;
|
|
2732
2919
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2920
|
+
dispatch18(slice.actions.setPath(path));
|
|
2921
|
+
dispatch18(slice.actions.setCurrentComponentId(currentComponentId));
|
|
2735
2922
|
}
|
|
2736
2923
|
|
|
2737
2924
|
// src/components/edit-component/component-modal.tsx
|
|
@@ -2955,14 +3142,31 @@ function getUpdatedComponentPath(path, nextDocument) {
|
|
|
2955
3142
|
if (componentIndex >= 0) {
|
|
2956
3143
|
return path.slice(0, componentIndex + 1);
|
|
2957
3144
|
}
|
|
3145
|
+
const instanceId = nextDocument?.container.view?.el?.dataset.id;
|
|
3146
|
+
const instanceTitle = getInstanceTitle(instanceId, path);
|
|
2958
3147
|
return [
|
|
2959
3148
|
...path,
|
|
2960
3149
|
{
|
|
2961
|
-
instanceId
|
|
3150
|
+
instanceId,
|
|
3151
|
+
instanceTitle,
|
|
2962
3152
|
componentId: nextDocument.id
|
|
2963
3153
|
}
|
|
2964
3154
|
];
|
|
2965
3155
|
}
|
|
3156
|
+
function getInstanceTitle(instanceId, path) {
|
|
3157
|
+
if (!instanceId) {
|
|
3158
|
+
return void 0;
|
|
3159
|
+
}
|
|
3160
|
+
const documentsManager = getV1DocumentsManager4();
|
|
3161
|
+
const parentDocId = path.at(-1)?.componentId ?? documentsManager.getInitialId();
|
|
3162
|
+
const parentDoc = documentsManager.get(parentDocId);
|
|
3163
|
+
const parentContainer = parentDoc?.container;
|
|
3164
|
+
const widget = parentContainer?.children?.findRecursive?.(
|
|
3165
|
+
(container) => container.id === instanceId
|
|
3166
|
+
);
|
|
3167
|
+
const editorSettings = widget?.model?.get?.("editor_settings");
|
|
3168
|
+
return editorSettings?.title;
|
|
3169
|
+
}
|
|
2966
3170
|
function getComponentDOMElement(id2) {
|
|
2967
3171
|
if (!id2) {
|
|
2968
3172
|
return null;
|
|
@@ -3142,9 +3346,9 @@ function getControlsByBind(controls) {
|
|
|
3142
3346
|
}
|
|
3143
3347
|
|
|
3144
3348
|
// src/store/actions/update-overridable-prop.ts
|
|
3145
|
-
import { __dispatch as
|
|
3349
|
+
import { __dispatch as dispatch12, __getState as getState15 } from "@elementor/store";
|
|
3146
3350
|
function updateOverridableProp(componentId, propValue, originPropFields) {
|
|
3147
|
-
const overridableProps = selectOverridableProps(
|
|
3351
|
+
const overridableProps = selectOverridableProps(getState15(), componentId);
|
|
3148
3352
|
if (!overridableProps) {
|
|
3149
3353
|
return;
|
|
3150
3354
|
}
|
|
@@ -3168,7 +3372,7 @@ function updateOverridableProp(componentId, propValue, originPropFields) {
|
|
|
3168
3372
|
}
|
|
3169
3373
|
}
|
|
3170
3374
|
};
|
|
3171
|
-
|
|
3375
|
+
dispatch12(
|
|
3172
3376
|
slice.actions.setOverridableProps({
|
|
3173
3377
|
componentId,
|
|
3174
3378
|
overridableProps: newOverridableProps
|
|
@@ -3453,7 +3657,7 @@ import { bindPopover as bindPopover2, bindTrigger as bindTrigger4, Popover as Po
|
|
|
3453
3657
|
import { __ as __24 } from "@wordpress/i18n";
|
|
3454
3658
|
|
|
3455
3659
|
// src/store/actions/set-overridable-prop.ts
|
|
3456
|
-
import { __dispatch as
|
|
3660
|
+
import { __dispatch as dispatch13, __getState as getState16 } from "@elementor/store";
|
|
3457
3661
|
import { generateUniqueId as generateUniqueId4 } from "@elementor/utils";
|
|
3458
3662
|
function setOverridableProp({
|
|
3459
3663
|
componentId,
|
|
@@ -3467,7 +3671,7 @@ function setOverridableProp({
|
|
|
3467
3671
|
originValue,
|
|
3468
3672
|
originPropFields
|
|
3469
3673
|
}) {
|
|
3470
|
-
const overridableProps = selectOverridableProps(
|
|
3674
|
+
const overridableProps = selectOverridableProps(getState16(), componentId);
|
|
3471
3675
|
if (!overridableProps) {
|
|
3472
3676
|
return;
|
|
3473
3677
|
}
|
|
@@ -3504,7 +3708,7 @@ function setOverridableProp({
|
|
|
3504
3708
|
if (isChangingGroups) {
|
|
3505
3709
|
groups = removePropFromGroup(groups, existingOverridableProp.groupId, overridableProp.overrideKey);
|
|
3506
3710
|
}
|
|
3507
|
-
|
|
3711
|
+
dispatch13(
|
|
3508
3712
|
slice.actions.setOverridableProps({
|
|
3509
3713
|
componentId,
|
|
3510
3714
|
overridableProps: {
|
|
@@ -3520,10 +3724,10 @@ function setOverridableProp({
|
|
|
3520
3724
|
import * as React28 from "react";
|
|
3521
3725
|
import { forwardRef as forwardRef2 } from "react";
|
|
3522
3726
|
import { CheckIcon, PlusIcon } from "@elementor/icons";
|
|
3523
|
-
import { Box as Box14, styled as
|
|
3727
|
+
import { Box as Box14, styled as styled4 } from "@elementor/ui";
|
|
3524
3728
|
import { __ as __23 } from "@wordpress/i18n";
|
|
3525
3729
|
var SIZE2 = "tiny";
|
|
3526
|
-
var IconContainer =
|
|
3730
|
+
var IconContainer = styled4(Box14)`
|
|
3527
3731
|
pointer-events: none;
|
|
3528
3732
|
opacity: 0;
|
|
3529
3733
|
transition: opacity 0.2s ease-in-out;
|
|
@@ -3540,7 +3744,7 @@ var IconContainer = styled3(Box14)`
|
|
|
3540
3744
|
stroke-width: 2px;
|
|
3541
3745
|
}
|
|
3542
3746
|
`;
|
|
3543
|
-
var Content =
|
|
3747
|
+
var Content = styled4(Box14)`
|
|
3544
3748
|
position: relative;
|
|
3545
3749
|
display: flex;
|
|
3546
3750
|
align-items: center;
|
|
@@ -3577,7 +3781,7 @@ var Content = styled3(Box14)`
|
|
|
3577
3781
|
}
|
|
3578
3782
|
}
|
|
3579
3783
|
`;
|
|
3580
|
-
var
|
|
3784
|
+
var Indicator2 = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React28.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React28.createElement(
|
|
3581
3785
|
IconContainer,
|
|
3582
3786
|
{
|
|
3583
3787
|
className: "icon",
|
|
@@ -3587,12 +3791,12 @@ var Indicator = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @__
|
|
|
3587
3791
|
)));
|
|
3588
3792
|
|
|
3589
3793
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
3590
|
-
import { __getState as
|
|
3794
|
+
import { __getState as getState17 } from "@elementor/store";
|
|
3591
3795
|
function getOverridableProp({
|
|
3592
3796
|
componentId,
|
|
3593
3797
|
overrideKey
|
|
3594
3798
|
}) {
|
|
3595
|
-
const overridableProps = selectOverridableProps(
|
|
3799
|
+
const overridableProps = selectOverridableProps(getState17(), componentId);
|
|
3596
3800
|
if (!overridableProps) {
|
|
3597
3801
|
return void 0;
|
|
3598
3802
|
}
|
|
@@ -3652,7 +3856,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
3652
3856
|
popupState.close();
|
|
3653
3857
|
};
|
|
3654
3858
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
3655
|
-
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(Tooltip5, { placement: "top", title: __24("Override Property", "elementor") }, /* @__PURE__ */ React29.createElement(
|
|
3859
|
+
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(Tooltip5, { placement: "top", title: __24("Override Property", "elementor") }, /* @__PURE__ */ React29.createElement(Indicator2, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React29.createElement(
|
|
3656
3860
|
Popover4,
|
|
3657
3861
|
{
|
|
3658
3862
|
disableScrollLock: true,
|
|
@@ -4102,10 +4306,10 @@ function initMcp() {
|
|
|
4102
4306
|
|
|
4103
4307
|
// src/populate-store.ts
|
|
4104
4308
|
import { useEffect as useEffect6 } from "react";
|
|
4105
|
-
import { __dispatch as
|
|
4309
|
+
import { __dispatch as dispatch14 } from "@elementor/store";
|
|
4106
4310
|
function PopulateStore() {
|
|
4107
4311
|
useEffect6(() => {
|
|
4108
|
-
|
|
4312
|
+
dispatch14(loadComponents());
|
|
4109
4313
|
}, []);
|
|
4110
4314
|
return null;
|
|
4111
4315
|
}
|
|
@@ -4114,7 +4318,7 @@ function PopulateStore() {
|
|
|
4114
4318
|
import { getAllDescendants as getAllDescendants3 } from "@elementor/editor-elements";
|
|
4115
4319
|
import { notify as notify3 } from "@elementor/editor-notifications";
|
|
4116
4320
|
import { blockCommand as blockCommand2 } from "@elementor/editor-v1-adapters";
|
|
4117
|
-
import { __getState as
|
|
4321
|
+
import { __getState as getState18 } from "@elementor/store";
|
|
4118
4322
|
import { __ as __25 } from "@wordpress/i18n";
|
|
4119
4323
|
var COMPONENT_TYPE = "e-component";
|
|
4120
4324
|
var COMPONENT_CIRCULAR_NESTING_ALERT = {
|
|
@@ -4140,7 +4344,7 @@ function wouldCreateCircularNesting(componentIdToAdd) {
|
|
|
4140
4344
|
if (componentIdToAdd === void 0) {
|
|
4141
4345
|
return false;
|
|
4142
4346
|
}
|
|
4143
|
-
const state =
|
|
4347
|
+
const state = getState18();
|
|
4144
4348
|
const currentComponentId = selectCurrentComponentId(state);
|
|
4145
4349
|
const path = selectPath(state);
|
|
4146
4350
|
if (currentComponentId === null) {
|
|
@@ -4238,15 +4442,15 @@ function blockCircularPaste(args) {
|
|
|
4238
4442
|
}
|
|
4239
4443
|
|
|
4240
4444
|
// src/store/actions/remove-component-styles.ts
|
|
4241
|
-
import { __dispatch as
|
|
4445
|
+
import { __dispatch as dispatch15 } from "@elementor/store";
|
|
4242
4446
|
function removeComponentStyles(id2) {
|
|
4243
4447
|
apiClient.invalidateComponentConfigCache(id2);
|
|
4244
|
-
|
|
4448
|
+
dispatch15(slice.actions.removeStyles({ id: id2 }));
|
|
4245
4449
|
}
|
|
4246
4450
|
|
|
4247
4451
|
// src/store/components-styles-provider.ts
|
|
4248
4452
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
4249
|
-
import { __getState as
|
|
4453
|
+
import { __getState as getState19, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
4250
4454
|
var componentsStylesProvider = createStylesProvider({
|
|
4251
4455
|
key: "components-styles",
|
|
4252
4456
|
priority: 100,
|
|
@@ -4258,29 +4462,29 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
4258
4462
|
),
|
|
4259
4463
|
actions: {
|
|
4260
4464
|
all: () => {
|
|
4261
|
-
return selectFlatStyles(
|
|
4465
|
+
return selectFlatStyles(getState19());
|
|
4262
4466
|
},
|
|
4263
4467
|
get: (id2) => {
|
|
4264
|
-
return selectFlatStyles(
|
|
4468
|
+
return selectFlatStyles(getState19()).find((style) => style.id === id2) ?? null;
|
|
4265
4469
|
}
|
|
4266
4470
|
}
|
|
4267
4471
|
});
|
|
4268
4472
|
|
|
4269
4473
|
// src/sync/create-components-before-save.ts
|
|
4270
4474
|
import { updateElementSettings as updateElementSettings3 } from "@elementor/editor-elements";
|
|
4271
|
-
import { __dispatch as
|
|
4475
|
+
import { __dispatch as dispatch16, __getState as getState20 } from "@elementor/store";
|
|
4272
4476
|
async function createComponentsBeforeSave({
|
|
4273
4477
|
elements,
|
|
4274
4478
|
status
|
|
4275
4479
|
}) {
|
|
4276
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
4480
|
+
const unpublishedComponents = selectUnpublishedComponents(getState20());
|
|
4277
4481
|
if (!unpublishedComponents.length) {
|
|
4278
4482
|
return;
|
|
4279
4483
|
}
|
|
4280
4484
|
try {
|
|
4281
4485
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
4282
4486
|
updateComponentInstances(elements, uidToComponentId);
|
|
4283
|
-
|
|
4487
|
+
dispatch16(
|
|
4284
4488
|
slice.actions.add(
|
|
4285
4489
|
unpublishedComponents.map((component) => ({
|
|
4286
4490
|
id: uidToComponentId.get(component.uid),
|
|
@@ -4290,7 +4494,7 @@ async function createComponentsBeforeSave({
|
|
|
4290
4494
|
}))
|
|
4291
4495
|
)
|
|
4292
4496
|
);
|
|
4293
|
-
|
|
4497
|
+
dispatch16(slice.actions.resetUnpublished());
|
|
4294
4498
|
} catch (error) {
|
|
4295
4499
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
4296
4500
|
}
|
|
@@ -4350,7 +4554,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
4350
4554
|
}
|
|
4351
4555
|
|
|
4352
4556
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
4353
|
-
import { __getState as
|
|
4557
|
+
import { __getState as getState21 } from "@elementor/store";
|
|
4354
4558
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
4355
4559
|
container
|
|
4356
4560
|
}) => {
|
|
@@ -4358,7 +4562,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
4358
4562
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
4359
4563
|
return;
|
|
4360
4564
|
}
|
|
4361
|
-
const overridableProps = selectOverridableProps(
|
|
4565
|
+
const overridableProps = selectOverridableProps(getState21(), currentDocument.id);
|
|
4362
4566
|
if (overridableProps) {
|
|
4363
4567
|
container.settings.set("overridable_props", overridableProps);
|
|
4364
4568
|
}
|
|
@@ -4366,7 +4570,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
4366
4570
|
|
|
4367
4571
|
// src/sync/update-archived-component-before-save.ts
|
|
4368
4572
|
import { notify as notify4 } from "@elementor/editor-notifications";
|
|
4369
|
-
import { __getState as
|
|
4573
|
+
import { __getState as getState22 } from "@elementor/store";
|
|
4370
4574
|
var failedNotification = (message) => ({
|
|
4371
4575
|
type: "error",
|
|
4372
4576
|
message: `Failed to archive components: ${message}`,
|
|
@@ -4379,7 +4583,7 @@ var successNotification = (message) => ({
|
|
|
4379
4583
|
});
|
|
4380
4584
|
var updateArchivedComponentBeforeSave = async () => {
|
|
4381
4585
|
try {
|
|
4382
|
-
const archivedComponents = selectArchivedComponents(
|
|
4586
|
+
const archivedComponents = selectArchivedComponents(getState22());
|
|
4383
4587
|
if (!archivedComponents.length) {
|
|
4384
4588
|
return;
|
|
4385
4589
|
}
|
|
@@ -4399,6 +4603,19 @@ var updateArchivedComponentBeforeSave = async () => {
|
|
|
4399
4603
|
}
|
|
4400
4604
|
};
|
|
4401
4605
|
|
|
4606
|
+
// src/sync/update-component-title-before-save.ts
|
|
4607
|
+
import { __dispatch as dispatch17, __getState as getState23 } from "@elementor/store";
|
|
4608
|
+
var updateComponentTitleBeforeSave = async () => {
|
|
4609
|
+
const updatedComponentNames = selectUpdatedComponentNames(getState23());
|
|
4610
|
+
if (!updatedComponentNames.length) {
|
|
4611
|
+
return;
|
|
4612
|
+
}
|
|
4613
|
+
const result = await apiClient.updateComponentTitle(updatedComponentNames);
|
|
4614
|
+
if (result.failedIds.length === 0) {
|
|
4615
|
+
dispatch17(slice.actions.cleanUpdatedComponentNames());
|
|
4616
|
+
}
|
|
4617
|
+
};
|
|
4618
|
+
|
|
4402
4619
|
// src/sync/update-components-before-save.ts
|
|
4403
4620
|
import { isDocumentDirty as isDocumentDirty2 } from "@elementor/editor-documents";
|
|
4404
4621
|
async function updateComponentsBeforeSave({ status, elements }) {
|
|
@@ -4422,7 +4639,8 @@ var beforeSave = ({ container, status }) => {
|
|
|
4422
4639
|
updateArchivedComponentBeforeSave(),
|
|
4423
4640
|
createComponentsBeforeSave({ elements, status }),
|
|
4424
4641
|
updateComponentsBeforeSave({ elements, status }),
|
|
4425
|
-
setComponentOverridablePropsSettingsBeforeSave({ container })
|
|
4642
|
+
setComponentOverridablePropsSettingsBeforeSave({ container }),
|
|
4643
|
+
updateComponentTitleBeforeSave()
|
|
4426
4644
|
]);
|
|
4427
4645
|
};
|
|
4428
4646
|
|