@elementor/editor-components 3.35.0-332 → 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.mjs CHANGED
@@ -544,6 +544,21 @@ var onElementDrop = (_args, element) => {
544
544
 
545
545
  // src/create-component-type.ts
546
546
  var TYPE = "e-component";
547
+ var updateGroups = (groups, config) => {
548
+ const disableMap = new Map(Object.entries(config.disable ?? {}));
549
+ const addMap = new Map(Object.entries(config.add ?? {}));
550
+ return groups.map((group) => {
551
+ const disabledActions = disableMap.get(group.name) ?? [];
552
+ const addConfig = addMap.get(group.name);
553
+ const updatedActions = group.actions.map(
554
+ (action) => disabledActions.includes(action.name) ? { ...action, isEnabled: () => false } : action
555
+ );
556
+ if (addConfig) {
557
+ updatedActions.splice(addConfig.index, 0, addConfig.action);
558
+ }
559
+ return { ...group, actions: updatedActions };
560
+ });
561
+ };
547
562
  function createComponentType(options) {
548
563
  const legacyWindow = window;
549
564
  return class extends legacyWindow.elementor.modules.elements.types.Widget {
@@ -551,7 +566,7 @@ function createComponentType(options) {
551
566
  return options.type;
552
567
  }
553
568
  getView() {
554
- return createComponentView(options);
569
+ return createComponentView({ ...options });
555
570
  }
556
571
  };
557
572
  }
@@ -594,21 +609,32 @@ function createComponentView(options) {
594
609
  if (!componentId) {
595
610
  return filteredGroups;
596
611
  }
597
- const newGroup = [
598
- {
599
- name: "edit component",
600
- actions: [
601
- {
602
- name: "edit component",
603
- icon: "eicon-edit",
604
- title: () => __4("Edit Component", "elementor"),
605
- isEnabled: () => true,
606
- callback: (_, eventData) => this.editComponent(eventData)
607
- }
608
- ]
612
+ const newGroups = updateGroups(
613
+ filteredGroups,
614
+ this._getContextMenuConfig()
615
+ );
616
+ return newGroups;
617
+ }
618
+ _getContextMenuConfig() {
619
+ const legacyWindow = this.legacyWindow || window;
620
+ const elementorWithConfig = legacyWindow.elementor;
621
+ const isAdministrator = elementorWithConfig.config?.user?.is_administrator ?? false;
622
+ const addedGroup = {
623
+ general: {
624
+ index: 1,
625
+ action: {
626
+ name: "edit component",
627
+ icon: "eicon-edit",
628
+ title: () => __4("Edit Component", "elementor"),
629
+ isEnabled: () => true,
630
+ callback: (_, eventData) => this.editComponent(eventData)
631
+ }
609
632
  }
610
- ];
611
- return [...filteredGroups, ...newGroup];
633
+ };
634
+ const disabledGroup = {
635
+ clipboard: ["pasteStyle", "resetStyle"]
636
+ };
637
+ return { add: isAdministrator ? addedGroup : {}, disable: disabledGroup };
612
638
  }
613
639
  async switchDocument() {
614
640
  const { isAllowedToSwitchDocument, lockedBy } = await apiClient.getComponentLockStatus(