@elementor/editor-components 4.0.1 → 4.0.3

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": "4.0.1",
4
+ "version": "4.0.3",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,31 +40,31 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor": "4.0.1",
44
- "@elementor/editor-canvas": "4.0.1",
45
- "@elementor/editor-controls": "4.0.1",
46
- "@elementor/editor-documents": "4.0.1",
47
- "@elementor/editor-editing-panel": "4.0.1",
48
- "@elementor/editor-elements": "4.0.1",
49
- "@elementor/editor-elements-panel": "4.0.1",
50
- "@elementor/editor-mcp": "4.0.1",
51
- "@elementor/editor-templates": "4.0.1",
52
- "@elementor/editor-panels": "4.0.1",
53
- "@elementor/editor-props": "4.0.1",
54
- "@elementor/editor-styles-repository": "4.0.1",
55
- "@elementor/editor-ui": "4.0.1",
56
- "@elementor/editor-v1-adapters": "4.0.1",
57
- "@elementor/http-client": "4.0.1",
43
+ "@elementor/editor": "4.0.3",
44
+ "@elementor/editor-canvas": "4.0.3",
45
+ "@elementor/editor-controls": "4.0.3",
46
+ "@elementor/editor-documents": "4.0.3",
47
+ "@elementor/editor-editing-panel": "4.0.3",
48
+ "@elementor/editor-elements": "4.0.3",
49
+ "@elementor/editor-elements-panel": "4.0.3",
50
+ "@elementor/editor-mcp": "4.0.3",
51
+ "@elementor/editor-templates": "4.0.3",
52
+ "@elementor/editor-panels": "4.0.3",
53
+ "@elementor/editor-props": "4.0.3",
54
+ "@elementor/editor-styles-repository": "4.0.3",
55
+ "@elementor/editor-ui": "4.0.3",
56
+ "@elementor/editor-v1-adapters": "4.0.3",
57
+ "@elementor/http-client": "4.0.3",
58
58
  "@elementor/icons": "^1.68.0",
59
- "@elementor/events": "4.0.1",
60
- "@elementor/query": "4.0.1",
61
- "@elementor/schema": "4.0.1",
62
- "@elementor/store": "4.0.1",
59
+ "@elementor/events": "4.0.3",
60
+ "@elementor/query": "4.0.3",
61
+ "@elementor/schema": "4.0.3",
62
+ "@elementor/store": "4.0.3",
63
63
  "@elementor/ui": "1.36.17",
64
- "@elementor/utils": "4.0.1",
64
+ "@elementor/utils": "4.0.3",
65
65
  "@wordpress/i18n": "^5.13.0",
66
- "@elementor/editor-notifications": "4.0.1",
67
- "@elementor/editor-current-user": "4.0.1"
66
+ "@elementor/editor-notifications": "4.0.3",
67
+ "@elementor/editor-current-user": "4.0.3"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.3.1",
package/src/api.ts CHANGED
@@ -92,14 +92,15 @@ export const apiClient = {
92
92
  componentId,
93
93
  } )
94
94
  .then( ( res ) => res.data ),
95
- getOverridableProps: async ( componentId: number ) =>
95
+ getOverridableProps: async ( componentIds: number[] ) =>
96
96
  await httpService()
97
- .get< HttpResponse< OverridableProps > >( `${ BASE_URL }/overridable-props`, {
98
- params: {
99
- componentId: componentId.toString(),
100
- },
101
- } )
102
- .then( ( res ) => res.data.data ),
97
+ .get< HttpResponse< Record< number, OverridableProps | null >, { errors: Record< number, string > } > >(
98
+ `${ BASE_URL }/overridable-props`,
99
+ {
100
+ params: { 'componentIds[]': componentIds },
101
+ }
102
+ )
103
+ .then( ( res ) => res.data ),
103
104
  updateArchivedComponents: async ( componentIds: number[], status: DocumentSaveStatus ) =>
104
105
  await httpService()
105
106
  .post< { data: { failedIds: number[]; successIds: number[]; success: boolean } } >(
@@ -3,31 +3,14 @@ import { __dispatch as dispatch, __getState as getState } from '@elementor/store
3
3
  import { apiClient } from '../../api';
4
4
  import { selectIsOverridablePropsLoaded, slice } from '../store';
5
5
 
6
- export function loadComponentsOverridableProps( componentIds: number[] ) {
7
- if ( ! componentIds.length ) {
8
- return;
9
- }
10
-
11
- return Promise.all( componentIds.map( loadComponentOverrides ) );
12
- }
6
+ export async function loadComponentsOverridableProps( componentIds: number[] ) {
7
+ const unloadedIds = componentIds.filter( ( id ) => ! selectIsOverridablePropsLoaded( getState(), id ) );
13
8
 
14
- async function loadComponentOverrides( componentId: number ) {
15
- const isOverridablePropsLoaded = selectIsOverridablePropsLoaded( getState(), componentId );
16
-
17
- if ( isOverridablePropsLoaded ) {
9
+ if ( ! unloadedIds.length ) {
18
10
  return;
19
11
  }
20
12
 
21
- const overridableProps = await apiClient.getOverridableProps( componentId );
22
-
23
- if ( ! overridableProps ) {
24
- return;
25
- }
13
+ const { data } = await apiClient.getOverridableProps( unloadedIds );
26
14
 
27
- dispatch(
28
- slice.actions.setOverridableProps( {
29
- componentId,
30
- overridableProps,
31
- } )
32
- );
15
+ dispatch( slice.actions.loadOverridableProps( data ) );
33
16
  }
@@ -1,3 +1,4 @@
1
+ import { getCurrentDocumentId } from '@elementor/editor-elements';
1
2
  import { createStylesProvider } from '@elementor/editor-styles-repository';
2
3
  import { __getState as getState, __subscribeWithSelector as subscribeWithSelector } from '@elementor/store';
3
4
 
@@ -15,7 +16,8 @@ export const componentsStylesProvider = createStylesProvider( {
15
16
  ),
16
17
  actions: {
17
18
  all: () => {
18
- return selectFlatStyles( getState() );
19
+ const currentDocumentId = getCurrentDocumentId();
20
+ return selectFlatStyles( getState(), currentDocumentId );
19
21
  },
20
22
  get: ( id ) => {
21
23
  return selectFlatStyles( getState() ).find( ( style ) => style.id === id ) ?? null;
@@ -105,6 +105,25 @@ const baseSlice = createSlice( {
105
105
 
106
106
  component.overridableProps = payload.overridableProps;
107
107
  },
108
+ loadOverridableProps: (
109
+ state,
110
+ { payload }: PayloadAction< Record< ComponentId, OverridableProps | null > >
111
+ ) => {
112
+ const componentIds = Object.keys( payload );
113
+
114
+ componentIds.forEach( ( id ) => {
115
+ const componentId = Number( id );
116
+ const overridableProps = payload[ componentId ];
117
+
118
+ const component = state.data.find( ( comp ) => comp.id === componentId );
119
+
120
+ if ( ! component || ! overridableProps ) {
121
+ return;
122
+ }
123
+
124
+ component.overridableProps = overridableProps;
125
+ } );
126
+ },
108
127
  rename: ( state, { payload }: PayloadAction< { componentUid: string; name: string } > ) => {
109
128
  const component = state.data.find( ( comp ) => comp.uid === payload.componentUid );
110
129
 
@@ -47,7 +47,20 @@ export const selectUnpublishedComponents = createSelector(
47
47
  export const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );
48
48
  export const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );
49
49
  export const selectStyles = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};
50
- export const selectFlatStyles = createSelector( selectStylesDefinitions, ( data ) => Object.values( data ).flat() );
50
+ export const selectFlatStyles = createSelector(
51
+ selectStylesDefinitions,
52
+ ( _state: ComponentsSlice, excludeComponentId: ComponentId | null = null ) => excludeComponentId,
53
+ ( data, excludeComponentId ) => {
54
+ if ( excludeComponentId === null ) {
55
+ return Object.values( data ).flat();
56
+ }
57
+
58
+ return Object.entries( data )
59
+ .filter( ( [ id ] ) => id !== String( excludeComponentId ) )
60
+ .map( ( [ , styles ] ) => styles )
61
+ .flat();
62
+ }
63
+ );
51
64
  export const selectCreatedThisSession = createSelector(
52
65
  getCreatedThisSession,
53
66
  ( createdThisSession ) => createdThisSession