@elementor/editor-components 3.35.0-478 → 3.35.0-480

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-components",
3
3
  "description": "Elementor editor components",
4
- "version": "3.35.0-478",
4
+ "version": "3.35.0-480",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,30 +40,30 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor": "3.35.0-478",
44
- "@elementor/editor-canvas": "3.35.0-478",
45
- "@elementor/editor-controls": "3.35.0-478",
46
- "@elementor/editor-documents": "3.35.0-478",
47
- "@elementor/editor-editing-panel": "3.35.0-478",
48
- "@elementor/editor-elements": "3.35.0-478",
49
- "@elementor/editor-elements-panel": "3.35.0-478",
50
- "@elementor/editor-mcp": "3.35.0-478",
51
- "@elementor/editor-panels": "3.35.0-478",
52
- "@elementor/editor-props": "3.35.0-478",
53
- "@elementor/editor-styles-repository": "3.35.0-478",
54
- "@elementor/editor-ui": "3.35.0-478",
55
- "@elementor/editor-v1-adapters": "3.35.0-478",
56
- "@elementor/http-client": "3.35.0-478",
43
+ "@elementor/editor": "3.35.0-480",
44
+ "@elementor/editor-canvas": "3.35.0-480",
45
+ "@elementor/editor-controls": "3.35.0-480",
46
+ "@elementor/editor-documents": "3.35.0-480",
47
+ "@elementor/editor-editing-panel": "3.35.0-480",
48
+ "@elementor/editor-elements": "3.35.0-480",
49
+ "@elementor/editor-elements-panel": "3.35.0-480",
50
+ "@elementor/editor-mcp": "3.35.0-480",
51
+ "@elementor/editor-panels": "3.35.0-480",
52
+ "@elementor/editor-props": "3.35.0-480",
53
+ "@elementor/editor-styles-repository": "3.35.0-480",
54
+ "@elementor/editor-ui": "3.35.0-480",
55
+ "@elementor/editor-v1-adapters": "3.35.0-480",
56
+ "@elementor/http-client": "3.35.0-480",
57
57
  "@elementor/icons": "^1.63.0",
58
- "@elementor/mixpanel": "3.35.0-478",
59
- "@elementor/query": "3.35.0-478",
60
- "@elementor/schema": "3.35.0-478",
61
- "@elementor/store": "3.35.0-478",
58
+ "@elementor/mixpanel": "3.35.0-480",
59
+ "@elementor/query": "3.35.0-480",
60
+ "@elementor/schema": "3.35.0-480",
61
+ "@elementor/store": "3.35.0-480",
62
62
  "@elementor/ui": "1.36.17",
63
- "@elementor/utils": "3.35.0-478",
63
+ "@elementor/utils": "3.35.0-480",
64
64
  "@wordpress/i18n": "^5.13.0",
65
- "@elementor/editor-notifications": "3.35.0-478",
66
- "@elementor/editor-current-user": "3.35.0-478"
65
+ "@elementor/editor-notifications": "3.35.0-480",
66
+ "@elementor/editor-current-user": "3.35.0-480"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "react": "^18.3.1",
package/src/api.ts CHANGED
@@ -100,21 +100,23 @@ export const apiClient = {
100
100
  },
101
101
  } )
102
102
  .then( ( res ) => res.data.data ),
103
- updateArchivedComponents: async ( componentIds: number[] ) =>
103
+ updateArchivedComponents: async ( componentIds: number[], status: DocumentSaveStatus ) =>
104
104
  await httpService()
105
105
  .post< { data: { failedIds: number[]; successIds: number[]; success: boolean } } >(
106
106
  `${ BASE_URL }/archive`,
107
107
  {
108
108
  componentIds,
109
+ status,
109
110
  }
110
111
  )
111
112
  .then( ( res ) => res.data.data ),
112
- updateComponentTitle: ( updatedComponentNames: UpdatedComponentName[] ) =>
113
+ updateComponentTitle: ( updatedComponentNames: UpdatedComponentName[], status: DocumentSaveStatus ) =>
113
114
  httpService()
114
115
  .post< { data: { failedIds: number[]; successIds: number[]; success: boolean } } >(
115
116
  `${ BASE_URL }/update-titles`,
116
117
  {
117
118
  components: updatedComponentNames,
119
+ status,
118
120
  }
119
121
  )
120
122
  .then( ( res ) => res.data.data ),
@@ -20,8 +20,10 @@ type Props = {
20
20
  };
21
21
 
22
22
  export function OverridablePropForm( { onSubmit, groups, currentValue, existingLabels = [], sx }: Props ) {
23
+ const selectGroups = groups?.length ? groups : [ DEFAULT_GROUP ];
24
+
23
25
  const [ propLabel, setPropLabel ] = useState< string | null >( currentValue?.label ?? null );
24
- const [ group, setGroup ] = useState< string | null >( currentValue?.groupId ?? groups?.[ 0 ]?.value ?? null );
26
+ const [ group, setGroup ] = useState< string | null >( currentValue?.groupId ?? selectGroups[ 0 ]?.value ?? null );
25
27
  const [ error, setError ] = useState< string | null >( null );
26
28
 
27
29
  const name = __( 'Name', 'elementor' );
@@ -98,16 +100,17 @@ export function OverridablePropForm( { onSubmit, groups, currentValue, existingL
98
100
  }
99
101
  displayEmpty
100
102
  renderValue={ ( selectedValue: string | null ) => {
101
- if ( ! selectedValue || selectedValue === '' ) {
102
- const [ firstGroup = DEFAULT_GROUP ] = groups ?? [];
103
-
104
- return firstGroup.label;
103
+ if ( ! selectedValue ) {
104
+ return selectGroups[ 0 ].label;
105
105
  }
106
106
 
107
- return groups?.find( ( { value } ) => value === selectedValue )?.label ?? selectedValue;
107
+ return (
108
+ selectGroups.find( ( { value } ) => value === selectedValue )?.label ??
109
+ selectedValue
110
+ );
108
111
  } }
109
112
  >
110
- { ( groups ?? [ DEFAULT_GROUP ] ).map( ( { label: groupLabel, ...props } ) => (
113
+ { selectGroups.map( ( { label: groupLabel, ...props } ) => (
111
114
  <MenuListItem key={ props.value } { ...props } value={ props.value ?? '' }>
112
115
  { groupLabel }
113
116
  </MenuListItem>
@@ -3,10 +3,10 @@ import { type V1Element, type V1ElementData } from '@elementor/editor-elements';
3
3
 
4
4
  import { type DocumentSaveStatus } from '../types';
5
5
  import { createComponentsBeforeSave } from './create-components-before-save';
6
+ import { publishDraftComponentsInPageBeforeSave } from './publish-draft-components-in-page-before-save';
6
7
  import { setComponentOverridablePropsSettingsBeforeSave } from './set-component-overridable-props-settings-before-save';
7
8
  import { updateArchivedComponentBeforeSave } from './update-archived-component-before-save';
8
9
  import { updateComponentTitleBeforeSave } from './update-component-title-before-save';
9
- import { updateComponentsBeforeSave } from './update-components-before-save';
10
10
 
11
11
  type Options = {
12
12
  container: V1Element & {
@@ -24,10 +24,29 @@ export const beforeSave = ( { container, status }: Options ) => {
24
24
  const elements = container?.model.get( 'elements' ).toJSON?.() ?? [];
25
25
 
26
26
  return Promise.all( [
27
- updateArchivedComponentBeforeSave(),
28
- createComponentsBeforeSave( { elements, status } ),
29
- updateComponentsBeforeSave( { elements, status } ),
27
+ syncComponents( { elements, status } ),
30
28
  setComponentOverridablePropsSettingsBeforeSave( { container } ),
31
- updateComponentTitleBeforeSave(),
32
29
  ] );
33
30
  };
31
+
32
+ // These operations run sequentially to prevent race conditions when multiple
33
+ // edits occur on the same component simultaneously.
34
+ // TODO: Consolidate these into a single PUT /components endpoint.
35
+ const syncComponents = async ( { elements, status }: { elements: V1ElementData[]; status: DocumentSaveStatus } ) => {
36
+ // This order is important - first update existing components, then create new components,
37
+ // Since new component validation depends on the existing components (preventing duplicate names).
38
+ await updateExistingComponentsBeforeSave( { elements, status } );
39
+ await createComponentsBeforeSave( { elements, status } );
40
+ };
41
+
42
+ const updateExistingComponentsBeforeSave = async ( {
43
+ elements,
44
+ status,
45
+ }: {
46
+ elements: V1ElementData[];
47
+ status: DocumentSaveStatus;
48
+ } ) => {
49
+ await updateComponentTitleBeforeSave( status );
50
+ await updateArchivedComponentBeforeSave( status );
51
+ await publishDraftComponentsInPageBeforeSave( { elements, status } );
52
+ };
@@ -11,7 +11,7 @@ type Options = {
11
11
  elements: V1ElementData[];
12
12
  };
13
13
 
14
- export async function updateComponentsBeforeSave( { status, elements }: Options ) {
14
+ export async function publishDraftComponentsInPageBeforeSave( { status, elements }: Options ) {
15
15
  if ( status !== 'publish' ) {
16
16
  return;
17
17
  }
@@ -3,6 +3,7 @@ import { __getState as getState } from '@elementor/store';
3
3
 
4
4
  import { apiClient } from '../api';
5
5
  import { selectArchivedThisSession } from '../store/store';
6
+ import { type DocumentSaveStatus } from '../types';
6
7
 
7
8
  const failedNotification = ( message: string ): NotificationData => ( {
8
9
  type: 'error',
@@ -10,7 +11,7 @@ const failedNotification = ( message: string ): NotificationData => ( {
10
11
  id: 'failed-archived-components-notification',
11
12
  } );
12
13
 
13
- export const updateArchivedComponentBeforeSave = async () => {
14
+ export const updateArchivedComponentBeforeSave = async ( status: DocumentSaveStatus ) => {
14
15
  try {
15
16
  const archivedComponents = selectArchivedThisSession( getState() );
16
17
 
@@ -18,7 +19,7 @@ export const updateArchivedComponentBeforeSave = async () => {
18
19
  return;
19
20
  }
20
21
 
21
- const result = await apiClient.updateArchivedComponents( archivedComponents );
22
+ const result = await apiClient.updateArchivedComponents( archivedComponents, status );
22
23
 
23
24
  const failedIds = result.failedIds.join( ', ' );
24
25
 
@@ -2,15 +2,16 @@ import { __dispatch as dispatch, __getState as getState } from '@elementor/store
2
2
 
3
3
  import { apiClient } from '../api';
4
4
  import { selectUpdatedComponentNames, slice } from '../store/store';
5
+ import { type DocumentSaveStatus } from '../types';
5
6
 
6
- export const updateComponentTitleBeforeSave = async () => {
7
+ export const updateComponentTitleBeforeSave = async ( status: DocumentSaveStatus ) => {
7
8
  const updatedComponentNames = selectUpdatedComponentNames( getState() );
8
9
 
9
10
  if ( ! updatedComponentNames.length ) {
10
11
  return;
11
12
  }
12
13
 
13
- const result = await apiClient.updateComponentTitle( updatedComponentNames );
14
+ const result = await apiClient.updateComponentTitle( updatedComponentNames, status );
14
15
 
15
16
  if ( result.failedIds.length === 0 ) {
16
17
  dispatch( slice.actions.cleanUpdatedComponentNames() );