@elementor/editor-elements 3.33.0-278 → 3.33.0-280
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/hooks/use-element-children.ts +11 -11
|
@@ -11,7 +11,7 @@ export type ElementChildren = Record< string, ElementModel[] >;
|
|
|
11
11
|
|
|
12
12
|
export function useElementChildren< T extends ElementChildren >(
|
|
13
13
|
elementId: ElementID,
|
|
14
|
-
childrenTypes:
|
|
14
|
+
childrenTypes: Record< string, string >
|
|
15
15
|
): T {
|
|
16
16
|
return useListenTo(
|
|
17
17
|
[
|
|
@@ -24,19 +24,19 @@ export function useElementChildren< T extends ElementChildren >(
|
|
|
24
24
|
() => {
|
|
25
25
|
const container = getContainer( elementId );
|
|
26
26
|
|
|
27
|
-
const elementChildren = childrenTypes.reduce( ( acc,
|
|
28
|
-
|
|
27
|
+
const elementChildren = Object.entries( childrenTypes ).reduce( ( acc, [ parentType, childType ] ) => {
|
|
28
|
+
const parent = container?.children?.findRecursive?.(
|
|
29
|
+
( { model } ) => model.get( 'elType' ) === parentType
|
|
30
|
+
);
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
}, {} as ElementChildren );
|
|
32
|
+
const children = parent?.children ?? [];
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
acc[ childType ] = children
|
|
35
|
+
.filter( ( { model } ) => model.get( 'elType' ) === childType )
|
|
36
|
+
.map( ( { id } ) => ( { id } ) );
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
} );
|
|
38
|
+
return acc;
|
|
39
|
+
}, {} as ElementChildren );
|
|
40
40
|
|
|
41
41
|
return elementChildren;
|
|
42
42
|
},
|