@elementor/editor-components 3.35.0-489 → 3.35.0-490
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.js +106 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/components/create-component-form/create-component-form.tsx +1 -0
- package/src/store/actions/create-unpublished-component.ts +38 -3
- package/src/store/store.ts +9 -0
- package/src/sync/create-components-before-save.ts +4 -1
- package/src/types.ts +6 -0
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-
|
|
4
|
+
"version": "3.35.0-490",
|
|
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-
|
|
44
|
-
"@elementor/editor-canvas": "3.35.0-
|
|
45
|
-
"@elementor/editor-controls": "3.35.0-
|
|
46
|
-
"@elementor/editor-documents": "3.35.0-
|
|
47
|
-
"@elementor/editor-editing-panel": "3.35.0-
|
|
48
|
-
"@elementor/editor-elements": "3.35.0-
|
|
49
|
-
"@elementor/editor-elements-panel": "3.35.0-
|
|
50
|
-
"@elementor/editor-mcp": "3.35.0-
|
|
51
|
-
"@elementor/editor-panels": "3.35.0-
|
|
52
|
-
"@elementor/editor-props": "3.35.0-
|
|
53
|
-
"@elementor/editor-styles-repository": "3.35.0-
|
|
54
|
-
"@elementor/editor-ui": "3.35.0-
|
|
55
|
-
"@elementor/editor-v1-adapters": "3.35.0-
|
|
56
|
-
"@elementor/http-client": "3.35.0-
|
|
43
|
+
"@elementor/editor": "3.35.0-490",
|
|
44
|
+
"@elementor/editor-canvas": "3.35.0-490",
|
|
45
|
+
"@elementor/editor-controls": "3.35.0-490",
|
|
46
|
+
"@elementor/editor-documents": "3.35.0-490",
|
|
47
|
+
"@elementor/editor-editing-panel": "3.35.0-490",
|
|
48
|
+
"@elementor/editor-elements": "3.35.0-490",
|
|
49
|
+
"@elementor/editor-elements-panel": "3.35.0-490",
|
|
50
|
+
"@elementor/editor-mcp": "3.35.0-490",
|
|
51
|
+
"@elementor/editor-panels": "3.35.0-490",
|
|
52
|
+
"@elementor/editor-props": "3.35.0-490",
|
|
53
|
+
"@elementor/editor-styles-repository": "3.35.0-490",
|
|
54
|
+
"@elementor/editor-ui": "3.35.0-490",
|
|
55
|
+
"@elementor/editor-v1-adapters": "3.35.0-490",
|
|
56
|
+
"@elementor/http-client": "3.35.0-490",
|
|
57
57
|
"@elementor/icons": "^1.63.0",
|
|
58
|
-
"@elementor/mixpanel": "3.35.0-
|
|
59
|
-
"@elementor/query": "3.35.0-
|
|
60
|
-
"@elementor/schema": "3.35.0-
|
|
61
|
-
"@elementor/store": "3.35.0-
|
|
58
|
+
"@elementor/mixpanel": "3.35.0-490",
|
|
59
|
+
"@elementor/query": "3.35.0-490",
|
|
60
|
+
"@elementor/schema": "3.35.0-490",
|
|
61
|
+
"@elementor/store": "3.35.0-490",
|
|
62
62
|
"@elementor/ui": "1.36.17",
|
|
63
|
-
"@elementor/utils": "3.35.0-
|
|
63
|
+
"@elementor/utils": "3.35.0-490",
|
|
64
64
|
"@wordpress/i18n": "^5.13.0",
|
|
65
|
-
"@elementor/editor-notifications": "3.35.0-
|
|
66
|
-
"@elementor/editor-current-user": "3.35.0-
|
|
65
|
+
"@elementor/editor-notifications": "3.35.0-490",
|
|
66
|
+
"@elementor/editor-current-user": "3.35.0-490"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"react": "^18.3.1",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { type V1ElementData } from '@elementor/editor-elements';
|
|
1
|
+
import { createElements, deleteElement, getContainer, type V1ElementData } from '@elementor/editor-elements';
|
|
2
2
|
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
3
3
|
import { __dispatch as dispatch } from '@elementor/store';
|
|
4
4
|
import { generateUniqueId } from '@elementor/utils';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
import { type ComponentEventData } from '../../components/create-component-form/utils/get-component-event-data';
|
|
7
8
|
import { replaceElementWithComponent } from '../../components/create-component-form/utils/replace-element-with-component';
|
|
8
|
-
import { type OverridableProps } from '../../types';
|
|
9
|
+
import { type OriginalElementData, type OverridableProps } from '../../types';
|
|
9
10
|
import { revertAllOverridablesInElementData } from '../../utils/revert-overridable-settings';
|
|
10
11
|
import { type Source, trackComponentEvent } from '../../utils/tracking';
|
|
11
12
|
import { slice } from '../store';
|
|
@@ -31,6 +32,14 @@ export async function createUnpublishedComponent( {
|
|
|
31
32
|
const componentBase = { uid: generatedUid, name };
|
|
32
33
|
const elementDataWithOverridablesReverted = revertAllOverridablesInElementData( element );
|
|
33
34
|
|
|
35
|
+
const container = getContainer( element.id );
|
|
36
|
+
const modelFromContainer = container?.model?.toJSON?.() as V1ElementData | undefined;
|
|
37
|
+
const originalElement: OriginalElementData = {
|
|
38
|
+
model: modelFromContainer ?? element,
|
|
39
|
+
parentId: container?.parent?.id ?? '',
|
|
40
|
+
index: container?.view?._index ?? 0,
|
|
41
|
+
};
|
|
42
|
+
|
|
34
43
|
dispatch(
|
|
35
44
|
slice.actions.addUnpublished( {
|
|
36
45
|
...componentBase,
|
|
@@ -51,7 +60,33 @@ export async function createUnpublishedComponent( {
|
|
|
51
60
|
...eventData,
|
|
52
61
|
} );
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
try {
|
|
64
|
+
await runCommand( 'document/save/auto' );
|
|
65
|
+
} catch ( error ) {
|
|
66
|
+
restoreOriginalElement( originalElement, componentInstance.id );
|
|
67
|
+
|
|
68
|
+
dispatch( slice.actions.removeUnpublished( generatedUid ) );
|
|
69
|
+
dispatch( slice.actions.removeCreatedThisSession( generatedUid ) );
|
|
70
|
+
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
55
73
|
|
|
56
74
|
return { uid: generatedUid, instanceId: componentInstance.id };
|
|
57
75
|
}
|
|
76
|
+
|
|
77
|
+
function restoreOriginalElement( originalElement: OriginalElementData, componentInstanceId: string ): void {
|
|
78
|
+
deleteElement( { elementId: componentInstanceId, options: { useHistory: false } } );
|
|
79
|
+
|
|
80
|
+
const clonedModel = structuredClone( originalElement.model );
|
|
81
|
+
|
|
82
|
+
createElements( {
|
|
83
|
+
title: __( 'Restore Element', 'elementor' ),
|
|
84
|
+
elements: [
|
|
85
|
+
{
|
|
86
|
+
containerId: originalElement.parentId,
|
|
87
|
+
model: clonedModel as Parameters< typeof createElements >[ 0 ][ 'elements' ][ 0 ][ 'model' ],
|
|
88
|
+
options: { at: originalElement.index },
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
} );
|
|
92
|
+
}
|
package/src/store/store.ts
CHANGED
|
@@ -72,6 +72,12 @@ export const slice = createSlice( {
|
|
|
72
72
|
addUnpublished: ( state, { payload }: PayloadAction< UnpublishedComponent > ) => {
|
|
73
73
|
state.unpublishedData.unshift( payload );
|
|
74
74
|
},
|
|
75
|
+
removeUnpublished: ( state, { payload }: PayloadAction< string | string[] > ) => {
|
|
76
|
+
const uidsToRemove = Array.isArray( payload ) ? payload : [ payload ];
|
|
77
|
+
state.unpublishedData = state.unpublishedData.filter(
|
|
78
|
+
( component ) => ! uidsToRemove.includes( component.uid )
|
|
79
|
+
);
|
|
80
|
+
},
|
|
75
81
|
resetUnpublished: ( state ) => {
|
|
76
82
|
state.unpublishedData = [];
|
|
77
83
|
},
|
|
@@ -86,6 +92,9 @@ export const slice = createSlice( {
|
|
|
86
92
|
addCreatedThisSession: ( state, { payload }: PayloadAction< string > ) => {
|
|
87
93
|
state.createdThisSession.push( payload );
|
|
88
94
|
},
|
|
95
|
+
removeCreatedThisSession: ( state, { payload }: PayloadAction< string > ) => {
|
|
96
|
+
state.createdThisSession = state.createdThisSession.filter( ( uid ) => uid !== payload );
|
|
97
|
+
},
|
|
89
98
|
archive: ( state, { payload }: PayloadAction< number > ) => {
|
|
90
99
|
const component = state.data.find( ( comp ) => comp.id === payload );
|
|
91
100
|
|
|
@@ -36,7 +36,10 @@ export async function createComponentsBeforeSave( {
|
|
|
36
36
|
);
|
|
37
37
|
dispatch( slice.actions.resetUnpublished() );
|
|
38
38
|
} catch ( error ) {
|
|
39
|
-
|
|
39
|
+
const failedUids = unpublishedComponents.map( ( component ) => component.uid );
|
|
40
|
+
dispatch( slice.actions.removeUnpublished( failedUids ) );
|
|
41
|
+
|
|
42
|
+
throw new Error( `Failed to publish components: ${ error }` );
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
|
package/src/types.ts
CHANGED
|
@@ -18,6 +18,12 @@ export type PublishedComponent = BaseComponent & {
|
|
|
18
18
|
isArchived?: boolean;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
export type OriginalElementData = {
|
|
22
|
+
model: V1ElementData;
|
|
23
|
+
parentId: string;
|
|
24
|
+
index: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
21
27
|
export type UnpublishedComponent = BaseComponent & {
|
|
22
28
|
elements: V1ElementData[];
|
|
23
29
|
};
|