@elementor/editor-editing-panel 3.33.0-237 → 3.33.0-239

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-editing-panel",
3
- "version": "3.33.0-237",
3
+ "version": "3.33.0-239",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,27 +39,27 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "3.33.0-237",
43
- "@elementor/editor-canvas": "3.33.0-237",
44
- "@elementor/editor-controls": "3.33.0-237",
45
- "@elementor/editor-documents": "3.33.0-237",
46
- "@elementor/editor-elements": "3.33.0-237",
47
- "@elementor/editor-interactions": "3.33.0-237",
48
- "@elementor/editor-panels": "3.33.0-237",
49
- "@elementor/editor-props": "3.33.0-237",
50
- "@elementor/editor-responsive": "3.33.0-237",
51
- "@elementor/editor-styles": "3.33.0-237",
52
- "@elementor/editor-styles-repository": "3.33.0-237",
53
- "@elementor/editor-ui": "3.33.0-237",
54
- "@elementor/editor-v1-adapters": "3.33.0-237",
42
+ "@elementor/editor": "3.33.0-239",
43
+ "@elementor/editor-canvas": "3.33.0-239",
44
+ "@elementor/editor-controls": "3.33.0-239",
45
+ "@elementor/editor-documents": "3.33.0-239",
46
+ "@elementor/editor-elements": "3.33.0-239",
47
+ "@elementor/editor-interactions": "3.33.0-239",
48
+ "@elementor/editor-panels": "3.33.0-239",
49
+ "@elementor/editor-props": "3.33.0-239",
50
+ "@elementor/editor-responsive": "3.33.0-239",
51
+ "@elementor/editor-styles": "3.33.0-239",
52
+ "@elementor/editor-styles-repository": "3.33.0-239",
53
+ "@elementor/editor-ui": "3.33.0-239",
54
+ "@elementor/editor-v1-adapters": "3.33.0-239",
55
55
  "@elementor/icons": "1.56.0",
56
- "@elementor/locations": "3.33.0-237",
57
- "@elementor/menus": "3.33.0-237",
58
- "@elementor/schema": "3.33.0-237",
59
- "@elementor/session": "3.33.0-237",
56
+ "@elementor/locations": "3.33.0-239",
57
+ "@elementor/menus": "3.33.0-239",
58
+ "@elementor/schema": "3.33.0-239",
59
+ "@elementor/session": "3.33.0-239",
60
60
  "@elementor/ui": "1.36.15",
61
- "@elementor/utils": "3.33.0-237",
62
- "@elementor/wp-media": "3.33.0-237",
61
+ "@elementor/utils": "3.33.0-239",
62
+ "@elementor/wp-media": "3.33.0-239",
63
63
  "@wordpress/i18n": "^5.13.0"
64
64
  },
65
65
  "peerDependencies": {
@@ -2,13 +2,10 @@ import { type ItemActionPayload } from '@elementor/editor-controls';
2
2
  import {
3
3
  createElements,
4
4
  duplicateElements,
5
- generateElementId,
6
- getElementSetting,
5
+ getContainer,
7
6
  moveElements,
8
7
  removeElements,
9
- updateElementSettings,
10
8
  } from '@elementor/editor-elements';
11
- import { stringPropTypeUtil, type StringPropValue } from '@elementor/editor-props';
12
9
  import { __ } from '@wordpress/i18n';
13
10
 
14
11
  export type TabItem = {
@@ -19,11 +16,17 @@ export type TabItem = {
19
16
  export const TAB_ELEMENT_TYPE = 'e-tab';
20
17
  export const TAB_CONTENT_ELEMENT_TYPE = 'e-tab-content';
21
18
 
22
- export const duplicateItem = ( { items }: { items: ItemActionPayload< TabItem > } ) => {
23
- items.forEach( ( { item } ) => {
19
+ export const duplicateItem = ( {
20
+ items,
21
+ tabContentAreaId,
22
+ }: {
23
+ items: ItemActionPayload< TabItem >;
24
+ tabContentAreaId: string;
25
+ } ) => {
26
+ items.forEach( ( { item, index } ) => {
24
27
  const tabId = item.id as string;
25
-
26
- const { value: tabContentId } = getElementSetting< StringPropValue >( tabId, 'tab-content-id' ) ?? {};
28
+ const tabContentAreaContainer = getContainer( tabContentAreaId );
29
+ const tabContentId = tabContentAreaContainer?.children?.[ index ]?.id;
27
30
 
28
31
  if ( ! tabContentId ) {
29
32
  throw new Error( 'Original content ID is required for duplication' );
@@ -32,27 +35,6 @@ export const duplicateItem = ( { items }: { items: ItemActionPayload< TabItem >
32
35
  duplicateElements( {
33
36
  elementIds: [ tabId, tabContentId ],
34
37
  title: __( 'Duplicate Tab', 'elementor' ),
35
- onCreate: ( duplicatedElements ) => {
36
- const tab = duplicatedElements.find( ( element ) => element.originalElementId === tabId );
37
- const tabContent = duplicatedElements.find( ( element ) => element.originalElementId === tabContentId );
38
-
39
- if ( tabContent && tab ) {
40
- updateElementSettings( {
41
- withHistory: false,
42
- id: tab.id,
43
- props: {
44
- 'tab-content-id': stringPropTypeUtil.create( tabContent.id ),
45
- },
46
- } );
47
- updateElementSettings( {
48
- withHistory: false,
49
- id: tabContent.id,
50
- props: {
51
- 'tab-id': stringPropTypeUtil.create( tab.id ),
52
- },
53
- } );
54
- }
55
- },
56
38
  } );
57
39
  } );
58
40
  };
@@ -62,16 +44,19 @@ export const moveItem = ( {
62
44
  tabsMenuId,
63
45
  tabContentAreaId,
64
46
  movedElementId,
47
+ movedElementIndex,
65
48
  }: {
66
49
  toIndex: number;
67
50
  tabsMenuId: string;
68
51
  tabContentAreaId: string;
69
52
  movedElementId: string;
53
+ movedElementIndex: number;
70
54
  } ) => {
71
- const { value: tabContentId } = getElementSetting< StringPropValue >( movedElementId, 'tab-content-id' ) ?? {};
55
+ const tabContentContainer = getContainer( tabContentAreaId );
56
+ const tabContentId = tabContentContainer?.children?.[ movedElementIndex ]?.id;
72
57
 
73
58
  if ( ! tabContentId ) {
74
- throw new Error( 'Required tab elements not found for reordering' );
59
+ throw new Error( 'Content ID is required' );
75
60
  }
76
61
 
77
62
  moveElements( {
@@ -91,12 +76,19 @@ export const moveItem = ( {
91
76
  } );
92
77
  };
93
78
 
94
- export const removeItem = ( { items }: { items: ItemActionPayload< TabItem > } ) => {
79
+ export const removeItem = ( {
80
+ items,
81
+ tabContentAreaId,
82
+ }: {
83
+ items: ItemActionPayload< TabItem >;
84
+ tabContentAreaId: string;
85
+ } ) => {
95
86
  removeElements( {
96
87
  title: __( 'Tabs', 'elementor' ),
97
- elementIds: items.flatMap( ( { item } ) => {
88
+ elementIds: items.flatMap( ( { item, index } ) => {
98
89
  const tabId = item.id as string;
99
- const { value: tabContentId } = getElementSetting< StringPropValue >( tabId, 'tab-content-id' ) ?? {};
90
+ const tabContentContainer = getContainer( tabContentAreaId );
91
+ const tabContentId = tabContentContainer?.children?.[ index ]?.id;
100
92
 
101
93
  if ( ! tabContentId ) {
102
94
  throw new Error( 'Content ID is required' );
@@ -116,33 +108,21 @@ export const addItem = ( {
116
108
  tabsMenuId: string;
117
109
  items: ItemActionPayload< TabItem >;
118
110
  } ) => {
119
- items.forEach( ( { item, index } ) => {
120
- const newTabContentId = generateElementId();
121
- const newTabId = generateElementId();
122
-
111
+ items.forEach( ( { index } ) => {
123
112
  createElements( {
124
113
  title: __( 'Tabs', 'elementor' ),
125
114
  elements: [
126
115
  {
127
116
  containerId: tabContentAreaId,
128
117
  model: {
129
- id: newTabContentId,
130
118
  elType: TAB_CONTENT_ELEMENT_TYPE,
131
- settings: {
132
- 'tab-id': stringPropTypeUtil.create( newTabId ),
133
- },
134
119
  editor_settings: { title: `Tab ${ index + 1 } content` },
135
120
  },
136
121
  },
137
122
  {
138
123
  containerId: tabsMenuId,
139
124
  model: {
140
- id: newTabId,
141
125
  elType: TAB_ELEMENT_TYPE,
142
- settings: {
143
- ...item,
144
- 'tab-content-id': stringPropTypeUtil.create( newTabContentId ),
145
- },
146
126
  editor_settings: { title: `Tab ${ index + 1 } trigger` },
147
127
  },
148
128
  },
@@ -12,7 +12,7 @@ import {
12
12
  useElementChildren,
13
13
  useElementEditorSettings,
14
14
  } from '@elementor/editor-elements';
15
- import { type CreateOptions, stringPropTypeUtil } from '@elementor/editor-props';
15
+ import { type CreateOptions, numberPropTypeUtil } from '@elementor/editor-props';
16
16
  import { InfoCircleFilledIcon } from '@elementor/icons';
17
17
  import { Alert, Chip, Infotip, type InfotipProps, Stack, Switch, TextField, Typography } from '@elementor/ui';
18
18
  import { __ } from '@wordpress/i18n';
@@ -44,12 +44,13 @@ export const TabsControl = ( { label }: { label: string } ) => {
44
44
  const tabList = getElementByType( element.id, TAB_MENU_ELEMENT_TYPE );
45
45
  const tabContentArea = getElementByType( element.id, TAB_CONTENT_AREA_ELEMENT_TYPE );
46
46
 
47
- const repeaterValues: RepeaterItem< TabItem >[] = tabLinks.map( ( tabLink ) => {
47
+ const repeaterValues: RepeaterItem< TabItem >[] = tabLinks.map( ( tabLink, index ) => {
48
48
  const { title: titleSetting } = getElementEditorSettings( tabLink.id ) ?? {};
49
49
 
50
50
  return {
51
51
  id: tabLink.id,
52
52
  title: titleSetting,
53
+ index,
53
54
  };
54
55
  } );
55
56
 
@@ -67,13 +68,13 @@ export const TabsControl = ( { label }: { label: string } ) => {
67
68
  if ( meta?.action?.type === 'remove' ) {
68
69
  const items = meta.action.payload;
69
70
 
70
- return removeItem( { items } );
71
+ return removeItem( { items, tabContentAreaId: tabContentArea.id } );
71
72
  }
72
73
 
73
74
  if ( meta?.action?.type === 'duplicate' ) {
74
75
  const items = meta.action.payload;
75
76
 
76
- return duplicateItem( { items } );
77
+ return duplicateItem( { items, tabContentAreaId: tabContentArea.id } );
77
78
  }
78
79
 
79
80
  if ( meta?.action?.type === 'reorder' ) {
@@ -84,6 +85,7 @@ export const TabsControl = ( { label }: { label: string } ) => {
84
85
  tabsMenuId: tabList.id,
85
86
  tabContentAreaId: tabContentArea.id,
86
87
  movedElementId: tabLinks[ from ].id,
88
+ movedElementIndex: from,
87
89
  } );
88
90
  }
89
91
  };
@@ -106,7 +108,7 @@ export const TabsControl = ( { label }: { label: string } ) => {
106
108
  );
107
109
  };
108
110
 
109
- const ItemLabel = ( { value }: { value: TabItem } ) => {
111
+ const ItemLabel = ( { value, index }: { value: TabItem; index: number } ) => {
110
112
  const id = value.id ?? '';
111
113
 
112
114
  const editorSettings = useElementEditorSettings( id );
@@ -117,17 +119,16 @@ const ItemLabel = ( { value }: { value: TabItem } ) => {
117
119
  <Stack sx={ { minHeight: 20 } } direction="row" alignItems="center" gap={ 1.5 }>
118
120
  <span>{ elementTitle }</span>
119
121
  <SettingsField bind="default-active-tab" propDisplayName={ __( 'Tabs', 'elementor' ) }>
120
- <ItemDefaultTab value={ value } />
122
+ <ItemDefaultTab index={ index } />
121
123
  </SettingsField>
122
124
  </Stack>
123
125
  );
124
126
  };
125
127
 
126
- const ItemDefaultTab = ( { value }: { value: TabItem } ) => {
127
- const id = value.id ?? '';
128
- const { value: defaultItem } = useBoundProp( stringPropTypeUtil );
128
+ const ItemDefaultTab = ( { index }: { index: number } ) => {
129
+ const { value: defaultItem } = useBoundProp( numberPropTypeUtil );
129
130
 
130
- const isDefault = defaultItem === id;
131
+ const isDefault = defaultItem === index;
131
132
 
132
133
  if ( ! isDefault ) {
133
134
  return null;
@@ -136,7 +137,7 @@ const ItemDefaultTab = ( { value }: { value: TabItem } ) => {
136
137
  return <Chip size="tiny" shape="rounded" label={ __( 'Default', 'elementor' ) } />;
137
138
  };
138
139
 
139
- const ItemContent = ( { value }: { value: TabItem } ) => {
140
+ const ItemContent = ( { value, index }: { value: TabItem; index: number } ) => {
140
141
  if ( ! value.id ) {
141
142
  return null;
142
143
  }
@@ -145,16 +146,16 @@ const ItemContent = ( { value }: { value: TabItem } ) => {
145
146
  <Stack p={ 2 } gap={ 1.5 }>
146
147
  <TabLabelControl elementId={ value.id } />
147
148
  <SettingsField bind="default-active-tab" propDisplayName={ __( 'Tabs', 'elementor' ) }>
148
- <DefaultTabControl elementId={ value.id } />
149
+ <DefaultTabControl tabIndex={ index } />
149
150
  </SettingsField>
150
151
  </Stack>
151
152
  );
152
153
  };
153
154
 
154
- const DefaultTabControl = ( { elementId }: { elementId: string } ) => {
155
- const { value, setValue } = useBoundProp( stringPropTypeUtil );
155
+ const DefaultTabControl = ( { tabIndex }: { tabIndex: number } ) => {
156
+ const { value, setValue } = useBoundProp( numberPropTypeUtil );
156
157
 
157
- const isDefault = value === elementId;
158
+ const isDefault = value === tabIndex;
158
159
 
159
160
  return (
160
161
  <Stack direction="row" alignItems="center" justifyContent="space-between" gap={ 2 }>
@@ -165,7 +166,7 @@ const DefaultTabControl = ( { elementId }: { elementId: string } ) => {
165
166
  checked={ isDefault }
166
167
  disabled={ isDefault }
167
168
  onChange={ ( { target }: React.ChangeEvent< HTMLInputElement > ) => {
168
- setValue( target.checked ? elementId : null );
169
+ setValue( target.checked ? tabIndex : null );
169
170
  } }
170
171
  inputProps={ {
171
172
  ...( isDefault ? { style: { opacity: 0, cursor: 'not-allowed' } } : {} ),