@elementor/editor-elements 4.4.0-1121 → 4.4.0-1123
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-elements",
|
|
3
3
|
"description": "This package contains the elements model for the Elementor editor",
|
|
4
|
-
"version": "4.4.0-
|
|
4
|
+
"version": "4.4.0-1123",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-mcp": "4.4.0-
|
|
44
|
-
"@elementor/editor-props": "4.4.0-
|
|
45
|
-
"@elementor/editor-styles": "4.4.0-
|
|
46
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
47
|
-
"@elementor/schema": "4.4.0-
|
|
48
|
-
"@elementor/session": "4.4.0-
|
|
49
|
-
"@elementor/utils": "4.4.0-
|
|
43
|
+
"@elementor/editor-mcp": "4.4.0-1123",
|
|
44
|
+
"@elementor/editor-props": "4.4.0-1123",
|
|
45
|
+
"@elementor/editor-styles": "4.4.0-1123",
|
|
46
|
+
"@elementor/editor-v1-adapters": "4.4.0-1123",
|
|
47
|
+
"@elementor/schema": "4.4.0-1123",
|
|
48
|
+
"@elementor/session": "4.4.0-1123",
|
|
49
|
+
"@elementor/utils": "4.4.0-1123",
|
|
50
50
|
"@wordpress/i18n": "^3.1.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
@@ -82,6 +82,7 @@ function attachChildFromRule( parentId: string, rule: ChildDependencyRule, stash
|
|
|
82
82
|
const alreadyPresent = currentChildren.some( ( child ) => child.elType === rule.child_type );
|
|
83
83
|
|
|
84
84
|
if ( alreadyPresent ) {
|
|
85
|
+
placeAnchoredChild( parentId, rule );
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -123,6 +124,53 @@ function detachChildFromRule( parentId: string, rule: ChildDependencyRule, stash
|
|
|
123
124
|
requestNavigatorRefresh( parentId );
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
function placeAnchoredChild( parentId: string, rule: ChildDependencyRule ): void {
|
|
128
|
+
if ( rule.position.kind !== 'after_type' && rule.position.kind !== 'before_type' ) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let parent: V1Element | undefined;
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
parent = getContainer( parentId ) ?? undefined;
|
|
136
|
+
} catch {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const collection = parent?.model?.get?.( 'elements' ) as
|
|
141
|
+
| {
|
|
142
|
+
models?: Array< { get: ( key: string ) => unknown } >;
|
|
143
|
+
remove?: ( model: unknown, options?: { silent?: boolean } ) => void;
|
|
144
|
+
add?: ( model: unknown, options?: { at?: number; silent?: boolean } ) => void;
|
|
145
|
+
}
|
|
146
|
+
| undefined;
|
|
147
|
+
const models = collection?.models;
|
|
148
|
+
|
|
149
|
+
if ( ! models || ! collection?.remove || ! collection?.add ) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const existingIndex = models.findIndex( ( model ) => model.get( 'elType' ) === rule.child_type );
|
|
154
|
+
|
|
155
|
+
if ( existingIndex < 0 ) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const siblings = models.map( ( model ) => ( { elType: model.get( 'elType' ) } ) as V1ElementData );
|
|
160
|
+
const remaining = siblings.filter( ( _, index ) => index !== existingIndex );
|
|
161
|
+
const insertAt = resolveInsertIndex( rule.position, remaining );
|
|
162
|
+
|
|
163
|
+
if ( insertAt === existingIndex ) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const model = models[ existingIndex ];
|
|
168
|
+
|
|
169
|
+
collection.remove( model, { silent: true } );
|
|
170
|
+
collection.add( model, { at: insertAt, silent: true } );
|
|
171
|
+
requestNavigatorRefresh( parentId );
|
|
172
|
+
}
|
|
173
|
+
|
|
126
174
|
// Backbone `add`/`remove` on the parent elements collection is silent (see
|
|
127
175
|
// assets/dev/js/editor/document/component.js addModelToParent / removeModelFromParent),
|
|
128
176
|
// so the Marionette Navigator CompositeView never observes our mutation. The
|
|
@@ -33,6 +33,18 @@ export function reconcileInitialChildren( {
|
|
|
33
33
|
const existingIndex = elements.findIndex( ( element ) => element.elType === rule.child_type );
|
|
34
34
|
const isPresent = existingIndex >= 0;
|
|
35
35
|
|
|
36
|
+
if ( isMet && isPresent && isAnchoredPosition( rule.position.kind ) ) {
|
|
37
|
+
const remaining = elements.filter( ( _, index ) => index !== existingIndex );
|
|
38
|
+
const insertAt = resolveInsertIndex( rule.position, remaining );
|
|
39
|
+
|
|
40
|
+
if ( insertAt !== existingIndex ) {
|
|
41
|
+
const [ moved ] = elements.splice( existingIndex, 1 );
|
|
42
|
+
elements.splice( insertAt, 0, moved );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
36
48
|
if ( isMet && ! isPresent ) {
|
|
37
49
|
const { modelData, wasStashed } = resolveChildModelData( elementId, rule, stash );
|
|
38
50
|
const insertAt = resolveInsertIndex( rule.position, elements );
|
|
@@ -57,3 +69,7 @@ export function reconcileInitialChildren( {
|
|
|
57
69
|
|
|
58
70
|
attributes.elements = elements;
|
|
59
71
|
}
|
|
72
|
+
|
|
73
|
+
function isAnchoredPosition( kind: string ): boolean {
|
|
74
|
+
return kind === 'after_type' || kind === 'before_type';
|
|
75
|
+
}
|