@elementor/editor-elements 4.5.0-1183 → 4.5.0-1185
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.d.mts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +35 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +6 -1
- package/src/sync/create-element.ts +1 -0
- package/src/sync/create-elements.ts +5 -3
- package/src/sync/delete-element.ts +1 -0
- package/src/sync/duplicate-element.ts +1 -0
- package/src/sync/duplicate-elements.ts +5 -3
- package/src/sync/get-element-widget-markers.ts +14 -2
- package/src/sync/move-element.ts +1 -0
- package/src/sync/move-elements.ts +5 -2
- package/src/sync/remove-elements.ts +5 -3
- package/src/sync/types.ts +1 -0
package/src/index.ts
CHANGED
|
@@ -50,7 +50,12 @@ export { getElementTitle } from './sync/get-element-title';
|
|
|
50
50
|
export { getElementSetting, getElementSettings } from './sync/get-element-setting';
|
|
51
51
|
export { getElementStyles } from './sync/get-element-styles';
|
|
52
52
|
export { getElementType } from './sync/get-element-type';
|
|
53
|
-
export {
|
|
53
|
+
export {
|
|
54
|
+
getElementPart,
|
|
55
|
+
getElementWidgetMarker,
|
|
56
|
+
isElementSlot,
|
|
57
|
+
WIDGET_MARKER_KEYS,
|
|
58
|
+
} from './sync/get-element-widget-markers';
|
|
54
59
|
export { regenerateLocalStyleIds } from './sync/regenerate-local-style-ids';
|
|
55
60
|
export { getAllDescendants } from './sync/get-all-descendants';
|
|
56
61
|
export {
|
|
@@ -10,6 +10,7 @@ type CreateElementsParams = {
|
|
|
10
10
|
elements: CreateElementParams[];
|
|
11
11
|
title: string;
|
|
12
12
|
subtitle?: string;
|
|
13
|
+
origin?: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
type CreatedElement = {
|
|
@@ -31,6 +32,7 @@ export const createElements = ( {
|
|
|
31
32
|
elements,
|
|
32
33
|
title,
|
|
33
34
|
subtitle = __( 'Item added', 'elementor' ),
|
|
35
|
+
origin,
|
|
34
36
|
}: CreateElementsParams ): CreatedElementsResult => {
|
|
35
37
|
const undoableCreate = undoable(
|
|
36
38
|
{
|
|
@@ -47,7 +49,7 @@ export const createElements = ( {
|
|
|
47
49
|
const element = createElement( {
|
|
48
50
|
container: parentContainer,
|
|
49
51
|
...elementParams,
|
|
50
|
-
options: { ...options, useHistory: false },
|
|
52
|
+
options: { ...options, useHistory: false, origin },
|
|
51
53
|
} );
|
|
52
54
|
|
|
53
55
|
createdElements.push( {
|
|
@@ -69,7 +71,7 @@ export const createElements = ( {
|
|
|
69
71
|
if ( freshContainer ) {
|
|
70
72
|
deleteElement( {
|
|
71
73
|
container: freshContainer,
|
|
72
|
-
options: { useHistory: false },
|
|
74
|
+
options: { useHistory: false, origin },
|
|
73
75
|
} );
|
|
74
76
|
|
|
75
77
|
return;
|
|
@@ -91,7 +93,7 @@ export const createElements = ( {
|
|
|
91
93
|
const element = createElement( {
|
|
92
94
|
container: freshParent,
|
|
93
95
|
model,
|
|
94
|
-
options: { ...options, useHistory: false },
|
|
96
|
+
options: { ...options, useHistory: false, origin },
|
|
95
97
|
} );
|
|
96
98
|
|
|
97
99
|
newElements.push( {
|
|
@@ -14,6 +14,7 @@ type DuplicateElementsParams = {
|
|
|
14
14
|
subtitle?: string;
|
|
15
15
|
onDuplicateElements?: () => void;
|
|
16
16
|
onRestoreElements?: () => void;
|
|
17
|
+
origin?: string;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
type DuplicatedElement = {
|
|
@@ -37,6 +38,7 @@ export const duplicateElements = ( {
|
|
|
37
38
|
subtitle = __( 'Item duplicated', 'elementor' ),
|
|
38
39
|
onDuplicateElements,
|
|
39
40
|
onRestoreElements,
|
|
41
|
+
origin,
|
|
40
42
|
}: DuplicateElementsParams ): DuplicatedElementsResult => {
|
|
41
43
|
const undoableDuplicate = undoable(
|
|
42
44
|
{
|
|
@@ -53,7 +55,7 @@ export const duplicateElements = ( {
|
|
|
53
55
|
|
|
54
56
|
const duplicatedElement = duplicateElement( {
|
|
55
57
|
element: originalContainer,
|
|
56
|
-
options: { useHistory: false },
|
|
58
|
+
options: { useHistory: false, origin },
|
|
57
59
|
} );
|
|
58
60
|
|
|
59
61
|
if ( ! duplicatedElement.parent ) {
|
|
@@ -81,7 +83,7 @@ export const duplicateElements = ( {
|
|
|
81
83
|
if ( freshContainer ) {
|
|
82
84
|
deleteElement( {
|
|
83
85
|
container: freshContainer,
|
|
84
|
-
options: { useHistory: false },
|
|
86
|
+
options: { useHistory: false, origin },
|
|
85
87
|
} );
|
|
86
88
|
|
|
87
89
|
return;
|
|
@@ -104,7 +106,7 @@ export const duplicateElements = ( {
|
|
|
104
106
|
const createdElement = createElement( {
|
|
105
107
|
container: freshParent,
|
|
106
108
|
model,
|
|
107
|
-
options: { useHistory: false, clone: false, at },
|
|
109
|
+
options: { useHistory: false, clone: false, at, origin },
|
|
108
110
|
} );
|
|
109
111
|
|
|
110
112
|
duplicatedElements.push( {
|
|
@@ -8,6 +8,12 @@ const WIDGET_ID_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/;
|
|
|
8
8
|
const PART_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
9
9
|
const MIN_VERSION = 1;
|
|
10
10
|
|
|
11
|
+
export const WIDGET_MARKER_KEYS = {
|
|
12
|
+
widget: 'widget',
|
|
13
|
+
part: 'part',
|
|
14
|
+
slot: 'slot',
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
11
17
|
const widgetMarkerSchema = z.object( {
|
|
12
18
|
id: z.string().regex( WIDGET_ID_PATTERN ),
|
|
13
19
|
version: z.number().int().min( MIN_VERSION ),
|
|
@@ -17,7 +23,7 @@ const widgetMarkerSchema = z.object( {
|
|
|
17
23
|
const partSchema = z.string().regex( PART_PATTERN );
|
|
18
24
|
|
|
19
25
|
export function getElementWidgetMarker( elementId: ElementID ): Required< V1ElementWidgetMarker > | null {
|
|
20
|
-
const result = widgetMarkerSchema.safeParse( getContainer( elementId )?.model.get(
|
|
26
|
+
const result = widgetMarkerSchema.safeParse( getContainer( elementId )?.model.get( WIDGET_MARKER_KEYS.widget ) );
|
|
21
27
|
|
|
22
28
|
if ( ! result.success ) {
|
|
23
29
|
return null;
|
|
@@ -27,7 +33,13 @@ export function getElementWidgetMarker( elementId: ElementID ): Required< V1Elem
|
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export function getElementPart( elementId: ElementID ): string | null {
|
|
30
|
-
const result = partSchema.safeParse( getContainer( elementId )?.model.get(
|
|
36
|
+
const result = partSchema.safeParse( getContainer( elementId )?.model.get( WIDGET_MARKER_KEYS.part ) );
|
|
31
37
|
|
|
32
38
|
return result.success ? result.data : null;
|
|
33
39
|
}
|
|
40
|
+
|
|
41
|
+
export function isElementSlot( elementId: ElementID ): boolean {
|
|
42
|
+
return (
|
|
43
|
+
true === getContainer( elementId )?.model.get( WIDGET_MARKER_KEYS.slot ) && null !== getElementPart( elementId )
|
|
44
|
+
);
|
|
45
|
+
}
|
package/src/sync/move-element.ts
CHANGED
|
@@ -23,6 +23,7 @@ type MoveElementsParams = {
|
|
|
23
23
|
subtitle?: string;
|
|
24
24
|
onMoveElements?: () => void;
|
|
25
25
|
onRestoreElements?: () => void;
|
|
26
|
+
origin?: string;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
type MovedElement = {
|
|
@@ -48,6 +49,7 @@ export const moveElements = ( {
|
|
|
48
49
|
subtitle = __( 'Elements moved', 'elementor' ),
|
|
49
50
|
onMoveElements,
|
|
50
51
|
onRestoreElements,
|
|
52
|
+
origin,
|
|
51
53
|
}: MoveElementsParams ): MovedElementsResult => {
|
|
52
54
|
const undoableMove = undoable(
|
|
53
55
|
{
|
|
@@ -77,7 +79,7 @@ export const moveElements = ( {
|
|
|
77
79
|
const newElement = moveElement( {
|
|
78
80
|
element: sourceElement,
|
|
79
81
|
targetContainer: target,
|
|
80
|
-
options: { ...options, useHistory: false },
|
|
82
|
+
options: { ...options, useHistory: false, origin },
|
|
81
83
|
} );
|
|
82
84
|
|
|
83
85
|
movedElements.push( {
|
|
@@ -114,6 +116,7 @@ export const moveElements = ( {
|
|
|
114
116
|
options: {
|
|
115
117
|
useHistory: false,
|
|
116
118
|
at: originalIndex >= 0 ? originalIndex : undefined,
|
|
119
|
+
origin,
|
|
117
120
|
},
|
|
118
121
|
} );
|
|
119
122
|
} );
|
|
@@ -144,7 +147,7 @@ export const moveElements = ( {
|
|
|
144
147
|
const newElement = moveElement( {
|
|
145
148
|
element: freshElement,
|
|
146
149
|
targetContainer: freshTarget,
|
|
147
|
-
options: { ...options, useHistory: false },
|
|
150
|
+
options: { ...options, useHistory: false, origin },
|
|
148
151
|
} );
|
|
149
152
|
|
|
150
153
|
newMovedElements.push( {
|
|
@@ -13,6 +13,7 @@ type RemoveElementsParams = {
|
|
|
13
13
|
subtitle?: string;
|
|
14
14
|
onRemoveElements?: () => void;
|
|
15
15
|
onRestoreElements?: () => void;
|
|
16
|
+
origin?: string;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
type RemovedElement = {
|
|
@@ -34,6 +35,7 @@ export const removeElements = ( {
|
|
|
34
35
|
subtitle = __( 'Item removed', 'elementor' ),
|
|
35
36
|
onRemoveElements,
|
|
36
37
|
onRestoreElements,
|
|
38
|
+
origin,
|
|
37
39
|
}: RemoveElementsParams ): RemovedElementsResult => {
|
|
38
40
|
const undoableRemove = undoable(
|
|
39
41
|
{
|
|
@@ -60,7 +62,7 @@ export const removeElements = ( {
|
|
|
60
62
|
removedElements.forEach( ( { container } ) => {
|
|
61
63
|
deleteElement( {
|
|
62
64
|
container,
|
|
63
|
-
options: { useHistory: false },
|
|
65
|
+
options: { useHistory: false, origin },
|
|
64
66
|
} );
|
|
65
67
|
} );
|
|
66
68
|
|
|
@@ -76,7 +78,7 @@ export const removeElements = ( {
|
|
|
76
78
|
createElement( {
|
|
77
79
|
container: freshParent,
|
|
78
80
|
model,
|
|
79
|
-
options: { useHistory: false, at },
|
|
81
|
+
options: { useHistory: false, at, origin },
|
|
80
82
|
} );
|
|
81
83
|
|
|
82
84
|
return;
|
|
@@ -100,7 +102,7 @@ export const removeElements = ( {
|
|
|
100
102
|
if ( freshContainer && freshParent ) {
|
|
101
103
|
deleteElement( {
|
|
102
104
|
container: freshContainer,
|
|
103
|
-
options: { useHistory: false },
|
|
105
|
+
options: { useHistory: false, origin },
|
|
104
106
|
} );
|
|
105
107
|
|
|
106
108
|
newRemovedElements.push( {
|