Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ interface InNumbers extends Parent {
```ts
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>
type CardChildren = ImageSet | FormattingBlock
/**
* A card describes a subject with images and text
*/
Expand Down
8 changes: 4 additions & 4 deletions content-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export declare namespace ContentTree {
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
type CardChildren = ImageSet | FormattingBlock;
/**
* A card describes a subject with images and text
*/
Expand Down Expand Up @@ -848,7 +848,7 @@ export declare namespace ContentTree {
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
type CardChildren = ImageSet | FormattingBlock;
/**
* A card describes a subject with images and text
*/
Expand Down Expand Up @@ -1263,7 +1263,7 @@ export declare namespace ContentTree {
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
type CardChildren = ImageSet | FormattingBlock;
/**
* A card describes a subject with images and text
*/
Expand Down Expand Up @@ -1705,7 +1705,7 @@ export declare namespace ContentTree {
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
type CardChildren = ImageSet | FormattingBlock;
/**
* A card describes a subject with images and text
*/
Expand Down
15 changes: 15 additions & 0 deletions content_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -3430,6 +3430,7 @@ type CardChild struct {
*Blockquote
*ThematicBreak
*Text
*Heading
*ImageSet
}

Expand All @@ -3449,6 +3450,8 @@ func (n *CardChild) GetEmbedded() Node {
return n.ThematicBreak
case n.Text != nil:
return n.Text
case n.Heading != nil:
return n.Heading
case n.ImageSet != nil:
return n.ImageSet
default:
Expand All @@ -3468,6 +3471,8 @@ func (n *CardChild) GetChildren() []Node {
return n.ThematicBreak.GetChildren()
case n.Text != nil:
return n.Text.GetChildren()
case n.Heading != nil:
return n.Heading.GetChildren()
case n.ImageSet != nil:
return n.ImageSet.GetChildren()
default:
Expand Down Expand Up @@ -3513,6 +3518,12 @@ func (n *CardChild) UnmarshalJSON(data []byte) error {
return err
}
n.Text = &v
case HeadingType:
var v Heading
if err := json.Unmarshal(data, &v); err != nil {
return err
}
n.Heading = &v
case ImageSetType:
var v ImageSet
if err := json.Unmarshal(data, &v); err != nil {
Expand All @@ -3537,6 +3548,8 @@ func (n *CardChild) MarshalJSON() ([]byte, error) {
return json.Marshal(n.ThematicBreak)
case n.Text != nil:
return json.Marshal(n.Text)
case n.Heading != nil:
return json.Marshal(n.Heading)
case n.ImageSet != nil:
return json.Marshal(n.ImageSet)
default:
Expand All @@ -3556,6 +3569,8 @@ func makeCardChild(n Node) (*CardChild, error) {
return &CardChild{ThematicBreak: n.(*ThematicBreak)}, nil
case TextType:
return &CardChild{Text: n.(*Text)}, nil
case HeadingType:
return &CardChild{Heading: n.(*Heading)}, nil
case ImageSetType:
return &CardChild{ImageSet: n.(*ImageSet)}, nil
default:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@financial-times/content-tree",
"description": "content tree format",
"version": "0.11.0",
"version": "0.12.0",
"publishConfig": {
"access": "public"
},
Expand Down
3 changes: 3 additions & 0 deletions schemas/body-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
{
"$ref": "#/definitions/ContentTree.transit.Paragraph"
},
{
"$ref": "#/definitions/ContentTree.transit.Heading"
},
{
"$ref": "#/definitions/ContentTree.transit.List"
},
Expand Down
3 changes: 3 additions & 0 deletions schemas/content-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
{
"$ref": "#/definitions/ContentTree.full.Paragraph"
},
{
"$ref": "#/definitions/ContentTree.full.Heading"
},
{
"$ref": "#/definitions/ContentTree.full.List"
},
Expand Down
3 changes: 3 additions & 0 deletions schemas/transit-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
{
"$ref": "#/definitions/ContentTree.transit.Paragraph"
},
{
"$ref": "#/definitions/ContentTree.transit.Heading"
},
{
"$ref": "#/definitions/ContentTree.transit.List"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<body><section data-type="info-box" data-layout-width="inset-left"><div data-type="card"><h4>Title</h4><p>paragraph</p><ul><li><p>para inside list</p></li></ul><blockquote><p>para inside blockquote</p></blockquote>text<hr></hr><content data-embedded="true" type="http://www.ft.com/ontology/content/ImageSet" id="23925844-4d8d-11ea-0bc6-d44b54b3bebc"></content></div></section></body>
<body><section data-type="info-box" data-layout-width="inset-left"><div data-type="card"><h4>Title</h4><p>paragraph</p><ul><li><p>para inside list</p></li></ul><blockquote><p>para inside blockquote</p></blockquote>text<hr></hr><h3>Heading (subheading)</h3><h4>Heading (label)</h4><content data-embedded="true" type="http://www.ft.com/ontology/content/ImageSet" id="23925844-4d8d-11ea-0bc6-d44b54b3bebc"></content></div></section></body>
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@
{
"type":"thematic-break"
},
{
"type": "heading",
"children":[
{
"type": "text",
"value": "Heading (subheading)"
}
],
"level": "subheading"
},
{
"type": "heading",
"children":[
{
"type": "text",
"value": "Heading (label)"
}
],
"level": "label"
},
{
"type":"image-set",
"id":"23925844-4d8d-11ea-0bc6-d44b54b3bebc"
Expand Down
Loading