@@ -7,6 +7,7 @@ let ContentType = {
7
7
video : "http://www.ft.com/ontology/content/Video" ,
8
8
content : "http://www.ft.com/ontology/content/Content" ,
9
9
article : "http://www.ft.com/ontology/content/Article" ,
10
+ customCodeComponent : "http://www.ft.com/ontology/content/CustomCodeComponent" ,
10
11
} ;
11
12
12
13
/**
@@ -292,6 +293,21 @@ export let defaultTransformers = {
292
293
title : content . attributes . dataTitle ?? "" ,
293
294
} ;
294
295
} ,
296
+ /**
297
+ * @type {Transformer<ContentTree.transit.CustomCodeComponent> }
298
+ */
299
+ [ ContentType . customCodeComponent ] ( content ) {
300
+ const id = content . attributes . url ?? "" ;
301
+ const uuid = id . split ( "/" ) . pop ( ) ;
302
+ return {
303
+ type : "custom-code-component" ,
304
+ id : uuid ?? "" ,
305
+ layoutWidth : toValidLayoutWidth (
306
+ content . attributes [ "data-layout-width" ] || ""
307
+ ) ,
308
+ children : null ,
309
+ } ;
310
+ } ,
295
311
/**
296
312
* @type {Transformer<ContentTree.transit.Recommended> }
297
313
*/
@@ -311,7 +327,7 @@ export let defaultTransformers = {
311
327
* ContentTree.transit.Layout |
312
328
* ContentTree.transit.LayoutSlot |
313
329
* { type: "__LIFT_CHILDREN__"} |
314
- * { type: "__UNKNOWN__"}
330
+ * { type: "__UNKNOWN__", data?: any }
315
331
* >}
316
332
*/
317
333
div ( div ) {
@@ -332,7 +348,7 @@ export let defaultTransformers = {
332
348
type : "layout-slot" ,
333
349
} ) ;
334
350
}
335
- return { type : "__UNKNOWN__" } ;
351
+ return { type : "__UNKNOWN__" , data : div } ;
336
352
} ,
337
353
experimental ( ) {
338
354
return { type : "__LIFT_CHILDREN__" } ;
@@ -408,15 +424,15 @@ export function fromXast(bodyxast, transformers = defaultTransformers) {
408
424
}
409
425
return ctnode ;
410
426
} else {
411
- return { type : "__UNKNOWN__" } ;
427
+ return { type : "__UNKNOWN__" , data : xmlnode } ;
412
428
}
413
429
} else if ( isXText ( xmlnode ) ) {
414
430
return {
415
431
type : "text" ,
416
432
value : xmlnode . value ,
417
433
} ;
418
434
} else {
419
- return { type : "__UNKNOWN__" } ;
435
+ return { type : "__UNKNOWN__" , data : xmlnode } ;
420
436
}
421
437
} ) ( bodyxast ) ;
422
438
}
0 commit comments