@elementor/editor-components 4.1.0-764 → 4.1.0-766

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.1.0-764",
4
+ "version": "4.1.0-766",
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.1.0-764",
44
- "@elementor/editor-canvas": "4.1.0-764",
45
- "@elementor/editor-controls": "4.1.0-764",
46
- "@elementor/editor-documents": "4.1.0-764",
47
- "@elementor/editor-editing-panel": "4.1.0-764",
48
- "@elementor/editor-elements": "4.1.0-764",
49
- "@elementor/editor-elements-panel": "4.1.0-764",
50
- "@elementor/editor-mcp": "4.1.0-764",
51
- "@elementor/editor-templates": "4.1.0-764",
52
- "@elementor/editor-panels": "4.1.0-764",
53
- "@elementor/editor-props": "4.1.0-764",
54
- "@elementor/editor-styles-repository": "4.1.0-764",
55
- "@elementor/editor-ui": "4.1.0-764",
56
- "@elementor/editor-v1-adapters": "4.1.0-764",
57
- "@elementor/http-client": "4.1.0-764",
43
+ "@elementor/editor": "4.1.0-766",
44
+ "@elementor/editor-canvas": "4.1.0-766",
45
+ "@elementor/editor-controls": "4.1.0-766",
46
+ "@elementor/editor-documents": "4.1.0-766",
47
+ "@elementor/editor-editing-panel": "4.1.0-766",
48
+ "@elementor/editor-elements": "4.1.0-766",
49
+ "@elementor/editor-elements-panel": "4.1.0-766",
50
+ "@elementor/editor-mcp": "4.1.0-766",
51
+ "@elementor/editor-templates": "4.1.0-766",
52
+ "@elementor/editor-panels": "4.1.0-766",
53
+ "@elementor/editor-props": "4.1.0-766",
54
+ "@elementor/editor-styles-repository": "4.1.0-766",
55
+ "@elementor/editor-ui": "4.1.0-766",
56
+ "@elementor/editor-v1-adapters": "4.1.0-766",
57
+ "@elementor/http-client": "4.1.0-766",
58
58
  "@elementor/icons": "^1.68.0",
59
- "@elementor/events": "4.1.0-764",
60
- "@elementor/query": "4.1.0-764",
61
- "@elementor/schema": "4.1.0-764",
62
- "@elementor/store": "4.1.0-764",
59
+ "@elementor/events": "4.1.0-766",
60
+ "@elementor/query": "4.1.0-766",
61
+ "@elementor/schema": "4.1.0-766",
62
+ "@elementor/store": "4.1.0-766",
63
63
  "@elementor/ui": "1.36.17",
64
- "@elementor/utils": "4.1.0-764",
64
+ "@elementor/utils": "4.1.0-766",
65
65
  "@wordpress/i18n": "^5.13.0",
66
- "@elementor/editor-notifications": "4.1.0-764",
67
- "@elementor/editor-current-user": "4.1.0-764"
66
+ "@elementor/editor-notifications": "4.1.0-766",
67
+ "@elementor/editor-current-user": "4.1.0-766"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.3.1",
package/src/init.ts CHANGED
@@ -13,6 +13,7 @@ import { registerDataHook } from '@elementor/editor-v1-adapters';
13
13
  import { __registerSlice as registerSlice } from '@elementor/store';
14
14
  import { __ } from '@wordpress/i18n';
15
15
 
16
+ import { apiClient } from './api';
16
17
  import { componentInstanceTransformer } from './component-instance-transformer';
17
18
  import { componentOverridableTransformer } from './component-overridable-transformer';
18
19
  import { componentOverrideTransformer } from './component-override-transformer';
@@ -25,7 +26,6 @@ import { COMPONENT_WIDGET_TYPE, createComponentType } from './create-component-t
25
26
  import { PopulateStore } from './populate-store';
26
27
  import { initCircularNestingPrevention } from './prevent-circular-nesting';
27
28
  import { loadComponentsAssets } from './store/actions/load-components-assets';
28
- import { removeComponentStyles } from './store/actions/remove-component-styles';
29
29
  import { componentsStylesProvider } from './store/components-styles-provider';
30
30
  import { slice } from './store/store';
31
31
  import { beforeSave } from './sync/before-save';
@@ -63,7 +63,7 @@ export function init() {
63
63
  const { id, config } = getV1CurrentDocument();
64
64
 
65
65
  if ( id ) {
66
- removeComponentStyles( id );
66
+ apiClient.invalidateComponentConfigCache( id );
67
67
  }
68
68
 
69
69
  await loadComponentsAssets( ( config?.elements as V1ElementData[] ) ?? [] );
@@ -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;
@@ -24,9 +24,6 @@ export const componentsActions = {
24
24
  resetUnpublished() {
25
25
  dispatch( slice.actions.resetUnpublished() );
26
26
  },
27
- removeStyles( id: ComponentId ) {
28
- dispatch( slice.actions.removeStyles( { id } ) );
29
- },
30
27
  addStyles( styles: Record< string, unknown > ) {
31
28
  dispatch( slice.actions.addStyles( styles ) );
32
29
  },
@@ -65,11 +65,6 @@ const baseSlice = createSlice( {
65
65
  resetUnpublished: ( state ) => {
66
66
  state.unpublishedData = [];
67
67
  },
68
- removeStyles( state, { payload }: PayloadAction< { id: ComponentId } > ) {
69
- const { [ payload.id ]: _, ...rest } = state.styles;
70
-
71
- state.styles = rest;
72
- },
73
68
  addStyles: ( state, { payload } ) => {
74
69
  state.styles = { ...state.styles, ...payload };
75
70
  },
@@ -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
@@ -1,9 +0,0 @@
1
- import { __dispatch as dispatch } from '@elementor/store';
2
-
3
- import { apiClient } from '../../api';
4
- import { slice } from '../store';
5
-
6
- export function removeComponentStyles( id: number ) {
7
- apiClient.invalidateComponentConfigCache( id );
8
- dispatch( slice.actions.removeStyles( { id } ) );
9
- }