11import { EntryEmbedable , EmbeddedObject } from '../Models/embedded-object' ;
22import { RenderOption , RenderObject , RenderContentType } from '../options/index' ;
3- import { AssetAttributes , EntryAttributes , Metadata } from '../Models/metadata-model' ;
3+ import { EntryAttributes , Metadata } from '../Models/metadata-model' ;
44import { defaultOptions } from '../options/default-options' ;
55
66// This function will find Embedded object present in string
@@ -26,16 +26,19 @@ export function findEmbeddedAsset(uid: string, embeddedAssets: EmbeddedObject[]
2626
2727export function findEmbeddedObjects ( object : Metadata , entry : EntryEmbedable ) : ( EmbeddedObject ) [ ] {
2828 if ( object && object !== undefined && entry && entry !== undefined ) {
29- if ( object . itemType === 'entry' ) {
30- const embeddedEntry = object . attributes as EntryAttributes ;
31- return findEmbeddedEntry (
32- object . itemUid ,
33- object . contentTypeUid ,
34- Object . values ( entry . _embedded_items || [ ] ) . reduce ( ( accumulator , value ) => accumulator . concat ( value ) , [ ] ) ,
35- ) ;
36- } else {
37- const embeddedAsset = object . attributes as AssetAttributes ;
38- return findEmbeddedAsset ( object . itemUid , Object . values ( entry . _embedded_items || [ ] ) . reduce ( ( accumulator , value ) => accumulator . concat ( value ) , [ ] ) , ) ;
29+ if ( entry . _embedded_items !== undefined ) {
30+ const entryEmbedable = entry
31+ if ( object . itemType === 'entry' ) {
32+ return findEmbeddedEntry (
33+ object . itemUid ,
34+ object . contentTypeUid ,
35+ Object . values ( entryEmbedable . _embedded_items || [ ] ) . reduce ( ( accumulator , value ) => accumulator . concat ( value ) , [ ] ) ,
36+ ) ;
37+ } else {
38+ return findEmbeddedAsset (
39+ object . itemUid ,
40+ Object . values ( entryEmbedable . _embedded_items || [ ] ) . reduce ( ( accumulator , value ) => accumulator . concat ( value ) , [ ] ) , ) ;
41+ }
3942 }
4043 }
4144 return [ ] ;
0 commit comments