@elementor/editor-elements 4.5.0-1211 → 4.5.0-1212

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.5.0-1211",
4
+ "version": "4.5.0-1212",
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.5.0-1211",
44
- "@elementor/editor-props": "4.5.0-1211",
45
- "@elementor/editor-styles": "4.5.0-1211",
46
- "@elementor/editor-v1-adapters": "4.5.0-1211",
47
- "@elementor/schema": "4.5.0-1211",
48
- "@elementor/session": "4.5.0-1211",
49
- "@elementor/utils": "4.5.0-1211",
43
+ "@elementor/editor-mcp": "4.5.0-1212",
44
+ "@elementor/editor-props": "4.5.0-1212",
45
+ "@elementor/editor-styles": "4.5.0-1212",
46
+ "@elementor/editor-v1-adapters": "4.5.0-1212",
47
+ "@elementor/schema": "4.5.0-1212",
48
+ "@elementor/session": "4.5.0-1212",
49
+ "@elementor/utils": "4.5.0-1212",
50
50
  "@wordpress/i18n": "^3.1.0"
51
51
  },
52
52
  "peerDependencies": {
@@ -1,9 +1,15 @@
1
1
  import { type PropValue } from '@elementor/editor-props';
2
2
 
3
3
  import { getContainer } from '../sync/get-container';
4
- import { addModelToParent, removeModelFromParent } from '../sync/resolve-element';
4
+ import { addModelToParent, findModelInDocument, removeModelFromParent } from '../sync/resolve-element';
5
5
  import { resolveInsertIndex } from '../sync/resolve-insert-index';
6
- import { type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementModelProps } from '../sync/types';
6
+ import {
7
+ type BackboneCollection,
8
+ type V1Element,
9
+ type V1ElementConfig,
10
+ type V1ElementData,
11
+ type V1ElementModelProps,
12
+ } from '../sync/types';
7
13
  import { createChildrenStash } from './stash';
8
14
  import { type ChildDependencyRule, type ChildrenStash } from './types';
9
15
  import { evaluateWhen, resolveChildModelData } from './utils';
@@ -77,8 +83,7 @@ export function bindSettingsReconcile( { model, elementConfig }: BindSettingsRec
77
83
  }
78
84
 
79
85
  function attachChildFromRule( parentId: string, rule: ChildDependencyRule, stash: ChildrenStash ): void {
80
- const parent = getContainer( parentId ) ?? undefined;
81
- const currentChildren = getDirectChildData( parent );
86
+ const currentChildren = getDirectChildData( parentId );
82
87
  const alreadyPresent = currentChildren.some( ( child ) => child.elType === rule.child_type );
83
88
 
84
89
  if ( alreadyPresent ) {
@@ -190,6 +195,10 @@ function requestNavigatorRefresh( parentId: string ): void {
190
195
  );
191
196
  }
192
197
 
193
- function getDirectChildData( parent: V1Element | undefined ): V1ElementData[] {
194
- return ( parent?.children ?? [] ).map( ( child ) => child.model.toJSON() as unknown as V1ElementData );
198
+ // Read from the model collection `addModelToParent` writes to: a child attached earlier in the same settings change
199
+ // has no container until the view renders, and a later rule may be anchored on it.
200
+ function getDirectChildData( parentId: string ): V1ElementData[] {
201
+ const elements = findModelInDocument( parentId )?.get( 'elements' ) as BackboneCollection | undefined;
202
+
203
+ return ( elements?.models ?? [] ).map( ( model ) => ( { elType: model.get( 'elType' ) } ) as V1ElementData );
195
204
  }