@elementor/editor-components 3.35.0-331 → 3.35.0-333
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 +41 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/create-component-type.ts +75 -17
package/dist/index.js
CHANGED
|
@@ -556,6 +556,21 @@ var onElementDrop = (_args, element) => {
|
|
|
556
556
|
|
|
557
557
|
// src/create-component-type.ts
|
|
558
558
|
var TYPE = "e-component";
|
|
559
|
+
var updateGroups = (groups, config) => {
|
|
560
|
+
const disableMap = new Map(Object.entries(config.disable ?? {}));
|
|
561
|
+
const addMap = new Map(Object.entries(config.add ?? {}));
|
|
562
|
+
return groups.map((group) => {
|
|
563
|
+
const disabledActions = disableMap.get(group.name) ?? [];
|
|
564
|
+
const addConfig = addMap.get(group.name);
|
|
565
|
+
const updatedActions = group.actions.map(
|
|
566
|
+
(action) => disabledActions.includes(action.name) ? { ...action, isEnabled: () => false } : action
|
|
567
|
+
);
|
|
568
|
+
if (addConfig) {
|
|
569
|
+
updatedActions.splice(addConfig.index, 0, addConfig.action);
|
|
570
|
+
}
|
|
571
|
+
return { ...group, actions: updatedActions };
|
|
572
|
+
});
|
|
573
|
+
};
|
|
559
574
|
function createComponentType(options) {
|
|
560
575
|
const legacyWindow = window;
|
|
561
576
|
return class extends legacyWindow.elementor.modules.elements.types.Widget {
|
|
@@ -563,7 +578,7 @@ function createComponentType(options) {
|
|
|
563
578
|
return options.type;
|
|
564
579
|
}
|
|
565
580
|
getView() {
|
|
566
|
-
return createComponentView(options);
|
|
581
|
+
return createComponentView({ ...options });
|
|
567
582
|
}
|
|
568
583
|
};
|
|
569
584
|
}
|
|
@@ -606,21 +621,32 @@ function createComponentView(options) {
|
|
|
606
621
|
if (!componentId) {
|
|
607
622
|
return filteredGroups;
|
|
608
623
|
}
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
624
|
+
const newGroups = updateGroups(
|
|
625
|
+
filteredGroups,
|
|
626
|
+
this._getContextMenuConfig()
|
|
627
|
+
);
|
|
628
|
+
return newGroups;
|
|
629
|
+
}
|
|
630
|
+
_getContextMenuConfig() {
|
|
631
|
+
const legacyWindow = this.legacyWindow || window;
|
|
632
|
+
const elementorWithConfig = legacyWindow.elementor;
|
|
633
|
+
const isAdministrator = elementorWithConfig.config?.user?.is_administrator ?? false;
|
|
634
|
+
const addedGroup = {
|
|
635
|
+
general: {
|
|
636
|
+
index: 1,
|
|
637
|
+
action: {
|
|
638
|
+
name: "edit component",
|
|
639
|
+
icon: "eicon-edit",
|
|
640
|
+
title: () => (0, import_i18n4.__)("Edit Component", "elementor"),
|
|
641
|
+
isEnabled: () => true,
|
|
642
|
+
callback: (_, eventData) => this.editComponent(eventData)
|
|
643
|
+
}
|
|
621
644
|
}
|
|
622
|
-
|
|
623
|
-
|
|
645
|
+
};
|
|
646
|
+
const disabledGroup = {
|
|
647
|
+
clipboard: ["pasteStyle", "resetStyle"]
|
|
648
|
+
};
|
|
649
|
+
return { add: isAdministrator ? addedGroup : {}, disable: disabledGroup };
|
|
624
650
|
}
|
|
625
651
|
async switchDocument() {
|
|
626
652
|
const { isAllowedToSwitchDocument, lockedBy } = await apiClient.getComponentLockStatus(
|