@elementor/editor-components 4.0.0-665 → 4.0.0-667
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 +191 -3870
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +184 -3904
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/init.ts +0 -13
- package/src/extended/components/component-introduction.tsx +0 -77
- package/src/extended/components/component-panel-header/component-badge.tsx +0 -73
- package/src/extended/components/component-panel-header/component-panel-header.tsx +0 -98
- package/src/extended/components/component-properties-panel/component-properties-panel-content.tsx +0 -176
- package/src/extended/components/component-properties-panel/component-properties-panel.tsx +0 -43
- package/src/extended/components/component-properties-panel/properties-empty-state.tsx +0 -51
- package/src/extended/components/component-properties-panel/properties-group.tsx +0 -196
- package/src/extended/components/component-properties-panel/property-item.tsx +0 -124
- package/src/extended/components/component-properties-panel/sortable.tsx +0 -92
- package/src/extended/components/component-properties-panel/use-current-editable-item.ts +0 -73
- package/src/extended/components/component-properties-panel/utils/generate-unique-label.ts +0 -21
- package/src/extended/components/component-properties-panel/utils/validate-group-label.ts +0 -24
- package/src/extended/components/components-tab/component-item.tsx +0 -180
- package/src/extended/components/components-tab/components.tsx +0 -58
- package/src/extended/components/components-tab/delete-confirmation-dialog.tsx +0 -26
- package/src/extended/components/create-component-form/create-component-form.tsx +0 -281
- package/src/extended/components/create-component-form/hooks/use-form.ts +0 -72
- package/src/extended/components/create-component-form/utils/get-component-event-data.ts +0 -54
- package/src/extended/components/edit-component/component-modal.tsx +0 -133
- package/src/extended/components/edit-component/edit-component.tsx +0 -166
- package/src/extended/components/edit-component/use-canvas-document.ts +0 -9
- package/src/extended/components/edit-component/use-element-rect.ts +0 -81
- package/src/extended/components/instance-editing-panel/instance-editing-panel.tsx +0 -60
- package/src/extended/components/overridable-props/indicator.tsx +0 -83
- package/src/extended/components/overridable-props/overridable-prop-control.tsx +0 -127
- package/src/extended/components/overridable-props/overridable-prop-form.tsx +0 -135
- package/src/extended/components/overridable-props/overridable-prop-indicator.tsx +0 -138
- package/src/extended/components/overridable-props/utils/validate-prop-label.ts +0 -38
- package/src/extended/consts.ts +0 -3
- package/src/extended/hooks/use-navigate-back.ts +0 -24
- package/src/extended/init.ts +0 -108
- package/src/extended/mcp/index.ts +0 -14
- package/src/extended/mcp/save-as-component-tool.ts +0 -436
- package/src/extended/shortcuts/create-component-shortcut.ts +0 -121
- package/src/extended/store/actions/add-overridable-group.ts +0 -53
- package/src/extended/store/actions/archive-component.ts +0 -18
- package/src/extended/store/actions/create-unpublished-component.ts +0 -99
- package/src/extended/store/actions/delete-overridable-group.ts +0 -32
- package/src/extended/store/actions/delete-overridable-prop.ts +0 -64
- package/src/extended/store/actions/rename-component.ts +0 -48
- package/src/extended/store/actions/rename-overridable-group.ts +0 -33
- package/src/extended/store/actions/reorder-group-props.ts +0 -37
- package/src/extended/store/actions/reorder-overridable-groups.ts +0 -24
- package/src/extended/store/actions/reset-sanitized-components.ts +0 -5
- package/src/extended/store/actions/set-overridable-prop.ts +0 -109
- package/src/extended/store/actions/update-component-sanitized-attribute.ts +0 -7
- package/src/extended/store/actions/update-current-component.ts +0 -12
- package/src/extended/store/actions/update-overridable-prop-params.ts +0 -52
- package/src/extended/store/utils/groups-transformers.ts +0 -187
- package/src/extended/sync/before-save.ts +0 -52
- package/src/extended/sync/cleanup-overridable-props-on-delete.ts +0 -78
- package/src/extended/sync/create-components-before-save.ts +0 -111
- package/src/extended/sync/handle-component-edit-mode-container.ts +0 -114
- package/src/extended/sync/prevent-non-atomic-nesting.ts +0 -198
- package/src/extended/sync/revert-overridables-on-copy-or-duplicate.ts +0 -66
- package/src/extended/sync/sanitize-overridable-props.ts +0 -32
- package/src/extended/sync/set-component-overridable-props-settings-before-save.ts +0 -22
- package/src/extended/sync/update-archived-component-before-save.ts +0 -31
- package/src/extended/sync/update-component-title-before-save.ts +0 -18
- package/src/extended/utils/component-form-schema.ts +0 -32
- package/src/extended/utils/component-name-validation.ts +0 -25
- package/src/extended/utils/create-component-model.ts +0 -28
- package/src/extended/utils/get-container-for-new-element.ts +0 -49
- package/src/extended/utils/is-editing-component.ts +0 -5
- package/src/extended/utils/replace-element-with-component.ts +0 -11
- package/src/extended/utils/revert-overridable-settings.ts +0 -207
package/dist/index.js
CHANGED
|
@@ -85,16 +85,15 @@ __export(index_exports, {
|
|
|
85
85
|
module.exports = __toCommonJS(index_exports);
|
|
86
86
|
|
|
87
87
|
// src/init.ts
|
|
88
|
-
var
|
|
89
|
-
var
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
var
|
|
88
|
+
var import_editor = require("@elementor/editor");
|
|
89
|
+
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
90
|
+
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
91
|
+
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
92
|
+
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
93
93
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
var
|
|
97
|
-
var import_i18n36 = require("@wordpress/i18n");
|
|
94
|
+
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
95
|
+
var import_store35 = require("@elementor/store");
|
|
96
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
98
97
|
|
|
99
98
|
// src/component-instance-transformer.ts
|
|
100
99
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
@@ -110,10 +109,10 @@ var import_store = require("@elementor/store");
|
|
|
110
109
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
111
110
|
var import_http_client = require("@elementor/http-client");
|
|
112
111
|
var BASE_URL = "elementor/v1/components";
|
|
113
|
-
var getParams = (
|
|
112
|
+
var getParams = (id) => ({
|
|
114
113
|
action: "get_document_config",
|
|
115
|
-
unique_id: `document-config-${
|
|
116
|
-
data: { id
|
|
114
|
+
unique_id: `document-config-${id}`,
|
|
115
|
+
data: { id }
|
|
117
116
|
});
|
|
118
117
|
var apiClient = {
|
|
119
118
|
get: () => (0, import_http_client.httpService)().get(`${BASE_URL}`).then((res) => res.data.data),
|
|
@@ -122,8 +121,8 @@ var apiClient = {
|
|
|
122
121
|
ids,
|
|
123
122
|
status
|
|
124
123
|
}),
|
|
125
|
-
getComponentConfig: (
|
|
126
|
-
invalidateComponentConfigCache: (
|
|
124
|
+
getComponentConfig: (id) => import_editor_v1_adapters.ajax.load(getParams(id)),
|
|
125
|
+
invalidateComponentConfigCache: (id) => import_editor_v1_adapters.ajax.invalidateCache(getParams(id)),
|
|
127
126
|
getComponentLockStatus: async (componentId) => await (0, import_http_client.httpService)().get(`${BASE_URL}/lock-status`, {
|
|
128
127
|
params: {
|
|
129
128
|
componentId
|
|
@@ -377,10 +376,10 @@ var useIsSanitizedComponent = (componentId, key) => {
|
|
|
377
376
|
|
|
378
377
|
// src/utils/component-document-data.ts
|
|
379
378
|
var import_editor_documents = require("@elementor/editor-documents");
|
|
380
|
-
var getComponentDocumentData = async (
|
|
379
|
+
var getComponentDocumentData = async (id) => {
|
|
381
380
|
const documentManager = (0, import_editor_documents.getV1DocumentsManager)();
|
|
382
381
|
try {
|
|
383
|
-
return await documentManager.request(
|
|
382
|
+
return await documentManager.request(id);
|
|
384
383
|
} catch {
|
|
385
384
|
return null;
|
|
386
385
|
}
|
|
@@ -389,11 +388,11 @@ var getComponentDocumentData = async (id2) => {
|
|
|
389
388
|
// src/component-instance-transformer.ts
|
|
390
389
|
var componentInstanceTransformer = (0, import_editor_canvas.createTransformer)(
|
|
391
390
|
async ({
|
|
392
|
-
component_id:
|
|
391
|
+
component_id: id,
|
|
393
392
|
overrides: overridesValue
|
|
394
393
|
}) => {
|
|
395
394
|
const unpublishedComponents = selectUnpublishedComponents((0, import_store3.__getState)());
|
|
396
|
-
const unpublishedComponent = unpublishedComponents.find(({ uid }) => uid ===
|
|
395
|
+
const unpublishedComponent = unpublishedComponents.find(({ uid }) => uid === id);
|
|
397
396
|
const overrides = overridesValue?.reduce((acc, override) => ({ ...acc, ...override }), {});
|
|
398
397
|
if (unpublishedComponent) {
|
|
399
398
|
return {
|
|
@@ -401,10 +400,10 @@ var componentInstanceTransformer = (0, import_editor_canvas.createTransformer)(
|
|
|
401
400
|
overrides
|
|
402
401
|
};
|
|
403
402
|
}
|
|
404
|
-
if (typeof
|
|
405
|
-
throw new Error(`Component ID "${
|
|
403
|
+
if (typeof id !== "number") {
|
|
404
|
+
throw new Error(`Component ID "${id}" not valid.`);
|
|
406
405
|
}
|
|
407
|
-
const data = await getComponentDocumentData(
|
|
406
|
+
const data = await getComponentDocumentData(id);
|
|
408
407
|
return {
|
|
409
408
|
elements: data?.elements ?? [],
|
|
410
409
|
overrides
|
|
@@ -1443,8 +1442,8 @@ var componentsActions = {
|
|
|
1443
1442
|
resetUnpublished() {
|
|
1444
1443
|
(0, import_store11.__dispatch)(slice.actions.resetUnpublished());
|
|
1445
1444
|
},
|
|
1446
|
-
removeStyles(
|
|
1447
|
-
(0, import_store11.__dispatch)(slice.actions.removeStyles({ id
|
|
1445
|
+
removeStyles(id) {
|
|
1446
|
+
(0, import_store11.__dispatch)(slice.actions.removeStyles({ id }));
|
|
1448
1447
|
},
|
|
1449
1448
|
addStyles(styles) {
|
|
1450
1449
|
(0, import_store11.__dispatch)(slice.actions.addStyles(styles));
|
|
@@ -1458,8 +1457,8 @@ var componentsActions = {
|
|
|
1458
1457
|
archive(componentId) {
|
|
1459
1458
|
(0, import_store11.__dispatch)(slice.actions.archive(componentId));
|
|
1460
1459
|
},
|
|
1461
|
-
setCurrentComponentId(
|
|
1462
|
-
safeDispatch()?.(slice.actions.setCurrentComponentId(
|
|
1460
|
+
setCurrentComponentId(id) {
|
|
1461
|
+
safeDispatch()?.(slice.actions.setCurrentComponentId(id));
|
|
1463
1462
|
},
|
|
1464
1463
|
setPath(path) {
|
|
1465
1464
|
safeDispatch()?.(slice.actions.setPath(path));
|
|
@@ -1928,9 +1927,9 @@ function OverridePropsGroup({ group }) {
|
|
|
1928
1927
|
const handleClick = () => {
|
|
1929
1928
|
setIsOpen(!isOpen);
|
|
1930
1929
|
};
|
|
1931
|
-
const
|
|
1932
|
-
const labelId = `label-${
|
|
1933
|
-
const contentId = `content-${
|
|
1930
|
+
const id = (0, import_react6.useId)();
|
|
1931
|
+
const labelId = `label-${id}`;
|
|
1932
|
+
const contentId = `content-${id}`;
|
|
1934
1933
|
const title = group.label;
|
|
1935
1934
|
return /* @__PURE__ */ React17.createElement(import_ui11.Box, { "aria-label": `${title} section` }, /* @__PURE__ */ React17.createElement(
|
|
1936
1935
|
import_ui11.ListItemButton,
|
|
@@ -2124,12 +2123,12 @@ async function getComponentIds(elements, cache) {
|
|
|
2124
2123
|
}
|
|
2125
2124
|
async function getDocumentsMap(ids, cache) {
|
|
2126
2125
|
const documents = await Promise.all(
|
|
2127
|
-
ids.map(async (
|
|
2128
|
-
const document = await cache.get(
|
|
2126
|
+
ids.map(async (id) => {
|
|
2127
|
+
const document = await cache.get(id);
|
|
2129
2128
|
if (!document) {
|
|
2130
2129
|
return null;
|
|
2131
2130
|
}
|
|
2132
|
-
return [
|
|
2131
|
+
return [id, document];
|
|
2133
2132
|
})
|
|
2134
2133
|
);
|
|
2135
2134
|
return new Map(documents.filter((document) => document !== null));
|
|
@@ -2167,7 +2166,7 @@ function loadComponentsStyles(documents) {
|
|
|
2167
2166
|
return;
|
|
2168
2167
|
}
|
|
2169
2168
|
const knownComponents = selectStyles((0, import_store24.__getState)());
|
|
2170
|
-
const unknownDocuments = new Map([...documents.entries()].filter(([
|
|
2169
|
+
const unknownDocuments = new Map([...documents.entries()].filter(([id]) => !knownComponents[id]));
|
|
2171
2170
|
if (!unknownDocuments.size) {
|
|
2172
2171
|
return;
|
|
2173
2172
|
}
|
|
@@ -2175,7 +2174,7 @@ function loadComponentsStyles(documents) {
|
|
|
2175
2174
|
}
|
|
2176
2175
|
function addStyles(documents) {
|
|
2177
2176
|
const styles = Object.fromEntries(
|
|
2178
|
-
[...documents.entries()].map(([
|
|
2177
|
+
[...documents.entries()].map(([id, document]) => [id, extractStylesFromDocument(document)])
|
|
2179
2178
|
);
|
|
2180
2179
|
(0, import_store24.__dispatch)(slice.actions.addStyles(styles));
|
|
2181
2180
|
}
|
|
@@ -2229,10 +2228,10 @@ var ELEMENT_ID_LENGTH = 7;
|
|
|
2229
2228
|
function formatComponentElementsId(elements, path) {
|
|
2230
2229
|
return elements.map((element) => {
|
|
2231
2230
|
const nestingPath = [...path, element.id];
|
|
2232
|
-
const
|
|
2231
|
+
const id = (0, import_utils3.hashString)(nestingPath.join("_"), ELEMENT_ID_LENGTH);
|
|
2233
2232
|
return {
|
|
2234
2233
|
...element,
|
|
2235
|
-
id
|
|
2234
|
+
id,
|
|
2236
2235
|
originId: element.id,
|
|
2237
2236
|
elements: element.elements ? formatComponentElementsId(element.elements, nestingPath) : void 0
|
|
2238
2237
|
};
|
|
@@ -2592,3871 +2591,200 @@ function createComponentModel() {
|
|
|
2592
2591
|
});
|
|
2593
2592
|
}
|
|
2594
2593
|
|
|
2595
|
-
// src/
|
|
2596
|
-
var import_editor = require("@elementor/editor");
|
|
2597
|
-
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
2598
|
-
var import_editor_documents13 = require("@elementor/editor-documents");
|
|
2599
|
-
var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
|
|
2600
|
-
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
2601
|
-
var import_editor_panels6 = require("@elementor/editor-panels");
|
|
2602
|
-
var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
2603
|
-
var import_i18n34 = require("@wordpress/i18n");
|
|
2604
|
-
|
|
2605
|
-
// src/extended/components/component-panel-header/component-panel-header.tsx
|
|
2606
|
-
var React29 = __toESM(require("react"));
|
|
2607
|
-
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
2608
|
-
var import_editor_documents8 = require("@elementor/editor-documents");
|
|
2609
|
-
var import_editor_panels5 = require("@elementor/editor-panels");
|
|
2610
|
-
var import_editor_ui13 = require("@elementor/editor-ui");
|
|
2611
|
-
var import_icons16 = require("@elementor/icons");
|
|
2612
|
-
var import_store32 = require("@elementor/store");
|
|
2613
|
-
var import_ui23 = require("@elementor/ui");
|
|
2614
|
-
var import_i18n22 = require("@wordpress/i18n");
|
|
2615
|
-
|
|
2616
|
-
// src/extended/hooks/use-navigate-back.ts
|
|
2594
|
+
// src/populate-store.ts
|
|
2617
2595
|
var import_react8 = require("react");
|
|
2618
|
-
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
2619
2596
|
var import_store28 = require("@elementor/store");
|
|
2620
|
-
function
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
if (prevComponentId && prevComponentInstanceId) {
|
|
2626
|
-
switchToComponent(prevComponentId, prevComponentInstanceId);
|
|
2627
|
-
return;
|
|
2628
|
-
}
|
|
2629
|
-
switchToComponent(documentsManager.getInitialId());
|
|
2630
|
-
}, [path, documentsManager]);
|
|
2597
|
+
function PopulateStore() {
|
|
2598
|
+
(0, import_react8.useEffect)(() => {
|
|
2599
|
+
(0, import_store28.__dispatch)(loadComponents());
|
|
2600
|
+
}, []);
|
|
2601
|
+
return null;
|
|
2631
2602
|
}
|
|
2632
2603
|
|
|
2633
|
-
// src/
|
|
2634
|
-
var
|
|
2635
|
-
var
|
|
2636
|
-
var
|
|
2637
|
-
var
|
|
2604
|
+
// src/prevent-circular-nesting.ts
|
|
2605
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
2606
|
+
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
2607
|
+
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
2608
|
+
var import_store29 = require("@elementor/store");
|
|
2638
2609
|
var import_i18n11 = require("@wordpress/i18n");
|
|
2639
|
-
var
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
if (!anchorRef.current || !shouldShowIntroduction) {
|
|
2645
|
-
return null;
|
|
2646
|
-
}
|
|
2647
|
-
return /* @__PURE__ */ React20.createElement(
|
|
2648
|
-
import_ui14.Popover,
|
|
2649
|
-
{
|
|
2650
|
-
anchorEl: anchorRef.current,
|
|
2651
|
-
open: shouldShowIntroduction,
|
|
2652
|
-
anchorOrigin: {
|
|
2653
|
-
vertical: "top",
|
|
2654
|
-
horizontal: "right"
|
|
2655
|
-
},
|
|
2656
|
-
transformOrigin: {
|
|
2657
|
-
vertical: "top",
|
|
2658
|
-
horizontal: -30
|
|
2659
|
-
},
|
|
2660
|
-
onClose
|
|
2661
|
-
},
|
|
2662
|
-
/* @__PURE__ */ React20.createElement(import_ui14.Box, { sx: { width: "296px" } }, /* @__PURE__ */ React20.createElement(import_editor_ui8.PopoverHeader, { title: (0, import_i18n11.__)("Add your first property", "elementor"), onClose }), /* @__PURE__ */ React20.createElement(
|
|
2663
|
-
import_ui14.Image,
|
|
2664
|
-
{
|
|
2665
|
-
sx: { width: "296px", height: "160px" },
|
|
2666
|
-
src: "https://assets.elementor.com/packages/v1/images/components-properties-intro.png",
|
|
2667
|
-
alt: ""
|
|
2668
|
-
}
|
|
2669
|
-
), /* @__PURE__ */ React20.createElement(import_editor_controls4.PopoverContent, null, /* @__PURE__ */ React20.createElement(import_ui14.Stack, { sx: { p: 2 } }, /* @__PURE__ */ React20.createElement(import_ui14.Typography, { variant: "body2" }, (0, import_i18n11.__)("Properties make instances flexible.", "elementor")), /* @__PURE__ */ React20.createElement(import_ui14.Typography, { variant: "body2" }, (0, import_i18n11.__)(
|
|
2670
|
-
"Select any Element, then in the General tab, click next to any setting you want users to customize - like text, images, or links.",
|
|
2671
|
-
"elementor"
|
|
2672
|
-
)), /* @__PURE__ */ React20.createElement(import_ui14.Typography, { variant: "body2", sx: { mt: 2 } }, (0, import_i18n11.__)(
|
|
2673
|
-
"Your properties will appear in the Properties panel, where you can organize and manage them anytime.",
|
|
2674
|
-
"elementor"
|
|
2675
|
-
)), /* @__PURE__ */ React20.createElement(
|
|
2676
|
-
import_ui14.Link,
|
|
2677
|
-
{
|
|
2678
|
-
href: "http://go.elementor.com/components-guide",
|
|
2679
|
-
target: "_blank",
|
|
2680
|
-
sx: { mt: 2 },
|
|
2681
|
-
color: "info.main",
|
|
2682
|
-
variant: "body2"
|
|
2683
|
-
},
|
|
2684
|
-
(0, import_i18n11.__)("Learn more", "elementor")
|
|
2685
|
-
), /* @__PURE__ */ React20.createElement(import_ui14.Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", sx: { pt: 1 } }, /* @__PURE__ */ React20.createElement(import_ui14.Button, { size: "medium", variant: "contained", onClick: onClose }, (0, import_i18n11.__)("Got it", "elementor"))))))
|
|
2686
|
-
);
|
|
2610
|
+
var COMPONENT_TYPE = "e-component";
|
|
2611
|
+
var COMPONENT_CIRCULAR_NESTING_ALERT = {
|
|
2612
|
+
type: "default",
|
|
2613
|
+
message: (0, import_i18n11.__)("Can't add this component - components that contain each other can't be nested.", "elementor"),
|
|
2614
|
+
id: "circular-component-nesting-blocked"
|
|
2687
2615
|
};
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
var import_editor_panels4 = require("@elementor/editor-panels");
|
|
2693
|
-
var import_editor_ui12 = require("@elementor/editor-ui");
|
|
2694
|
-
var import_ui21 = require("@elementor/ui");
|
|
2695
|
-
var import_i18n20 = require("@wordpress/i18n");
|
|
2696
|
-
|
|
2697
|
-
// src/extended/components/component-properties-panel/component-properties-panel-content.tsx
|
|
2698
|
-
var React26 = __toESM(require("react"));
|
|
2699
|
-
var import_react12 = require("react");
|
|
2700
|
-
var import_editor_documents7 = require("@elementor/editor-documents");
|
|
2701
|
-
var import_editor_panels3 = require("@elementor/editor-panels");
|
|
2702
|
-
var import_icons14 = require("@elementor/icons");
|
|
2703
|
-
var import_ui20 = require("@elementor/ui");
|
|
2704
|
-
var import_utils6 = require("@elementor/utils");
|
|
2705
|
-
var import_i18n19 = require("@wordpress/i18n");
|
|
2706
|
-
|
|
2707
|
-
// src/extended/store/actions/add-overridable-group.ts
|
|
2708
|
-
function addOverridableGroup({
|
|
2709
|
-
componentId,
|
|
2710
|
-
groupId,
|
|
2711
|
-
label,
|
|
2712
|
-
source
|
|
2713
|
-
}) {
|
|
2714
|
-
const currentComponent = componentsSelectors.getCurrentComponent();
|
|
2715
|
-
const overridableProps = componentsSelectors.getOverridableProps(componentId);
|
|
2716
|
-
if (!overridableProps) {
|
|
2717
|
-
return;
|
|
2718
|
-
}
|
|
2719
|
-
const newGroup = {
|
|
2720
|
-
id: groupId,
|
|
2721
|
-
label,
|
|
2722
|
-
props: []
|
|
2723
|
-
};
|
|
2724
|
-
componentsActions.setOverridableProps(componentId, {
|
|
2725
|
-
...overridableProps,
|
|
2726
|
-
groups: {
|
|
2727
|
-
...overridableProps.groups,
|
|
2728
|
-
items: {
|
|
2729
|
-
...overridableProps.groups.items,
|
|
2730
|
-
[groupId]: newGroup
|
|
2731
|
-
},
|
|
2732
|
-
order: [groupId, ...overridableProps.groups.order]
|
|
2733
|
-
}
|
|
2616
|
+
function initCircularNestingPrevention() {
|
|
2617
|
+
(0, import_editor_v1_adapters4.blockCommand)({
|
|
2618
|
+
command: "document/elements/create",
|
|
2619
|
+
condition: blockCircularCreate
|
|
2734
2620
|
});
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2621
|
+
(0, import_editor_v1_adapters4.blockCommand)({
|
|
2622
|
+
command: "document/elements/move",
|
|
2623
|
+
condition: blockCircularMove
|
|
2624
|
+
});
|
|
2625
|
+
(0, import_editor_v1_adapters4.blockCommand)({
|
|
2626
|
+
command: "document/elements/paste",
|
|
2627
|
+
condition: blockCircularPaste
|
|
2740
2628
|
});
|
|
2741
|
-
return newGroup;
|
|
2742
|
-
}
|
|
2743
|
-
|
|
2744
|
-
// src/extended/store/utils/groups-transformers.ts
|
|
2745
|
-
var import_utils5 = require("@elementor/utils");
|
|
2746
|
-
var import_i18n12 = require("@wordpress/i18n");
|
|
2747
|
-
function removePropFromAllGroups(groups, propKey) {
|
|
2748
|
-
const propKeys = Array.isArray(propKey) ? propKey : [propKey];
|
|
2749
|
-
return {
|
|
2750
|
-
...groups,
|
|
2751
|
-
items: Object.fromEntries(
|
|
2752
|
-
Object.entries(groups.items).map(([groupId, group]) => [
|
|
2753
|
-
groupId,
|
|
2754
|
-
{
|
|
2755
|
-
...group,
|
|
2756
|
-
props: group.props.filter((p) => !propKeys.includes(p))
|
|
2757
|
-
}
|
|
2758
|
-
])
|
|
2759
|
-
)
|
|
2760
|
-
};
|
|
2761
2629
|
}
|
|
2762
|
-
function
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
return groups;
|
|
2766
|
-
}
|
|
2767
|
-
if (group.props.includes(propKey)) {
|
|
2768
|
-
return groups;
|
|
2630
|
+
function wouldCreateCircularNesting(componentIdToAdd) {
|
|
2631
|
+
if (componentIdToAdd === void 0) {
|
|
2632
|
+
return false;
|
|
2769
2633
|
}
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
...group,
|
|
2776
|
-
props: [...group.props, propKey]
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
};
|
|
2780
|
-
}
|
|
2781
|
-
function movePropBetweenGroups(groups, propKey, fromGroupId, toGroupId) {
|
|
2782
|
-
if (fromGroupId === toGroupId) {
|
|
2783
|
-
return groups;
|
|
2634
|
+
const state = (0, import_store29.__getState)();
|
|
2635
|
+
const currentComponentId = selectCurrentComponentId(state);
|
|
2636
|
+
const path = selectPath(state);
|
|
2637
|
+
if (currentComponentId === null) {
|
|
2638
|
+
return false;
|
|
2784
2639
|
}
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
}
|
|
2788
|
-
function removePropFromGroup(groups, groupId, propKey) {
|
|
2789
|
-
const group = groups.items[groupId];
|
|
2790
|
-
if (!group) {
|
|
2791
|
-
return groups;
|
|
2640
|
+
if (componentIdToAdd === currentComponentId) {
|
|
2641
|
+
return true;
|
|
2792
2642
|
}
|
|
2793
|
-
return
|
|
2794
|
-
...groups,
|
|
2795
|
-
items: {
|
|
2796
|
-
...groups.items,
|
|
2797
|
-
[groupId]: {
|
|
2798
|
-
...group,
|
|
2799
|
-
props: group.props.filter((p) => p !== propKey)
|
|
2800
|
-
}
|
|
2801
|
-
}
|
|
2802
|
-
};
|
|
2643
|
+
return path.some((item) => item.componentId === componentIdToAdd);
|
|
2803
2644
|
}
|
|
2804
|
-
function
|
|
2805
|
-
if (
|
|
2806
|
-
return
|
|
2645
|
+
function extractComponentIdFromModel(model) {
|
|
2646
|
+
if (!model) {
|
|
2647
|
+
return null;
|
|
2807
2648
|
}
|
|
2808
|
-
|
|
2809
|
-
|
|
2649
|
+
const isComponent = model.widgetType === COMPONENT_TYPE;
|
|
2650
|
+
if (!isComponent) {
|
|
2651
|
+
return null;
|
|
2810
2652
|
}
|
|
2811
|
-
return
|
|
2653
|
+
return model.settings?.component_instance?.value?.component_id?.value ?? null;
|
|
2812
2654
|
}
|
|
2813
|
-
function
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
...groups,
|
|
2819
|
-
items: {
|
|
2820
|
-
...groups.items,
|
|
2821
|
-
[newGroupId]: {
|
|
2822
|
-
id: newGroupId,
|
|
2823
|
-
label: newLabel,
|
|
2824
|
-
props: []
|
|
2825
|
-
}
|
|
2826
|
-
},
|
|
2827
|
-
order: [...groups.order, newGroupId]
|
|
2828
|
-
},
|
|
2829
|
-
groupId: newGroupId
|
|
2830
|
-
};
|
|
2655
|
+
function extractComponentIdFromElement(element) {
|
|
2656
|
+
if (element.widgetType !== COMPONENT_TYPE) {
|
|
2657
|
+
return null;
|
|
2658
|
+
}
|
|
2659
|
+
return element.settings?.component_instance?.value?.component_id?.value ?? null;
|
|
2831
2660
|
}
|
|
2832
|
-
function
|
|
2833
|
-
const
|
|
2834
|
-
const
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
{
|
|
2842
|
-
...group,
|
|
2843
|
-
props: group.props.filter((prop) => !overrideKeysToRemove.includes(prop))
|
|
2844
|
-
}
|
|
2845
|
-
]
|
|
2846
|
-
)
|
|
2847
|
-
);
|
|
2848
|
-
return {
|
|
2849
|
-
props: remainingProps,
|
|
2850
|
-
groups: {
|
|
2851
|
-
items: updatedGroupItems,
|
|
2852
|
-
order: overridableProps.groups.order.filter((groupId) => !overrideKeysToRemove.includes(groupId))
|
|
2661
|
+
function extractComponentIdsFromElements(elements) {
|
|
2662
|
+
const ids = [];
|
|
2663
|
+
for (const element of elements) {
|
|
2664
|
+
const componentId = extractComponentIdFromElement(element);
|
|
2665
|
+
if (componentId !== null) {
|
|
2666
|
+
ids.push(componentId);
|
|
2667
|
+
}
|
|
2668
|
+
if (element.elements?.length) {
|
|
2669
|
+
ids.push(...extractComponentIdsFromElements(element.elements));
|
|
2853
2670
|
}
|
|
2854
|
-
};
|
|
2855
|
-
}
|
|
2856
|
-
function ensureGroupInOrder(groups, groupId) {
|
|
2857
|
-
if (groups.order.includes(groupId)) {
|
|
2858
|
-
return groups;
|
|
2859
2671
|
}
|
|
2860
|
-
return
|
|
2861
|
-
...groups,
|
|
2862
|
-
order: [...groups.order, groupId]
|
|
2863
|
-
};
|
|
2864
|
-
}
|
|
2865
|
-
function deleteGroup(groups, groupId) {
|
|
2866
|
-
const { [groupId]: removed, ...remainingItems } = groups.items;
|
|
2867
|
-
return {
|
|
2868
|
-
items: remainingItems,
|
|
2869
|
-
order: groups.order.filter((id2) => id2 !== groupId)
|
|
2870
|
-
};
|
|
2672
|
+
return ids;
|
|
2871
2673
|
}
|
|
2872
|
-
function
|
|
2873
|
-
const
|
|
2874
|
-
if (
|
|
2875
|
-
return
|
|
2674
|
+
function extractComponentIdFromContainer(container) {
|
|
2675
|
+
const widgetType = container.model?.get?.("widgetType");
|
|
2676
|
+
if (widgetType !== COMPONENT_TYPE) {
|
|
2677
|
+
return null;
|
|
2876
2678
|
}
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
...groups.items,
|
|
2881
|
-
[groupId]: {
|
|
2882
|
-
...group,
|
|
2883
|
-
label: newLabel
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
};
|
|
2679
|
+
const settings = container.model?.get?.("settings");
|
|
2680
|
+
const componentInstance = settings?.get?.("component_instance");
|
|
2681
|
+
return componentInstance?.value?.component_id?.value ?? null;
|
|
2887
2682
|
}
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
const overridableProps = componentsSelectors.getOverridableProps(componentId);
|
|
2892
|
-
if (!overridableProps) {
|
|
2683
|
+
function blockCircularCreate(args) {
|
|
2684
|
+
const componentId = extractComponentIdFromModel(args.model);
|
|
2685
|
+
if (componentId === null) {
|
|
2893
2686
|
return false;
|
|
2894
2687
|
}
|
|
2895
|
-
const
|
|
2896
|
-
if (
|
|
2897
|
-
|
|
2688
|
+
const isBlocked = wouldCreateCircularNesting(componentId);
|
|
2689
|
+
if (isBlocked) {
|
|
2690
|
+
(0, import_editor_notifications3.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
2898
2691
|
}
|
|
2899
|
-
|
|
2900
|
-
componentsActions.setOverridableProps(componentId, {
|
|
2901
|
-
...overridableProps,
|
|
2902
|
-
groups: updatedGroups
|
|
2903
|
-
});
|
|
2904
|
-
return true;
|
|
2692
|
+
return isBlocked;
|
|
2905
2693
|
}
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
props: { [settingKey]: originValue ?? null },
|
|
2921
|
-
withHistory: false
|
|
2694
|
+
function blockCircularMove(args) {
|
|
2695
|
+
const { containers = [args.container] } = args;
|
|
2696
|
+
const hasCircularComponent = containers.some((container) => {
|
|
2697
|
+
if (!container) {
|
|
2698
|
+
return false;
|
|
2699
|
+
}
|
|
2700
|
+
const allElements = (0, import_editor_elements9.getAllDescendants)(container);
|
|
2701
|
+
return allElements.some((element) => {
|
|
2702
|
+
const componentId = extractComponentIdFromContainer(element);
|
|
2703
|
+
if (componentId === null) {
|
|
2704
|
+
return false;
|
|
2705
|
+
}
|
|
2706
|
+
return wouldCreateCircularNesting(componentId);
|
|
2707
|
+
});
|
|
2922
2708
|
});
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
const setting = (0, import_editor_elements9.getElementSetting)(elementId, "component_instance");
|
|
2926
|
-
const componentInstance = componentInstancePropTypeUtil.extract(setting);
|
|
2927
|
-
const overrides = componentInstanceOverridesPropTypeUtil.extract(componentInstance?.overrides);
|
|
2928
|
-
if (!overrides?.length) {
|
|
2929
|
-
return;
|
|
2709
|
+
if (hasCircularComponent) {
|
|
2710
|
+
(0, import_editor_notifications3.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
2930
2711
|
}
|
|
2931
|
-
|
|
2932
|
-
const updatedSetting = componentInstancePropTypeUtil.create({
|
|
2933
|
-
...componentInstance,
|
|
2934
|
-
overrides: componentInstanceOverridesPropTypeUtil.create(revertedOverrides)
|
|
2935
|
-
});
|
|
2936
|
-
(0, import_editor_elements9.updateElementSettings)({
|
|
2937
|
-
id: elementId,
|
|
2938
|
-
props: { component_instance: updatedSetting },
|
|
2939
|
-
withHistory: false
|
|
2940
|
-
});
|
|
2941
|
-
}
|
|
2942
|
-
function revertComponentInstanceOverrides(overrides, filterByKey) {
|
|
2943
|
-
return overrides.map((item) => {
|
|
2944
|
-
if (!componentOverridablePropTypeUtil.isValid(item)) {
|
|
2945
|
-
return item;
|
|
2946
|
-
}
|
|
2947
|
-
if (!componentInstanceOverridePropTypeUtil.isValid(item.value.origin_value)) {
|
|
2948
|
-
return null;
|
|
2949
|
-
}
|
|
2950
|
-
if (filterByKey && item.value.override_key !== filterByKey) {
|
|
2951
|
-
return item;
|
|
2952
|
-
}
|
|
2953
|
-
return item.value.origin_value;
|
|
2954
|
-
}).filter((item) => item !== null);
|
|
2712
|
+
return hasCircularComponent;
|
|
2955
2713
|
}
|
|
2956
|
-
function
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
if (componentOverridablePropTypeUtil.isValid(value)) {
|
|
2961
|
-
revertedSettings[key] = value.value.origin_value;
|
|
2962
|
-
hasChanges = true;
|
|
2963
|
-
} else {
|
|
2964
|
-
revertedSettings[key] = value;
|
|
2965
|
-
}
|
|
2714
|
+
function blockCircularPaste(args) {
|
|
2715
|
+
const { storageType } = args;
|
|
2716
|
+
if (storageType !== "localstorage") {
|
|
2717
|
+
return false;
|
|
2966
2718
|
}
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
const revertedElement = { ...elementData };
|
|
2971
|
-
if (isComponentInstance({ widgetType: elementData.widgetType, elType: elementData.elType })) {
|
|
2972
|
-
revertedElement.settings = revertComponentInstanceSettings(elementData.settings);
|
|
2973
|
-
} else if (revertedElement.settings) {
|
|
2974
|
-
const { settings } = revertOverridablePropsFromSettings(revertedElement.settings);
|
|
2975
|
-
revertedElement.settings = settings;
|
|
2719
|
+
const data = window?.elementorCommon?.storage?.get();
|
|
2720
|
+
if (!data?.clipboard?.elements) {
|
|
2721
|
+
return false;
|
|
2976
2722
|
}
|
|
2977
|
-
|
|
2978
|
-
|
|
2723
|
+
const allComponentIds = extractComponentIdsFromElements(data.clipboard.elements);
|
|
2724
|
+
const hasCircularComponent = allComponentIds.some(wouldCreateCircularNesting);
|
|
2725
|
+
if (hasCircularComponent) {
|
|
2726
|
+
(0, import_editor_notifications3.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
2979
2727
|
}
|
|
2980
|
-
return
|
|
2728
|
+
return hasCircularComponent;
|
|
2981
2729
|
}
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
if (!overrides?.length) {
|
|
2989
|
-
return settings;
|
|
2990
|
-
}
|
|
2991
|
-
const revertedOverrides = revertComponentInstanceOverrides(overrides);
|
|
2992
|
-
return {
|
|
2993
|
-
...settings,
|
|
2994
|
-
component_instance: componentInstancePropTypeUtil.create({
|
|
2995
|
-
...componentInstance,
|
|
2996
|
-
overrides: componentInstanceOverridesPropTypeUtil.create(revertedOverrides)
|
|
2997
|
-
})
|
|
2998
|
-
};
|
|
2730
|
+
|
|
2731
|
+
// src/store/actions/remove-component-styles.ts
|
|
2732
|
+
var import_store31 = require("@elementor/store");
|
|
2733
|
+
function removeComponentStyles(id) {
|
|
2734
|
+
apiClient.invalidateComponentConfigCache(id);
|
|
2735
|
+
(0, import_store31.__dispatch)(slice.actions.removeStyles({ id }));
|
|
2999
2736
|
}
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
2737
|
+
|
|
2738
|
+
// src/store/components-styles-provider.ts
|
|
2739
|
+
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
2740
|
+
var import_store33 = require("@elementor/store");
|
|
2741
|
+
var componentsStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
2742
|
+
key: "components-styles",
|
|
2743
|
+
priority: 100,
|
|
2744
|
+
subscribe: (cb) => (0, import_store33.__subscribeWithSelector)(
|
|
2745
|
+
(state) => state[SLICE_NAME],
|
|
2746
|
+
() => {
|
|
2747
|
+
cb();
|
|
2748
|
+
}
|
|
2749
|
+
),
|
|
2750
|
+
actions: {
|
|
2751
|
+
all: () => {
|
|
2752
|
+
return selectFlatStyles((0, import_store33.__getState)());
|
|
2753
|
+
},
|
|
2754
|
+
get: (id) => {
|
|
2755
|
+
return selectFlatStyles((0, import_store33.__getState)()).find((style) => style.id === id) ?? null;
|
|
3006
2756
|
}
|
|
3007
|
-
});
|
|
3008
|
-
}
|
|
3009
|
-
function revertComponentInstanceOverridesInElement(element) {
|
|
3010
|
-
const settings = element.settings?.toJSON() ?? {};
|
|
3011
|
-
const componentInstance = componentInstancePropTypeUtil.extract(settings.component_instance);
|
|
3012
|
-
const overrides = componentInstanceOverridesPropTypeUtil.extract(componentInstance?.overrides);
|
|
3013
|
-
if (!overrides?.length) {
|
|
3014
|
-
return;
|
|
3015
|
-
}
|
|
3016
|
-
const revertedOverrides = revertComponentInstanceOverrides(overrides);
|
|
3017
|
-
const updatedSetting = componentInstancePropTypeUtil.create({
|
|
3018
|
-
...componentInstance,
|
|
3019
|
-
overrides: componentInstanceOverridesPropTypeUtil.create(revertedOverrides)
|
|
3020
|
-
});
|
|
3021
|
-
(0, import_editor_elements9.updateElementSettings)({
|
|
3022
|
-
id: element.id,
|
|
3023
|
-
props: { component_instance: updatedSetting },
|
|
3024
|
-
withHistory: false
|
|
3025
|
-
});
|
|
3026
|
-
}
|
|
3027
|
-
function revertElementSettings(element) {
|
|
3028
|
-
const settings = element.settings?.toJSON() ?? {};
|
|
3029
|
-
const { hasChanges, settings: revertedSettings } = revertOverridablePropsFromSettings(settings);
|
|
3030
|
-
if (!hasChanges) {
|
|
3031
|
-
return;
|
|
3032
2757
|
}
|
|
3033
|
-
|
|
3034
|
-
id: element.id,
|
|
3035
|
-
props: revertedSettings,
|
|
3036
|
-
withHistory: false
|
|
3037
|
-
});
|
|
3038
|
-
}
|
|
2758
|
+
});
|
|
3039
2759
|
|
|
3040
|
-
// src/
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
if (
|
|
2760
|
+
// src/sync/publish-draft-components-in-page-before-save.ts
|
|
2761
|
+
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
2762
|
+
async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
|
|
2763
|
+
if (status !== "publish") {
|
|
3044
2764
|
return;
|
|
3045
2765
|
}
|
|
3046
|
-
const
|
|
3047
|
-
const
|
|
3048
|
-
|
|
3049
|
-
const prop = overridableProps.props[key];
|
|
3050
|
-
if (!prop) {
|
|
3051
|
-
continue;
|
|
3052
|
-
}
|
|
3053
|
-
deletedProps.push(prop);
|
|
3054
|
-
revertElementOverridableSetting(prop.elementId, prop.propKey, prop.originValue, key);
|
|
3055
|
-
}
|
|
3056
|
-
if (deletedProps.length === 0) {
|
|
2766
|
+
const documents = await getComponentDocuments(elements);
|
|
2767
|
+
const draftIds = [...documents.values()].filter(import_editor_documents5.isDocumentDirty).map((document) => document.id);
|
|
2768
|
+
if (draftIds.length === 0) {
|
|
3057
2769
|
return;
|
|
3058
2770
|
}
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
);
|
|
3062
|
-
const updatedGroups = removePropFromAllGroups(overridableProps.groups, propKey);
|
|
3063
|
-
componentsActions.setOverridableProps(componentId, {
|
|
3064
|
-
...overridableProps,
|
|
3065
|
-
props: remainingProps,
|
|
3066
|
-
groups: updatedGroups
|
|
3067
|
-
});
|
|
3068
|
-
const currentComponent = componentsSelectors.getCurrentComponent();
|
|
3069
|
-
for (const prop of deletedProps) {
|
|
3070
|
-
trackComponentEvent({
|
|
3071
|
-
action: "propertyRemoved",
|
|
3072
|
-
source,
|
|
3073
|
-
component_uid: currentComponent?.uid,
|
|
3074
|
-
property_id: prop.overrideKey,
|
|
3075
|
-
property_path: prop.propKey,
|
|
3076
|
-
property_name: prop.label,
|
|
3077
|
-
element_type: prop.widgetType ?? prop.elType
|
|
3078
|
-
});
|
|
3079
|
-
}
|
|
2771
|
+
await apiClient.updateStatuses(draftIds, "publish");
|
|
2772
|
+
draftIds.forEach((id) => (0, import_editor_documents5.invalidateDocumentData)(id));
|
|
3080
2773
|
}
|
|
3081
2774
|
|
|
3082
|
-
// src/extended/store/actions/reorder-group-props.ts
|
|
3083
|
-
function reorderGroupProps({ componentId, groupId, newPropsOrder }) {
|
|
3084
|
-
const overridableProps = componentsSelectors.getOverridableProps(componentId);
|
|
3085
|
-
if (!overridableProps) {
|
|
3086
|
-
return;
|
|
3087
|
-
}
|
|
3088
|
-
const group = overridableProps.groups.items[groupId];
|
|
3089
|
-
if (!group) {
|
|
3090
|
-
return;
|
|
3091
|
-
}
|
|
3092
|
-
componentsActions.setOverridableProps(componentId, {
|
|
3093
|
-
...overridableProps,
|
|
3094
|
-
groups: {
|
|
3095
|
-
...overridableProps.groups,
|
|
3096
|
-
items: {
|
|
3097
|
-
...overridableProps.groups.items,
|
|
3098
|
-
[groupId]: {
|
|
3099
|
-
...group,
|
|
3100
|
-
props: newPropsOrder
|
|
3101
|
-
}
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
});
|
|
3105
|
-
}
|
|
3106
|
-
|
|
3107
|
-
// src/extended/store/actions/reorder-overridable-groups.ts
|
|
3108
|
-
function reorderOverridableGroups({ componentId, newOrder }) {
|
|
3109
|
-
const overridableProps = componentsSelectors.getOverridableProps(componentId);
|
|
3110
|
-
if (!overridableProps) {
|
|
3111
|
-
return;
|
|
3112
|
-
}
|
|
3113
|
-
componentsActions.setOverridableProps(componentId, {
|
|
3114
|
-
...overridableProps,
|
|
3115
|
-
groups: {
|
|
3116
|
-
...overridableProps.groups,
|
|
3117
|
-
order: newOrder
|
|
3118
|
-
}
|
|
3119
|
-
});
|
|
3120
|
-
}
|
|
3121
|
-
|
|
3122
|
-
// src/extended/store/actions/update-overridable-prop-params.ts
|
|
3123
|
-
function updateOverridablePropParams({
|
|
3124
|
-
componentId,
|
|
3125
|
-
overrideKey,
|
|
3126
|
-
label,
|
|
3127
|
-
groupId
|
|
3128
|
-
}) {
|
|
3129
|
-
const overridableProps = componentsSelectors.getOverridableProps(componentId);
|
|
3130
|
-
if (!overridableProps) {
|
|
3131
|
-
return;
|
|
3132
|
-
}
|
|
3133
|
-
const prop = overridableProps.props[overrideKey];
|
|
3134
|
-
if (!prop) {
|
|
3135
|
-
return;
|
|
3136
|
-
}
|
|
3137
|
-
const oldGroupId = prop.groupId;
|
|
3138
|
-
const newGroupId = groupId ?? oldGroupId;
|
|
3139
|
-
const updatedProp = {
|
|
3140
|
-
...prop,
|
|
3141
|
-
label,
|
|
3142
|
-
groupId: newGroupId
|
|
3143
|
-
};
|
|
3144
|
-
const updatedGroups = movePropBetweenGroups(overridableProps.groups, overrideKey, oldGroupId, newGroupId);
|
|
3145
|
-
componentsActions.setOverridableProps(componentId, {
|
|
3146
|
-
...overridableProps,
|
|
3147
|
-
props: {
|
|
3148
|
-
...overridableProps.props,
|
|
3149
|
-
[overrideKey]: updatedProp
|
|
3150
|
-
},
|
|
3151
|
-
groups: updatedGroups
|
|
3152
|
-
});
|
|
3153
|
-
return updatedProp;
|
|
3154
|
-
}
|
|
3155
|
-
|
|
3156
|
-
// src/extended/components/component-properties-panel/properties-empty-state.tsx
|
|
3157
|
-
var React21 = __toESM(require("react"));
|
|
3158
|
-
var import_react9 = require("react");
|
|
3159
|
-
var import_icons10 = require("@elementor/icons");
|
|
3160
|
-
var import_ui15 = require("@elementor/ui");
|
|
3161
|
-
var import_i18n13 = require("@wordpress/i18n");
|
|
3162
|
-
function PropertiesEmptyState({ introductionRef }) {
|
|
3163
|
-
const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
|
|
3164
|
-
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(
|
|
3165
|
-
import_ui15.Stack,
|
|
3166
|
-
{
|
|
3167
|
-
alignItems: "center",
|
|
3168
|
-
justifyContent: "flex-start",
|
|
3169
|
-
height: "100%",
|
|
3170
|
-
color: "text.secondary",
|
|
3171
|
-
sx: { px: 2.5, pt: 10, pb: 5.5 },
|
|
3172
|
-
gap: 1
|
|
3173
|
-
},
|
|
3174
|
-
/* @__PURE__ */ React21.createElement(import_icons10.ComponentPropListIcon, { fontSize: "large" }),
|
|
3175
|
-
/* @__PURE__ */ React21.createElement(import_ui15.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n13.__)("Add your first property", "elementor")),
|
|
3176
|
-
/* @__PURE__ */ React21.createElement(import_ui15.Typography, { align: "center", variant: "caption" }, (0, import_i18n13.__)("Make instances flexible while keeping design synced.", "elementor")),
|
|
3177
|
-
/* @__PURE__ */ React21.createElement(import_ui15.Typography, { align: "center", variant: "caption" }, (0, import_i18n13.__)("Select any element, then click + next to a setting to expose it.", "elementor")),
|
|
3178
|
-
/* @__PURE__ */ React21.createElement(
|
|
3179
|
-
import_ui15.Link,
|
|
3180
|
-
{
|
|
3181
|
-
variant: "caption",
|
|
3182
|
-
color: "secondary",
|
|
3183
|
-
sx: { textDecorationLine: "underline" },
|
|
3184
|
-
onClick: () => setIsOpen(true)
|
|
3185
|
-
},
|
|
3186
|
-
(0, import_i18n13.__)("Learn more", "elementor")
|
|
3187
|
-
)
|
|
3188
|
-
), /* @__PURE__ */ React21.createElement(
|
|
3189
|
-
ComponentIntroduction,
|
|
3190
|
-
{
|
|
3191
|
-
anchorRef: introductionRef,
|
|
3192
|
-
shouldShowIntroduction: isOpen,
|
|
3193
|
-
onClose: () => setIsOpen(false)
|
|
3194
|
-
}
|
|
3195
|
-
));
|
|
3196
|
-
}
|
|
3197
|
-
|
|
3198
|
-
// src/extended/components/component-properties-panel/properties-group.tsx
|
|
3199
|
-
var React25 = __toESM(require("react"));
|
|
3200
|
-
var import_editor_ui10 = require("@elementor/editor-ui");
|
|
3201
|
-
var import_icons13 = require("@elementor/icons");
|
|
3202
|
-
var import_ui19 = require("@elementor/ui");
|
|
3203
|
-
var import_i18n16 = require("@wordpress/i18n");
|
|
3204
|
-
|
|
3205
|
-
// src/extended/components/component-properties-panel/property-item.tsx
|
|
3206
|
-
var React24 = __toESM(require("react"));
|
|
3207
|
-
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
3208
|
-
var import_icons12 = require("@elementor/icons");
|
|
3209
|
-
var import_ui18 = require("@elementor/ui");
|
|
3210
|
-
|
|
3211
|
-
// src/extended/components/overridable-props/overridable-prop-form.tsx
|
|
3212
|
-
var React22 = __toESM(require("react"));
|
|
3213
|
-
var import_react10 = require("react");
|
|
3214
|
-
var import_editor_ui9 = require("@elementor/editor-ui");
|
|
3215
|
-
var import_ui16 = require("@elementor/ui");
|
|
3216
|
-
var import_i18n15 = require("@wordpress/i18n");
|
|
3217
|
-
|
|
3218
|
-
// src/extended/components/overridable-props/utils/validate-prop-label.ts
|
|
3219
|
-
var import_i18n14 = require("@wordpress/i18n");
|
|
3220
|
-
var ERROR_MESSAGES = {
|
|
3221
|
-
EMPTY_NAME: (0, import_i18n14.__)("Property name is required", "elementor"),
|
|
3222
|
-
DUPLICATE_NAME: (0, import_i18n14.__)("Property name already exists", "elementor")
|
|
3223
|
-
};
|
|
3224
|
-
function validatePropLabel(label, existingLabels, currentLabel) {
|
|
3225
|
-
const trimmedLabel = label.trim();
|
|
3226
|
-
if (!trimmedLabel) {
|
|
3227
|
-
return { isValid: false, errorMessage: ERROR_MESSAGES.EMPTY_NAME };
|
|
3228
|
-
}
|
|
3229
|
-
const normalizedLabel = trimmedLabel.toLowerCase();
|
|
3230
|
-
const normalizedCurrentLabel = currentLabel?.trim().toLowerCase();
|
|
3231
|
-
const isDuplicate = existingLabels.some((existingLabel) => {
|
|
3232
|
-
const normalizedExisting = existingLabel.trim().toLowerCase();
|
|
3233
|
-
if (normalizedCurrentLabel && normalizedExisting === normalizedCurrentLabel) {
|
|
3234
|
-
return false;
|
|
3235
|
-
}
|
|
3236
|
-
return normalizedExisting === normalizedLabel;
|
|
3237
|
-
});
|
|
3238
|
-
if (isDuplicate) {
|
|
3239
|
-
return { isValid: false, errorMessage: ERROR_MESSAGES.DUPLICATE_NAME };
|
|
3240
|
-
}
|
|
3241
|
-
return { isValid: true, errorMessage: null };
|
|
3242
|
-
}
|
|
3243
|
-
|
|
3244
|
-
// src/extended/components/overridable-props/overridable-prop-form.tsx
|
|
3245
|
-
var SIZE = "tiny";
|
|
3246
|
-
var DEFAULT_GROUP = { value: null, label: (0, import_i18n15.__)("Default", "elementor") };
|
|
3247
|
-
function OverridablePropForm({ onSubmit, groups, currentValue, existingLabels = [], sx }) {
|
|
3248
|
-
const selectGroups = groups?.length ? groups : [DEFAULT_GROUP];
|
|
3249
|
-
const [propLabel, setPropLabel] = (0, import_react10.useState)(currentValue?.label ?? null);
|
|
3250
|
-
const [group, setGroup] = (0, import_react10.useState)(currentValue?.groupId ?? selectGroups[0]?.value ?? null);
|
|
3251
|
-
const [error, setError] = (0, import_react10.useState)(null);
|
|
3252
|
-
const name = (0, import_i18n15.__)("Name", "elementor");
|
|
3253
|
-
const groupName = (0, import_i18n15.__)("Group Name", "elementor");
|
|
3254
|
-
const isCreate = currentValue === void 0;
|
|
3255
|
-
const title = isCreate ? (0, import_i18n15.__)("Create new property", "elementor") : (0, import_i18n15.__)("Update property", "elementor");
|
|
3256
|
-
const ctaLabel = isCreate ? (0, import_i18n15.__)("Create", "elementor") : (0, import_i18n15.__)("Update", "elementor");
|
|
3257
|
-
const handleSubmit = () => {
|
|
3258
|
-
const validationResult = validatePropLabel(propLabel ?? "", existingLabels, currentValue?.label);
|
|
3259
|
-
if (!validationResult.isValid) {
|
|
3260
|
-
setError(validationResult.errorMessage);
|
|
3261
|
-
return;
|
|
3262
|
-
}
|
|
3263
|
-
onSubmit({ label: propLabel ?? "", group });
|
|
3264
|
-
};
|
|
3265
|
-
return /* @__PURE__ */ React22.createElement(import_editor_ui9.Form, { onSubmit: handleSubmit, "data-testid": "overridable-prop-form" }, /* @__PURE__ */ React22.createElement(import_ui16.Stack, { alignItems: "start", sx: { width: "268px", ...sx } }, /* @__PURE__ */ React22.createElement(
|
|
3266
|
-
import_ui16.Stack,
|
|
3267
|
-
{
|
|
3268
|
-
direction: "row",
|
|
3269
|
-
alignItems: "center",
|
|
3270
|
-
py: 1,
|
|
3271
|
-
px: 1.5,
|
|
3272
|
-
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
3273
|
-
},
|
|
3274
|
-
/* @__PURE__ */ React22.createElement(import_ui16.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
3275
|
-
), /* @__PURE__ */ React22.createElement(import_ui16.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React22.createElement(import_ui16.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React22.createElement(import_ui16.FormLabel, { size: "tiny" }, name)), /* @__PURE__ */ React22.createElement(import_ui16.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React22.createElement(
|
|
3276
|
-
import_ui16.TextField,
|
|
3277
|
-
{
|
|
3278
|
-
name,
|
|
3279
|
-
size: SIZE,
|
|
3280
|
-
fullWidth: true,
|
|
3281
|
-
placeholder: (0, import_i18n15.__)("Enter value", "elementor"),
|
|
3282
|
-
value: propLabel ?? "",
|
|
3283
|
-
onChange: (e) => {
|
|
3284
|
-
const newValue = e.target.value;
|
|
3285
|
-
setPropLabel(newValue);
|
|
3286
|
-
const validationResult = validatePropLabel(
|
|
3287
|
-
newValue,
|
|
3288
|
-
existingLabels,
|
|
3289
|
-
currentValue?.label
|
|
3290
|
-
);
|
|
3291
|
-
setError(validationResult.errorMessage);
|
|
3292
|
-
},
|
|
3293
|
-
error: Boolean(error),
|
|
3294
|
-
helperText: error
|
|
3295
|
-
}
|
|
3296
|
-
))), /* @__PURE__ */ React22.createElement(import_ui16.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React22.createElement(import_ui16.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React22.createElement(import_ui16.FormLabel, { size: "tiny" }, groupName)), /* @__PURE__ */ React22.createElement(import_ui16.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React22.createElement(
|
|
3297
|
-
import_ui16.Select,
|
|
3298
|
-
{
|
|
3299
|
-
name: groupName,
|
|
3300
|
-
size: SIZE,
|
|
3301
|
-
fullWidth: true,
|
|
3302
|
-
value: group ?? null,
|
|
3303
|
-
onChange: (e) => setGroup(e.target.value),
|
|
3304
|
-
displayEmpty: true,
|
|
3305
|
-
renderValue: (selectedValue) => {
|
|
3306
|
-
if (!selectedValue) {
|
|
3307
|
-
return selectGroups[0].label;
|
|
3308
|
-
}
|
|
3309
|
-
return selectGroups.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
3310
|
-
}
|
|
3311
|
-
},
|
|
3312
|
-
selectGroups.map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React22.createElement(import_editor_ui9.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
3313
|
-
))), /* @__PURE__ */ React22.createElement(import_ui16.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React22.createElement(
|
|
3314
|
-
import_ui16.Button,
|
|
3315
|
-
{
|
|
3316
|
-
type: "submit",
|
|
3317
|
-
disabled: !propLabel || Boolean(error),
|
|
3318
|
-
variant: "contained",
|
|
3319
|
-
color: "primary",
|
|
3320
|
-
size: "small"
|
|
3321
|
-
},
|
|
3322
|
-
ctaLabel
|
|
3323
|
-
))));
|
|
3324
|
-
}
|
|
3325
|
-
|
|
3326
|
-
// src/extended/components/component-properties-panel/sortable.tsx
|
|
3327
|
-
var React23 = __toESM(require("react"));
|
|
3328
|
-
var import_icons11 = require("@elementor/icons");
|
|
3329
|
-
var import_ui17 = require("@elementor/ui");
|
|
3330
|
-
var SortableProvider = (props) => /* @__PURE__ */ React23.createElement(import_ui17.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
|
|
3331
|
-
var SortableTrigger = ({ triggerClassName, ...props }) => /* @__PURE__ */ React23.createElement(
|
|
3332
|
-
StyledSortableTrigger,
|
|
3333
|
-
{
|
|
3334
|
-
...props,
|
|
3335
|
-
role: "button",
|
|
3336
|
-
className: `sortable-trigger ${triggerClassName ?? ""}`.trim(),
|
|
3337
|
-
"aria-label": "sort"
|
|
3338
|
-
},
|
|
3339
|
-
/* @__PURE__ */ React23.createElement(import_icons11.GripVerticalIcon, { fontSize: "tiny" })
|
|
3340
|
-
);
|
|
3341
|
-
var SortableItem = ({ children, id: id2 }) => /* @__PURE__ */ React23.createElement(
|
|
3342
|
-
import_ui17.UnstableSortableItem,
|
|
3343
|
-
{
|
|
3344
|
-
id: id2,
|
|
3345
|
-
render: ({
|
|
3346
|
-
itemProps,
|
|
3347
|
-
isDragged,
|
|
3348
|
-
triggerProps,
|
|
3349
|
-
itemStyle,
|
|
3350
|
-
triggerStyle,
|
|
3351
|
-
dropIndicationStyle,
|
|
3352
|
-
showDropIndication,
|
|
3353
|
-
isDragOverlay,
|
|
3354
|
-
isDragPlaceholder
|
|
3355
|
-
}) => /* @__PURE__ */ React23.createElement(
|
|
3356
|
-
import_ui17.Box,
|
|
3357
|
-
{
|
|
3358
|
-
...itemProps,
|
|
3359
|
-
style: itemStyle,
|
|
3360
|
-
component: "div",
|
|
3361
|
-
role: "listitem",
|
|
3362
|
-
sx: {
|
|
3363
|
-
backgroundColor: isDragOverlay ? "background.paper" : void 0
|
|
3364
|
-
}
|
|
3365
|
-
},
|
|
3366
|
-
children({
|
|
3367
|
-
isDragged,
|
|
3368
|
-
isDragPlaceholder,
|
|
3369
|
-
triggerProps,
|
|
3370
|
-
triggerStyle
|
|
3371
|
-
}),
|
|
3372
|
-
showDropIndication && /* @__PURE__ */ React23.createElement(SortableItemIndicator, { style: dropIndicationStyle })
|
|
3373
|
-
)
|
|
3374
|
-
}
|
|
3375
|
-
);
|
|
3376
|
-
var StyledSortableTrigger = (0, import_ui17.styled)("div")(({ theme }) => ({
|
|
3377
|
-
position: "absolute",
|
|
3378
|
-
left: "-2px",
|
|
3379
|
-
top: "50%",
|
|
3380
|
-
transform: `translate( -${theme.spacing(1.5)}, -50% )`,
|
|
3381
|
-
color: theme.palette.action.active,
|
|
3382
|
-
cursor: "grab"
|
|
3383
|
-
}));
|
|
3384
|
-
var SortableItemIndicator = (0, import_ui17.styled)(import_ui17.Box)`
|
|
3385
|
-
width: 100%;
|
|
3386
|
-
height: 1px;
|
|
3387
|
-
background-color: ${({ theme }) => theme.palette.text.primary};
|
|
3388
|
-
`;
|
|
3389
|
-
|
|
3390
|
-
// src/extended/components/component-properties-panel/property-item.tsx
|
|
3391
|
-
function PropertyItem({
|
|
3392
|
-
prop,
|
|
3393
|
-
sortableTriggerProps,
|
|
3394
|
-
isDragPlaceholder,
|
|
3395
|
-
groups,
|
|
3396
|
-
existingLabels,
|
|
3397
|
-
onDelete,
|
|
3398
|
-
onUpdate
|
|
3399
|
-
}) {
|
|
3400
|
-
const popoverState = (0, import_ui18.usePopupState)({
|
|
3401
|
-
variant: "popover"
|
|
3402
|
-
});
|
|
3403
|
-
const icon = getElementIcon(prop);
|
|
3404
|
-
const popoverProps = (0, import_ui18.bindPopover)(popoverState);
|
|
3405
|
-
const handleSubmit = (data) => {
|
|
3406
|
-
onUpdate(data);
|
|
3407
|
-
popoverState.close();
|
|
3408
|
-
};
|
|
3409
|
-
const handleDelete = (event) => {
|
|
3410
|
-
event.stopPropagation();
|
|
3411
|
-
onDelete(prop.overrideKey);
|
|
3412
|
-
};
|
|
3413
|
-
return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(
|
|
3414
|
-
import_ui18.Box,
|
|
3415
|
-
{
|
|
3416
|
-
...(0, import_ui18.bindTrigger)(popoverState),
|
|
3417
|
-
sx: {
|
|
3418
|
-
position: "relative",
|
|
3419
|
-
pl: 0.5,
|
|
3420
|
-
pr: 1,
|
|
3421
|
-
py: 0.25,
|
|
3422
|
-
minHeight: 28,
|
|
3423
|
-
borderRadius: 1,
|
|
3424
|
-
border: "1px solid",
|
|
3425
|
-
borderColor: "divider",
|
|
3426
|
-
display: "flex",
|
|
3427
|
-
alignItems: "center",
|
|
3428
|
-
gap: 0.5,
|
|
3429
|
-
opacity: isDragPlaceholder ? 0.5 : 1,
|
|
3430
|
-
cursor: "pointer",
|
|
3431
|
-
"&:hover": {
|
|
3432
|
-
backgroundColor: "action.hover"
|
|
3433
|
-
},
|
|
3434
|
-
"&:hover .sortable-trigger": {
|
|
3435
|
-
visibility: "visible"
|
|
3436
|
-
},
|
|
3437
|
-
"& .sortable-trigger": {
|
|
3438
|
-
visibility: "hidden"
|
|
3439
|
-
},
|
|
3440
|
-
"&:hover .delete-button": {
|
|
3441
|
-
visibility: "visible"
|
|
3442
|
-
},
|
|
3443
|
-
"& .delete-button": {
|
|
3444
|
-
visibility: "hidden"
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
},
|
|
3448
|
-
/* @__PURE__ */ React24.createElement(SortableTrigger, { ...sortableTriggerProps }),
|
|
3449
|
-
/* @__PURE__ */ React24.createElement(
|
|
3450
|
-
import_ui18.Box,
|
|
3451
|
-
{
|
|
3452
|
-
sx: { display: "flex", alignItems: "center", color: "text.primary", fontSize: 12, padding: 0.25 }
|
|
3453
|
-
},
|
|
3454
|
-
/* @__PURE__ */ React24.createElement("i", { className: icon })
|
|
3455
|
-
),
|
|
3456
|
-
/* @__PURE__ */ React24.createElement(import_ui18.Typography, { variant: "caption", sx: { color: "text.primary", flexGrow: 1, fontSize: 10 } }, prop.label),
|
|
3457
|
-
/* @__PURE__ */ React24.createElement(import_ui18.IconButton, { size: "tiny", onClick: handleDelete, "aria-label": "Delete property", sx: { p: 0.25 } }, /* @__PURE__ */ React24.createElement(import_icons12.XIcon, { fontSize: "tiny" }))
|
|
3458
|
-
), /* @__PURE__ */ React24.createElement(
|
|
3459
|
-
import_ui18.Popover,
|
|
3460
|
-
{
|
|
3461
|
-
...popoverProps,
|
|
3462
|
-
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
3463
|
-
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
3464
|
-
PaperProps: { sx: { width: popoverState.anchorEl?.getBoundingClientRect().width } }
|
|
3465
|
-
},
|
|
3466
|
-
/* @__PURE__ */ React24.createElement(
|
|
3467
|
-
OverridablePropForm,
|
|
3468
|
-
{
|
|
3469
|
-
onSubmit: handleSubmit,
|
|
3470
|
-
currentValue: prop,
|
|
3471
|
-
groups,
|
|
3472
|
-
existingLabels,
|
|
3473
|
-
sx: { width: "100%" }
|
|
3474
|
-
}
|
|
3475
|
-
)
|
|
3476
|
-
));
|
|
3477
|
-
}
|
|
3478
|
-
function getElementIcon(prop) {
|
|
3479
|
-
const elType = prop.elType === "widget" ? prop.widgetType : prop.elType;
|
|
3480
|
-
const widgetsCache = (0, import_editor_elements10.getWidgetsCache)();
|
|
3481
|
-
if (!widgetsCache) {
|
|
3482
|
-
return "eicon-apps";
|
|
3483
|
-
}
|
|
3484
|
-
const widgetConfig = widgetsCache[elType];
|
|
3485
|
-
return widgetConfig?.icon || "eicon-apps";
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3488
|
-
// src/extended/components/component-properties-panel/properties-group.tsx
|
|
3489
|
-
function PropertiesGroup({
|
|
3490
|
-
group,
|
|
3491
|
-
props,
|
|
3492
|
-
allGroups,
|
|
3493
|
-
sortableTriggerProps,
|
|
3494
|
-
isDragPlaceholder,
|
|
3495
|
-
onPropsReorder,
|
|
3496
|
-
onPropertyDelete,
|
|
3497
|
-
onPropertyUpdate,
|
|
3498
|
-
onGroupDelete,
|
|
3499
|
-
editableLabelProps
|
|
3500
|
-
}) {
|
|
3501
|
-
const groupProps = group.props.map((propId) => props[propId]).filter((prop) => Boolean(prop));
|
|
3502
|
-
const popupState = (0, import_ui19.usePopupState)({
|
|
3503
|
-
variant: "popover",
|
|
3504
|
-
disableAutoFocus: true
|
|
3505
|
-
});
|
|
3506
|
-
const { editableRef, isEditing, error, getEditableProps, setEditingGroupId, editingGroupId } = editableLabelProps;
|
|
3507
|
-
const hasProperties = group.props.length > 0;
|
|
3508
|
-
const isThisGroupEditing = isEditing && editingGroupId === group.id;
|
|
3509
|
-
const handleRenameClick = () => {
|
|
3510
|
-
popupState.close();
|
|
3511
|
-
setEditingGroupId(group.id);
|
|
3512
|
-
};
|
|
3513
|
-
const handleDeleteClick = () => {
|
|
3514
|
-
popupState.close();
|
|
3515
|
-
onGroupDelete(group.id);
|
|
3516
|
-
};
|
|
3517
|
-
return /* @__PURE__ */ React25.createElement(
|
|
3518
|
-
import_ui19.Box,
|
|
3519
|
-
{
|
|
3520
|
-
sx: {
|
|
3521
|
-
opacity: isDragPlaceholder ? 0.5 : 1
|
|
3522
|
-
}
|
|
3523
|
-
},
|
|
3524
|
-
/* @__PURE__ */ React25.createElement(import_ui19.Stack, { gap: 1 }, /* @__PURE__ */ React25.createElement(
|
|
3525
|
-
import_ui19.Box,
|
|
3526
|
-
{
|
|
3527
|
-
className: "group-header",
|
|
3528
|
-
sx: {
|
|
3529
|
-
position: "relative",
|
|
3530
|
-
"&:hover .group-sortable-trigger": {
|
|
3531
|
-
visibility: "visible"
|
|
3532
|
-
},
|
|
3533
|
-
"& .group-sortable-trigger": {
|
|
3534
|
-
visibility: "hidden"
|
|
3535
|
-
},
|
|
3536
|
-
"&:hover .group-menu": {
|
|
3537
|
-
visibility: "visible"
|
|
3538
|
-
},
|
|
3539
|
-
"& .group-menu": {
|
|
3540
|
-
visibility: "hidden"
|
|
3541
|
-
}
|
|
3542
|
-
}
|
|
3543
|
-
},
|
|
3544
|
-
/* @__PURE__ */ React25.createElement(SortableTrigger, { triggerClassName: "group-sortable-trigger", ...sortableTriggerProps }),
|
|
3545
|
-
/* @__PURE__ */ React25.createElement(import_ui19.Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 2 }, isThisGroupEditing ? /* @__PURE__ */ React25.createElement(
|
|
3546
|
-
import_ui19.Box,
|
|
3547
|
-
{
|
|
3548
|
-
sx: {
|
|
3549
|
-
height: 28,
|
|
3550
|
-
display: "flex",
|
|
3551
|
-
alignItems: "center",
|
|
3552
|
-
border: 2,
|
|
3553
|
-
borderColor: "text.secondary",
|
|
3554
|
-
borderRadius: 1,
|
|
3555
|
-
pl: 0.5,
|
|
3556
|
-
flexGrow: 1,
|
|
3557
|
-
overflow: "hidden",
|
|
3558
|
-
textOverflow: "ellipsis",
|
|
3559
|
-
whiteSpace: "nowrap",
|
|
3560
|
-
width: "100%"
|
|
3561
|
-
}
|
|
3562
|
-
},
|
|
3563
|
-
/* @__PURE__ */ React25.createElement(
|
|
3564
|
-
import_editor_ui10.EditableField,
|
|
3565
|
-
{
|
|
3566
|
-
ref: editableRef,
|
|
3567
|
-
as: import_ui19.Typography,
|
|
3568
|
-
variant: "caption",
|
|
3569
|
-
error: error ?? void 0,
|
|
3570
|
-
sx: { color: "text.primary", fontWeight: 400, lineHeight: 1.66 },
|
|
3571
|
-
...getEditableProps()
|
|
3572
|
-
}
|
|
3573
|
-
)
|
|
3574
|
-
) : /* @__PURE__ */ React25.createElement(
|
|
3575
|
-
import_editor_ui10.EllipsisWithTooltip,
|
|
3576
|
-
{
|
|
3577
|
-
title: group.label,
|
|
3578
|
-
as: import_ui19.Typography,
|
|
3579
|
-
variant: "caption",
|
|
3580
|
-
sx: { color: "text.primary", fontWeight: 400, lineHeight: 1.66 }
|
|
3581
|
-
}
|
|
3582
|
-
), /* @__PURE__ */ React25.createElement(
|
|
3583
|
-
import_ui19.IconButton,
|
|
3584
|
-
{
|
|
3585
|
-
className: "group-menu",
|
|
3586
|
-
size: "tiny",
|
|
3587
|
-
sx: { p: 0.25, visibility: isThisGroupEditing ? "visible" : void 0 },
|
|
3588
|
-
"aria-label": (0, import_i18n16.__)("Group actions", "elementor"),
|
|
3589
|
-
...(0, import_ui19.bindTrigger)(popupState)
|
|
3590
|
-
},
|
|
3591
|
-
/* @__PURE__ */ React25.createElement(import_icons13.DotsVerticalIcon, { fontSize: "tiny" })
|
|
3592
|
-
))
|
|
3593
|
-
), /* @__PURE__ */ React25.createElement(import_ui19.List, { sx: { p: 0, display: "flex", flexDirection: "column", gap: 1 } }, /* @__PURE__ */ React25.createElement(SortableProvider, { value: group.props, onChange: onPropsReorder }, groupProps.map((prop) => /* @__PURE__ */ React25.createElement(SortableItem, { key: prop.overrideKey, id: prop.overrideKey }, ({ triggerProps, triggerStyle, isDragPlaceholder: isItemDragPlaceholder }) => /* @__PURE__ */ React25.createElement(
|
|
3594
|
-
PropertyItem,
|
|
3595
|
-
{
|
|
3596
|
-
prop,
|
|
3597
|
-
sortableTriggerProps: { ...triggerProps, style: triggerStyle },
|
|
3598
|
-
isDragPlaceholder: isItemDragPlaceholder,
|
|
3599
|
-
groups: allGroups,
|
|
3600
|
-
existingLabels: Object.values(props).map((p) => p.label),
|
|
3601
|
-
onDelete: onPropertyDelete,
|
|
3602
|
-
onUpdate: (data) => onPropertyUpdate(prop.overrideKey, data)
|
|
3603
|
-
}
|
|
3604
|
-
)))))),
|
|
3605
|
-
/* @__PURE__ */ React25.createElement(
|
|
3606
|
-
import_ui19.Menu,
|
|
3607
|
-
{
|
|
3608
|
-
...(0, import_ui19.bindMenu)(popupState),
|
|
3609
|
-
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
3610
|
-
transformOrigin: { vertical: "top", horizontal: "right" }
|
|
3611
|
-
},
|
|
3612
|
-
/* @__PURE__ */ React25.createElement(import_editor_ui10.MenuListItem, { sx: { minWidth: "160px" }, onClick: handleRenameClick }, /* @__PURE__ */ React25.createElement(import_ui19.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n16.__)("Rename", "elementor"))),
|
|
3613
|
-
/* @__PURE__ */ React25.createElement(
|
|
3614
|
-
import_ui19.Tooltip,
|
|
3615
|
-
{
|
|
3616
|
-
title: hasProperties ? (0, import_i18n16.__)("To delete the group, first remove all the properties", "elementor") : "",
|
|
3617
|
-
placement: "right"
|
|
3618
|
-
},
|
|
3619
|
-
/* @__PURE__ */ React25.createElement("span", null, /* @__PURE__ */ React25.createElement(import_editor_ui10.MenuListItem, { onClick: handleDeleteClick, disabled: hasProperties }, /* @__PURE__ */ React25.createElement(
|
|
3620
|
-
import_ui19.Typography,
|
|
3621
|
-
{
|
|
3622
|
-
variant: "caption",
|
|
3623
|
-
sx: { color: hasProperties ? "text.disabled" : "error.light" }
|
|
3624
|
-
},
|
|
3625
|
-
(0, import_i18n16.__)("Delete", "elementor")
|
|
3626
|
-
)))
|
|
3627
|
-
)
|
|
3628
|
-
)
|
|
3629
|
-
);
|
|
3630
|
-
}
|
|
3631
|
-
|
|
3632
|
-
// src/extended/components/component-properties-panel/use-current-editable-item.ts
|
|
3633
|
-
var import_react11 = require("react");
|
|
3634
|
-
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
3635
|
-
var import_editor_ui11 = require("@elementor/editor-ui");
|
|
3636
|
-
var import_i18n18 = require("@wordpress/i18n");
|
|
3637
|
-
|
|
3638
|
-
// src/extended/store/actions/rename-overridable-group.ts
|
|
3639
|
-
function renameOverridableGroup({ componentId, groupId, label }) {
|
|
3640
|
-
const overridableProps = componentsSelectors.getOverridableProps(componentId);
|
|
3641
|
-
if (!overridableProps) {
|
|
3642
|
-
return false;
|
|
3643
|
-
}
|
|
3644
|
-
const group = overridableProps.groups.items[groupId];
|
|
3645
|
-
if (!group) {
|
|
3646
|
-
return false;
|
|
3647
|
-
}
|
|
3648
|
-
const updatedGroups = renameGroup(overridableProps.groups, groupId, label);
|
|
3649
|
-
componentsActions.setOverridableProps(componentId, {
|
|
3650
|
-
...overridableProps,
|
|
3651
|
-
groups: updatedGroups
|
|
3652
|
-
});
|
|
3653
|
-
return true;
|
|
3654
|
-
}
|
|
3655
|
-
|
|
3656
|
-
// src/extended/components/component-properties-panel/utils/validate-group-label.ts
|
|
3657
|
-
var import_i18n17 = require("@wordpress/i18n");
|
|
3658
|
-
var ERROR_MESSAGES2 = {
|
|
3659
|
-
EMPTY_NAME: (0, import_i18n17.__)("Group name is required", "elementor"),
|
|
3660
|
-
DUPLICATE_NAME: (0, import_i18n17.__)("Group name already exists", "elementor")
|
|
3661
|
-
};
|
|
3662
|
-
function validateGroupLabel(label, existingGroups) {
|
|
3663
|
-
const trimmedLabel = label.trim();
|
|
3664
|
-
if (!trimmedLabel) {
|
|
3665
|
-
return ERROR_MESSAGES2.EMPTY_NAME;
|
|
3666
|
-
}
|
|
3667
|
-
const isDuplicate = Object.values(existingGroups).some((group) => group.label === trimmedLabel);
|
|
3668
|
-
if (isDuplicate) {
|
|
3669
|
-
return ERROR_MESSAGES2.DUPLICATE_NAME;
|
|
3670
|
-
}
|
|
3671
|
-
return "";
|
|
3672
|
-
}
|
|
3673
|
-
|
|
3674
|
-
// src/extended/components/component-properties-panel/use-current-editable-item.ts
|
|
3675
|
-
function useCurrentEditableItem() {
|
|
3676
|
-
const [editingGroupId, setEditingGroupId] = (0, import_react11.useState)(null);
|
|
3677
|
-
const currentComponentId = useCurrentComponentId();
|
|
3678
|
-
const overridableProps = useOverridableProps(currentComponentId);
|
|
3679
|
-
const allGroupsRecord = overridableProps?.groups?.items ?? {};
|
|
3680
|
-
const currentGroup = editingGroupId ? allGroupsRecord[editingGroupId] : null;
|
|
3681
|
-
const validateLabel = (newLabel) => {
|
|
3682
|
-
const otherGroups = Object.fromEntries(
|
|
3683
|
-
Object.entries(allGroupsRecord).filter(([id2]) => id2 !== editingGroupId)
|
|
3684
|
-
);
|
|
3685
|
-
return validateGroupLabel(newLabel, otherGroups) || null;
|
|
3686
|
-
};
|
|
3687
|
-
const handleSubmit = (newLabel) => {
|
|
3688
|
-
if (!editingGroupId || !currentComponentId) {
|
|
3689
|
-
throw new Error((0, import_i18n18.__)("Group ID or component ID is missing", "elementor"));
|
|
3690
|
-
}
|
|
3691
|
-
renameOverridableGroup({
|
|
3692
|
-
componentId: currentComponentId,
|
|
3693
|
-
groupId: editingGroupId,
|
|
3694
|
-
label: newLabel
|
|
3695
|
-
});
|
|
3696
|
-
(0, import_editor_documents6.setDocumentModifiedStatus)(true);
|
|
3697
|
-
};
|
|
3698
|
-
const {
|
|
3699
|
-
ref: editableRef,
|
|
3700
|
-
openEditMode,
|
|
3701
|
-
isEditing,
|
|
3702
|
-
error,
|
|
3703
|
-
getProps: getEditableProps
|
|
3704
|
-
} = (0, import_editor_ui11.useEditable)({
|
|
3705
|
-
value: currentGroup?.label ?? "",
|
|
3706
|
-
onSubmit: handleSubmit,
|
|
3707
|
-
validation: validateLabel
|
|
3708
|
-
});
|
|
3709
|
-
return {
|
|
3710
|
-
editableRef,
|
|
3711
|
-
isEditing,
|
|
3712
|
-
error,
|
|
3713
|
-
getEditableProps,
|
|
3714
|
-
setEditingGroupId: (groupId) => {
|
|
3715
|
-
setEditingGroupId(groupId);
|
|
3716
|
-
openEditMode();
|
|
3717
|
-
},
|
|
3718
|
-
editingGroupId
|
|
3719
|
-
};
|
|
3720
|
-
}
|
|
3721
|
-
|
|
3722
|
-
// src/extended/components/component-properties-panel/utils/generate-unique-label.ts
|
|
3723
|
-
var DEFAULT_NEW_GROUP_LABEL = "New group";
|
|
3724
|
-
function generateUniqueLabel(groups) {
|
|
3725
|
-
const existingLabels = new Set(groups.map((group) => group.label));
|
|
3726
|
-
if (!existingLabels.has(DEFAULT_NEW_GROUP_LABEL)) {
|
|
3727
|
-
return DEFAULT_NEW_GROUP_LABEL;
|
|
3728
|
-
}
|
|
3729
|
-
let index = 1;
|
|
3730
|
-
let newLabel = `${DEFAULT_NEW_GROUP_LABEL}-${index}`;
|
|
3731
|
-
while (existingLabels.has(newLabel)) {
|
|
3732
|
-
index++;
|
|
3733
|
-
newLabel = `${DEFAULT_NEW_GROUP_LABEL}-${index}`;
|
|
3734
|
-
}
|
|
3735
|
-
return newLabel;
|
|
3736
|
-
}
|
|
3737
|
-
|
|
3738
|
-
// src/extended/components/component-properties-panel/component-properties-panel-content.tsx
|
|
3739
|
-
function ComponentPropertiesPanelContent({ onClose }) {
|
|
3740
|
-
const currentComponentId = useCurrentComponentId();
|
|
3741
|
-
const overridableProps = useSanitizeOverridableProps(currentComponentId);
|
|
3742
|
-
const [isAddingGroup, setIsAddingGroup] = (0, import_react12.useState)(false);
|
|
3743
|
-
const introductionRef = (0, import_react12.useRef)(null);
|
|
3744
|
-
const groupLabelEditable = useCurrentEditableItem();
|
|
3745
|
-
const groups = (0, import_react12.useMemo)(() => {
|
|
3746
|
-
if (!overridableProps) {
|
|
3747
|
-
return [];
|
|
3748
|
-
}
|
|
3749
|
-
return overridableProps.groups.order.map((groupId) => overridableProps.groups.items[groupId] ?? null).filter(Boolean);
|
|
3750
|
-
}, [overridableProps]);
|
|
3751
|
-
const allGroupsForSelect = (0, import_react12.useMemo)(
|
|
3752
|
-
() => groups.map((group) => ({ value: group.id, label: group.label })),
|
|
3753
|
-
[groups]
|
|
3754
|
-
);
|
|
3755
|
-
if (!currentComponentId || !overridableProps) {
|
|
3756
|
-
return null;
|
|
3757
|
-
}
|
|
3758
|
-
const hasGroups = groups.length > 0;
|
|
3759
|
-
const showEmptyState = !hasGroups && !isAddingGroup;
|
|
3760
|
-
const groupIds = overridableProps.groups.order;
|
|
3761
|
-
const handleAddGroupClick = () => {
|
|
3762
|
-
if (isAddingGroup) {
|
|
3763
|
-
return;
|
|
3764
|
-
}
|
|
3765
|
-
const newGroupId = (0, import_utils6.generateUniqueId)("group");
|
|
3766
|
-
const newLabel = generateUniqueLabel(groups);
|
|
3767
|
-
addOverridableGroup({
|
|
3768
|
-
componentId: currentComponentId,
|
|
3769
|
-
groupId: newGroupId,
|
|
3770
|
-
label: newLabel,
|
|
3771
|
-
source: "user"
|
|
3772
|
-
});
|
|
3773
|
-
(0, import_editor_documents7.setDocumentModifiedStatus)(true);
|
|
3774
|
-
setIsAddingGroup(false);
|
|
3775
|
-
groupLabelEditable.setEditingGroupId(newGroupId);
|
|
3776
|
-
};
|
|
3777
|
-
const handleGroupsReorder = (newOrder) => {
|
|
3778
|
-
reorderOverridableGroups({ componentId: currentComponentId, newOrder });
|
|
3779
|
-
(0, import_editor_documents7.setDocumentModifiedStatus)(true);
|
|
3780
|
-
};
|
|
3781
|
-
const handlePropsReorder = (groupId, newPropsOrder) => {
|
|
3782
|
-
reorderGroupProps({ componentId: currentComponentId, groupId, newPropsOrder });
|
|
3783
|
-
(0, import_editor_documents7.setDocumentModifiedStatus)(true);
|
|
3784
|
-
};
|
|
3785
|
-
const handlePropertyDelete = (propKey) => {
|
|
3786
|
-
deleteOverridableProp({ componentId: currentComponentId, propKey, source: "user" });
|
|
3787
|
-
(0, import_editor_documents7.setDocumentModifiedStatus)(true);
|
|
3788
|
-
};
|
|
3789
|
-
const handlePropertyUpdate = (overrideKey, data) => {
|
|
3790
|
-
updateOverridablePropParams({
|
|
3791
|
-
componentId: currentComponentId,
|
|
3792
|
-
overrideKey,
|
|
3793
|
-
label: data.label,
|
|
3794
|
-
groupId: data.group
|
|
3795
|
-
});
|
|
3796
|
-
(0, import_editor_documents7.setDocumentModifiedStatus)(true);
|
|
3797
|
-
};
|
|
3798
|
-
const handleGroupDelete = (groupId) => {
|
|
3799
|
-
deleteOverridableGroup({ componentId: currentComponentId, groupId });
|
|
3800
|
-
(0, import_editor_documents7.setDocumentModifiedStatus)(true);
|
|
3801
|
-
};
|
|
3802
|
-
return /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement(import_editor_panels3.PanelHeader, { sx: { justifyContent: "start", pl: 1.5, pr: 1, py: 1 } }, /* @__PURE__ */ React26.createElement(import_ui20.Stack, { direction: "row", alignItems: "center", gap: 0.5, flexGrow: 1 }, /* @__PURE__ */ React26.createElement(import_icons14.ComponentPropListIcon, { fontSize: "tiny" }), /* @__PURE__ */ React26.createElement(import_editor_panels3.PanelHeaderTitle, { variant: "subtitle2" }, (0, import_i18n19.__)("Component properties", "elementor"))), !showEmptyState && /* @__PURE__ */ React26.createElement(import_ui20.Tooltip, { title: (0, import_i18n19.__)("Add new group", "elementor") }, /* @__PURE__ */ React26.createElement(
|
|
3803
|
-
import_ui20.IconButton,
|
|
3804
|
-
{
|
|
3805
|
-
size: "tiny",
|
|
3806
|
-
"aria-label": (0, import_i18n19.__)("Add new group", "elementor"),
|
|
3807
|
-
onClick: handleAddGroupClick
|
|
3808
|
-
},
|
|
3809
|
-
/* @__PURE__ */ React26.createElement(import_icons14.FolderPlusIcon, { fontSize: "tiny" })
|
|
3810
|
-
)), /* @__PURE__ */ React26.createElement(import_ui20.Tooltip, { title: (0, import_i18n19.__)("Close panel", "elementor") }, /* @__PURE__ */ React26.createElement(
|
|
3811
|
-
import_ui20.IconButton,
|
|
3812
|
-
{
|
|
3813
|
-
ref: introductionRef,
|
|
3814
|
-
size: "tiny",
|
|
3815
|
-
"aria-label": (0, import_i18n19.__)("Close panel", "elementor"),
|
|
3816
|
-
onClick: onClose
|
|
3817
|
-
},
|
|
3818
|
-
/* @__PURE__ */ React26.createElement(import_icons14.XIcon, { fontSize: "tiny" })
|
|
3819
|
-
))), /* @__PURE__ */ React26.createElement(import_ui20.Divider, null), /* @__PURE__ */ React26.createElement(import_editor_panels3.PanelBody, null, showEmptyState ? /* @__PURE__ */ React26.createElement(PropertiesEmptyState, { introductionRef }) : /* @__PURE__ */ React26.createElement(import_ui20.List, { sx: { p: 2, display: "flex", flexDirection: "column", gap: 2 } }, /* @__PURE__ */ React26.createElement(SortableProvider, { value: groupIds, onChange: handleGroupsReorder }, groups.map((group) => /* @__PURE__ */ React26.createElement(SortableItem, { key: group.id, id: group.id }, ({ triggerProps, triggerStyle, isDragPlaceholder }) => /* @__PURE__ */ React26.createElement(
|
|
3820
|
-
PropertiesGroup,
|
|
3821
|
-
{
|
|
3822
|
-
group,
|
|
3823
|
-
props: overridableProps.props,
|
|
3824
|
-
allGroups: allGroupsForSelect,
|
|
3825
|
-
allGroupsRecord: overridableProps.groups.items,
|
|
3826
|
-
sortableTriggerProps: { ...triggerProps, style: triggerStyle },
|
|
3827
|
-
isDragPlaceholder,
|
|
3828
|
-
setIsAddingGroup,
|
|
3829
|
-
onPropsReorder: (newOrder) => handlePropsReorder(group.id, newOrder),
|
|
3830
|
-
onPropertyDelete: handlePropertyDelete,
|
|
3831
|
-
onPropertyUpdate: handlePropertyUpdate,
|
|
3832
|
-
editableLabelProps: groupLabelEditable,
|
|
3833
|
-
onGroupDelete: handleGroupDelete
|
|
3834
|
-
}
|
|
3835
|
-
)))))));
|
|
3836
|
-
}
|
|
3837
|
-
|
|
3838
|
-
// src/extended/components/component-properties-panel/component-properties-panel.tsx
|
|
3839
|
-
var id = "component-properties-panel";
|
|
3840
|
-
var { panel, usePanelActions } = (0, import_editor_panels4.__createPanel)({
|
|
3841
|
-
id,
|
|
3842
|
-
component: ComponentPropertiesPanel
|
|
3843
|
-
});
|
|
3844
|
-
function ComponentPropertiesPanel() {
|
|
3845
|
-
const { close: closePanel } = usePanelActions();
|
|
3846
|
-
const { open: openEditingPanel } = (0, import_editor_editing_panel5.usePanelActions)();
|
|
3847
|
-
return /* @__PURE__ */ React27.createElement(import_editor_ui12.ThemeProvider, null, /* @__PURE__ */ React27.createElement(import_ui21.ErrorBoundary, { fallback: /* @__PURE__ */ React27.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React27.createElement(import_editor_panels4.Panel, null, /* @__PURE__ */ React27.createElement(
|
|
3848
|
-
ComponentPropertiesPanelContent,
|
|
3849
|
-
{
|
|
3850
|
-
onClose: () => {
|
|
3851
|
-
closePanel();
|
|
3852
|
-
openEditingPanel();
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
))));
|
|
3856
|
-
}
|
|
3857
|
-
var ErrorBoundaryFallback = () => /* @__PURE__ */ React27.createElement(import_ui21.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React27.createElement(import_ui21.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React27.createElement("strong", null, (0, import_i18n20.__)("Something went wrong", "elementor"))));
|
|
3858
|
-
|
|
3859
|
-
// src/extended/components/component-panel-header/component-badge.tsx
|
|
3860
|
-
var React28 = __toESM(require("react"));
|
|
3861
|
-
var import_react13 = require("react");
|
|
3862
|
-
var import_icons15 = require("@elementor/icons");
|
|
3863
|
-
var import_ui22 = require("@elementor/ui");
|
|
3864
|
-
var import_i18n21 = require("@wordpress/i18n");
|
|
3865
|
-
var ComponentsBadge = React28.forwardRef(({ overridablePropsCount, onClick }, ref) => {
|
|
3866
|
-
const prevCount = usePrevious(overridablePropsCount);
|
|
3867
|
-
const isFirstExposedProperty = prevCount === 0 && overridablePropsCount === 1;
|
|
3868
|
-
return /* @__PURE__ */ React28.createElement(
|
|
3869
|
-
StyledBadge,
|
|
3870
|
-
{
|
|
3871
|
-
ref,
|
|
3872
|
-
color: "primary",
|
|
3873
|
-
key: overridablePropsCount,
|
|
3874
|
-
invisible: overridablePropsCount === 0,
|
|
3875
|
-
animate: isFirstExposedProperty,
|
|
3876
|
-
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
3877
|
-
badgeContent: /* @__PURE__ */ React28.createElement(import_ui22.Box, { sx: { animation: !isFirstExposedProperty ? `${slideUp} 300ms ease-out` : "none" } }, overridablePropsCount)
|
|
3878
|
-
},
|
|
3879
|
-
/* @__PURE__ */ React28.createElement(import_ui22.Tooltip, { title: (0, import_i18n21.__)("Component properties", "elementor") }, /* @__PURE__ */ React28.createElement(
|
|
3880
|
-
import_ui22.ToggleButton,
|
|
3881
|
-
{
|
|
3882
|
-
value: "exposed properties",
|
|
3883
|
-
size: "tiny",
|
|
3884
|
-
onClick,
|
|
3885
|
-
"aria-label": (0, import_i18n21.__)("Component properties", "elementor")
|
|
3886
|
-
},
|
|
3887
|
-
/* @__PURE__ */ React28.createElement(import_icons15.ComponentPropListIcon, { fontSize: "tiny" })
|
|
3888
|
-
))
|
|
3889
|
-
);
|
|
3890
|
-
});
|
|
3891
|
-
var StyledBadge = (0, import_ui22.styled)(import_ui22.Badge, { shouldForwardProp: (prop) => prop !== "animate" })(
|
|
3892
|
-
({ theme, animate }) => ({
|
|
3893
|
-
"& .MuiBadge-badge": {
|
|
3894
|
-
minWidth: theme.spacing(2),
|
|
3895
|
-
height: theme.spacing(2),
|
|
3896
|
-
minHeight: theme.spacing(2),
|
|
3897
|
-
maxWidth: theme.spacing(2),
|
|
3898
|
-
fontSize: theme.typography.caption.fontSize,
|
|
3899
|
-
animation: animate ? `${bounceIn} 300ms ease-out` : "none"
|
|
3900
|
-
}
|
|
3901
|
-
})
|
|
3902
|
-
);
|
|
3903
|
-
function usePrevious(value) {
|
|
3904
|
-
const ref = (0, import_react13.useRef)(value);
|
|
3905
|
-
(0, import_react13.useEffect)(() => {
|
|
3906
|
-
ref.current = value;
|
|
3907
|
-
}, [value]);
|
|
3908
|
-
return ref.current;
|
|
3909
|
-
}
|
|
3910
|
-
var bounceIn = import_ui22.keyframes`
|
|
3911
|
-
0% { transform: scale(0) translate(50%, 50%); opacity: 0; }
|
|
3912
|
-
70% { transform: scale(1.1) translate(50%, -50%); opacity: 1; }
|
|
3913
|
-
100% { transform: scale(1) translate(50%, -50%); opacity: 1; }
|
|
3914
|
-
`;
|
|
3915
|
-
var slideUp = import_ui22.keyframes`
|
|
3916
|
-
from { transform: translateY(100%); opacity: 0; }
|
|
3917
|
-
to { transform: translateY(0); opacity: 1; }
|
|
3918
|
-
`;
|
|
3919
|
-
|
|
3920
|
-
// src/extended/components/component-panel-header/component-panel-header.tsx
|
|
3921
|
-
var MESSAGE_KEY = "components-properties-introduction";
|
|
3922
|
-
var ComponentPanelHeader = () => {
|
|
3923
|
-
const { id: currentComponentId, uid: componentUid } = useCurrentComponent() ?? { id: null, uid: null };
|
|
3924
|
-
const overridableProps = useSanitizeOverridableProps(currentComponentId);
|
|
3925
|
-
const onBack = useNavigateBack();
|
|
3926
|
-
const componentName = getComponentName();
|
|
3927
|
-
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user2.useSuppressedMessage)(MESSAGE_KEY);
|
|
3928
|
-
const [shouldShowIntroduction, setShouldShowIntroduction] = React29.useState(!isMessageSuppressed);
|
|
3929
|
-
const { open: openPropertiesPanel } = usePanelActions();
|
|
3930
|
-
const overridablePropsCount = overridableProps ? Object.keys(overridableProps.props).length : 0;
|
|
3931
|
-
const anchorRef = React29.useRef(null);
|
|
3932
|
-
if (!currentComponentId) {
|
|
3933
|
-
return null;
|
|
3934
|
-
}
|
|
3935
|
-
const handleCloseIntroduction = () => {
|
|
3936
|
-
suppressMessage();
|
|
3937
|
-
setShouldShowIntroduction(false);
|
|
3938
|
-
};
|
|
3939
|
-
const handleOpenPropertiesPanel = () => {
|
|
3940
|
-
openPropertiesPanel();
|
|
3941
|
-
trackComponentEvent({
|
|
3942
|
-
action: "propertiesPanelOpened",
|
|
3943
|
-
source: "user",
|
|
3944
|
-
component_uid: componentUid,
|
|
3945
|
-
properties_count: overridablePropsCount
|
|
3946
|
-
});
|
|
3947
|
-
};
|
|
3948
|
-
return /* @__PURE__ */ React29.createElement(import_ui23.Box, { "data-testid": "component-panel-header" }, /* @__PURE__ */ React29.createElement(import_editor_panels5.PanelHeader, { sx: { justifyContent: "start", px: 2 } }, /* @__PURE__ */ React29.createElement(import_ui23.Tooltip, { title: (0, import_i18n22.__)("Back", "elementor") }, /* @__PURE__ */ React29.createElement(import_ui23.IconButton, { size: "tiny", onClick: onBack, "aria-label": (0, import_i18n22.__)("Back", "elementor") }, /* @__PURE__ */ React29.createElement(import_icons16.ArrowLeftIcon, { fontSize: "tiny" }))), /* @__PURE__ */ React29.createElement(import_icons16.ComponentsFilledIcon, { fontSize: "tiny", stroke: "currentColor" }), /* @__PURE__ */ React29.createElement(
|
|
3949
|
-
import_editor_ui13.EllipsisWithTooltip,
|
|
3950
|
-
{
|
|
3951
|
-
title: componentName,
|
|
3952
|
-
as: import_ui23.Typography,
|
|
3953
|
-
variant: "caption",
|
|
3954
|
-
sx: { fontWeight: 500, flexGrow: 1 }
|
|
3955
|
-
}
|
|
3956
|
-
), /* @__PURE__ */ React29.createElement(
|
|
3957
|
-
ComponentsBadge,
|
|
3958
|
-
{
|
|
3959
|
-
overridablePropsCount,
|
|
3960
|
-
ref: anchorRef,
|
|
3961
|
-
onClick: handleOpenPropertiesPanel
|
|
3962
|
-
}
|
|
3963
|
-
)), /* @__PURE__ */ React29.createElement(import_ui23.Divider, null), /* @__PURE__ */ React29.createElement(
|
|
3964
|
-
ComponentIntroduction,
|
|
3965
|
-
{
|
|
3966
|
-
anchorRef,
|
|
3967
|
-
shouldShowIntroduction,
|
|
3968
|
-
onClose: handleCloseIntroduction
|
|
3969
|
-
}
|
|
3970
|
-
));
|
|
3971
|
-
};
|
|
3972
|
-
function getComponentName() {
|
|
3973
|
-
const state = (0, import_store32.__getState)();
|
|
3974
|
-
const path = state[SLICE_NAME].path;
|
|
3975
|
-
const { instanceTitle } = path.at(-1) ?? {};
|
|
3976
|
-
if (instanceTitle) {
|
|
3977
|
-
return instanceTitle;
|
|
3978
|
-
}
|
|
3979
|
-
const documentsManager = (0, import_editor_documents8.getV1DocumentsManager)();
|
|
3980
|
-
const currentDocument = documentsManager.getCurrent();
|
|
3981
|
-
return currentDocument?.container?.settings?.get("post_title") ?? "";
|
|
3982
|
-
}
|
|
3983
|
-
|
|
3984
|
-
// src/extended/components/components-tab/components.tsx
|
|
3985
|
-
var React32 = __toESM(require("react"));
|
|
3986
|
-
var import_editor_ui16 = require("@elementor/editor-ui");
|
|
3987
|
-
var import_ui25 = require("@elementor/ui");
|
|
3988
|
-
|
|
3989
|
-
// src/extended/components/components-tab/component-item.tsx
|
|
3990
|
-
var React31 = __toESM(require("react"));
|
|
3991
|
-
var import_react14 = require("react");
|
|
3992
|
-
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
3993
|
-
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
3994
|
-
var import_editor_ui15 = require("@elementor/editor-ui");
|
|
3995
|
-
var import_icons17 = require("@elementor/icons");
|
|
3996
|
-
var import_ui24 = require("@elementor/ui");
|
|
3997
|
-
var import_i18n26 = require("@wordpress/i18n");
|
|
3998
|
-
|
|
3999
|
-
// src/extended/store/actions/archive-component.ts
|
|
4000
|
-
var import_editor_documents9 = require("@elementor/editor-documents");
|
|
4001
|
-
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
4002
|
-
var import_i18n23 = require("@wordpress/i18n");
|
|
4003
|
-
var successNotification = (componentId, componentName) => ({
|
|
4004
|
-
type: "success",
|
|
4005
|
-
/* translators: %s: component name */
|
|
4006
|
-
message: (0, import_i18n23.__)("Successfully deleted component %s", "elementor").replace("%s", componentName),
|
|
4007
|
-
id: `success-archived-components-notification-${componentId}`
|
|
4008
|
-
});
|
|
4009
|
-
var archiveComponent = (componentId, componentName) => {
|
|
4010
|
-
componentsActions.archive(componentId);
|
|
4011
|
-
(0, import_editor_documents9.setDocumentModifiedStatus)(true);
|
|
4012
|
-
(0, import_editor_notifications3.notify)(successNotification(componentId, componentName));
|
|
4013
|
-
};
|
|
4014
|
-
|
|
4015
|
-
// src/extended/store/actions/rename-component.ts
|
|
4016
|
-
var import_editor_documents10 = require("@elementor/editor-documents");
|
|
4017
|
-
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
4018
|
-
var TITLE_EXTERNAL_CHANGE_COMMAND = "title_external_change";
|
|
4019
|
-
var renameComponent = (componentUid, newName) => {
|
|
4020
|
-
componentsActions.rename(componentUid, newName);
|
|
4021
|
-
(0, import_editor_documents10.setDocumentModifiedStatus)(true);
|
|
4022
|
-
refreshComponentInstanceTitles(componentUid);
|
|
4023
|
-
};
|
|
4024
|
-
function refreshComponentInstanceTitles(componentUid) {
|
|
4025
|
-
const documentContainer = getDocumentContainer();
|
|
4026
|
-
if (!documentContainer) {
|
|
4027
|
-
return;
|
|
4028
|
-
}
|
|
4029
|
-
const componentInstances = findComponentInstancesByUid(documentContainer, componentUid);
|
|
4030
|
-
componentInstances.forEach((element) => {
|
|
4031
|
-
element.model.trigger?.(TITLE_EXTERNAL_CHANGE_COMMAND);
|
|
4032
|
-
});
|
|
4033
|
-
}
|
|
4034
|
-
function getDocumentContainer() {
|
|
4035
|
-
const documentsManager = (0, import_editor_documents10.getV1DocumentsManager)();
|
|
4036
|
-
return documentsManager?.getCurrent()?.container;
|
|
4037
|
-
}
|
|
4038
|
-
function findComponentInstancesByUid(documentContainer, componentUid) {
|
|
4039
|
-
const allDescendants = (0, import_editor_elements11.getAllDescendants)(documentContainer);
|
|
4040
|
-
return allDescendants.filter((element) => {
|
|
4041
|
-
const widgetType = element.model.get("widgetType");
|
|
4042
|
-
const editorSettings = element.model.get("editor_settings");
|
|
4043
|
-
const isMatch = widgetType === COMPONENT_WIDGET_TYPE2 && editorSettings?.component_uid === componentUid;
|
|
4044
|
-
return isMatch;
|
|
4045
|
-
});
|
|
4046
|
-
}
|
|
4047
|
-
|
|
4048
|
-
// src/extended/utils/component-form-schema.ts
|
|
4049
|
-
var import_schema5 = require("@elementor/schema");
|
|
4050
|
-
var import_i18n24 = require("@wordpress/i18n");
|
|
4051
|
-
var MIN_NAME_LENGTH = 2;
|
|
4052
|
-
var MAX_NAME_LENGTH = 50;
|
|
4053
|
-
var baseComponentSchema = import_schema5.z.string().trim().max(MAX_NAME_LENGTH, (0, import_i18n24.__)("Component name is too long. Please keep it under 50 characters.", "elementor"));
|
|
4054
|
-
var createBaseComponentSchema = (existingNames) => {
|
|
4055
|
-
return import_schema5.z.object({
|
|
4056
|
-
componentName: baseComponentSchema.refine((value) => !existingNames.includes(value), {
|
|
4057
|
-
message: (0, import_i18n24.__)("Component name already exists", "elementor")
|
|
4058
|
-
})
|
|
4059
|
-
});
|
|
4060
|
-
};
|
|
4061
|
-
var createSubmitComponentSchema = (existingNames) => {
|
|
4062
|
-
const baseSchema = createBaseComponentSchema(existingNames);
|
|
4063
|
-
return baseSchema.extend({
|
|
4064
|
-
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
4065
|
-
message: (0, import_i18n24.__)("Component name is required.", "elementor")
|
|
4066
|
-
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
4067
|
-
message: (0, import_i18n24.__)("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
4068
|
-
})
|
|
4069
|
-
});
|
|
4070
|
-
};
|
|
4071
|
-
|
|
4072
|
-
// src/extended/utils/component-name-validation.ts
|
|
4073
|
-
function validateComponentName(label) {
|
|
4074
|
-
const existingComponentTitles = componentsSelectors.getComponents()?.map(({ name }) => name) ?? [];
|
|
4075
|
-
const schema = createSubmitComponentSchema(existingComponentTitles);
|
|
4076
|
-
const result = schema.safeParse({ componentName: label.toLowerCase() });
|
|
4077
|
-
if (result.success) {
|
|
4078
|
-
return {
|
|
4079
|
-
isValid: true,
|
|
4080
|
-
errorMessage: null
|
|
4081
|
-
};
|
|
4082
|
-
}
|
|
4083
|
-
const formattedErrors = result.error.format();
|
|
4084
|
-
const errorMessage = formattedErrors.componentName?._errors[0] ?? formattedErrors._errors[0];
|
|
4085
|
-
return {
|
|
4086
|
-
isValid: false,
|
|
4087
|
-
errorMessage
|
|
4088
|
-
};
|
|
4089
|
-
}
|
|
4090
|
-
|
|
4091
|
-
// src/extended/utils/create-component-model.ts
|
|
4092
|
-
var createComponentModel2 = (component) => {
|
|
4093
|
-
return {
|
|
4094
|
-
elType: "widget",
|
|
4095
|
-
widgetType: "e-component",
|
|
4096
|
-
settings: {
|
|
4097
|
-
component_instance: {
|
|
4098
|
-
$$type: "component-instance",
|
|
4099
|
-
value: {
|
|
4100
|
-
component_id: {
|
|
4101
|
-
$$type: "number",
|
|
4102
|
-
value: component.id ?? component.uid
|
|
4103
|
-
}
|
|
4104
|
-
}
|
|
4105
|
-
}
|
|
4106
|
-
},
|
|
4107
|
-
editor_settings: {
|
|
4108
|
-
component_uid: component.uid
|
|
4109
|
-
}
|
|
4110
|
-
};
|
|
4111
|
-
};
|
|
4112
|
-
|
|
4113
|
-
// src/extended/utils/get-container-for-new-element.ts
|
|
4114
|
-
var import_editor_elements12 = require("@elementor/editor-elements");
|
|
4115
|
-
var getContainerForNewElement = () => {
|
|
4116
|
-
const currentDocumentContainer = (0, import_editor_elements12.getCurrentDocumentContainer)();
|
|
4117
|
-
const selectedElement = getSelectedElementContainer();
|
|
4118
|
-
let container, options;
|
|
4119
|
-
if (selectedElement) {
|
|
4120
|
-
switch (selectedElement.model.get("elType")) {
|
|
4121
|
-
case "widget": {
|
|
4122
|
-
container = selectedElement?.parent;
|
|
4123
|
-
const selectedElIndex = selectedElement.view?._index ?? -1;
|
|
4124
|
-
if (selectedElIndex > -1) {
|
|
4125
|
-
options = { at: selectedElIndex + 1 };
|
|
4126
|
-
}
|
|
4127
|
-
break;
|
|
4128
|
-
}
|
|
4129
|
-
case "section": {
|
|
4130
|
-
container = selectedElement?.children?.[0];
|
|
4131
|
-
break;
|
|
4132
|
-
}
|
|
4133
|
-
default: {
|
|
4134
|
-
container = selectedElement;
|
|
4135
|
-
break;
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
}
|
|
4139
|
-
return { container: container ?? currentDocumentContainer, options };
|
|
4140
|
-
};
|
|
4141
|
-
function getSelectedElementContainer() {
|
|
4142
|
-
const selectedElements = (0, import_editor_elements12.getSelectedElements)();
|
|
4143
|
-
if (selectedElements.length !== 1) {
|
|
4144
|
-
return void 0;
|
|
4145
|
-
}
|
|
4146
|
-
return (0, import_editor_elements12.getContainer)(selectedElements[0].id);
|
|
4147
|
-
}
|
|
4148
|
-
|
|
4149
|
-
// src/extended/components/components-tab/delete-confirmation-dialog.tsx
|
|
4150
|
-
var React30 = __toESM(require("react"));
|
|
4151
|
-
var import_editor_ui14 = require("@elementor/editor-ui");
|
|
4152
|
-
var import_i18n25 = require("@wordpress/i18n");
|
|
4153
|
-
function DeleteConfirmationDialog({ open, onClose, onConfirm }) {
|
|
4154
|
-
return /* @__PURE__ */ React30.createElement(import_editor_ui14.ConfirmationDialog, { open, onClose }, /* @__PURE__ */ React30.createElement(import_editor_ui14.ConfirmationDialog.Title, null, (0, import_i18n25.__)("Delete this component?", "elementor")), /* @__PURE__ */ React30.createElement(import_editor_ui14.ConfirmationDialog.Content, null, /* @__PURE__ */ React30.createElement(import_editor_ui14.ConfirmationDialog.ContentText, null, (0, import_i18n25.__)(
|
|
4155
|
-
"Existing instances on your pages will remain functional. You will no longer find this component in your list.",
|
|
4156
|
-
"elementor"
|
|
4157
|
-
))), /* @__PURE__ */ React30.createElement(import_editor_ui14.ConfirmationDialog.Actions, { onClose, onConfirm }));
|
|
4158
|
-
}
|
|
4159
|
-
|
|
4160
|
-
// src/extended/components/components-tab/component-item.tsx
|
|
4161
|
-
function ComponentItem2({ component }) {
|
|
4162
|
-
const itemRef = (0, import_react14.useRef)(null);
|
|
4163
|
-
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = (0, import_react14.useState)(false);
|
|
4164
|
-
const { canRename, canDelete } = useComponentsPermissions();
|
|
4165
|
-
const shouldShowActions = canRename || canDelete;
|
|
4166
|
-
const {
|
|
4167
|
-
ref: editableRef,
|
|
4168
|
-
isEditing,
|
|
4169
|
-
openEditMode,
|
|
4170
|
-
error,
|
|
4171
|
-
getProps: getEditableProps
|
|
4172
|
-
} = (0, import_editor_ui15.useEditable)({
|
|
4173
|
-
value: component.name,
|
|
4174
|
-
onSubmit: (newName) => renameComponent(component.uid, newName),
|
|
4175
|
-
validation: validateComponentTitle
|
|
4176
|
-
});
|
|
4177
|
-
const componentModel = createComponentModel2(component);
|
|
4178
|
-
const popupState = (0, import_ui24.usePopupState)({
|
|
4179
|
-
variant: "popover",
|
|
4180
|
-
disableAutoFocus: true
|
|
4181
|
-
});
|
|
4182
|
-
const handleClick = () => {
|
|
4183
|
-
addComponentToPage(componentModel);
|
|
4184
|
-
};
|
|
4185
|
-
const handleDragEnd = () => {
|
|
4186
|
-
loadComponentsAssets([componentModel]);
|
|
4187
|
-
(0, import_editor_canvas5.endDragElementFromPanel)();
|
|
4188
|
-
};
|
|
4189
|
-
const handleDeleteClick = () => {
|
|
4190
|
-
setIsDeleteDialogOpen(true);
|
|
4191
|
-
popupState.close();
|
|
4192
|
-
};
|
|
4193
|
-
const handleDeleteConfirm = () => {
|
|
4194
|
-
if (!component.id) {
|
|
4195
|
-
throw new Error("Component ID is required");
|
|
4196
|
-
}
|
|
4197
|
-
setIsDeleteDialogOpen(false);
|
|
4198
|
-
archiveComponent(component.id, component.name);
|
|
4199
|
-
};
|
|
4200
|
-
const handleDeleteDialogClose = () => {
|
|
4201
|
-
setIsDeleteDialogOpen(false);
|
|
4202
|
-
};
|
|
4203
|
-
return /* @__PURE__ */ React31.createElement(import_ui24.Stack, null, /* @__PURE__ */ React31.createElement(
|
|
4204
|
-
import_editor_ui15.WarningInfotip,
|
|
4205
|
-
{
|
|
4206
|
-
open: Boolean(error),
|
|
4207
|
-
text: error ?? "",
|
|
4208
|
-
placement: "bottom",
|
|
4209
|
-
width: itemRef.current?.getBoundingClientRect().width,
|
|
4210
|
-
offset: [0, -15]
|
|
4211
|
-
},
|
|
4212
|
-
/* @__PURE__ */ React31.createElement(
|
|
4213
|
-
ComponentItem,
|
|
4214
|
-
{
|
|
4215
|
-
ref: itemRef,
|
|
4216
|
-
component,
|
|
4217
|
-
disabled: false,
|
|
4218
|
-
draggable: true,
|
|
4219
|
-
onDragStart: (event) => (0, import_editor_canvas5.startDragElementFromPanel)(componentModel, event),
|
|
4220
|
-
onDragEnd: handleDragEnd,
|
|
4221
|
-
onClick: handleClick,
|
|
4222
|
-
isEditing,
|
|
4223
|
-
error,
|
|
4224
|
-
nameSlot: /* @__PURE__ */ React31.createElement(
|
|
4225
|
-
ComponentName,
|
|
4226
|
-
{
|
|
4227
|
-
name: component.name,
|
|
4228
|
-
editable: { ref: editableRef, isEditing, getProps: getEditableProps }
|
|
4229
|
-
}
|
|
4230
|
-
),
|
|
4231
|
-
endSlot: shouldShowActions ? /* @__PURE__ */ React31.createElement(import_ui24.IconButton, { size: "tiny", ...(0, import_ui24.bindTrigger)(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React31.createElement(import_icons17.DotsVerticalIcon, { fontSize: "tiny" })) : void 0
|
|
4232
|
-
}
|
|
4233
|
-
)
|
|
4234
|
-
), shouldShowActions && /* @__PURE__ */ React31.createElement(
|
|
4235
|
-
import_ui24.Menu,
|
|
4236
|
-
{
|
|
4237
|
-
...(0, import_ui24.bindMenu)(popupState),
|
|
4238
|
-
anchorOrigin: {
|
|
4239
|
-
vertical: "bottom",
|
|
4240
|
-
horizontal: "right"
|
|
4241
|
-
},
|
|
4242
|
-
transformOrigin: {
|
|
4243
|
-
vertical: "top",
|
|
4244
|
-
horizontal: "right"
|
|
4245
|
-
}
|
|
4246
|
-
},
|
|
4247
|
-
canRename && /* @__PURE__ */ React31.createElement(
|
|
4248
|
-
import_editor_ui15.MenuListItem,
|
|
4249
|
-
{
|
|
4250
|
-
sx: { minWidth: "160px" },
|
|
4251
|
-
primaryTypographyProps: { variant: "caption", color: "text.primary" },
|
|
4252
|
-
onClick: () => {
|
|
4253
|
-
popupState.close();
|
|
4254
|
-
openEditMode();
|
|
4255
|
-
}
|
|
4256
|
-
},
|
|
4257
|
-
(0, import_i18n26.__)("Rename", "elementor")
|
|
4258
|
-
),
|
|
4259
|
-
canDelete && /* @__PURE__ */ React31.createElement(
|
|
4260
|
-
import_editor_ui15.MenuListItem,
|
|
4261
|
-
{
|
|
4262
|
-
sx: { minWidth: "160px" },
|
|
4263
|
-
primaryTypographyProps: { variant: "caption", color: "error.light" },
|
|
4264
|
-
onClick: handleDeleteClick
|
|
4265
|
-
},
|
|
4266
|
-
(0, import_i18n26.__)("Delete", "elementor")
|
|
4267
|
-
)
|
|
4268
|
-
), /* @__PURE__ */ React31.createElement(
|
|
4269
|
-
DeleteConfirmationDialog,
|
|
4270
|
-
{
|
|
4271
|
-
open: isDeleteDialogOpen,
|
|
4272
|
-
onClose: handleDeleteDialogClose,
|
|
4273
|
-
onConfirm: handleDeleteConfirm
|
|
4274
|
-
}
|
|
4275
|
-
));
|
|
4276
|
-
}
|
|
4277
|
-
var addComponentToPage = (model) => {
|
|
4278
|
-
const { container, options } = getContainerForNewElement();
|
|
4279
|
-
if (!container) {
|
|
4280
|
-
throw new Error(`Can't find container to drop new component instance at`);
|
|
4281
|
-
}
|
|
4282
|
-
loadComponentsAssets([model]);
|
|
4283
|
-
(0, import_editor_elements13.dropElement)({
|
|
4284
|
-
containerId: container.id,
|
|
4285
|
-
model,
|
|
4286
|
-
options: { ...options, useHistory: false, scrollIntoView: true }
|
|
4287
|
-
});
|
|
4288
|
-
};
|
|
4289
|
-
var validateComponentTitle = (newTitle) => {
|
|
4290
|
-
const result = validateComponentName(newTitle);
|
|
4291
|
-
if (!result.errorMessage) {
|
|
4292
|
-
return null;
|
|
4293
|
-
}
|
|
4294
|
-
return result.errorMessage;
|
|
4295
|
-
};
|
|
4296
|
-
|
|
4297
|
-
// src/extended/components/components-tab/components.tsx
|
|
4298
|
-
var ExtendedComponentsList = () => {
|
|
4299
|
-
const { components, isLoading, searchValue } = useFilteredComponents();
|
|
4300
|
-
if (isLoading) {
|
|
4301
|
-
return /* @__PURE__ */ React32.createElement(LoadingComponents, null);
|
|
4302
|
-
}
|
|
4303
|
-
const isEmpty = !components?.length;
|
|
4304
|
-
if (isEmpty) {
|
|
4305
|
-
return searchValue.length ? /* @__PURE__ */ React32.createElement(EmptySearchResult, null) : /* @__PURE__ */ React32.createElement(EmptyState, null);
|
|
4306
|
-
}
|
|
4307
|
-
return /* @__PURE__ */ React32.createElement(import_ui25.List, { sx: { display: "flex", flexDirection: "column", gap: 1, px: 2 } }, components.map((component) => /* @__PURE__ */ React32.createElement(ComponentItem2, { key: component.uid, component })));
|
|
4308
|
-
};
|
|
4309
|
-
var ExtendedComponentsContent = () => {
|
|
4310
|
-
const { components, isLoading } = useComponents();
|
|
4311
|
-
const hasComponents = !isLoading && components.length > 0;
|
|
4312
|
-
return /* @__PURE__ */ React32.createElement(React32.Fragment, null, hasComponents && /* @__PURE__ */ React32.createElement(ComponentSearch, null), /* @__PURE__ */ React32.createElement(ExtendedComponentsList, null));
|
|
4313
|
-
};
|
|
4314
|
-
var ExtendedComponents = () => {
|
|
4315
|
-
return /* @__PURE__ */ React32.createElement(import_editor_ui16.ThemeProvider, null, /* @__PURE__ */ React32.createElement(SearchProvider, { localStorageKey: "elementor-components-search" }, /* @__PURE__ */ React32.createElement(ExtendedComponentsContent, null)));
|
|
4316
|
-
};
|
|
4317
|
-
|
|
4318
|
-
// src/extended/components/create-component-form/create-component-form.tsx
|
|
4319
|
-
var React33 = __toESM(require("react"));
|
|
4320
|
-
var import_react16 = require("react");
|
|
4321
|
-
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
4322
|
-
var import_editor_notifications5 = require("@elementor/editor-notifications");
|
|
4323
|
-
var import_editor_ui17 = require("@elementor/editor-ui");
|
|
4324
|
-
var import_icons18 = require("@elementor/icons");
|
|
4325
|
-
var import_ui26 = require("@elementor/ui");
|
|
4326
|
-
var import_i18n29 = require("@wordpress/i18n");
|
|
4327
|
-
|
|
4328
|
-
// src/extended/store/actions/create-unpublished-component.ts
|
|
4329
|
-
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
4330
|
-
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
4331
|
-
var import_utils7 = require("@elementor/utils");
|
|
4332
|
-
var import_i18n27 = require("@wordpress/i18n");
|
|
4333
|
-
|
|
4334
|
-
// src/extended/utils/replace-element-with-component.ts
|
|
4335
|
-
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4336
|
-
var replaceElementWithComponent = (element, component) => {
|
|
4337
|
-
return (0, import_editor_elements14.replaceElement)({
|
|
4338
|
-
currentElementId: element.id,
|
|
4339
|
-
newElement: createComponentModel2(component),
|
|
4340
|
-
withHistory: false
|
|
4341
|
-
});
|
|
4342
|
-
};
|
|
4343
|
-
|
|
4344
|
-
// src/extended/store/actions/create-unpublished-component.ts
|
|
4345
|
-
async function createUnpublishedComponent({
|
|
4346
|
-
name,
|
|
4347
|
-
element,
|
|
4348
|
-
eventData,
|
|
4349
|
-
uid,
|
|
4350
|
-
overridableProps,
|
|
4351
|
-
source
|
|
4352
|
-
}) {
|
|
4353
|
-
const generatedUid = uid ?? (0, import_utils7.generateUniqueId)("component");
|
|
4354
|
-
const componentBase = { uid: generatedUid, name };
|
|
4355
|
-
const elementDataWithOverridablesReverted = revertAllOverridablesInElementData(element);
|
|
4356
|
-
const container = (0, import_editor_elements15.getContainer)(element.id);
|
|
4357
|
-
const modelFromContainer = container?.model?.toJSON?.();
|
|
4358
|
-
const originalElement = {
|
|
4359
|
-
model: modelFromContainer ?? element,
|
|
4360
|
-
parentId: container?.parent?.id ?? "",
|
|
4361
|
-
index: container?.view?._index ?? 0
|
|
4362
|
-
};
|
|
4363
|
-
componentsActions.addUnpublished({
|
|
4364
|
-
...componentBase,
|
|
4365
|
-
elements: [elementDataWithOverridablesReverted],
|
|
4366
|
-
overridableProps
|
|
4367
|
-
});
|
|
4368
|
-
componentsActions.addCreatedThisSession(generatedUid);
|
|
4369
|
-
const componentInstance = replaceElementWithComponent(element, componentBase);
|
|
4370
|
-
trackComponentEvent({
|
|
4371
|
-
action: "created",
|
|
4372
|
-
source,
|
|
4373
|
-
component_uid: generatedUid,
|
|
4374
|
-
component_name: name,
|
|
4375
|
-
...eventData
|
|
4376
|
-
});
|
|
4377
|
-
try {
|
|
4378
|
-
await (0, import_editor_v1_adapters4.__privateRunCommand)("document/save/auto");
|
|
4379
|
-
} catch (error) {
|
|
4380
|
-
restoreOriginalElement(originalElement, componentInstance.id);
|
|
4381
|
-
componentsActions.removeUnpublished(generatedUid);
|
|
4382
|
-
componentsActions.removeCreatedThisSession(generatedUid);
|
|
4383
|
-
throw error;
|
|
4384
|
-
}
|
|
4385
|
-
return { uid: generatedUid, instanceId: componentInstance.id };
|
|
4386
|
-
}
|
|
4387
|
-
function restoreOriginalElement(originalElement, componentInstanceId) {
|
|
4388
|
-
const componentContainer = (0, import_editor_elements15.getContainer)(componentInstanceId);
|
|
4389
|
-
if (componentContainer) {
|
|
4390
|
-
(0, import_editor_elements15.deleteElement)({ container: componentContainer, options: { useHistory: false } });
|
|
4391
|
-
}
|
|
4392
|
-
const parentContainer = (0, import_editor_elements15.getContainer)(originalElement.parentId);
|
|
4393
|
-
if (!parentContainer) {
|
|
4394
|
-
return;
|
|
4395
|
-
}
|
|
4396
|
-
const clonedModel = structuredClone(originalElement.model);
|
|
4397
|
-
(0, import_editor_elements15.createElements)({
|
|
4398
|
-
title: (0, import_i18n27.__)("Restore Element", "elementor"),
|
|
4399
|
-
elements: [
|
|
4400
|
-
{
|
|
4401
|
-
container: parentContainer,
|
|
4402
|
-
model: clonedModel,
|
|
4403
|
-
options: { at: originalElement.index }
|
|
4404
|
-
}
|
|
4405
|
-
]
|
|
4406
|
-
});
|
|
4407
|
-
}
|
|
4408
|
-
|
|
4409
|
-
// src/extended/sync/prevent-non-atomic-nesting.ts
|
|
4410
|
-
var import_editor_canvas6 = require("@elementor/editor-canvas");
|
|
4411
|
-
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
4412
|
-
var import_editor_notifications4 = require("@elementor/editor-notifications");
|
|
4413
|
-
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
4414
|
-
var import_i18n28 = require("@wordpress/i18n");
|
|
4415
|
-
|
|
4416
|
-
// src/extended/utils/is-editing-component.ts
|
|
4417
|
-
function isEditingComponent() {
|
|
4418
|
-
return componentsSelectors.getCurrentComponentId() !== null;
|
|
4419
|
-
}
|
|
4420
|
-
|
|
4421
|
-
// src/extended/sync/prevent-non-atomic-nesting.ts
|
|
4422
|
-
var NON_ATOMIC_ELEMENT_ALERT = {
|
|
4423
|
-
type: "default",
|
|
4424
|
-
message: (0, import_i18n28.__)("This widget isn't compatible with components. Use atomic elements instead.", "elementor"),
|
|
4425
|
-
id: "non-atomic-element-blocked"
|
|
4426
|
-
};
|
|
4427
|
-
function initNonAtomicNestingPrevention() {
|
|
4428
|
-
(0, import_editor_v1_adapters5.blockCommand)({
|
|
4429
|
-
command: "document/elements/create",
|
|
4430
|
-
condition: blockNonAtomicCreate
|
|
4431
|
-
});
|
|
4432
|
-
(0, import_editor_v1_adapters5.blockCommand)({
|
|
4433
|
-
command: "document/elements/move",
|
|
4434
|
-
condition: blockNonAtomicMove
|
|
4435
|
-
});
|
|
4436
|
-
(0, import_editor_v1_adapters5.blockCommand)({
|
|
4437
|
-
command: "document/elements/paste",
|
|
4438
|
-
condition: blockNonAtomicPaste
|
|
4439
|
-
});
|
|
4440
|
-
}
|
|
4441
|
-
function isElementAtomic(elementType) {
|
|
4442
|
-
return (0, import_editor_elements16.getElementType)(elementType) !== null;
|
|
4443
|
-
}
|
|
4444
|
-
function blockNonAtomicCreate(args) {
|
|
4445
|
-
if (!isEditingComponent()) {
|
|
4446
|
-
return false;
|
|
4447
|
-
}
|
|
4448
|
-
const { model } = args;
|
|
4449
|
-
const elementType = model?.widgetType || model?.elType;
|
|
4450
|
-
if (!elementType) {
|
|
4451
|
-
return false;
|
|
4452
|
-
}
|
|
4453
|
-
if (isElementAtomic(elementType)) {
|
|
4454
|
-
return false;
|
|
4455
|
-
}
|
|
4456
|
-
(0, import_editor_notifications4.notify)(NON_ATOMIC_ELEMENT_ALERT);
|
|
4457
|
-
return true;
|
|
4458
|
-
}
|
|
4459
|
-
function blockNonAtomicMove(args) {
|
|
4460
|
-
if (!isEditingComponent()) {
|
|
4461
|
-
return false;
|
|
4462
|
-
}
|
|
4463
|
-
const { containers = [args.container] } = args;
|
|
4464
|
-
const hasNonAtomicElement = containers.some((container) => {
|
|
4465
|
-
if (!container) {
|
|
4466
|
-
return false;
|
|
4467
|
-
}
|
|
4468
|
-
const allElements = (0, import_editor_elements16.getAllDescendants)(container);
|
|
4469
|
-
return allElements.some((element) => !(0, import_editor_canvas6.isAtomicWidget)(element));
|
|
4470
|
-
});
|
|
4471
|
-
if (hasNonAtomicElement) {
|
|
4472
|
-
(0, import_editor_notifications4.notify)(NON_ATOMIC_ELEMENT_ALERT);
|
|
4473
|
-
}
|
|
4474
|
-
return hasNonAtomicElement;
|
|
4475
|
-
}
|
|
4476
|
-
function blockNonAtomicPaste(args) {
|
|
4477
|
-
if (!isEditingComponent()) {
|
|
4478
|
-
return false;
|
|
4479
|
-
}
|
|
4480
|
-
const { storageType } = args;
|
|
4481
|
-
if (storageType !== "localstorage") {
|
|
4482
|
-
return false;
|
|
4483
|
-
}
|
|
4484
|
-
const data = window?.elementorCommon?.storage?.get();
|
|
4485
|
-
if (!data?.clipboard?.elements) {
|
|
4486
|
-
return false;
|
|
4487
|
-
}
|
|
4488
|
-
const hasNonAtomicElement = hasNonAtomicElementsInTree(data.clipboard.elements);
|
|
4489
|
-
if (hasNonAtomicElement) {
|
|
4490
|
-
(0, import_editor_notifications4.notify)(NON_ATOMIC_ELEMENT_ALERT);
|
|
4491
|
-
}
|
|
4492
|
-
return hasNonAtomicElement;
|
|
4493
|
-
}
|
|
4494
|
-
function hasNonAtomicElementsInTree(elements) {
|
|
4495
|
-
for (const element of elements) {
|
|
4496
|
-
const elementType = element.widgetType || element.elType;
|
|
4497
|
-
if (elementType && !isElementAtomic(elementType)) {
|
|
4498
|
-
return true;
|
|
4499
|
-
}
|
|
4500
|
-
if (element.elements?.length) {
|
|
4501
|
-
if (hasNonAtomicElementsInTree(element.elements)) {
|
|
4502
|
-
return true;
|
|
4503
|
-
}
|
|
4504
|
-
}
|
|
4505
|
-
}
|
|
4506
|
-
return false;
|
|
4507
|
-
}
|
|
4508
|
-
function findNonAtomicElementsInElement(element) {
|
|
4509
|
-
const nonAtomicElements = [];
|
|
4510
|
-
const elementType = element.widgetType || element.elType;
|
|
4511
|
-
if (elementType && !isElementAtomic(elementType)) {
|
|
4512
|
-
nonAtomicElements.push(elementType);
|
|
4513
|
-
}
|
|
4514
|
-
if (element.elements?.length) {
|
|
4515
|
-
for (const child of element.elements) {
|
|
4516
|
-
nonAtomicElements.push(...findNonAtomicElementsInElement(child));
|
|
4517
|
-
}
|
|
4518
|
-
}
|
|
4519
|
-
return [...new Set(nonAtomicElements)];
|
|
4520
|
-
}
|
|
4521
|
-
|
|
4522
|
-
// src/extended/components/create-component-form/hooks/use-form.ts
|
|
4523
|
-
var import_react15 = require("react");
|
|
4524
|
-
var useForm = (initialValues) => {
|
|
4525
|
-
const [values, setValues] = (0, import_react15.useState)(initialValues);
|
|
4526
|
-
const [errors, setErrors] = (0, import_react15.useState)({});
|
|
4527
|
-
const isValid = (0, import_react15.useMemo)(() => {
|
|
4528
|
-
return !Object.values(errors).some((error) => error);
|
|
4529
|
-
}, [errors]);
|
|
4530
|
-
const handleChange = (e, field, validationSchema) => {
|
|
4531
|
-
const updated = { ...values, [field]: e.target.value };
|
|
4532
|
-
setValues(updated);
|
|
4533
|
-
const { success, errors: validationErrors } = validateForm(updated, validationSchema);
|
|
4534
|
-
if (!success) {
|
|
4535
|
-
setErrors(validationErrors);
|
|
4536
|
-
} else {
|
|
4537
|
-
setErrors({});
|
|
4538
|
-
}
|
|
4539
|
-
};
|
|
4540
|
-
const validate = (validationSchema) => {
|
|
4541
|
-
const { success, errors: validationErrors, parsedValues } = validateForm(values, validationSchema);
|
|
4542
|
-
if (!success) {
|
|
4543
|
-
setErrors(validationErrors);
|
|
4544
|
-
return { success };
|
|
4545
|
-
}
|
|
4546
|
-
setErrors({});
|
|
4547
|
-
return { success, parsedValues };
|
|
4548
|
-
};
|
|
4549
|
-
return {
|
|
4550
|
-
values,
|
|
4551
|
-
errors,
|
|
4552
|
-
isValid,
|
|
4553
|
-
handleChange,
|
|
4554
|
-
validateForm: validate
|
|
4555
|
-
};
|
|
4556
|
-
};
|
|
4557
|
-
var validateForm = (values, schema) => {
|
|
4558
|
-
const result = schema.safeParse(values);
|
|
4559
|
-
if (result.success) {
|
|
4560
|
-
return { success: true, parsedValues: result.data };
|
|
4561
|
-
}
|
|
4562
|
-
const errors = {};
|
|
4563
|
-
Object.entries(result.error.formErrors.fieldErrors).forEach(
|
|
4564
|
-
([field, error]) => {
|
|
4565
|
-
errors[field] = error[0];
|
|
4566
|
-
}
|
|
4567
|
-
);
|
|
4568
|
-
return { success: false, errors };
|
|
4569
|
-
};
|
|
4570
|
-
|
|
4571
|
-
// src/extended/components/create-component-form/utils/get-component-event-data.ts
|
|
4572
|
-
var getComponentEventData = (containerElement, options) => {
|
|
4573
|
-
const { elementsCount, componentsCount } = countNestedElements(containerElement);
|
|
4574
|
-
return {
|
|
4575
|
-
nested_elements_count: elementsCount,
|
|
4576
|
-
nested_components_count: componentsCount,
|
|
4577
|
-
top_element_type: containerElement.elType,
|
|
4578
|
-
location: options?.location,
|
|
4579
|
-
secondary_location: options?.secondaryLocation,
|
|
4580
|
-
trigger: options?.trigger
|
|
4581
|
-
};
|
|
4582
|
-
};
|
|
4583
|
-
function countNestedElements(container) {
|
|
4584
|
-
if (!container.elements || container.elements.length === 0) {
|
|
4585
|
-
return { elementsCount: 0, componentsCount: 0 };
|
|
4586
|
-
}
|
|
4587
|
-
let elementsCount = container.elements.length;
|
|
4588
|
-
let componentsCount = 0;
|
|
4589
|
-
for (const element of container.elements) {
|
|
4590
|
-
if (element.widgetType === "e-component") {
|
|
4591
|
-
componentsCount++;
|
|
4592
|
-
}
|
|
4593
|
-
const { elementsCount: nestedElementsCount, componentsCount: nestedComponentsCount } = countNestedElements(element);
|
|
4594
|
-
elementsCount += nestedElementsCount;
|
|
4595
|
-
componentsCount += nestedComponentsCount;
|
|
4596
|
-
}
|
|
4597
|
-
return { elementsCount, componentsCount };
|
|
4598
|
-
}
|
|
4599
|
-
|
|
4600
|
-
// src/extended/components/create-component-form/create-component-form.tsx
|
|
4601
|
-
var MAX_COMPONENTS = 100;
|
|
4602
|
-
function CreateComponentForm() {
|
|
4603
|
-
const [element, setElement] = (0, import_react16.useState)(null);
|
|
4604
|
-
const [anchorPosition, setAnchorPosition] = (0, import_react16.useState)();
|
|
4605
|
-
const { components } = useComponents();
|
|
4606
|
-
const eventData = (0, import_react16.useRef)(null);
|
|
4607
|
-
(0, import_react16.useEffect)(() => {
|
|
4608
|
-
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT2 = "elementor/editor/open-save-as-component-form";
|
|
4609
|
-
const openPopup = (event) => {
|
|
4610
|
-
const { shouldOpen, notification } = shouldOpenForm(event.detail.element, components?.length ?? 0);
|
|
4611
|
-
if (!shouldOpen) {
|
|
4612
|
-
(0, import_editor_notifications5.notify)(notification);
|
|
4613
|
-
return;
|
|
4614
|
-
}
|
|
4615
|
-
setElement({ element: event.detail.element, elementLabel: (0, import_editor_elements17.getElementLabel)(event.detail.element.id) });
|
|
4616
|
-
setAnchorPosition(event.detail.anchorPosition);
|
|
4617
|
-
eventData.current = getComponentEventData(event.detail.element, event.detail.options);
|
|
4618
|
-
trackComponentEvent({
|
|
4619
|
-
action: "createClicked",
|
|
4620
|
-
source: "user",
|
|
4621
|
-
...eventData.current
|
|
4622
|
-
});
|
|
4623
|
-
};
|
|
4624
|
-
window.addEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT2, openPopup);
|
|
4625
|
-
return () => {
|
|
4626
|
-
window.removeEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT2, openPopup);
|
|
4627
|
-
};
|
|
4628
|
-
}, [components?.length]);
|
|
4629
|
-
const handleSave = async (values) => {
|
|
4630
|
-
try {
|
|
4631
|
-
if (!element) {
|
|
4632
|
-
throw new Error(`Can't save element as component: element not found`);
|
|
4633
|
-
}
|
|
4634
|
-
const { uid, instanceId } = await createUnpublishedComponent({
|
|
4635
|
-
name: values.componentName,
|
|
4636
|
-
element: element.element,
|
|
4637
|
-
eventData: eventData.current,
|
|
4638
|
-
source: "user"
|
|
4639
|
-
});
|
|
4640
|
-
const publishedComponentId = componentsSelectors.getComponentByUid(uid)?.id;
|
|
4641
|
-
if (publishedComponentId) {
|
|
4642
|
-
switchToComponent(publishedComponentId, instanceId);
|
|
4643
|
-
} else {
|
|
4644
|
-
throw new Error("Failed to find published component");
|
|
4645
|
-
}
|
|
4646
|
-
(0, import_editor_notifications5.notify)({
|
|
4647
|
-
type: "success",
|
|
4648
|
-
message: (0, import_i18n29.__)("Component created successfully.", "elementor"),
|
|
4649
|
-
id: `component-saved-successfully-${uid}`
|
|
4650
|
-
});
|
|
4651
|
-
resetAndClosePopup();
|
|
4652
|
-
} catch {
|
|
4653
|
-
const errorMessage = (0, import_i18n29.__)("Failed to create component. Please try again.", "elementor");
|
|
4654
|
-
(0, import_editor_notifications5.notify)({
|
|
4655
|
-
type: "error",
|
|
4656
|
-
message: errorMessage,
|
|
4657
|
-
id: "component-save-failed"
|
|
4658
|
-
});
|
|
4659
|
-
resetAndClosePopup();
|
|
4660
|
-
}
|
|
4661
|
-
};
|
|
4662
|
-
const resetAndClosePopup = () => {
|
|
4663
|
-
setElement(null);
|
|
4664
|
-
setAnchorPosition(void 0);
|
|
4665
|
-
};
|
|
4666
|
-
const cancelSave = () => {
|
|
4667
|
-
resetAndClosePopup();
|
|
4668
|
-
trackComponentEvent({
|
|
4669
|
-
action: "createCancelled",
|
|
4670
|
-
source: "user",
|
|
4671
|
-
...eventData.current
|
|
4672
|
-
});
|
|
4673
|
-
};
|
|
4674
|
-
return /* @__PURE__ */ React33.createElement(import_editor_ui17.ThemeProvider, null, /* @__PURE__ */ React33.createElement(
|
|
4675
|
-
import_ui26.Popover,
|
|
4676
|
-
{
|
|
4677
|
-
open: element !== null,
|
|
4678
|
-
onClose: cancelSave,
|
|
4679
|
-
anchorReference: "anchorPosition",
|
|
4680
|
-
anchorPosition,
|
|
4681
|
-
"data-testid": "create-component-form"
|
|
4682
|
-
},
|
|
4683
|
-
element !== null && /* @__PURE__ */ React33.createElement(
|
|
4684
|
-
Form2,
|
|
4685
|
-
{
|
|
4686
|
-
initialValues: { componentName: element.elementLabel },
|
|
4687
|
-
handleSave,
|
|
4688
|
-
closePopup: cancelSave
|
|
4689
|
-
}
|
|
4690
|
-
)
|
|
4691
|
-
));
|
|
4692
|
-
}
|
|
4693
|
-
function shouldOpenForm(element, componentsCount) {
|
|
4694
|
-
const nonAtomicElements = findNonAtomicElementsInElement(element);
|
|
4695
|
-
if (nonAtomicElements.length > 0) {
|
|
4696
|
-
return {
|
|
4697
|
-
shouldOpen: false,
|
|
4698
|
-
notification: {
|
|
4699
|
-
type: "default",
|
|
4700
|
-
message: (0, import_i18n29.__)(
|
|
4701
|
-
"Components require atomic elements only. Remove widgets to create this component.",
|
|
4702
|
-
"elementor"
|
|
4703
|
-
),
|
|
4704
|
-
id: "non-atomic-element-save-blocked"
|
|
4705
|
-
}
|
|
4706
|
-
};
|
|
4707
|
-
}
|
|
4708
|
-
if (componentsCount >= MAX_COMPONENTS) {
|
|
4709
|
-
return {
|
|
4710
|
-
shouldOpen: false,
|
|
4711
|
-
notification: {
|
|
4712
|
-
type: "default",
|
|
4713
|
-
/* translators: %s is the maximum number of components */
|
|
4714
|
-
message: (0, import_i18n29.__)(
|
|
4715
|
-
`You've reached the limit of %s components. Please remove an existing one to create a new component.`,
|
|
4716
|
-
"elementor"
|
|
4717
|
-
).replace("%s", MAX_COMPONENTS.toString()),
|
|
4718
|
-
id: "maximum-number-of-components-exceeded"
|
|
4719
|
-
}
|
|
4720
|
-
};
|
|
4721
|
-
}
|
|
4722
|
-
return { shouldOpen: true, notification: null };
|
|
4723
|
-
}
|
|
4724
|
-
var FONT_SIZE = "tiny";
|
|
4725
|
-
var Form2 = ({
|
|
4726
|
-
initialValues,
|
|
4727
|
-
handleSave,
|
|
4728
|
-
closePopup
|
|
4729
|
-
}) => {
|
|
4730
|
-
const { values, errors, isValid, handleChange, validateForm: validateForm2 } = useForm(initialValues);
|
|
4731
|
-
const nameInputRef = (0, import_editor_ui17.useTextFieldAutoSelect)();
|
|
4732
|
-
const { components } = useComponents();
|
|
4733
|
-
const existingComponentNames = (0, import_react16.useMemo)(() => {
|
|
4734
|
-
return components?.map((component) => component.name) ?? [];
|
|
4735
|
-
}, [components]);
|
|
4736
|
-
const changeValidationSchema = (0, import_react16.useMemo)(
|
|
4737
|
-
() => createBaseComponentSchema(existingComponentNames),
|
|
4738
|
-
[existingComponentNames]
|
|
4739
|
-
);
|
|
4740
|
-
const submitValidationSchema = (0, import_react16.useMemo)(
|
|
4741
|
-
() => createSubmitComponentSchema(existingComponentNames),
|
|
4742
|
-
[existingComponentNames]
|
|
4743
|
-
);
|
|
4744
|
-
const handleSubmit = () => {
|
|
4745
|
-
const { success, parsedValues } = validateForm2(submitValidationSchema);
|
|
4746
|
-
if (success) {
|
|
4747
|
-
handleSave(parsedValues);
|
|
4748
|
-
}
|
|
4749
|
-
};
|
|
4750
|
-
const texts = {
|
|
4751
|
-
heading: (0, import_i18n29.__)("Create component", "elementor"),
|
|
4752
|
-
name: (0, import_i18n29.__)("Name", "elementor"),
|
|
4753
|
-
cancel: (0, import_i18n29.__)("Cancel", "elementor"),
|
|
4754
|
-
create: (0, import_i18n29.__)("Create", "elementor")
|
|
4755
|
-
};
|
|
4756
|
-
const nameInputId = "component-name";
|
|
4757
|
-
return /* @__PURE__ */ React33.createElement(import_editor_ui17.Form, { onSubmit: handleSubmit }, /* @__PURE__ */ React33.createElement(import_ui26.Stack, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React33.createElement(
|
|
4758
|
-
import_ui26.Stack,
|
|
4759
|
-
{
|
|
4760
|
-
direction: "row",
|
|
4761
|
-
alignItems: "center",
|
|
4762
|
-
py: 1,
|
|
4763
|
-
px: 1.5,
|
|
4764
|
-
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
4765
|
-
},
|
|
4766
|
-
/* @__PURE__ */ React33.createElement(import_icons18.ComponentsIcon, { fontSize: FONT_SIZE }),
|
|
4767
|
-
/* @__PURE__ */ React33.createElement(import_ui26.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, texts.heading)
|
|
4768
|
-
), /* @__PURE__ */ React33.createElement(import_ui26.Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React33.createElement(import_ui26.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React33.createElement(import_ui26.FormLabel, { htmlFor: nameInputId, size: "tiny" }, texts.name)), /* @__PURE__ */ React33.createElement(import_ui26.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React33.createElement(
|
|
4769
|
-
import_ui26.TextField,
|
|
4770
|
-
{
|
|
4771
|
-
id: nameInputId,
|
|
4772
|
-
size: FONT_SIZE,
|
|
4773
|
-
fullWidth: true,
|
|
4774
|
-
value: values.componentName,
|
|
4775
|
-
onChange: (e) => handleChange(e, "componentName", changeValidationSchema),
|
|
4776
|
-
inputProps: { style: { color: "text.primary", fontWeight: "600" } },
|
|
4777
|
-
error: Boolean(errors.componentName),
|
|
4778
|
-
helperText: errors.componentName,
|
|
4779
|
-
inputRef: nameInputRef
|
|
4780
|
-
}
|
|
4781
|
-
))), /* @__PURE__ */ React33.createElement(import_ui26.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React33.createElement(import_ui26.Button, { onClick: closePopup, color: "secondary", variant: "text", size: "small" }, texts.cancel), /* @__PURE__ */ React33.createElement(import_ui26.Button, { type: "submit", disabled: !isValid, variant: "contained", color: "primary", size: "small" }, texts.create))));
|
|
4782
|
-
};
|
|
4783
|
-
|
|
4784
|
-
// src/extended/components/edit-component/edit-component.tsx
|
|
4785
|
-
var React35 = __toESM(require("react"));
|
|
4786
|
-
var import_react19 = require("react");
|
|
4787
|
-
var import_editor_documents11 = require("@elementor/editor-documents");
|
|
4788
|
-
var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
4789
|
-
var import_store34 = require("@elementor/store");
|
|
4790
|
-
var import_utils9 = require("@elementor/utils");
|
|
4791
|
-
|
|
4792
|
-
// src/extended/consts.ts
|
|
4793
|
-
var OVERRIDABLE_PROP_REPLACEMENT_ID = "overridable-prop";
|
|
4794
|
-
var COMPONENT_DOCUMENT_TYPE = "elementor_component";
|
|
4795
|
-
|
|
4796
|
-
// src/extended/store/actions/reset-sanitized-components.ts
|
|
4797
|
-
function resetSanitizedComponents() {
|
|
4798
|
-
componentsActions.resetSanitizedComponents();
|
|
4799
|
-
}
|
|
4800
|
-
|
|
4801
|
-
// src/extended/store/actions/update-current-component.ts
|
|
4802
|
-
function updateCurrentComponent(params) {
|
|
4803
|
-
componentsActions.setPath(params.path);
|
|
4804
|
-
componentsActions.setCurrentComponentId(params.currentComponentId);
|
|
4805
|
-
}
|
|
4806
|
-
|
|
4807
|
-
// src/extended/components/edit-component/component-modal.tsx
|
|
4808
|
-
var React34 = __toESM(require("react"));
|
|
4809
|
-
var import_react18 = require("react");
|
|
4810
|
-
var import_react_dom = require("react-dom");
|
|
4811
|
-
var import_i18n30 = require("@wordpress/i18n");
|
|
4812
|
-
|
|
4813
|
-
// src/extended/components/edit-component/use-canvas-document.ts
|
|
4814
|
-
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
4815
|
-
function useCanvasDocument() {
|
|
4816
|
-
return (0, import_editor_v1_adapters6.__privateUseListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters6.getCanvasIframeDocument)());
|
|
4817
|
-
}
|
|
4818
|
-
|
|
4819
|
-
// src/extended/components/edit-component/use-element-rect.ts
|
|
4820
|
-
var import_react17 = require("react");
|
|
4821
|
-
var import_utils8 = require("@elementor/utils");
|
|
4822
|
-
function useElementRect(element) {
|
|
4823
|
-
const [rect, setRect] = (0, import_react17.useState)(new DOMRect(0, 0, 0, 0));
|
|
4824
|
-
const onChange = (0, import_utils8.throttle)(
|
|
4825
|
-
() => {
|
|
4826
|
-
setRect(element?.getBoundingClientRect() ?? new DOMRect(0, 0, 0, 0));
|
|
4827
|
-
},
|
|
4828
|
-
20,
|
|
4829
|
-
true
|
|
4830
|
-
);
|
|
4831
|
-
useScrollListener({ element, onChange });
|
|
4832
|
-
useResizeListener({ element, onChange });
|
|
4833
|
-
useMutationsListener({ element, onChange });
|
|
4834
|
-
(0, import_react17.useEffect)(
|
|
4835
|
-
() => () => {
|
|
4836
|
-
onChange.cancel();
|
|
4837
|
-
},
|
|
4838
|
-
[onChange]
|
|
4839
|
-
);
|
|
4840
|
-
return rect;
|
|
4841
|
-
}
|
|
4842
|
-
function useScrollListener({ element, onChange }) {
|
|
4843
|
-
(0, import_react17.useEffect)(() => {
|
|
4844
|
-
if (!element) {
|
|
4845
|
-
return;
|
|
4846
|
-
}
|
|
4847
|
-
const win = element.ownerDocument?.defaultView;
|
|
4848
|
-
win?.addEventListener("scroll", onChange, { passive: true });
|
|
4849
|
-
return () => {
|
|
4850
|
-
win?.removeEventListener("scroll", onChange);
|
|
4851
|
-
};
|
|
4852
|
-
}, [element, onChange]);
|
|
4853
|
-
}
|
|
4854
|
-
function useResizeListener({ element, onChange }) {
|
|
4855
|
-
(0, import_react17.useEffect)(() => {
|
|
4856
|
-
if (!element) {
|
|
4857
|
-
return;
|
|
4858
|
-
}
|
|
4859
|
-
const resizeObserver = new ResizeObserver(onChange);
|
|
4860
|
-
resizeObserver.observe(element);
|
|
4861
|
-
const win = element.ownerDocument?.defaultView;
|
|
4862
|
-
win?.addEventListener("resize", onChange, { passive: true });
|
|
4863
|
-
return () => {
|
|
4864
|
-
resizeObserver.disconnect();
|
|
4865
|
-
win?.removeEventListener("resize", onChange);
|
|
4866
|
-
};
|
|
4867
|
-
}, [element, onChange]);
|
|
4868
|
-
}
|
|
4869
|
-
function useMutationsListener({ element, onChange }) {
|
|
4870
|
-
(0, import_react17.useEffect)(() => {
|
|
4871
|
-
if (!element) {
|
|
4872
|
-
return;
|
|
4873
|
-
}
|
|
4874
|
-
const mutationObserver = new MutationObserver(onChange);
|
|
4875
|
-
mutationObserver.observe(element, { childList: true, subtree: true });
|
|
4876
|
-
return () => {
|
|
4877
|
-
mutationObserver.disconnect();
|
|
4878
|
-
};
|
|
4879
|
-
}, [element, onChange]);
|
|
4880
|
-
}
|
|
4881
|
-
|
|
4882
|
-
// src/extended/components/edit-component/component-modal.tsx
|
|
4883
|
-
function ComponentModal({ topLevelElementDom, onClose }) {
|
|
4884
|
-
const canvasDocument = useCanvasDocument();
|
|
4885
|
-
(0, import_react18.useEffect)(() => {
|
|
4886
|
-
const handleEsc = (event) => {
|
|
4887
|
-
if (event.key === "Escape") {
|
|
4888
|
-
onClose();
|
|
4889
|
-
}
|
|
4890
|
-
};
|
|
4891
|
-
canvasDocument?.body.addEventListener("keydown", handleEsc);
|
|
4892
|
-
return () => {
|
|
4893
|
-
canvasDocument?.body.removeEventListener("keydown", handleEsc);
|
|
4894
|
-
};
|
|
4895
|
-
}, [canvasDocument, onClose]);
|
|
4896
|
-
if (!canvasDocument?.body) {
|
|
4897
|
-
return null;
|
|
4898
|
-
}
|
|
4899
|
-
return (0, import_react_dom.createPortal)(
|
|
4900
|
-
/* @__PURE__ */ React34.createElement(React34.Fragment, null, /* @__PURE__ */ React34.createElement(BlockEditPage, null), /* @__PURE__ */ React34.createElement(Backdrop, { canvas: canvasDocument, element: topLevelElementDom, onClose })),
|
|
4901
|
-
canvasDocument.body
|
|
4902
|
-
);
|
|
4903
|
-
}
|
|
4904
|
-
function Backdrop({
|
|
4905
|
-
canvas,
|
|
4906
|
-
element,
|
|
4907
|
-
onClose
|
|
4908
|
-
}) {
|
|
4909
|
-
const rect = useElementRect(element);
|
|
4910
|
-
const clipPath = element ? getRectPath(rect, canvas.defaultView) : void 0;
|
|
4911
|
-
const backdropStyle = {
|
|
4912
|
-
position: "fixed",
|
|
4913
|
-
top: 0,
|
|
4914
|
-
left: 0,
|
|
4915
|
-
width: "100vw",
|
|
4916
|
-
height: "100vh",
|
|
4917
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
4918
|
-
zIndex: 999,
|
|
4919
|
-
pointerEvents: "painted",
|
|
4920
|
-
cursor: "pointer",
|
|
4921
|
-
clipPath
|
|
4922
|
-
};
|
|
4923
|
-
const handleKeyDown = (event) => {
|
|
4924
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
4925
|
-
event.preventDefault();
|
|
4926
|
-
onClose();
|
|
4927
|
-
}
|
|
4928
|
-
};
|
|
4929
|
-
return /* @__PURE__ */ React34.createElement(
|
|
4930
|
-
"div",
|
|
4931
|
-
{
|
|
4932
|
-
style: backdropStyle,
|
|
4933
|
-
onClick: onClose,
|
|
4934
|
-
onKeyDown: handleKeyDown,
|
|
4935
|
-
role: "button",
|
|
4936
|
-
tabIndex: 0,
|
|
4937
|
-
"aria-label": (0, import_i18n30.__)("Exit component editing mode", "elementor")
|
|
4938
|
-
}
|
|
4939
|
-
);
|
|
4940
|
-
}
|
|
4941
|
-
function getRectPath(rect, viewport) {
|
|
4942
|
-
const { x, y, width, height } = rect;
|
|
4943
|
-
const { innerWidth: vw, innerHeight: vh } = viewport;
|
|
4944
|
-
const path = `path(evenodd, 'M 0 0
|
|
4945
|
-
L ${vw} 0
|
|
4946
|
-
L ${vw} ${vh}
|
|
4947
|
-
L 0 ${vh}
|
|
4948
|
-
Z
|
|
4949
|
-
M ${x} ${y}
|
|
4950
|
-
L ${x + width} ${y}
|
|
4951
|
-
L ${x + width} ${y + height}
|
|
4952
|
-
L ${x} ${y + height}
|
|
4953
|
-
L ${x} ${y}
|
|
4954
|
-
Z'
|
|
4955
|
-
)`;
|
|
4956
|
-
return path.replace(/\s{2,}/g, " ");
|
|
4957
|
-
}
|
|
4958
|
-
function BlockEditPage() {
|
|
4959
|
-
const blockV3DocumentHandlesStyles = `
|
|
4960
|
-
.elementor-editor-active {
|
|
4961
|
-
& .elementor-section-wrap.ui-sortable {
|
|
4962
|
-
display: contents;
|
|
4963
|
-
}
|
|
4964
|
-
|
|
4965
|
-
& *[data-editable-elementor-document]:not(.elementor-edit-mode):hover {
|
|
4966
|
-
& .elementor-document-handle:not(.elementor-document-save-back-handle) {
|
|
4967
|
-
display: none;
|
|
4968
|
-
|
|
4969
|
-
&::before,
|
|
4970
|
-
& .elementor-document-handle__inner {
|
|
4971
|
-
display: none;
|
|
4972
|
-
}
|
|
4973
|
-
}
|
|
4974
|
-
}
|
|
4975
|
-
}
|
|
4976
|
-
`;
|
|
4977
|
-
return /* @__PURE__ */ React34.createElement("style", { "data-e-style-id": "e-block-v3-document-handles-styles" }, blockV3DocumentHandlesStyles);
|
|
4978
|
-
}
|
|
4979
|
-
|
|
4980
|
-
// src/extended/components/edit-component/edit-component.tsx
|
|
4981
|
-
function EditComponent() {
|
|
4982
|
-
const currentComponentId = useCurrentComponentId();
|
|
4983
|
-
useHandleDocumentSwitches();
|
|
4984
|
-
const navigateBack = useNavigateBack();
|
|
4985
|
-
const onClose = (0, import_utils9.throttle)(navigateBack, 100);
|
|
4986
|
-
const topLevelElementDom = useComponentDOMElement(currentComponentId ?? void 0);
|
|
4987
|
-
if (!currentComponentId) {
|
|
4988
|
-
return null;
|
|
4989
|
-
}
|
|
4990
|
-
return /* @__PURE__ */ React35.createElement(ComponentModal, { topLevelElementDom, onClose });
|
|
4991
|
-
}
|
|
4992
|
-
function useHandleDocumentSwitches() {
|
|
4993
|
-
const documentsManager = (0, import_editor_documents11.getV1DocumentsManager)();
|
|
4994
|
-
const currentComponentId = useCurrentComponentId();
|
|
4995
|
-
const path = (0, import_store34.__useSelector)(selectPath);
|
|
4996
|
-
(0, import_react19.useEffect)(() => {
|
|
4997
|
-
return (0, import_editor_v1_adapters7.__privateListenTo)((0, import_editor_v1_adapters7.commandEndEvent)("editor/documents/open"), () => {
|
|
4998
|
-
const nextDocument = documentsManager.getCurrent();
|
|
4999
|
-
if (nextDocument.id === currentComponentId) {
|
|
5000
|
-
return;
|
|
5001
|
-
}
|
|
5002
|
-
if (currentComponentId) {
|
|
5003
|
-
apiClient.unlockComponent(currentComponentId);
|
|
5004
|
-
}
|
|
5005
|
-
resetSanitizedComponents();
|
|
5006
|
-
const isComponent2 = nextDocument.config.type === COMPONENT_DOCUMENT_TYPE;
|
|
5007
|
-
if (!isComponent2) {
|
|
5008
|
-
updateCurrentComponent({ path: [], currentComponentId: null });
|
|
5009
|
-
return;
|
|
5010
|
-
}
|
|
5011
|
-
updateCurrentComponent({
|
|
5012
|
-
path: getUpdatedComponentPath(path, nextDocument),
|
|
5013
|
-
currentComponentId: nextDocument.id
|
|
5014
|
-
});
|
|
5015
|
-
});
|
|
5016
|
-
}, [path, documentsManager, currentComponentId]);
|
|
5017
|
-
}
|
|
5018
|
-
function getUpdatedComponentPath(path, nextDocument) {
|
|
5019
|
-
const componentIndex = path.findIndex(({ componentId }) => componentId === nextDocument.id);
|
|
5020
|
-
if (componentIndex >= 0) {
|
|
5021
|
-
return path.slice(0, componentIndex + 1);
|
|
5022
|
-
}
|
|
5023
|
-
const instanceId = nextDocument?.container.view?.el?.dataset.id;
|
|
5024
|
-
const instanceTitle = getInstanceTitle(instanceId, path);
|
|
5025
|
-
return [
|
|
5026
|
-
...path,
|
|
5027
|
-
{
|
|
5028
|
-
instanceId,
|
|
5029
|
-
instanceTitle,
|
|
5030
|
-
componentId: nextDocument.id
|
|
5031
|
-
}
|
|
5032
|
-
];
|
|
5033
|
-
}
|
|
5034
|
-
function getInstanceTitle(instanceId, path) {
|
|
5035
|
-
if (!instanceId) {
|
|
5036
|
-
return void 0;
|
|
5037
|
-
}
|
|
5038
|
-
const documentsManager = (0, import_editor_documents11.getV1DocumentsManager)();
|
|
5039
|
-
const parentDocId = path.at(-1)?.componentId ?? documentsManager.getInitialId();
|
|
5040
|
-
const parentDoc = documentsManager.get(parentDocId);
|
|
5041
|
-
const parentContainer = parentDoc?.container;
|
|
5042
|
-
const widget = parentContainer?.children?.findRecursive?.(
|
|
5043
|
-
(container) => container.id === instanceId
|
|
5044
|
-
);
|
|
5045
|
-
const editorSettings = widget?.model?.get?.("editor_settings");
|
|
5046
|
-
return editorSettings?.title;
|
|
5047
|
-
}
|
|
5048
|
-
function useComponentDOMElement(id2) {
|
|
5049
|
-
const { componentContainerDomElement, topLevelElementDom } = getComponentDOMElements(id2);
|
|
5050
|
-
const [currentElementDom, setCurrentElementDom] = (0, import_react19.useState)(topLevelElementDom);
|
|
5051
|
-
(0, import_react19.useEffect)(() => {
|
|
5052
|
-
setCurrentElementDom(topLevelElementDom);
|
|
5053
|
-
}, [topLevelElementDom]);
|
|
5054
|
-
(0, import_react19.useEffect)(() => {
|
|
5055
|
-
if (!componentContainerDomElement) {
|
|
5056
|
-
return;
|
|
5057
|
-
}
|
|
5058
|
-
const mutationObserver = new MutationObserver(() => {
|
|
5059
|
-
const newElementDom = componentContainerDomElement.children[0];
|
|
5060
|
-
setCurrentElementDom(newElementDom);
|
|
5061
|
-
});
|
|
5062
|
-
mutationObserver.observe(componentContainerDomElement, { childList: true });
|
|
5063
|
-
return () => {
|
|
5064
|
-
mutationObserver.disconnect();
|
|
5065
|
-
};
|
|
5066
|
-
}, [componentContainerDomElement]);
|
|
5067
|
-
return currentElementDom;
|
|
5068
|
-
}
|
|
5069
|
-
function getComponentDOMElements(id2) {
|
|
5070
|
-
if (!id2) {
|
|
5071
|
-
return { componentContainerDomElement: null, topLevelElementDom: null };
|
|
5072
|
-
}
|
|
5073
|
-
const documentsManager = (0, import_editor_documents11.getV1DocumentsManager)();
|
|
5074
|
-
const currentComponent = documentsManager.get(id2);
|
|
5075
|
-
const componentContainer = currentComponent?.container;
|
|
5076
|
-
const componentContainerDomElement = componentContainer?.view?.el?.children?.[0] ?? null;
|
|
5077
|
-
const topLevelElementDom = componentContainerDomElement?.children[0] ?? null;
|
|
5078
|
-
return { componentContainerDomElement, topLevelElementDom };
|
|
5079
|
-
}
|
|
5080
|
-
|
|
5081
|
-
// src/extended/components/instance-editing-panel/instance-editing-panel.tsx
|
|
5082
|
-
var React36 = __toESM(require("react"));
|
|
5083
|
-
var import_icons19 = require("@elementor/icons");
|
|
5084
|
-
var import_ui27 = require("@elementor/ui");
|
|
5085
|
-
var import_i18n31 = require("@wordpress/i18n");
|
|
5086
|
-
function ExtendedInstanceEditingPanel() {
|
|
5087
|
-
const { canEdit } = useComponentsPermissions();
|
|
5088
|
-
const data = useInstancePanelData();
|
|
5089
|
-
if (!data) {
|
|
5090
|
-
return null;
|
|
5091
|
-
}
|
|
5092
|
-
const { componentId, component, overrides, overridableProps, groups, isEmpty, componentInstanceId } = data;
|
|
5093
|
-
const panelTitle = (0, import_i18n31.__)("Edit %s", "elementor").replace("%s", component.name);
|
|
5094
|
-
const handleEditComponent = () => switchToComponent(componentId, componentInstanceId);
|
|
5095
|
-
return /* @__PURE__ */ React36.createElement(import_ui27.Box, { "data-testid": "instance-editing-panel" }, /* @__PURE__ */ React36.createElement(
|
|
5096
|
-
ComponentInstanceProvider,
|
|
5097
|
-
{
|
|
5098
|
-
componentId,
|
|
5099
|
-
overrides,
|
|
5100
|
-
overridableProps
|
|
5101
|
-
},
|
|
5102
|
-
/* @__PURE__ */ React36.createElement(
|
|
5103
|
-
InstancePanelHeader,
|
|
5104
|
-
{
|
|
5105
|
-
componentName: component.name,
|
|
5106
|
-
actions: canEdit ? /* @__PURE__ */ React36.createElement(
|
|
5107
|
-
EditComponentAction,
|
|
5108
|
-
{
|
|
5109
|
-
label: panelTitle,
|
|
5110
|
-
onClick: handleEditComponent,
|
|
5111
|
-
icon: import_icons19.PencilIcon
|
|
5112
|
-
}
|
|
5113
|
-
) : void 0
|
|
5114
|
-
}
|
|
5115
|
-
),
|
|
5116
|
-
/* @__PURE__ */ React36.createElement(
|
|
5117
|
-
InstancePanelBody,
|
|
5118
|
-
{
|
|
5119
|
-
groups,
|
|
5120
|
-
isEmpty,
|
|
5121
|
-
emptyState: /* @__PURE__ */ React36.createElement(EmptyState2, { onEditComponent: canEdit ? handleEditComponent : void 0 }),
|
|
5122
|
-
componentInstanceId
|
|
5123
|
-
}
|
|
5124
|
-
)
|
|
5125
|
-
));
|
|
5126
|
-
}
|
|
5127
|
-
|
|
5128
|
-
// src/extended/components/overridable-props/overridable-prop-control.tsx
|
|
5129
|
-
var React37 = __toESM(require("react"));
|
|
5130
|
-
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
5131
|
-
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
5132
|
-
function OverridablePropControl({
|
|
5133
|
-
OriginalControl: OriginalControl2,
|
|
5134
|
-
...props
|
|
5135
|
-
}) {
|
|
5136
|
-
const { elementType } = (0, import_editor_editing_panel6.useElement)();
|
|
5137
|
-
const { value, bind, setValue, placeholder, ...propContext } = (0, import_editor_controls5.useBoundProp)(componentOverridablePropTypeUtil);
|
|
5138
|
-
const componentId = useCurrentComponentId();
|
|
5139
|
-
const overridableProps = useOverridableProps(componentId);
|
|
5140
|
-
const filteredReplacements = (0, import_editor_controls5.getControlReplacements)().filter(
|
|
5141
|
-
(r) => !r.id || r.id !== OVERRIDABLE_PROP_REPLACEMENT_ID
|
|
5142
|
-
);
|
|
5143
|
-
if (!componentId) {
|
|
5144
|
-
return null;
|
|
5145
|
-
}
|
|
5146
|
-
if (!value?.override_key) {
|
|
5147
|
-
throw new Error("Override key is required");
|
|
5148
|
-
}
|
|
5149
|
-
const isComponentInstance2 = elementType.key === "e-component";
|
|
5150
|
-
const overridablePropData = overridableProps?.props?.[value.override_key];
|
|
5151
|
-
const setOverridableValue = (newValue) => {
|
|
5152
|
-
const propValue2 = {
|
|
5153
|
-
...value,
|
|
5154
|
-
origin_value: newValue[bind]
|
|
5155
|
-
};
|
|
5156
|
-
setValue(propValue2);
|
|
5157
|
-
if (!isComponentInstance2) {
|
|
5158
|
-
updateOverridableProp(componentId, propValue2, overridablePropData?.originPropFields);
|
|
5159
|
-
}
|
|
5160
|
-
};
|
|
5161
|
-
const defaultPropType = elementType.propsSchema[bind];
|
|
5162
|
-
const overridePropType = overridablePropData ? getPropTypeForComponentOverride(overridablePropData) : void 0;
|
|
5163
|
-
const resolvedPropType = overridePropType ?? defaultPropType;
|
|
5164
|
-
if (!resolvedPropType) {
|
|
5165
|
-
return null;
|
|
5166
|
-
}
|
|
5167
|
-
const propType = (0, import_editor_editing_panel6.createTopLevelObjectType)({
|
|
5168
|
-
schema: {
|
|
5169
|
-
[bind]: resolvedPropType
|
|
5170
|
-
}
|
|
5171
|
-
});
|
|
5172
|
-
const propValue = isComponentInstance2 ? (value.origin_value?.value).override_value : value.origin_value;
|
|
5173
|
-
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
5174
|
-
return /* @__PURE__ */ React37.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React37.createElement(
|
|
5175
|
-
import_editor_controls5.PropProvider,
|
|
5176
|
-
{
|
|
5177
|
-
...propContext,
|
|
5178
|
-
propType,
|
|
5179
|
-
setValue: setOverridableValue,
|
|
5180
|
-
value: {
|
|
5181
|
-
[bind]: propValue
|
|
5182
|
-
},
|
|
5183
|
-
placeholder: objectPlaceholder
|
|
5184
|
-
},
|
|
5185
|
-
/* @__PURE__ */ React37.createElement(import_editor_controls5.PropKeyProvider, { bind }, /* @__PURE__ */ React37.createElement(import_editor_controls5.ControlReplacementsProvider, { replacements: filteredReplacements }, /* @__PURE__ */ React37.createElement(ControlWithReplacements, { OriginalControl: OriginalControl2, props })))
|
|
5186
|
-
));
|
|
5187
|
-
}
|
|
5188
|
-
function ControlWithReplacements({
|
|
5189
|
-
OriginalControl: OriginalControl2,
|
|
5190
|
-
props
|
|
5191
|
-
}) {
|
|
5192
|
-
const { ControlToRender, isReplaced } = (0, import_editor_controls5.useControlReplacement)(OriginalControl2);
|
|
5193
|
-
if (isReplaced) {
|
|
5194
|
-
const ReplacementControl = ControlToRender;
|
|
5195
|
-
return /* @__PURE__ */ React37.createElement(ReplacementControl, { ...props, OriginalControl: OriginalControl2 });
|
|
5196
|
-
}
|
|
5197
|
-
return /* @__PURE__ */ React37.createElement(OriginalControl2, { ...props });
|
|
5198
|
-
}
|
|
5199
|
-
|
|
5200
|
-
// src/extended/components/overridable-props/overridable-prop-indicator.tsx
|
|
5201
|
-
var React39 = __toESM(require("react"));
|
|
5202
|
-
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
5203
|
-
var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
|
|
5204
|
-
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5205
|
-
var import_ui29 = require("@elementor/ui");
|
|
5206
|
-
var import_i18n33 = require("@wordpress/i18n");
|
|
5207
|
-
|
|
5208
|
-
// src/extended/store/actions/set-overridable-prop.ts
|
|
5209
|
-
var import_utils10 = require("@elementor/utils");
|
|
5210
|
-
function setOverridableProp({
|
|
5211
|
-
componentId,
|
|
5212
|
-
overrideKey,
|
|
5213
|
-
elementId,
|
|
5214
|
-
label,
|
|
5215
|
-
groupId,
|
|
5216
|
-
propKey,
|
|
5217
|
-
elType,
|
|
5218
|
-
widgetType,
|
|
5219
|
-
originValue,
|
|
5220
|
-
originPropFields,
|
|
5221
|
-
source
|
|
5222
|
-
}) {
|
|
5223
|
-
const overridableProps = componentsSelectors.getOverridableProps(componentId);
|
|
5224
|
-
if (!overridableProps) {
|
|
5225
|
-
return;
|
|
5226
|
-
}
|
|
5227
|
-
const existingOverridableProp = overrideKey ? overridableProps.props[overrideKey] : null;
|
|
5228
|
-
const duplicatedTargetProps = Object.values(overridableProps.props).filter(
|
|
5229
|
-
(prop) => prop.elementId === elementId && prop.propKey === propKey && prop !== existingOverridableProp
|
|
5230
|
-
);
|
|
5231
|
-
const { groups: groupsAfterResolve, groupId: currentGroupId } = resolveOrCreateGroup(
|
|
5232
|
-
overridableProps.groups,
|
|
5233
|
-
groupId || existingOverridableProp?.groupId || void 0
|
|
5234
|
-
);
|
|
5235
|
-
const overridableProp = {
|
|
5236
|
-
overrideKey: existingOverridableProp?.overrideKey || (0, import_utils10.generateUniqueId)("prop"),
|
|
5237
|
-
label,
|
|
5238
|
-
elementId,
|
|
5239
|
-
propKey,
|
|
5240
|
-
widgetType,
|
|
5241
|
-
elType,
|
|
5242
|
-
originValue,
|
|
5243
|
-
groupId: currentGroupId,
|
|
5244
|
-
originPropFields
|
|
5245
|
-
};
|
|
5246
|
-
const stateAfterRemovingDuplicates = removePropsFromState(
|
|
5247
|
-
{ ...overridableProps, groups: groupsAfterResolve },
|
|
5248
|
-
duplicatedTargetProps
|
|
5249
|
-
);
|
|
5250
|
-
const props = {
|
|
5251
|
-
...stateAfterRemovingDuplicates.props,
|
|
5252
|
-
[overridableProp.overrideKey]: overridableProp
|
|
5253
|
-
};
|
|
5254
|
-
let groups = addPropToGroup(stateAfterRemovingDuplicates.groups, currentGroupId, overridableProp.overrideKey);
|
|
5255
|
-
groups = ensureGroupInOrder(groups, currentGroupId);
|
|
5256
|
-
const isChangingGroups = existingOverridableProp && existingOverridableProp.groupId !== currentGroupId;
|
|
5257
|
-
if (isChangingGroups) {
|
|
5258
|
-
groups = removePropFromGroup(groups, existingOverridableProp.groupId, overridableProp.overrideKey);
|
|
5259
|
-
}
|
|
5260
|
-
componentsActions.setOverridableProps(componentId, { props, groups });
|
|
5261
|
-
const isNewProperty = !existingOverridableProp;
|
|
5262
|
-
if (isNewProperty) {
|
|
5263
|
-
const currentComponent = componentsSelectors.getCurrentComponent();
|
|
5264
|
-
trackComponentEvent({
|
|
5265
|
-
action: "propertyExposed",
|
|
5266
|
-
source,
|
|
5267
|
-
component_uid: currentComponent?.uid,
|
|
5268
|
-
property_id: overridableProp.overrideKey,
|
|
5269
|
-
property_path: propKey,
|
|
5270
|
-
property_name: label,
|
|
5271
|
-
element_type: widgetType ?? elType
|
|
5272
|
-
});
|
|
5273
|
-
}
|
|
5274
|
-
return overridableProp;
|
|
5275
|
-
}
|
|
5276
|
-
|
|
5277
|
-
// src/extended/components/overridable-props/indicator.tsx
|
|
5278
|
-
var React38 = __toESM(require("react"));
|
|
5279
|
-
var import_react20 = require("react");
|
|
5280
|
-
var import_icons20 = require("@elementor/icons");
|
|
5281
|
-
var import_ui28 = require("@elementor/ui");
|
|
5282
|
-
var import_i18n32 = require("@wordpress/i18n");
|
|
5283
|
-
var SIZE2 = "tiny";
|
|
5284
|
-
var IconContainer = (0, import_ui28.styled)(import_ui28.Box)`
|
|
5285
|
-
pointer-events: none;
|
|
5286
|
-
opacity: 0;
|
|
5287
|
-
transition: opacity 0.2s ease-in-out;
|
|
5288
|
-
|
|
5289
|
-
& > svg {
|
|
5290
|
-
position: absolute;
|
|
5291
|
-
top: 50%;
|
|
5292
|
-
left: 50%;
|
|
5293
|
-
transform: translate( -50%, -50% );
|
|
5294
|
-
width: 10px;
|
|
5295
|
-
height: 10px;
|
|
5296
|
-
fill: ${({ theme }) => theme.palette.primary.contrastText};
|
|
5297
|
-
stroke: ${({ theme }) => theme.palette.primary.contrastText};
|
|
5298
|
-
stroke-width: 2px;
|
|
5299
|
-
}
|
|
5300
|
-
`;
|
|
5301
|
-
var Content = (0, import_ui28.styled)(import_ui28.Box)`
|
|
5302
|
-
position: relative;
|
|
5303
|
-
display: flex;
|
|
5304
|
-
align-items: center;
|
|
5305
|
-
justify-content: center;
|
|
5306
|
-
cursor: pointer;
|
|
5307
|
-
width: 16px;
|
|
5308
|
-
height: 16px;
|
|
5309
|
-
margin-inline: ${({ theme }) => theme.spacing(0.5)};
|
|
5310
|
-
|
|
5311
|
-
&:before {
|
|
5312
|
-
content: '';
|
|
5313
|
-
display: block;
|
|
5314
|
-
position: absolute;
|
|
5315
|
-
top: 50%;
|
|
5316
|
-
left: 50%;
|
|
5317
|
-
transform: translate( -50%, -50% ) rotate( 45deg );
|
|
5318
|
-
width: 5px;
|
|
5319
|
-
height: 5px;
|
|
5320
|
-
border-radius: 1px;
|
|
5321
|
-
background-color: ${({ theme }) => theme.palette.primary.main};
|
|
5322
|
-
transition: all 0.1s ease-in-out;
|
|
5323
|
-
}
|
|
5324
|
-
|
|
5325
|
-
&:hover,
|
|
5326
|
-
&.enlarged {
|
|
5327
|
-
&:before {
|
|
5328
|
-
width: 12px;
|
|
5329
|
-
height: 12px;
|
|
5330
|
-
border-radius: 2px;
|
|
5331
|
-
}
|
|
5332
|
-
|
|
5333
|
-
.icon {
|
|
5334
|
-
opacity: 1;
|
|
5335
|
-
}
|
|
5336
|
-
}
|
|
5337
|
-
`;
|
|
5338
|
-
var Indicator2 = (0, import_react20.forwardRef)(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React38.createElement(
|
|
5339
|
-
Content,
|
|
5340
|
-
{
|
|
5341
|
-
role: "button",
|
|
5342
|
-
ref,
|
|
5343
|
-
...props,
|
|
5344
|
-
className: isOpen || isOverridable ? "enlarged" : "",
|
|
5345
|
-
"aria-label": isOverridable ? (0, import_i18n32.__)("Overridable property", "elementor") : (0, import_i18n32.__)("Make prop overridable", "elementor")
|
|
5346
|
-
},
|
|
5347
|
-
/* @__PURE__ */ React38.createElement(IconContainer, { className: "icon" }, isOverridable ? /* @__PURE__ */ React38.createElement(import_icons20.CheckIcon, { fontSize: SIZE2 }) : /* @__PURE__ */ React38.createElement(import_icons20.PlusIcon, { fontSize: SIZE2 }))
|
|
5348
|
-
));
|
|
5349
|
-
|
|
5350
|
-
// src/extended/components/overridable-props/overridable-prop-indicator.tsx
|
|
5351
|
-
function OverridablePropIndicator() {
|
|
5352
|
-
const { propType } = (0, import_editor_controls6.useBoundProp)();
|
|
5353
|
-
const componentId = useCurrentComponentId();
|
|
5354
|
-
const overridableProps = useSanitizeOverridableProps(componentId);
|
|
5355
|
-
if (!isPropAllowed(propType) || !componentId || !overridableProps) {
|
|
5356
|
-
return null;
|
|
5357
|
-
}
|
|
5358
|
-
return /* @__PURE__ */ React39.createElement(Content2, { componentId, overridableProps });
|
|
5359
|
-
}
|
|
5360
|
-
function Content2({ componentId, overridableProps }) {
|
|
5361
|
-
const {
|
|
5362
|
-
element: { id: elementId },
|
|
5363
|
-
elementType
|
|
5364
|
-
} = (0, import_editor_editing_panel7.useElement)();
|
|
5365
|
-
const { value, bind, propType } = (0, import_editor_controls6.useBoundProp)();
|
|
5366
|
-
const contextOverridableValue = useOverridablePropValue();
|
|
5367
|
-
const componentInstanceElement = useComponentInstanceElement();
|
|
5368
|
-
const { value: boundPropOverridableValue, setValue: setOverridableValue } = (0, import_editor_controls6.useBoundProp)(
|
|
5369
|
-
componentOverridablePropTypeUtil
|
|
5370
|
-
);
|
|
5371
|
-
const overridableValue = boundPropOverridableValue ?? contextOverridableValue;
|
|
5372
|
-
const popupState = (0, import_ui29.usePopupState)({
|
|
5373
|
-
variant: "popover"
|
|
5374
|
-
});
|
|
5375
|
-
const triggerProps = (0, import_ui29.bindTrigger)(popupState);
|
|
5376
|
-
const popoverProps = (0, import_ui29.bindPopover)(popupState);
|
|
5377
|
-
const { elType } = (0, import_editor_elements18.getWidgetsCache)()?.[elementType.key] ?? { elType: "widget" };
|
|
5378
|
-
const handleSubmit = ({ label, group }) => {
|
|
5379
|
-
const propTypeDefault = propType.default ?? {};
|
|
5380
|
-
const originValue = resolveOverridePropValue(overridableValue?.origin_value) ?? value ?? propTypeDefault;
|
|
5381
|
-
const matchingOverridableProp = overridableValue ? overridableProps?.props?.[overridableValue.override_key] : void 0;
|
|
5382
|
-
const overridablePropConfig = setOverridableProp({
|
|
5383
|
-
componentId,
|
|
5384
|
-
overrideKey: overridableValue?.override_key ?? null,
|
|
5385
|
-
elementId: componentInstanceElement?.element.id ?? elementId,
|
|
5386
|
-
label,
|
|
5387
|
-
groupId: group,
|
|
5388
|
-
propKey: bind,
|
|
5389
|
-
elType: elType ?? "widget",
|
|
5390
|
-
widgetType: componentInstanceElement?.elementType.key ?? elementType.key,
|
|
5391
|
-
originValue,
|
|
5392
|
-
originPropFields: matchingOverridableProp?.originPropFields,
|
|
5393
|
-
source: "user"
|
|
5394
|
-
});
|
|
5395
|
-
if (!overridableValue && overridablePropConfig) {
|
|
5396
|
-
setOverridableValue({
|
|
5397
|
-
override_key: overridablePropConfig.overrideKey,
|
|
5398
|
-
origin_value: originValue
|
|
5399
|
-
});
|
|
5400
|
-
}
|
|
5401
|
-
popupState.close();
|
|
5402
|
-
};
|
|
5403
|
-
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
5404
|
-
return /* @__PURE__ */ React39.createElement(React39.Fragment, null, /* @__PURE__ */ React39.createElement(import_ui29.Tooltip, { placement: "top", title: (0, import_i18n33.__)("Override Property", "elementor") }, /* @__PURE__ */ React39.createElement(Indicator2, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React39.createElement(
|
|
5405
|
-
import_ui29.Popover,
|
|
5406
|
-
{
|
|
5407
|
-
disableScrollLock: true,
|
|
5408
|
-
anchorOrigin: {
|
|
5409
|
-
vertical: "bottom",
|
|
5410
|
-
horizontal: "right"
|
|
5411
|
-
},
|
|
5412
|
-
transformOrigin: {
|
|
5413
|
-
vertical: "top",
|
|
5414
|
-
horizontal: "right"
|
|
5415
|
-
},
|
|
5416
|
-
PaperProps: {
|
|
5417
|
-
sx: { my: 2.5 }
|
|
5418
|
-
},
|
|
5419
|
-
...popoverProps
|
|
5420
|
-
},
|
|
5421
|
-
/* @__PURE__ */ React39.createElement(
|
|
5422
|
-
OverridablePropForm,
|
|
5423
|
-
{
|
|
5424
|
-
onSubmit: handleSubmit,
|
|
5425
|
-
groups: overridableProps?.groups.order.map((groupId) => ({
|
|
5426
|
-
value: groupId,
|
|
5427
|
-
label: overridableProps.groups.items[groupId].label
|
|
5428
|
-
})),
|
|
5429
|
-
existingLabels: Object.values(overridableProps?.props ?? {}).map((prop) => prop.label),
|
|
5430
|
-
currentValue: overridableConfig
|
|
5431
|
-
}
|
|
5432
|
-
)
|
|
5433
|
-
));
|
|
5434
|
-
}
|
|
5435
|
-
function isPropAllowed(propType) {
|
|
5436
|
-
return propType.meta.overridable !== false;
|
|
5437
|
-
}
|
|
5438
|
-
|
|
5439
|
-
// src/extended/mcp/index.ts
|
|
5440
|
-
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
5441
|
-
|
|
5442
|
-
// src/extended/mcp/save-as-component-tool.ts
|
|
5443
|
-
var import_editor_canvas7 = require("@elementor/editor-canvas");
|
|
5444
|
-
var import_editor_elements19 = require("@elementor/editor-elements");
|
|
5445
|
-
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
5446
|
-
var import_http_client2 = require("@elementor/http-client");
|
|
5447
|
-
var import_schema6 = require("@elementor/schema");
|
|
5448
|
-
var import_utils11 = require("@elementor/utils");
|
|
5449
|
-
var InputSchema = {
|
|
5450
|
-
element_id: import_schema6.z.string().describe(
|
|
5451
|
-
'The unique identifier of the element to save as a component. Use the "list-elements" tool to find available element IDs in the current document.'
|
|
5452
|
-
),
|
|
5453
|
-
component_name: import_schema6.z.string().describe("The name for the new component. Should be descriptive and unique among existing components."),
|
|
5454
|
-
overridable_props: import_schema6.z.object({
|
|
5455
|
-
props: import_schema6.z.record(
|
|
5456
|
-
import_schema6.z.object({
|
|
5457
|
-
elementId: import_schema6.z.string().describe("The id of the child element that you want to override its settings"),
|
|
5458
|
-
propKey: import_schema6.z.string().describe(
|
|
5459
|
-
'The property key of the child element that you want to override its settings (e.g., "text", "url", "tag"). To get the available propKeys for an element, use the "get-element-type-config" tool.'
|
|
5460
|
-
),
|
|
5461
|
-
label: import_schema6.z.string().describe(
|
|
5462
|
-
'A unique, user-friendly display name for this property (e.g., "Hero Headline", "CTA Button Text"). Must be unique within the same component.'
|
|
5463
|
-
),
|
|
5464
|
-
group: import_schema6.z.string().optional().describe("Non unique, optional property grouping")
|
|
5465
|
-
})
|
|
5466
|
-
)
|
|
5467
|
-
}).optional().describe(
|
|
5468
|
-
'Overridable properties configuration. Specify which CHILD element properties can be customized. Only elementId and propKey are required; To get the available propKeys for a child element you must use the "get-element-type-config" tool.'
|
|
5469
|
-
),
|
|
5470
|
-
groups: import_schema6.z.array(import_schema6.z.string()).describe("Property Groups, by order, unique values").optional()
|
|
5471
|
-
};
|
|
5472
|
-
var OutputSchema = {
|
|
5473
|
-
message: import_schema6.z.string().optional().describe("Additional information about the operation result"),
|
|
5474
|
-
component_uid: import_schema6.z.string().optional().describe("The unique identifier of the newly created component (only present on success)")
|
|
5475
|
-
};
|
|
5476
|
-
var ERROR_MESSAGES3 = {
|
|
5477
|
-
ELEMENT_NOT_FOUND: "Element not found. Use 'list-elements' to get valid element IDs.",
|
|
5478
|
-
ELEMENT_NOT_ONE_OF_TYPES: (validTypes) => `Element is not one of the following types: ${validTypes.join(", ")}`,
|
|
5479
|
-
ELEMENT_IS_LOCKED: "Cannot save a locked element as a component."
|
|
5480
|
-
};
|
|
5481
|
-
var handleSaveAsComponent = async (params) => {
|
|
5482
|
-
const {
|
|
5483
|
-
groups = [],
|
|
5484
|
-
element_id: elementId,
|
|
5485
|
-
component_name: componentName,
|
|
5486
|
-
overridable_props: overridablePropsInput
|
|
5487
|
-
} = params;
|
|
5488
|
-
const validElementTypes = getValidElementTypes();
|
|
5489
|
-
const container = (0, import_editor_elements19.getContainer)(elementId);
|
|
5490
|
-
if (!container) {
|
|
5491
|
-
throw new Error(ERROR_MESSAGES3.ELEMENT_NOT_FOUND);
|
|
5492
|
-
}
|
|
5493
|
-
const elType = container.model.get("elType");
|
|
5494
|
-
if (!validElementTypes.includes(elType)) {
|
|
5495
|
-
throw new Error(ERROR_MESSAGES3.ELEMENT_NOT_ONE_OF_TYPES(validElementTypes));
|
|
5496
|
-
}
|
|
5497
|
-
const element = container.model.toJSON({ remove: ["default"] });
|
|
5498
|
-
if (element?.isLocked) {
|
|
5499
|
-
throw new Error(ERROR_MESSAGES3.ELEMENT_IS_LOCKED);
|
|
5500
|
-
}
|
|
5501
|
-
const groupsWithDefaultGroup = groups.indexOf("Default") >= 0 ? [...groups] : ["Default", ...groups];
|
|
5502
|
-
const propertyGroups = groupsWithDefaultGroup.map((groupName) => ({
|
|
5503
|
-
id: (0, import_utils11.generateUniqueId)("group"),
|
|
5504
|
-
label: groupName,
|
|
5505
|
-
props: []
|
|
5506
|
-
}));
|
|
5507
|
-
const overridableProps = overridablePropsInput ? enrichOverridableProps(overridablePropsInput, element, propertyGroups) : void 0;
|
|
5508
|
-
if (overridableProps) {
|
|
5509
|
-
updateElementDataWithOverridableProps(element, overridableProps);
|
|
5510
|
-
}
|
|
5511
|
-
const uid = (0, import_utils11.generateUniqueId)("component");
|
|
5512
|
-
try {
|
|
5513
|
-
await apiClient.validate({
|
|
5514
|
-
items: [
|
|
5515
|
-
{ uid, title: componentName, elements: [element], settings: { overridable_props: overridableProps } }
|
|
5516
|
-
]
|
|
5517
|
-
});
|
|
5518
|
-
} catch (error) {
|
|
5519
|
-
if (error instanceof import_http_client2.AxiosError) {
|
|
5520
|
-
throw new Error(error.response?.data.messge);
|
|
5521
|
-
}
|
|
5522
|
-
throw new Error("Unknown error");
|
|
5523
|
-
}
|
|
5524
|
-
await createUnpublishedComponent({
|
|
5525
|
-
name: componentName,
|
|
5526
|
-
element,
|
|
5527
|
-
eventData: null,
|
|
5528
|
-
uid,
|
|
5529
|
-
overridableProps,
|
|
5530
|
-
source: "mcp_tool"
|
|
5531
|
-
});
|
|
5532
|
-
return {
|
|
5533
|
-
status: "ok",
|
|
5534
|
-
message: `Component "${componentName}" created successfully.`,
|
|
5535
|
-
component_uid: uid
|
|
5536
|
-
};
|
|
5537
|
-
};
|
|
5538
|
-
function enrichOverridableProps(input, rootElement, propertGroups) {
|
|
5539
|
-
const enrichedProps = {};
|
|
5540
|
-
const enrichedGroups = {};
|
|
5541
|
-
const defaultGroup = propertGroups.find((g) => g.label === "Default");
|
|
5542
|
-
if (!defaultGroup) {
|
|
5543
|
-
throw new Error("Internal mcp error: could not generate default group");
|
|
5544
|
-
}
|
|
5545
|
-
Object.entries(input.props).forEach(([, prop]) => {
|
|
5546
|
-
const { elementId, propKey, label, group = "Default" } = prop;
|
|
5547
|
-
const targetGroup = propertGroups.find((g) => g.label === group) || defaultGroup;
|
|
5548
|
-
const targetGroupId = targetGroup.id;
|
|
5549
|
-
const element = findElementById(rootElement, elementId);
|
|
5550
|
-
if (!element) {
|
|
5551
|
-
throw new Error(`Element with ID "${elementId}" not found in component`);
|
|
5552
|
-
}
|
|
5553
|
-
const elType = element.elType;
|
|
5554
|
-
const widgetType = element.widgetType || element.elType;
|
|
5555
|
-
const elementType = (0, import_editor_elements19.getElementType)(widgetType);
|
|
5556
|
-
if (!elementType) {
|
|
5557
|
-
throw new Error(
|
|
5558
|
-
`Element type "${widgetType}" is not atomic or does not have a settings schema. Cannot expose property "${propKey}" for element "${elementId}".`
|
|
5559
|
-
);
|
|
5560
|
-
}
|
|
5561
|
-
if (!elementType.propsSchema[propKey]) {
|
|
5562
|
-
const availableProps = Object.keys(elementType.propsSchema).join(", ");
|
|
5563
|
-
throw new Error(
|
|
5564
|
-
`Property "${propKey}" does not exist in element "${elementId}" (type: ${widgetType}). Available properties: ${availableProps}`
|
|
5565
|
-
);
|
|
5566
|
-
}
|
|
5567
|
-
const overrideKey = (0, import_utils11.generateUniqueId)("prop");
|
|
5568
|
-
const originValue = element.settings?.[propKey] ? element.settings[propKey] : elementType.propsSchema[propKey].default ?? null;
|
|
5569
|
-
if (!enrichedGroups[targetGroupId]) {
|
|
5570
|
-
enrichedGroups[targetGroupId] = {
|
|
5571
|
-
id: targetGroupId,
|
|
5572
|
-
label: targetGroup.label,
|
|
5573
|
-
props: []
|
|
5574
|
-
};
|
|
5575
|
-
}
|
|
5576
|
-
enrichedGroups[targetGroupId].props.push(overrideKey);
|
|
5577
|
-
enrichedProps[overrideKey] = {
|
|
5578
|
-
overrideKey,
|
|
5579
|
-
label,
|
|
5580
|
-
elementId,
|
|
5581
|
-
propKey,
|
|
5582
|
-
elType,
|
|
5583
|
-
widgetType,
|
|
5584
|
-
originValue,
|
|
5585
|
-
groupId: targetGroupId
|
|
5586
|
-
};
|
|
5587
|
-
});
|
|
5588
|
-
return {
|
|
5589
|
-
props: enrichedProps,
|
|
5590
|
-
groups: {
|
|
5591
|
-
items: enrichedGroups,
|
|
5592
|
-
order: [defaultGroup.id]
|
|
5593
|
-
}
|
|
5594
|
-
};
|
|
5595
|
-
}
|
|
5596
|
-
function updateElementDataWithOverridableProps(rootElement, overridableProps) {
|
|
5597
|
-
Object.values(overridableProps.props).forEach((prop) => {
|
|
5598
|
-
const element = findElementById(rootElement, prop.elementId);
|
|
5599
|
-
if (!element || !element.settings) {
|
|
5600
|
-
return;
|
|
5601
|
-
}
|
|
5602
|
-
element.settings[prop.propKey] = {
|
|
5603
|
-
$$type: "overridable",
|
|
5604
|
-
value: {
|
|
5605
|
-
override_key: prop.overrideKey,
|
|
5606
|
-
origin_value: prop.originValue
|
|
5607
|
-
}
|
|
5608
|
-
};
|
|
5609
|
-
});
|
|
5610
|
-
}
|
|
5611
|
-
function findElementById(root, targetId) {
|
|
5612
|
-
if (root.id === targetId) {
|
|
5613
|
-
return root;
|
|
5614
|
-
}
|
|
5615
|
-
if (root.elements) {
|
|
5616
|
-
for (const child of root.elements) {
|
|
5617
|
-
const found = findElementById(child, targetId);
|
|
5618
|
-
if (found) {
|
|
5619
|
-
return found;
|
|
5620
|
-
}
|
|
5621
|
-
}
|
|
5622
|
-
}
|
|
5623
|
-
return null;
|
|
5624
|
-
}
|
|
5625
|
-
function getValidElementTypes() {
|
|
5626
|
-
const types = (0, import_editor_elements19.getWidgetsCache)();
|
|
5627
|
-
if (!types) {
|
|
5628
|
-
return [];
|
|
5629
|
-
}
|
|
5630
|
-
return Object.entries(types).reduce((acc, [type, value]) => {
|
|
5631
|
-
if (!value.atomic_props_schema || !value.show_in_panel || value.elType === "widget") {
|
|
5632
|
-
return acc;
|
|
5633
|
-
}
|
|
5634
|
-
acc.push(type);
|
|
5635
|
-
return acc;
|
|
5636
|
-
}, []);
|
|
5637
|
-
}
|
|
5638
|
-
var generatePrompt = () => {
|
|
5639
|
-
const saveAsComponentPrompt = (0, import_editor_mcp.toolPrompts)("save-as-component");
|
|
5640
|
-
saveAsComponentPrompt.description(`
|
|
5641
|
-
Save an existing element as a reusable component in the Elementor editor.
|
|
5642
|
-
|
|
5643
|
-
# When to use this tool
|
|
5644
|
-
Use this tool when the user wants to:
|
|
5645
|
-
- Create a reusable component from an existing element structure
|
|
5646
|
-
- Make specific child element properties customizable in component instances
|
|
5647
|
-
- Build a library of reusable design patterns
|
|
5648
|
-
|
|
5649
|
-
# When NOT to use this tool
|
|
5650
|
-
- Element is already a component (widgetType: 'e-component')
|
|
5651
|
-
- Element is locked
|
|
5652
|
-
- Element is not an atomic element (atomic_props_schema is not defined)
|
|
5653
|
-
- Element elType is a 'widget'
|
|
5654
|
-
|
|
5655
|
-
# **CRITICAL - REQUIRED RESOURCES (Must read before using this tool)**
|
|
5656
|
-
1. [${import_editor_canvas7.DOCUMENT_STRUCTURE_URI}]
|
|
5657
|
-
**MANDATORY** - Required to understand the document structure and identify child elements for overridable properties.
|
|
5658
|
-
Use this resource to find element IDs and understand the element hierarchy.
|
|
5659
|
-
|
|
5660
|
-
2. [${import_editor_canvas7.WIDGET_SCHEMA_URI}]
|
|
5661
|
-
**MANDATORY** - Required to understand which properties are available for each widget type.
|
|
5662
|
-
Use this to identify available propKeys in the atomic_props_schema for child elements.
|
|
5663
|
-
|
|
5664
|
-
# Instructions - MUST FOLLOW IN ORDER
|
|
5665
|
-
## Step 1: Identify the Target Element
|
|
5666
|
-
1. Read the [${import_editor_canvas7.DOCUMENT_STRUCTURE_URI}] resource to understand the document structure
|
|
5667
|
-
2. Locate the element you want to save as a component by its element_id
|
|
5668
|
-
3. Verify the element type is a valid element type
|
|
5669
|
-
4. Ensure the element is not locked and is not already a component
|
|
5670
|
-
|
|
5671
|
-
## Step 2: Define Overridable Properties
|
|
5672
|
-
Do this step to make child element properties customizable.
|
|
5673
|
-
Skip that step ONLY if the user explicitly requests to not make any properties customizable.
|
|
5674
|
-
|
|
5675
|
-
1. **Identify Child Elements**
|
|
5676
|
-
- Use the [${import_editor_canvas7.DOCUMENT_STRUCTURE_URI}] resource to find all child elements
|
|
5677
|
-
- Note the elementId and widgetType/elType of each child element you want to customize
|
|
5678
|
-
|
|
5679
|
-
2. **Find Available Properties**
|
|
5680
|
-
- Use the [${import_editor_canvas7.WIDGET_SCHEMA_URI}] resource to find the child element's widget type schema
|
|
5681
|
-
- Review the atomic_props_schema to find available propKeys (ONLY use top-level props)
|
|
5682
|
-
- Common propKeys include: "text", "url", "tag", "size", etc.
|
|
5683
|
-
- Use only the top level properties, do not use nested properties.
|
|
5684
|
-
|
|
5685
|
-
3. **Build the overridable_props Object**
|
|
5686
|
-
- For each property you want to make overridable, add an entry:
|
|
5687
|
-
\`{ "elementId": "<child-element-id>", "propKey": "<property-key>", "label": "<user-friendly-name>" }\`
|
|
5688
|
-
- The label must be unique within the component and should be meaningful to the user (e.g., "Hero Headline", "CTA Button Text")
|
|
5689
|
-
- Group all entries under the "props" object
|
|
5690
|
-
|
|
5691
|
-
## Step 3: Execute the Tool
|
|
5692
|
-
Call the tool with:
|
|
5693
|
-
- element_id: The ID of the parent element to save as component
|
|
5694
|
-
- component_name: A descriptive name for the component
|
|
5695
|
-
- overridable_props: (Optional) The properties configuration from Step 2
|
|
5696
|
-
|
|
5697
|
-
# CONSTRAINTS
|
|
5698
|
-
- NEVER try to override properties of the parent element itself - ONLY child elements
|
|
5699
|
-
- NEVER use invalid propKeys - always verify against the widget's atomic_props_schema in [${import_editor_canvas7.WIDGET_SCHEMA_URI}]
|
|
5700
|
-
- Property keys must exist in the child element's atomic_props_schema
|
|
5701
|
-
- Element IDs must exist within the target element's children
|
|
5702
|
-
- When tool execution fails, read the error message and adjust accordingly
|
|
5703
|
-
- The element being saved must not be inside another component
|
|
5704
|
-
`);
|
|
5705
|
-
saveAsComponentPrompt.parameter(
|
|
5706
|
-
"element_id",
|
|
5707
|
-
`**MANDATORY** The unique identifier of the element to save as a component.
|
|
5708
|
-
Use the [${import_editor_canvas7.DOCUMENT_STRUCTURE_URI}] resource to find available element IDs.`
|
|
5709
|
-
);
|
|
5710
|
-
saveAsComponentPrompt.parameter(
|
|
5711
|
-
"component_name",
|
|
5712
|
-
`**MANDATORY** A descriptive name for the new component.
|
|
5713
|
-
Should be unique and clearly describe the component's purpose (e.g., "Hero Section", "Feature Card").`
|
|
5714
|
-
);
|
|
5715
|
-
saveAsComponentPrompt.parameter(
|
|
5716
|
-
"overridable_props",
|
|
5717
|
-
`**OPTIONAL** Configuration for which child element properties can be customized in component instances.
|
|
5718
|
-
|
|
5719
|
-
Structure:
|
|
5720
|
-
\`\`\`json
|
|
5721
|
-
{
|
|
5722
|
-
"props": {
|
|
5723
|
-
"<unique-key>": {
|
|
5724
|
-
"elementId": "<child-element-id>",
|
|
5725
|
-
"propKey": "<property-key>",
|
|
5726
|
-
"label": "<user-friendly-name>"
|
|
5727
|
-
}
|
|
5728
|
-
}
|
|
5729
|
-
}
|
|
5730
|
-
\`\`\`
|
|
5731
|
-
|
|
5732
|
-
To populate this correctly:
|
|
5733
|
-
1. Use [${import_editor_canvas7.DOCUMENT_STRUCTURE_URI}] to find child element IDs and their widgetType
|
|
5734
|
-
2. Use [${import_editor_canvas7.WIDGET_SCHEMA_URI}] to find the atomic_props_schema for each child element's widgetType
|
|
5735
|
-
3. Only include properties you want to be customizable in component instances
|
|
5736
|
-
4. Provide a unique, user-friendly label for each property (e.g., "Hero Headline", "CTA Button Text")`
|
|
5737
|
-
);
|
|
5738
|
-
saveAsComponentPrompt.example(`
|
|
5739
|
-
Basic component without overridable properties:
|
|
5740
|
-
\`\`\`json
|
|
5741
|
-
{
|
|
5742
|
-
"element_id": "abc123",
|
|
5743
|
-
"component_name": "Hero Section"
|
|
5744
|
-
}
|
|
5745
|
-
\`\`\`
|
|
5746
|
-
|
|
5747
|
-
Component with overridable properties:
|
|
5748
|
-
\`\`\`json
|
|
5749
|
-
{
|
|
5750
|
-
"element_id": "abc123",
|
|
5751
|
-
"component_name": "Feature Card",
|
|
5752
|
-
"overridable_props": {
|
|
5753
|
-
"props": {
|
|
5754
|
-
"heading-text": {
|
|
5755
|
-
"elementId": "heading-123",
|
|
5756
|
-
"propKey": "text",
|
|
5757
|
-
"label": "Card Title",
|
|
5758
|
-
"group": "Content"
|
|
5759
|
-
},
|
|
5760
|
-
"button-text": {
|
|
5761
|
-
"elementId": "button-456",
|
|
5762
|
-
"propKey": "text",
|
|
5763
|
-
"label": "Button Text",
|
|
5764
|
-
"group": "Content"
|
|
5765
|
-
},
|
|
5766
|
-
"button-link": {
|
|
5767
|
-
"elementId": "button-456",
|
|
5768
|
-
"propKey": "url",
|
|
5769
|
-
"label": "Button Link",
|
|
5770
|
-
"group": "Settings"
|
|
5771
|
-
}
|
|
5772
|
-
}
|
|
5773
|
-
}
|
|
5774
|
-
}
|
|
5775
|
-
\`\`\`
|
|
5776
|
-
`);
|
|
5777
|
-
saveAsComponentPrompt.instruction(
|
|
5778
|
-
`After successful creation, the component will be available in the components library and can be inserted into any page or template.`
|
|
5779
|
-
);
|
|
5780
|
-
saveAsComponentPrompt.instruction(
|
|
5781
|
-
`When overridable properties are defined, component instances will show customization controls for those specific properties in the editing panel.`
|
|
5782
|
-
);
|
|
5783
|
-
return saveAsComponentPrompt.prompt();
|
|
5784
|
-
};
|
|
5785
|
-
var initSaveAsComponentTool = () => {
|
|
5786
|
-
return (0, import_editor_mcp.getMCPByDomain)("components").addTool({
|
|
5787
|
-
name: "save-as-component",
|
|
5788
|
-
schema: InputSchema,
|
|
5789
|
-
outputSchema: OutputSchema,
|
|
5790
|
-
description: generatePrompt(),
|
|
5791
|
-
handler: handleSaveAsComponent
|
|
5792
|
-
});
|
|
5793
|
-
};
|
|
5794
|
-
|
|
5795
|
-
// src/extended/mcp/index.ts
|
|
5796
|
-
function initMcp() {
|
|
5797
|
-
const { setMCPDescription } = (0, import_editor_mcp2.getMCPByDomain)("components");
|
|
5798
|
-
setMCPDescription(
|
|
5799
|
-
`Elementor Editor Components MCP - Tools for creating and managing reusable components.
|
|
5800
|
-
Components are reusable blocks of content that can be used multiple times across the pages, its a widget which contains a set of elements and styles.`
|
|
5801
|
-
);
|
|
5802
|
-
initSaveAsComponentTool();
|
|
5803
|
-
}
|
|
5804
|
-
|
|
5805
|
-
// src/sync/publish-draft-components-in-page-before-save.ts
|
|
5806
|
-
var import_editor_documents12 = require("@elementor/editor-documents");
|
|
5807
|
-
async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
|
|
5808
|
-
if (status !== "publish") {
|
|
5809
|
-
return;
|
|
5810
|
-
}
|
|
5811
|
-
const documents = await getComponentDocuments(elements);
|
|
5812
|
-
const draftIds = [...documents.values()].filter(import_editor_documents12.isDocumentDirty).map((document) => document.id);
|
|
5813
|
-
if (draftIds.length === 0) {
|
|
5814
|
-
return;
|
|
5815
|
-
}
|
|
5816
|
-
await apiClient.updateStatuses(draftIds, "publish");
|
|
5817
|
-
draftIds.forEach((id2) => (0, import_editor_documents12.invalidateDocumentData)(id2));
|
|
5818
|
-
}
|
|
5819
|
-
|
|
5820
|
-
// src/extended/sync/set-component-overridable-props-settings-before-save.ts
|
|
5821
|
-
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
5822
|
-
container
|
|
5823
|
-
}) => {
|
|
5824
|
-
const currentDocument = container.document;
|
|
5825
|
-
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
5826
|
-
return;
|
|
5827
|
-
}
|
|
5828
|
-
const overridableProps = componentsSelectors.getOverridableProps(currentDocument.id);
|
|
5829
|
-
if (overridableProps) {
|
|
5830
|
-
container.settings.set("overridable_props", overridableProps);
|
|
5831
|
-
}
|
|
5832
|
-
};
|
|
5833
|
-
|
|
5834
|
-
// src/extended/sync/update-archived-component-before-save.ts
|
|
5835
|
-
var import_editor_notifications6 = require("@elementor/editor-notifications");
|
|
5836
|
-
var failedNotification = (message) => ({
|
|
5837
|
-
type: "error",
|
|
5838
|
-
message: `Failed to archive components: ${message}`,
|
|
5839
|
-
id: "failed-archived-components-notification"
|
|
5840
|
-
});
|
|
5841
|
-
var updateArchivedComponentBeforeSave = async (status) => {
|
|
5842
|
-
try {
|
|
5843
|
-
const archivedComponents = componentsSelectors.getArchivedThisSession();
|
|
5844
|
-
if (!archivedComponents.length) {
|
|
5845
|
-
return;
|
|
5846
|
-
}
|
|
5847
|
-
const result = await apiClient.updateArchivedComponents(archivedComponents, status);
|
|
5848
|
-
const failedIds = result.failedIds.join(", ");
|
|
5849
|
-
if (failedIds) {
|
|
5850
|
-
(0, import_editor_notifications6.notify)(failedNotification(failedIds));
|
|
5851
|
-
}
|
|
5852
|
-
} catch (error) {
|
|
5853
|
-
throw new Error(`Failed to update archived components: ${error}`);
|
|
5854
|
-
}
|
|
5855
|
-
};
|
|
5856
|
-
|
|
5857
|
-
// src/extended/sync/update-component-title-before-save.ts
|
|
5858
|
-
var updateComponentTitleBeforeSave = async (status) => {
|
|
5859
|
-
const updatedComponentNames = componentsSelectors.getUpdatedComponentNames();
|
|
5860
|
-
if (!updatedComponentNames.length) {
|
|
5861
|
-
return;
|
|
5862
|
-
}
|
|
5863
|
-
const result = await apiClient.updateComponentTitle(updatedComponentNames, status);
|
|
5864
|
-
if (result.failedIds.length === 0) {
|
|
5865
|
-
componentsActions.cleanUpdatedComponentNames();
|
|
5866
|
-
}
|
|
5867
|
-
};
|
|
5868
|
-
|
|
5869
|
-
// src/extended/sync/create-components-before-save.ts
|
|
5870
|
-
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
5871
|
-
async function createComponentsBeforeSave({
|
|
5872
|
-
elements,
|
|
5873
|
-
status
|
|
5874
|
-
}) {
|
|
5875
|
-
const unpublishedComponents = componentsSelectors.getUnpublishedComponents();
|
|
5876
|
-
if (!unpublishedComponents.length) {
|
|
5877
|
-
return;
|
|
5878
|
-
}
|
|
5879
|
-
try {
|
|
5880
|
-
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
5881
|
-
updateComponentInstances(elements, uidToComponentId);
|
|
5882
|
-
componentsActions.add(
|
|
5883
|
-
unpublishedComponents.map((component) => ({
|
|
5884
|
-
id: uidToComponentId.get(component.uid),
|
|
5885
|
-
name: component.name,
|
|
5886
|
-
uid: component.uid,
|
|
5887
|
-
overridableProps: component.overridableProps ? component.overridableProps : void 0
|
|
5888
|
-
}))
|
|
5889
|
-
);
|
|
5890
|
-
componentsActions.resetUnpublished();
|
|
5891
|
-
} catch (error) {
|
|
5892
|
-
const failedUids = unpublishedComponents.map((component) => component.uid);
|
|
5893
|
-
componentsActions.removeUnpublished(failedUids);
|
|
5894
|
-
throw new Error(`Failed to publish components: ${error}`);
|
|
5895
|
-
}
|
|
5896
|
-
}
|
|
5897
|
-
async function createComponents(components, status) {
|
|
5898
|
-
const response = await apiClient.create({
|
|
5899
|
-
status,
|
|
5900
|
-
items: components.map((component) => ({
|
|
5901
|
-
uid: component.uid,
|
|
5902
|
-
title: component.name,
|
|
5903
|
-
elements: component.elements,
|
|
5904
|
-
settings: component.overridableProps ? { overridable_props: component.overridableProps } : void 0
|
|
5905
|
-
}))
|
|
5906
|
-
});
|
|
5907
|
-
const map = /* @__PURE__ */ new Map();
|
|
5908
|
-
Object.entries(response).forEach(([key, value]) => {
|
|
5909
|
-
map.set(key, value);
|
|
5910
|
-
});
|
|
5911
|
-
return map;
|
|
5912
|
-
}
|
|
5913
|
-
function updateComponentInstances(elements, uidToComponentId) {
|
|
5914
|
-
elements.forEach((element) => {
|
|
5915
|
-
const { shouldUpdate, newComponentId } = shouldUpdateElement(element, uidToComponentId);
|
|
5916
|
-
if (shouldUpdate) {
|
|
5917
|
-
updateElementComponentId(element.id, newComponentId);
|
|
5918
|
-
}
|
|
5919
|
-
if (element.elements) {
|
|
5920
|
-
updateComponentInstances(element.elements, uidToComponentId);
|
|
5921
|
-
}
|
|
5922
|
-
});
|
|
5923
|
-
}
|
|
5924
|
-
function shouldUpdateElement(element, uidToComponentId) {
|
|
5925
|
-
if (element.widgetType === "e-component") {
|
|
5926
|
-
const currentComponentId = element.settings?.component_instance?.value?.component_id.value;
|
|
5927
|
-
if (currentComponentId && uidToComponentId.has(currentComponentId.toString())) {
|
|
5928
|
-
return {
|
|
5929
|
-
shouldUpdate: true,
|
|
5930
|
-
newComponentId: uidToComponentId.get(currentComponentId.toString())
|
|
5931
|
-
};
|
|
5932
|
-
}
|
|
5933
|
-
}
|
|
5934
|
-
return { shouldUpdate: false, newComponentId: null };
|
|
5935
|
-
}
|
|
5936
|
-
function updateElementComponentId(elementId, componentId) {
|
|
5937
|
-
(0, import_editor_elements20.updateElementSettings)({
|
|
5938
|
-
id: elementId,
|
|
5939
|
-
props: {
|
|
5940
|
-
component_instance: {
|
|
5941
|
-
$$type: "component-instance",
|
|
5942
|
-
value: {
|
|
5943
|
-
component_id: { $$type: "number", value: componentId }
|
|
5944
|
-
}
|
|
5945
|
-
}
|
|
5946
|
-
},
|
|
5947
|
-
withHistory: false
|
|
5948
|
-
});
|
|
5949
|
-
}
|
|
5950
|
-
|
|
5951
|
-
// src/extended/sync/before-save.ts
|
|
5952
|
-
var beforeSave = ({ container, status }) => {
|
|
5953
|
-
const elements = container?.model.get("elements").toJSON?.() ?? [];
|
|
5954
|
-
return Promise.all([
|
|
5955
|
-
syncComponents({ elements, status }),
|
|
5956
|
-
setComponentOverridablePropsSettingsBeforeSave({ container })
|
|
5957
|
-
]);
|
|
5958
|
-
};
|
|
5959
|
-
var syncComponents = async ({ elements, status }) => {
|
|
5960
|
-
await updateExistingComponentsBeforeSave({ elements, status });
|
|
5961
|
-
await createComponentsBeforeSave({ elements, status });
|
|
5962
|
-
};
|
|
5963
|
-
var updateExistingComponentsBeforeSave = async ({
|
|
5964
|
-
elements,
|
|
5965
|
-
status
|
|
5966
|
-
}) => {
|
|
5967
|
-
await updateComponentTitleBeforeSave(status);
|
|
5968
|
-
await updateArchivedComponentBeforeSave(status);
|
|
5969
|
-
await publishDraftComponentsInPageBeforeSave({ elements, status });
|
|
5970
|
-
};
|
|
5971
|
-
|
|
5972
|
-
// src/extended/sync/cleanup-overridable-props-on-delete.ts
|
|
5973
|
-
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
5974
|
-
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
5975
|
-
function initCleanupOverridablePropsOnDelete() {
|
|
5976
|
-
(0, import_editor_v1_adapters8.registerDataHook)("dependency", "document/elements/delete", (args, options) => {
|
|
5977
|
-
if (isPartOfMoveCommand(options)) {
|
|
5978
|
-
return true;
|
|
5979
|
-
}
|
|
5980
|
-
const currentComponentId = componentsSelectors.getCurrentComponentId();
|
|
5981
|
-
if (!currentComponentId) {
|
|
5982
|
-
return true;
|
|
5983
|
-
}
|
|
5984
|
-
const overridableProps = componentsSelectors.getOverridableProps(currentComponentId);
|
|
5985
|
-
if (!overridableProps || Object.keys(overridableProps.props).length === 0) {
|
|
5986
|
-
return true;
|
|
5987
|
-
}
|
|
5988
|
-
const containers = args.containers ?? (args.container ? [args.container] : []);
|
|
5989
|
-
if (containers.length === 0) {
|
|
5990
|
-
return true;
|
|
5991
|
-
}
|
|
5992
|
-
const deletedElementIds = collectDeletedElementIds(containers);
|
|
5993
|
-
if (deletedElementIds.length === 0) {
|
|
5994
|
-
return true;
|
|
5995
|
-
}
|
|
5996
|
-
const propKeysToDelete = Object.entries(overridableProps.props).filter(([, prop]) => deletedElementIds.includes(prop.elementId)).map(([propKey]) => propKey);
|
|
5997
|
-
if (propKeysToDelete.length === 0) {
|
|
5998
|
-
return true;
|
|
5999
|
-
}
|
|
6000
|
-
deleteOverridableProp({ componentId: currentComponentId, propKey: propKeysToDelete, source: "system" });
|
|
6001
|
-
return true;
|
|
6002
|
-
});
|
|
6003
|
-
}
|
|
6004
|
-
function collectDeletedElementIds(containers) {
|
|
6005
|
-
const elementIds = containers.filter(Boolean).flatMap((container) => [container, ...(0, import_editor_elements21.getAllDescendants)(container)]).map((element) => element.model?.get?.("id") ?? element.id).filter((id2) => Boolean(id2));
|
|
6006
|
-
return elementIds;
|
|
6007
|
-
}
|
|
6008
|
-
function isPartOfMoveCommand(options) {
|
|
6009
|
-
const isMoveCommandInTrace = options?.commandsCurrentTrace?.includes("document/elements/move") || options?.commandsCurrentTrace?.includes("document/repeater/move");
|
|
6010
|
-
return Boolean(isMoveCommandInTrace);
|
|
6011
|
-
}
|
|
6012
|
-
|
|
6013
|
-
// src/extended/sync/handle-component-edit-mode-container.ts
|
|
6014
|
-
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
6015
|
-
var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
|
|
6016
|
-
var V4_DEFAULT_CONTAINER_TYPE = "e-flexbox";
|
|
6017
|
-
function initHandleComponentEditModeContainer() {
|
|
6018
|
-
initRedirectDropIntoComponent();
|
|
6019
|
-
initHandleTopLevelElementDelete();
|
|
6020
|
-
}
|
|
6021
|
-
function initHandleTopLevelElementDelete() {
|
|
6022
|
-
(0, import_editor_v1_adapters9.registerDataHook)("after", "document/elements/delete", (args) => {
|
|
6023
|
-
if (!isEditingComponent()) {
|
|
6024
|
-
return;
|
|
6025
|
-
}
|
|
6026
|
-
const containers = args.containers ?? (args.container ? [args.container] : []);
|
|
6027
|
-
for (const container of containers) {
|
|
6028
|
-
if (!container.parent || !isComponent(container.parent)) {
|
|
6029
|
-
continue;
|
|
6030
|
-
}
|
|
6031
|
-
const component = container.parent;
|
|
6032
|
-
const isComponentEmpty = component.children?.length === 0;
|
|
6033
|
-
if (isComponentEmpty) {
|
|
6034
|
-
createEmptyTopLevelContainer(container.parent);
|
|
6035
|
-
}
|
|
6036
|
-
}
|
|
6037
|
-
});
|
|
6038
|
-
}
|
|
6039
|
-
function initRedirectDropIntoComponent() {
|
|
6040
|
-
(0, import_editor_v1_adapters9.registerDataHook)("dependency", "preview/drop", (args) => {
|
|
6041
|
-
if (!isEditingComponent()) {
|
|
6042
|
-
return true;
|
|
6043
|
-
}
|
|
6044
|
-
const containers = args.containers ?? (args.container ? [args.container] : []);
|
|
6045
|
-
for (const container of containers) {
|
|
6046
|
-
if (!isComponent(container)) {
|
|
6047
|
-
continue;
|
|
6048
|
-
}
|
|
6049
|
-
const { shouldRedirect, container: redirectedContainer } = getComponentContainer(container);
|
|
6050
|
-
if (!shouldRedirect) {
|
|
6051
|
-
continue;
|
|
6052
|
-
}
|
|
6053
|
-
if (args.containers) {
|
|
6054
|
-
const index = args.containers.indexOf(container);
|
|
6055
|
-
args.containers[index] = redirectedContainer;
|
|
6056
|
-
} else {
|
|
6057
|
-
args.container = redirectedContainer;
|
|
6058
|
-
}
|
|
6059
|
-
}
|
|
6060
|
-
return true;
|
|
6061
|
-
});
|
|
6062
|
-
}
|
|
6063
|
-
function createEmptyTopLevelContainer(container) {
|
|
6064
|
-
const newContainer = (0, import_editor_elements22.createElement)({
|
|
6065
|
-
container,
|
|
6066
|
-
model: { elType: V4_DEFAULT_CONTAINER_TYPE }
|
|
6067
|
-
});
|
|
6068
|
-
(0, import_editor_elements22.selectElement)(newContainer.id);
|
|
6069
|
-
}
|
|
6070
|
-
function getComponentContainer(container) {
|
|
6071
|
-
const topLevelElement = container.children?.[0];
|
|
6072
|
-
if (topLevelElement) {
|
|
6073
|
-
return { shouldRedirect: true, container: topLevelElement };
|
|
6074
|
-
}
|
|
6075
|
-
return { shouldRedirect: false, container };
|
|
6076
|
-
}
|
|
6077
|
-
function isComponent(container) {
|
|
6078
|
-
const isDocument = container.id === "document";
|
|
6079
|
-
if (!isDocument) {
|
|
6080
|
-
return false;
|
|
6081
|
-
}
|
|
6082
|
-
return container.document?.config.type === COMPONENT_DOCUMENT_TYPE;
|
|
6083
|
-
}
|
|
6084
|
-
|
|
6085
|
-
// src/extended/sync/revert-overridables-on-copy-or-duplicate.ts
|
|
6086
|
-
var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
6087
|
-
function initRevertOverridablesOnCopyOrDuplicate() {
|
|
6088
|
-
(0, import_editor_v1_adapters10.registerDataHook)("after", "document/elements/duplicate", (_args, result) => {
|
|
6089
|
-
if (!isEditingComponent()) {
|
|
6090
|
-
return;
|
|
6091
|
-
}
|
|
6092
|
-
revertOverridablesForDuplicatedElements(result);
|
|
6093
|
-
});
|
|
6094
|
-
(0, import_editor_v1_adapters10.registerDataHook)("after", "document/elements/copy", (args) => {
|
|
6095
|
-
if (!isEditingComponent()) {
|
|
6096
|
-
return;
|
|
6097
|
-
}
|
|
6098
|
-
revertOverridablesInStorage(args.storageKey ?? "clipboard");
|
|
6099
|
-
});
|
|
6100
|
-
}
|
|
6101
|
-
function revertOverridablesForDuplicatedElements(duplicatedElements) {
|
|
6102
|
-
const containers = Array.isArray(duplicatedElements) ? duplicatedElements : [duplicatedElements];
|
|
6103
|
-
containers.forEach((container) => {
|
|
6104
|
-
revertAllOverridablesInContainer(container);
|
|
6105
|
-
});
|
|
6106
|
-
}
|
|
6107
|
-
function revertOverridablesInStorage(storageKey) {
|
|
6108
|
-
const storage = window.elementorCommon?.storage;
|
|
6109
|
-
if (!storage) {
|
|
6110
|
-
return;
|
|
6111
|
-
}
|
|
6112
|
-
const storageData = storage.get(storageKey);
|
|
6113
|
-
if (!storageData?.elements?.length) {
|
|
6114
|
-
return;
|
|
6115
|
-
}
|
|
6116
|
-
const elementsDataWithOverridablesReverted = storageData.elements.map(revertAllOverridablesInElementData);
|
|
6117
|
-
storage.set(storageKey, {
|
|
6118
|
-
...storageData,
|
|
6119
|
-
elements: elementsDataWithOverridablesReverted
|
|
6120
|
-
});
|
|
6121
|
-
}
|
|
6122
|
-
|
|
6123
|
-
// src/extended/sync/sanitize-overridable-props.ts
|
|
6124
|
-
var import_react21 = require("react");
|
|
6125
|
-
|
|
6126
|
-
// src/extended/store/actions/update-component-sanitized-attribute.ts
|
|
6127
|
-
function updateComponentSanitizedAttribute(componentId, attribute) {
|
|
6128
|
-
componentsActions.updateComponentSanitizedAttribute(componentId, attribute);
|
|
6129
|
-
}
|
|
6130
|
-
|
|
6131
|
-
// src/extended/sync/sanitize-overridable-props.ts
|
|
6132
|
-
function SanitizeOverridableProps() {
|
|
6133
|
-
const currentComponentId = useCurrentComponentId();
|
|
6134
|
-
const overridableProps = useOverridableProps(currentComponentId);
|
|
6135
|
-
const isSanitized = useIsSanitizedComponent(currentComponentId, "overridableProps");
|
|
6136
|
-
(0, import_react21.useEffect)(() => {
|
|
6137
|
-
if (isSanitized || !overridableProps || !currentComponentId) {
|
|
6138
|
-
return;
|
|
6139
|
-
}
|
|
6140
|
-
const filtered = filterValidOverridableProps(overridableProps);
|
|
6141
|
-
const propsToDelete = Object.keys(overridableProps.props ?? {}).filter((key) => !filtered.props[key]);
|
|
6142
|
-
if (propsToDelete.length > 0) {
|
|
6143
|
-
propsToDelete.forEach((key) => {
|
|
6144
|
-
deleteOverridableProp({ componentId: currentComponentId, propKey: key, source: "system" });
|
|
6145
|
-
});
|
|
6146
|
-
}
|
|
6147
|
-
updateComponentSanitizedAttribute(currentComponentId, "overridableProps");
|
|
6148
|
-
}, [currentComponentId, isSanitized, overridableProps]);
|
|
6149
|
-
return null;
|
|
6150
|
-
}
|
|
6151
|
-
|
|
6152
|
-
// src/extended/init.ts
|
|
6153
|
-
var PRIORITY = 1;
|
|
6154
|
-
function initExtended() {
|
|
6155
|
-
(0, import_editor_editing_panel8.registerEditingPanelReplacement)({
|
|
6156
|
-
id: "extended-component-instance-edit-panel",
|
|
6157
|
-
priority: PRIORITY,
|
|
6158
|
-
condition: (_, elementType) => elementType.key === "e-component",
|
|
6159
|
-
component: ExtendedInstanceEditingPanel
|
|
6160
|
-
});
|
|
6161
|
-
(0, import_editor_elements_panel.registerTab)({
|
|
6162
|
-
id: "components",
|
|
6163
|
-
label: (0, import_i18n34.__)("Components", "elementor"),
|
|
6164
|
-
component: ExtendedComponents,
|
|
6165
|
-
priority: PRIORITY
|
|
6166
|
-
});
|
|
6167
|
-
(0, import_editor_panels6.__registerPanel)(panel);
|
|
6168
|
-
(0, import_editor_v1_adapters11.registerDataHook)("dependency", "editor/documents/close", (args) => {
|
|
6169
|
-
const document = (0, import_editor_documents13.getV1CurrentDocument)();
|
|
6170
|
-
if (document.config.type === COMPONENT_DOCUMENT_TYPE) {
|
|
6171
|
-
args.mode = "autosave";
|
|
6172
|
-
}
|
|
6173
|
-
return true;
|
|
6174
|
-
});
|
|
6175
|
-
(0, import_editor_v1_adapters11.registerDataHook)("after", "preview/drop", onElementDrop);
|
|
6176
|
-
window.elementorCommon.__beforeSave = beforeSave;
|
|
6177
|
-
(0, import_editor.injectIntoTop)({
|
|
6178
|
-
id: "create-component-popup",
|
|
6179
|
-
component: CreateComponentForm
|
|
6180
|
-
});
|
|
6181
|
-
(0, import_editor.injectIntoTop)({
|
|
6182
|
-
id: "edit-component",
|
|
6183
|
-
component: EditComponent
|
|
6184
|
-
});
|
|
6185
|
-
(0, import_editor_editing_panel8.injectIntoPanelHeaderTop)({
|
|
6186
|
-
id: "component-panel-header",
|
|
6187
|
-
component: ComponentPanelHeader
|
|
6188
|
-
});
|
|
6189
|
-
(0, import_editor_editing_panel8.registerFieldIndicator)({
|
|
6190
|
-
fieldType: import_editor_editing_panel8.FIELD_TYPE.SETTINGS,
|
|
6191
|
-
id: "component-overridable-prop",
|
|
6192
|
-
priority: 1,
|
|
6193
|
-
indicator: OverridablePropIndicator
|
|
6194
|
-
});
|
|
6195
|
-
(0, import_editor_controls7.registerControlReplacement)({
|
|
6196
|
-
id: OVERRIDABLE_PROP_REPLACEMENT_ID,
|
|
6197
|
-
component: OverridablePropControl,
|
|
6198
|
-
condition: ({ value }) => componentOverridablePropTypeUtil.isValid(value)
|
|
6199
|
-
});
|
|
6200
|
-
initCleanupOverridablePropsOnDelete();
|
|
6201
|
-
initMcp();
|
|
6202
|
-
initNonAtomicNestingPrevention();
|
|
6203
|
-
initHandleComponentEditModeContainer();
|
|
6204
|
-
initRevertOverridablesOnCopyOrDuplicate();
|
|
6205
|
-
(0, import_editor.injectIntoLogic)({
|
|
6206
|
-
id: "sanitize-overridable-props",
|
|
6207
|
-
component: SanitizeOverridableProps
|
|
6208
|
-
});
|
|
6209
|
-
}
|
|
6210
|
-
|
|
6211
|
-
// src/extended/shortcuts/create-component-shortcut.ts
|
|
6212
|
-
var import_editor_elements23 = require("@elementor/editor-elements");
|
|
6213
|
-
var import_utils12 = require("@elementor/utils");
|
|
6214
|
-
var CREATE_COMPONENT_SHORTCUT_KEYS = "ctrl+shift+k";
|
|
6215
|
-
var OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
6216
|
-
function isCreateComponentAllowed() {
|
|
6217
|
-
const selectedElements = (0, import_editor_elements23.getSelectedElements)();
|
|
6218
|
-
if (selectedElements.length !== 1) {
|
|
6219
|
-
return { allowed: false };
|
|
6220
|
-
}
|
|
6221
|
-
const element = selectedElements[0];
|
|
6222
|
-
const elementType = (0, import_editor_elements23.getElementType)(element.type);
|
|
6223
|
-
if (!elementType) {
|
|
6224
|
-
return { allowed: false };
|
|
6225
|
-
}
|
|
6226
|
-
if (!(0, import_utils12.isProActive)()) {
|
|
6227
|
-
return { allowed: false };
|
|
6228
|
-
}
|
|
6229
|
-
const widgetsCache = (0, import_editor_elements23.getWidgetsCache)();
|
|
6230
|
-
const elementConfig = widgetsCache?.[element.type];
|
|
6231
|
-
if (!elementConfig?.atomic_props_schema || !elementConfig?.show_in_panel || elementConfig?.elType === "widget") {
|
|
6232
|
-
return { allowed: false };
|
|
6233
|
-
}
|
|
6234
|
-
const legacyWindow = window;
|
|
6235
|
-
const container = legacyWindow.elementor.getContainer(element.id);
|
|
6236
|
-
if (!container || container.isLocked()) {
|
|
6237
|
-
return { allowed: false };
|
|
6238
|
-
}
|
|
6239
|
-
return { allowed: true, container };
|
|
6240
|
-
}
|
|
6241
|
-
function triggerCreateComponentForm(container) {
|
|
6242
|
-
const legacyWindow = window;
|
|
6243
|
-
const elementRect = container.view.el.getBoundingClientRect();
|
|
6244
|
-
const iframeRect = legacyWindow.elementor.$preview[0].getBoundingClientRect();
|
|
6245
|
-
const anchorPosition = {
|
|
6246
|
-
left: iframeRect.left + elementRect.left + elementRect.width / 2,
|
|
6247
|
-
top: iframeRect.top + elementRect.top
|
|
6248
|
-
};
|
|
6249
|
-
window.dispatchEvent(
|
|
6250
|
-
new CustomEvent(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, {
|
|
6251
|
-
detail: {
|
|
6252
|
-
element: container.model.toJSON({ remove: ["default"] }),
|
|
6253
|
-
anchorPosition,
|
|
6254
|
-
options: {
|
|
6255
|
-
trigger: "keyboard",
|
|
6256
|
-
location: "canvas",
|
|
6257
|
-
secondaryLocation: "canvasElement"
|
|
6258
|
-
}
|
|
6259
|
-
}
|
|
6260
|
-
})
|
|
6261
|
-
);
|
|
6262
|
-
}
|
|
6263
|
-
function initCreateComponentShortcut() {
|
|
6264
|
-
const legacyWindow = window;
|
|
6265
|
-
legacyWindow.$e.shortcuts.register(CREATE_COMPONENT_SHORTCUT_KEYS, {
|
|
6266
|
-
callback: () => {
|
|
6267
|
-
const result = isCreateComponentAllowed();
|
|
6268
|
-
if (!result.allowed) {
|
|
6269
|
-
return;
|
|
6270
|
-
}
|
|
6271
|
-
triggerCreateComponentForm(result.container);
|
|
6272
|
-
},
|
|
6273
|
-
dependency: () => {
|
|
6274
|
-
const result = isCreateComponentAllowed();
|
|
6275
|
-
return result.allowed;
|
|
6276
|
-
},
|
|
6277
|
-
exclude: ["input"]
|
|
6278
|
-
});
|
|
6279
|
-
}
|
|
6280
|
-
|
|
6281
|
-
// src/populate-store.ts
|
|
6282
|
-
var import_react22 = require("react");
|
|
6283
|
-
var import_store39 = require("@elementor/store");
|
|
6284
|
-
function PopulateStore() {
|
|
6285
|
-
(0, import_react22.useEffect)(() => {
|
|
6286
|
-
(0, import_store39.__dispatch)(loadComponents());
|
|
6287
|
-
}, []);
|
|
6288
|
-
return null;
|
|
6289
|
-
}
|
|
6290
|
-
|
|
6291
|
-
// src/prevent-circular-nesting.ts
|
|
6292
|
-
var import_editor_elements24 = require("@elementor/editor-elements");
|
|
6293
|
-
var import_editor_notifications7 = require("@elementor/editor-notifications");
|
|
6294
|
-
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
6295
|
-
var import_store40 = require("@elementor/store");
|
|
6296
|
-
var import_i18n35 = require("@wordpress/i18n");
|
|
6297
|
-
var COMPONENT_TYPE = "e-component";
|
|
6298
|
-
var COMPONENT_CIRCULAR_NESTING_ALERT = {
|
|
6299
|
-
type: "default",
|
|
6300
|
-
message: (0, import_i18n35.__)("Can't add this component - components that contain each other can't be nested.", "elementor"),
|
|
6301
|
-
id: "circular-component-nesting-blocked"
|
|
6302
|
-
};
|
|
6303
|
-
function initCircularNestingPrevention() {
|
|
6304
|
-
(0, import_editor_v1_adapters12.blockCommand)({
|
|
6305
|
-
command: "document/elements/create",
|
|
6306
|
-
condition: blockCircularCreate
|
|
6307
|
-
});
|
|
6308
|
-
(0, import_editor_v1_adapters12.blockCommand)({
|
|
6309
|
-
command: "document/elements/move",
|
|
6310
|
-
condition: blockCircularMove
|
|
6311
|
-
});
|
|
6312
|
-
(0, import_editor_v1_adapters12.blockCommand)({
|
|
6313
|
-
command: "document/elements/paste",
|
|
6314
|
-
condition: blockCircularPaste
|
|
6315
|
-
});
|
|
6316
|
-
}
|
|
6317
|
-
function wouldCreateCircularNesting(componentIdToAdd) {
|
|
6318
|
-
if (componentIdToAdd === void 0) {
|
|
6319
|
-
return false;
|
|
6320
|
-
}
|
|
6321
|
-
const state = (0, import_store40.__getState)();
|
|
6322
|
-
const currentComponentId = selectCurrentComponentId(state);
|
|
6323
|
-
const path = selectPath(state);
|
|
6324
|
-
if (currentComponentId === null) {
|
|
6325
|
-
return false;
|
|
6326
|
-
}
|
|
6327
|
-
if (componentIdToAdd === currentComponentId) {
|
|
6328
|
-
return true;
|
|
6329
|
-
}
|
|
6330
|
-
return path.some((item) => item.componentId === componentIdToAdd);
|
|
6331
|
-
}
|
|
6332
|
-
function extractComponentIdFromModel(model) {
|
|
6333
|
-
if (!model) {
|
|
6334
|
-
return null;
|
|
6335
|
-
}
|
|
6336
|
-
const isComponent2 = model.widgetType === COMPONENT_TYPE;
|
|
6337
|
-
if (!isComponent2) {
|
|
6338
|
-
return null;
|
|
6339
|
-
}
|
|
6340
|
-
return model.settings?.component_instance?.value?.component_id?.value ?? null;
|
|
6341
|
-
}
|
|
6342
|
-
function extractComponentIdFromElement(element) {
|
|
6343
|
-
if (element.widgetType !== COMPONENT_TYPE) {
|
|
6344
|
-
return null;
|
|
6345
|
-
}
|
|
6346
|
-
return element.settings?.component_instance?.value?.component_id?.value ?? null;
|
|
6347
|
-
}
|
|
6348
|
-
function extractComponentIdsFromElements(elements) {
|
|
6349
|
-
const ids = [];
|
|
6350
|
-
for (const element of elements) {
|
|
6351
|
-
const componentId = extractComponentIdFromElement(element);
|
|
6352
|
-
if (componentId !== null) {
|
|
6353
|
-
ids.push(componentId);
|
|
6354
|
-
}
|
|
6355
|
-
if (element.elements?.length) {
|
|
6356
|
-
ids.push(...extractComponentIdsFromElements(element.elements));
|
|
6357
|
-
}
|
|
6358
|
-
}
|
|
6359
|
-
return ids;
|
|
6360
|
-
}
|
|
6361
|
-
function extractComponentIdFromContainer(container) {
|
|
6362
|
-
const widgetType = container.model?.get?.("widgetType");
|
|
6363
|
-
if (widgetType !== COMPONENT_TYPE) {
|
|
6364
|
-
return null;
|
|
6365
|
-
}
|
|
6366
|
-
const settings = container.model?.get?.("settings");
|
|
6367
|
-
const componentInstance = settings?.get?.("component_instance");
|
|
6368
|
-
return componentInstance?.value?.component_id?.value ?? null;
|
|
6369
|
-
}
|
|
6370
|
-
function blockCircularCreate(args) {
|
|
6371
|
-
const componentId = extractComponentIdFromModel(args.model);
|
|
6372
|
-
if (componentId === null) {
|
|
6373
|
-
return false;
|
|
6374
|
-
}
|
|
6375
|
-
const isBlocked = wouldCreateCircularNesting(componentId);
|
|
6376
|
-
if (isBlocked) {
|
|
6377
|
-
(0, import_editor_notifications7.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
6378
|
-
}
|
|
6379
|
-
return isBlocked;
|
|
6380
|
-
}
|
|
6381
|
-
function blockCircularMove(args) {
|
|
6382
|
-
const { containers = [args.container] } = args;
|
|
6383
|
-
const hasCircularComponent = containers.some((container) => {
|
|
6384
|
-
if (!container) {
|
|
6385
|
-
return false;
|
|
6386
|
-
}
|
|
6387
|
-
const allElements = (0, import_editor_elements24.getAllDescendants)(container);
|
|
6388
|
-
return allElements.some((element) => {
|
|
6389
|
-
const componentId = extractComponentIdFromContainer(element);
|
|
6390
|
-
if (componentId === null) {
|
|
6391
|
-
return false;
|
|
6392
|
-
}
|
|
6393
|
-
return wouldCreateCircularNesting(componentId);
|
|
6394
|
-
});
|
|
6395
|
-
});
|
|
6396
|
-
if (hasCircularComponent) {
|
|
6397
|
-
(0, import_editor_notifications7.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
6398
|
-
}
|
|
6399
|
-
return hasCircularComponent;
|
|
6400
|
-
}
|
|
6401
|
-
function blockCircularPaste(args) {
|
|
6402
|
-
const { storageType } = args;
|
|
6403
|
-
if (storageType !== "localstorage") {
|
|
6404
|
-
return false;
|
|
6405
|
-
}
|
|
6406
|
-
const data = window?.elementorCommon?.storage?.get();
|
|
6407
|
-
if (!data?.clipboard?.elements) {
|
|
6408
|
-
return false;
|
|
6409
|
-
}
|
|
6410
|
-
const allComponentIds = extractComponentIdsFromElements(data.clipboard.elements);
|
|
6411
|
-
const hasCircularComponent = allComponentIds.some(wouldCreateCircularNesting);
|
|
6412
|
-
if (hasCircularComponent) {
|
|
6413
|
-
(0, import_editor_notifications7.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
6414
|
-
}
|
|
6415
|
-
return hasCircularComponent;
|
|
6416
|
-
}
|
|
6417
|
-
|
|
6418
|
-
// src/store/actions/remove-component-styles.ts
|
|
6419
|
-
var import_store42 = require("@elementor/store");
|
|
6420
|
-
function removeComponentStyles(id2) {
|
|
6421
|
-
apiClient.invalidateComponentConfigCache(id2);
|
|
6422
|
-
(0, import_store42.__dispatch)(slice.actions.removeStyles({ id: id2 }));
|
|
6423
|
-
}
|
|
6424
|
-
|
|
6425
|
-
// src/store/components-styles-provider.ts
|
|
6426
|
-
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
6427
|
-
var import_store44 = require("@elementor/store");
|
|
6428
|
-
var componentsStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
6429
|
-
key: "components-styles",
|
|
6430
|
-
priority: 100,
|
|
6431
|
-
subscribe: (cb) => (0, import_store44.__subscribeWithSelector)(
|
|
6432
|
-
(state) => state[SLICE_NAME],
|
|
6433
|
-
() => {
|
|
6434
|
-
cb();
|
|
6435
|
-
}
|
|
6436
|
-
),
|
|
6437
|
-
actions: {
|
|
6438
|
-
all: () => {
|
|
6439
|
-
return selectFlatStyles((0, import_store44.__getState)());
|
|
6440
|
-
},
|
|
6441
|
-
get: (id2) => {
|
|
6442
|
-
return selectFlatStyles((0, import_store44.__getState)()).find((style) => style.id === id2) ?? null;
|
|
6443
|
-
}
|
|
6444
|
-
}
|
|
6445
|
-
});
|
|
6446
|
-
|
|
6447
2775
|
// src/sync/before-save.ts
|
|
6448
|
-
var
|
|
2776
|
+
var beforeSave = ({ container, status }) => {
|
|
6449
2777
|
const elements = container?.model.get("elements").toJSON?.() ?? [];
|
|
6450
2778
|
return publishDraftComponentsInPageBeforeSave({ elements, status });
|
|
6451
2779
|
};
|
|
6452
2780
|
|
|
6453
2781
|
// src/sync/load-component-data-after-instance-added.ts
|
|
6454
|
-
var
|
|
2782
|
+
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
6455
2783
|
function initLoadComponentDataAfterInstanceAdded() {
|
|
6456
|
-
(0,
|
|
2784
|
+
(0, import_editor_v1_adapters5.registerDataHook)("after", "document/elements/paste", (_args, result) => {
|
|
6457
2785
|
load(result);
|
|
6458
2786
|
});
|
|
6459
|
-
(0,
|
|
2787
|
+
(0, import_editor_v1_adapters5.registerDataHook)("after", "document/elements/import", (_args, result) => {
|
|
6460
2788
|
load(result);
|
|
6461
2789
|
});
|
|
6462
2790
|
}
|
|
@@ -6466,11 +2794,10 @@ function load(result) {
|
|
|
6466
2794
|
}
|
|
6467
2795
|
|
|
6468
2796
|
// src/init.ts
|
|
6469
|
-
var PRO_EXTENDED_MIGRATION_VERSION = "4.0.0";
|
|
6470
2797
|
function init() {
|
|
6471
2798
|
import_editor_styles_repository2.stylesRepository.register(componentsStylesProvider);
|
|
6472
|
-
(0,
|
|
6473
|
-
(0,
|
|
2799
|
+
(0, import_store35.__registerSlice)(slice);
|
|
2800
|
+
(0, import_editor_canvas5.registerElementType)(
|
|
6474
2801
|
COMPONENT_WIDGET_TYPE2,
|
|
6475
2802
|
(options) => createComponentType({
|
|
6476
2803
|
...options,
|
|
@@ -6478,44 +2805,38 @@ function init() {
|
|
|
6478
2805
|
showDetachConfirmDialog: openDetachConfirmDialog
|
|
6479
2806
|
})
|
|
6480
2807
|
);
|
|
6481
|
-
window.elementorCommon.__beforeSave =
|
|
6482
|
-
(0,
|
|
2808
|
+
window.elementorCommon.__beforeSave = beforeSave;
|
|
2809
|
+
(0, import_editor_elements_panel.injectTab)({
|
|
6483
2810
|
id: "components",
|
|
6484
|
-
label: (0,
|
|
2811
|
+
label: (0, import_i18n12.__)("Components", "elementor"),
|
|
6485
2812
|
component: Components,
|
|
6486
2813
|
position: 1
|
|
6487
2814
|
});
|
|
6488
|
-
(0,
|
|
2815
|
+
(0, import_editor.injectIntoLogic)({
|
|
6489
2816
|
id: "components-populate-store",
|
|
6490
2817
|
component: PopulateStore
|
|
6491
2818
|
});
|
|
6492
|
-
(0,
|
|
6493
|
-
const { id
|
|
6494
|
-
if (
|
|
6495
|
-
removeComponentStyles(
|
|
2819
|
+
(0, import_editor_v1_adapters6.registerDataHook)("after", "editor/documents/attach-preview", async () => {
|
|
2820
|
+
const { id, config } = (0, import_editor_documents6.getV1CurrentDocument)();
|
|
2821
|
+
if (id) {
|
|
2822
|
+
removeComponentStyles(id);
|
|
6496
2823
|
}
|
|
6497
2824
|
await loadComponentsAssets(config?.elements ?? []);
|
|
6498
2825
|
});
|
|
6499
|
-
(0,
|
|
2826
|
+
(0, import_editor.injectIntoLogic)({
|
|
6500
2827
|
id: "templates",
|
|
6501
2828
|
component: LoadTemplateComponents
|
|
6502
2829
|
});
|
|
6503
|
-
(0,
|
|
2830
|
+
(0, import_editor_editing_panel5.registerEditingPanelReplacement)({
|
|
6504
2831
|
id: "component-instance-edit-panel",
|
|
6505
2832
|
condition: (_, elementType) => elementType.key === "e-component",
|
|
6506
2833
|
component: InstanceEditingPanel
|
|
6507
2834
|
});
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
2835
|
+
import_editor_canvas5.settingsTransformersRegistry.register("component-instance", componentInstanceTransformer);
|
|
2836
|
+
import_editor_canvas5.settingsTransformersRegistry.register("overridable", componentOverridableTransformer);
|
|
2837
|
+
import_editor_canvas5.settingsTransformersRegistry.register("override", componentOverrideTransformer);
|
|
6511
2838
|
initCircularNestingPrevention();
|
|
6512
2839
|
initLoadComponentDataAfterInstanceAdded();
|
|
6513
|
-
if (!!window.elementorPro && !(0, import_utils13.isProAtLeast)(PRO_EXTENDED_MIGRATION_VERSION)) {
|
|
6514
|
-
initExtended();
|
|
6515
|
-
}
|
|
6516
|
-
if (!!window.elementorPro) {
|
|
6517
|
-
initCreateComponentShortcut();
|
|
6518
|
-
}
|
|
6519
2840
|
}
|
|
6520
2841
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6521
2842
|
0 && (module.exports = {
|