@elementor/editor-elements 3.33.0-278 → 3.33.0-279
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
package/dist/index.d.mts
CHANGED
|
@@ -142,7 +142,7 @@ type ElementModel = {
|
|
|
142
142
|
id: string;
|
|
143
143
|
};
|
|
144
144
|
type ElementChildren = Record<string, ElementModel[]>;
|
|
145
|
-
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes:
|
|
145
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>): T;
|
|
146
146
|
|
|
147
147
|
declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
|
|
148
148
|
|
package/dist/index.d.ts
CHANGED
|
@@ -142,7 +142,7 @@ type ElementModel = {
|
|
|
142
142
|
id: string;
|
|
143
143
|
};
|
|
144
144
|
type ElementChildren = Record<string, ElementModel[]>;
|
|
145
|
-
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes:
|
|
145
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>): T;
|
|
146
146
|
|
|
147
147
|
declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
|
|
148
148
|
|
package/dist/index.js
CHANGED
|
@@ -100,16 +100,14 @@ function useElementChildren(elementId, childrenTypes) {
|
|
|
100
100
|
],
|
|
101
101
|
() => {
|
|
102
102
|
const container = getContainer(elementId);
|
|
103
|
-
const elementChildren = childrenTypes.reduce((acc,
|
|
104
|
-
|
|
103
|
+
const elementChildren = Object.entries(childrenTypes).reduce((acc, [parentType, childType]) => {
|
|
104
|
+
const parent = container?.children?.findRecursive?.(
|
|
105
|
+
({ model }) => model.get("elType") === parentType
|
|
106
|
+
);
|
|
107
|
+
const children = parent?.children ?? [];
|
|
108
|
+
acc[childType] = children.filter(({ model }) => model.get("elType") === childType).map(({ id }) => ({ id }));
|
|
105
109
|
return acc;
|
|
106
110
|
}, {});
|
|
107
|
-
container?.children?.forEachRecursive?.(({ model, id }) => {
|
|
108
|
-
const elType = model.get("elType");
|
|
109
|
-
if (elType && elType in elementChildren) {
|
|
110
|
-
elementChildren[elType].push({ id });
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
111
|
return elementChildren;
|
|
114
112
|
},
|
|
115
113
|
[elementId]
|