@elementor/editor-editing-panel 4.5.0-1181 → 4.5.0-1183
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 +99 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -25
- package/src/controls-registry/element-controls/menu-items-control/menu-items-control.tsx +59 -4
- package/src/controls-registry/element-controls/menu-items-control/use-actions.ts +14 -3
- package/src/controls-registry/element-controls/menu-items-control/use-entry-item.ts +33 -0
package/dist/index.mjs
CHANGED
|
@@ -6831,10 +6831,12 @@ import * as React98 from "react";
|
|
|
6831
6831
|
import { useId as useId3 } from "react";
|
|
6832
6832
|
import { ControlFormLabel as ControlFormLabel5, Repeater as Repeater3 } from "@elementor/editor-controls";
|
|
6833
6833
|
import {
|
|
6834
|
+
getElementType as getElementType2,
|
|
6834
6835
|
updateElementEditorSettings as updateElementEditorSettings4,
|
|
6835
6836
|
useElementChildren as useElementChildren3,
|
|
6836
6837
|
useElementEditorSettings as useElementEditorSettings4
|
|
6837
6838
|
} from "@elementor/editor-elements";
|
|
6839
|
+
import { SessionStorageProvider as SessionStorageProvider4 } from "@elementor/session";
|
|
6838
6840
|
import { Stack as Stack17, TextField as TextField4 } from "@elementor/ui";
|
|
6839
6841
|
import { __ as __76 } from "@wordpress/i18n";
|
|
6840
6842
|
|
|
@@ -6865,6 +6867,7 @@ import { __ as __75 } from "@wordpress/i18n";
|
|
|
6865
6867
|
var MENU_ITEMS_ELEMENT_TYPE = "e-menu-items";
|
|
6866
6868
|
var MENU_ENTRY_ELEMENT_TYPE = "e-menu-entry";
|
|
6867
6869
|
var MENU_ITEM_ELEMENT_TYPE = "e-menu-item";
|
|
6870
|
+
var MIN_ENTRIES = 1;
|
|
6868
6871
|
var PARAGRAPH_WIDGET_TYPE3 = "e-paragraph";
|
|
6869
6872
|
var getEntryTitle = () => __75("Menu item", "elementor");
|
|
6870
6873
|
var buildEntryModel = (title) => ({
|
|
@@ -6908,10 +6911,17 @@ var useActions2 = () => {
|
|
|
6908
6911
|
});
|
|
6909
6912
|
});
|
|
6910
6913
|
};
|
|
6911
|
-
const removeItem2 = ({ items: items3 }) => {
|
|
6914
|
+
const removeItem2 = ({ menuItemsId, items: items3 }) => {
|
|
6915
|
+
const entriesCount = getContainer8(menuItemsId)?.children?.filter(
|
|
6916
|
+
(child) => child.model.get("elType") === MENU_ENTRY_ELEMENT_TYPE
|
|
6917
|
+
).length ?? 0;
|
|
6918
|
+
const removableCount = Math.max(0, Math.min(items3.length, entriesCount - MIN_ENTRIES));
|
|
6919
|
+
if (removableCount === 0) {
|
|
6920
|
+
return;
|
|
6921
|
+
}
|
|
6912
6922
|
removeElements3({
|
|
6913
6923
|
title: __75("Menu", "elementor"),
|
|
6914
|
-
elementIds: items3.map(({ item }) => item.id)
|
|
6924
|
+
elementIds: items3.slice(0, removableCount).map(({ item }) => item.id)
|
|
6915
6925
|
});
|
|
6916
6926
|
};
|
|
6917
6927
|
const duplicateItem2 = ({ items: items3 }) => {
|
|
@@ -6944,7 +6954,31 @@ var useActions2 = () => {
|
|
|
6944
6954
|
return { addItem: addItem2, removeItem: removeItem2, duplicateItem: duplicateItem2, moveItem: moveItem2 };
|
|
6945
6955
|
};
|
|
6946
6956
|
|
|
6957
|
+
// src/controls-registry/element-controls/menu-items-control/use-entry-item.ts
|
|
6958
|
+
import { getContainer as getContainer9, getElementSettings as getElementSettings4, getElementType } from "@elementor/editor-elements";
|
|
6959
|
+
import { __privateUseListenTo as useListenTo4, commandEndEvent as commandEndEvent4 } from "@elementor/editor-v1-adapters";
|
|
6960
|
+
var useEntryItem = (entryId) => {
|
|
6961
|
+
return useListenTo4(
|
|
6962
|
+
[commandEndEvent4("document/elements/set-settings"), commandEndEvent4("document/elements/settings")],
|
|
6963
|
+
() => {
|
|
6964
|
+
const item = getContainer9(entryId)?.children?.find(
|
|
6965
|
+
(child) => child.model.get("elType") === MENU_ITEM_ELEMENT_TYPE
|
|
6966
|
+
);
|
|
6967
|
+
return {
|
|
6968
|
+
itemId: item?.id ?? null,
|
|
6969
|
+
settings: item ? getEntrySettings(item.id) : {}
|
|
6970
|
+
};
|
|
6971
|
+
},
|
|
6972
|
+
[entryId]
|
|
6973
|
+
);
|
|
6974
|
+
};
|
|
6975
|
+
var getEntrySettings = (itemId) => {
|
|
6976
|
+
const propsSchema = getElementType(MENU_ITEM_ELEMENT_TYPE)?.propsSchema ?? {};
|
|
6977
|
+
return getElementSettings4(itemId, Object.keys(propsSchema));
|
|
6978
|
+
};
|
|
6979
|
+
|
|
6947
6980
|
// src/controls-registry/element-controls/menu-items-control/menu-items-control.tsx
|
|
6981
|
+
var LINK_BIND = "link";
|
|
6948
6982
|
var MenuItemsControl = ({ label }) => {
|
|
6949
6983
|
const { element } = useElement();
|
|
6950
6984
|
const { addItem: addItem2, duplicateItem: duplicateItem2, moveItem: moveItem2, removeItem: removeItem2 } = useActions2();
|
|
@@ -6968,7 +7002,7 @@ var MenuItemsControl = ({ label }) => {
|
|
|
6968
7002
|
});
|
|
6969
7003
|
}
|
|
6970
7004
|
if (meta?.action?.type === "remove") {
|
|
6971
|
-
return removeItem2({ items: meta.action.payload });
|
|
7005
|
+
return removeItem2({ menuItemsId: menuItems.id, items: meta.action.payload });
|
|
6972
7006
|
}
|
|
6973
7007
|
if (meta?.action?.type === "duplicate") {
|
|
6974
7008
|
return duplicateItem2({ items: meta.action.payload });
|
|
@@ -7010,12 +7044,12 @@ var ItemContent3 = ({ value }) => {
|
|
|
7010
7044
|
if (!value.id) {
|
|
7011
7045
|
return null;
|
|
7012
7046
|
}
|
|
7013
|
-
return /* @__PURE__ */ React98.createElement(Stack17, { p: 2, gap: 1.5 }, /* @__PURE__ */ React98.createElement(ItemNameControl2, { elementId: value.id }));
|
|
7047
|
+
return /* @__PURE__ */ React98.createElement(Stack17, { p: 2, gap: 1.5 }, /* @__PURE__ */ React98.createElement(ItemNameControl2, { elementId: value.id }), /* @__PURE__ */ React98.createElement(ItemLinkControl, { entryId: value.id }));
|
|
7014
7048
|
};
|
|
7015
7049
|
var ItemNameControl2 = ({ elementId }) => {
|
|
7016
7050
|
const editorSettings = useElementEditorSettings4(elementId);
|
|
7017
7051
|
const inputId = useId3();
|
|
7018
|
-
return /* @__PURE__ */ React98.createElement(Stack17, { gap: 1 }, /* @__PURE__ */ React98.createElement(ControlFormLabel5, { htmlFor: inputId }, __76("
|
|
7052
|
+
return /* @__PURE__ */ React98.createElement(Stack17, { gap: 1 }, /* @__PURE__ */ React98.createElement(ControlFormLabel5, { htmlFor: inputId }, __76("Item name", "elementor")), /* @__PURE__ */ React98.createElement(
|
|
7019
7053
|
TextField4,
|
|
7020
7054
|
{
|
|
7021
7055
|
id: inputId,
|
|
@@ -7027,6 +7061,37 @@ var ItemNameControl2 = ({ elementId }) => {
|
|
|
7027
7061
|
}
|
|
7028
7062
|
));
|
|
7029
7063
|
};
|
|
7064
|
+
var ItemLinkControl = ({ entryId }) => {
|
|
7065
|
+
const { itemId, settings } = useEntryItem(entryId);
|
|
7066
|
+
const elementType = itemId ? getElementType2(MENU_ITEM_ELEMENT_TYPE) : null;
|
|
7067
|
+
const linkControl = elementType ? findControlByBind(elementType.controls, LINK_BIND) : null;
|
|
7068
|
+
if (!itemId || !elementType || !linkControl) {
|
|
7069
|
+
return null;
|
|
7070
|
+
}
|
|
7071
|
+
return /* @__PURE__ */ React98.createElement(
|
|
7072
|
+
ElementProvider,
|
|
7073
|
+
{
|
|
7074
|
+
element: { id: itemId, type: MENU_ITEM_ELEMENT_TYPE },
|
|
7075
|
+
elementType,
|
|
7076
|
+
settings
|
|
7077
|
+
},
|
|
7078
|
+
/* @__PURE__ */ React98.createElement(SessionStorageProvider4, { prefix: itemId }, /* @__PURE__ */ React98.createElement(SettingsControl, { control: linkControl }))
|
|
7079
|
+
);
|
|
7080
|
+
};
|
|
7081
|
+
var findControlByBind = (items3, bind) => {
|
|
7082
|
+
for (const item of items3) {
|
|
7083
|
+
if (item.type === "section") {
|
|
7084
|
+
const found = findControlByBind(item.value.items, bind);
|
|
7085
|
+
if (found) {
|
|
7086
|
+
return found;
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
7089
|
+
if (item.type === "control" && item.value.bind === bind) {
|
|
7090
|
+
return item;
|
|
7091
|
+
}
|
|
7092
|
+
}
|
|
7093
|
+
return null;
|
|
7094
|
+
};
|
|
7030
7095
|
|
|
7031
7096
|
// src/controls-registry/element-controls/tabs-control/tabs-control.tsx
|
|
7032
7097
|
import * as React99 from "react";
|
|
@@ -7050,7 +7115,7 @@ import { useBoundProp as useBoundProp7 } from "@elementor/editor-controls";
|
|
|
7050
7115
|
import {
|
|
7051
7116
|
createElements as createElements4,
|
|
7052
7117
|
duplicateElements as duplicateElements4,
|
|
7053
|
-
getContainer as
|
|
7118
|
+
getContainer as getContainer10,
|
|
7054
7119
|
moveElements as moveElements4,
|
|
7055
7120
|
removeElements as removeElements4
|
|
7056
7121
|
} from "@elementor/editor-elements";
|
|
@@ -7071,7 +7136,7 @@ var useActions3 = () => {
|
|
|
7071
7136
|
});
|
|
7072
7137
|
items3.forEach(({ item, index }) => {
|
|
7073
7138
|
const tabId = item.id;
|
|
7074
|
-
const tabContentAreaContainer =
|
|
7139
|
+
const tabContentAreaContainer = getContainer10(tabContentAreaId);
|
|
7075
7140
|
const tabContentId = tabContentAreaContainer?.children?.[index]?.id;
|
|
7076
7141
|
if (!tabContentId) {
|
|
7077
7142
|
throw new Error("Original content ID is required for duplication");
|
|
@@ -7099,10 +7164,10 @@ var useActions3 = () => {
|
|
|
7099
7164
|
movedElementId,
|
|
7100
7165
|
movedElementIndex
|
|
7101
7166
|
}) => {
|
|
7102
|
-
const tabContentContainer =
|
|
7167
|
+
const tabContentContainer = getContainer10(tabContentAreaId);
|
|
7103
7168
|
const tabContent = tabContentContainer?.children?.[movedElementIndex];
|
|
7104
|
-
const movedElement =
|
|
7105
|
-
const tabsMenu =
|
|
7169
|
+
const movedElement = getContainer10(movedElementId);
|
|
7170
|
+
const tabsMenu = getContainer10(tabsMenuId);
|
|
7106
7171
|
if (!tabContent) {
|
|
7107
7172
|
throw new Error("Content element is required");
|
|
7108
7173
|
}
|
|
@@ -7152,7 +7217,7 @@ var useActions3 = () => {
|
|
|
7152
7217
|
title: __77("Tabs", "elementor"),
|
|
7153
7218
|
elementIds: items3.flatMap(({ item, index }) => {
|
|
7154
7219
|
const tabId = item.id;
|
|
7155
|
-
const tabContentContainer =
|
|
7220
|
+
const tabContentContainer = getContainer10(tabContentAreaId);
|
|
7156
7221
|
const tabContentId = tabContentContainer?.children?.[index]?.id;
|
|
7157
7222
|
if (!tabContentId) {
|
|
7158
7223
|
throw new Error("Content ID is required");
|
|
@@ -7176,8 +7241,8 @@ var useActions3 = () => {
|
|
|
7176
7241
|
tabsMenuId,
|
|
7177
7242
|
items: items3
|
|
7178
7243
|
}) => {
|
|
7179
|
-
const tabContentArea =
|
|
7180
|
-
const tabsMenu =
|
|
7244
|
+
const tabContentArea = getContainer10(tabContentAreaId);
|
|
7245
|
+
const tabsMenu = getContainer10(tabsMenuId);
|
|
7181
7246
|
if (!tabContentArea || !tabsMenu) {
|
|
7182
7247
|
throw new Error("Tab containers not found");
|
|
7183
7248
|
}
|