Skip to content

Commit 97a807d

Browse files
Implement Question and Answer nodes
1 parent 3af1726 commit 97a807d

6 files changed

Lines changed: 867 additions & 4 deletions

File tree

SPEC.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ type VideoSource = AVSource & {
6363
6464
`VideoSource` extends AVSource to add in the properties relevant just to videos
6565
66+
### `Byline`
67+
68+
```ts
69+
interface Byline extends Node {
70+
type: "byline"
71+
title?: string
72+
external displayName: string
73+
external headshotUrl: string
74+
}
75+
```
76+
77+
`Byline` defines a reusable visual representation of an author
78+
6679
## Core Nodes
6780

6881
### `Node`
@@ -342,6 +355,9 @@ type StoryBlock =
342355
| Definition
343356
| InfoBox
344357
| InfoPair
358+
| QuestionAndAnswer
359+
| Question
360+
| Answer
345361
```
346362
347363
`StoryBlock` nodes are things that can be inserted into an article body.
@@ -375,6 +391,41 @@ interface ImageSet extends Node {
375391
}
376392
```
377393

394+
### `QuestionAndAnswer`
395+
396+
```ts
397+
interface QuestionAndAnswer extends Parent {
398+
type: "question-and-answer"
399+
children: [Question, Answer, ...Answer[]]
400+
}
401+
```
402+
403+
`QuestionAndAnswer` defines a container grouping a `Question` followed by one or more `Answer` nodes
404+
405+
### `Question`
406+
407+
```ts
408+
interface Question extends Parent {
409+
type: "question"
410+
displayName?: string
411+
children: (Paragraph | Exclude<Phrasing, Link | FindOutMoreLink>)[]
412+
}
413+
```
414+
415+
`Question` defines the question copy with an optional `displayName` string, disallowing inline `Link` and `FindOutMoreLink` nodes
416+
417+
### `Answer`
418+
419+
```ts
420+
interface Answer extends Parent {
421+
type: "answer"
422+
author: Byline
423+
children: (Paragraph | Phrasing)[]
424+
}
425+
```
426+
427+
`Answer` defines an authored reply that requires an `Author`
428+
378429
#### Image types
379430

380431
##### `ImageSetPicture`

content-tree.d.ts

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export declare namespace ContentTree {
1212
pixelWidth?: number;
1313
videoCodec?: string;
1414
};
15+
interface Byline extends Node {
16+
type: "byline";
17+
title?: string;
18+
displayName: string;
19+
headshotUrl: string;
20+
}
1521
interface Node {
1622
type: string;
1723
data?: any;
@@ -88,7 +94,7 @@ export declare namespace ContentTree {
8894
type: "blockquote";
8995
children: (Paragraph | Phrasing)[];
9096
}
91-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
97+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | QuestionAndAnswer | Question | Answer;
9298
interface Pullquote extends Node {
9399
type: "pullquote";
94100
text: string;
@@ -100,6 +106,20 @@ export declare namespace ContentTree {
100106
picture: ImageSetPicture;
101107
fragmentIdentifier?: string;
102108
}
109+
interface QuestionAndAnswer extends Parent {
110+
type: "question-and-answer";
111+
children: [Question, Answer, ...Answer[]];
112+
}
113+
interface Question extends Parent {
114+
type: "question";
115+
displayName?: string;
116+
children: (Paragraph | Exclude<Phrasing, Link | FindOutMoreLink>)[];
117+
}
118+
interface Answer extends Parent {
119+
type: "answer";
120+
author: Byline;
121+
children: (Paragraph | Phrasing)[];
122+
}
103123
type ImageSetPicture = {
104124
layoutWidth: string;
105125
imageType: "image" | "graphic";
@@ -431,6 +451,12 @@ export declare namespace ContentTree {
431451
pixelWidth?: number;
432452
videoCodec?: string;
433453
};
454+
interface Byline extends Node {
455+
type: "byline";
456+
title?: string;
457+
displayName: string;
458+
headshotUrl: string;
459+
}
434460
interface Node {
435461
type: string;
436462
data?: any;
@@ -507,7 +533,7 @@ export declare namespace ContentTree {
507533
type: "blockquote";
508534
children: (Paragraph | Phrasing)[];
509535
}
510-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
536+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | QuestionAndAnswer | Question | Answer;
511537
interface Pullquote extends Node {
512538
type: "pullquote";
513539
text: string;
@@ -519,6 +545,20 @@ export declare namespace ContentTree {
519545
picture: ImageSetPicture;
520546
fragmentIdentifier?: string;
521547
}
548+
interface QuestionAndAnswer extends Parent {
549+
type: "question-and-answer";
550+
children: [Question, Answer, ...Answer[]];
551+
}
552+
interface Question extends Parent {
553+
type: "question";
554+
displayName?: string;
555+
children: (Paragraph | Exclude<Phrasing, Link | FindOutMoreLink>)[];
556+
}
557+
interface Answer extends Parent {
558+
type: "answer";
559+
author: Byline;
560+
children: (Paragraph | Phrasing)[];
561+
}
522562
type ImageSetPicture = {
523563
layoutWidth: string;
524564
imageType: "image" | "graphic";
@@ -851,6 +891,10 @@ export declare namespace ContentTree {
851891
pixelWidth?: number;
852892
videoCodec?: string;
853893
};
894+
interface Byline extends Node {
895+
type: "byline";
896+
title?: string;
897+
}
854898
interface Node {
855899
type: string;
856900
data?: any;
@@ -927,7 +971,7 @@ export declare namespace ContentTree {
927971
type: "blockquote";
928972
children: (Paragraph | Phrasing)[];
929973
}
930-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
974+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | QuestionAndAnswer | Question | Answer;
931975
interface Pullquote extends Node {
932976
type: "pullquote";
933977
text: string;
@@ -938,6 +982,20 @@ export declare namespace ContentTree {
938982
id: string;
939983
fragmentIdentifier?: string;
940984
}
985+
interface QuestionAndAnswer extends Parent {
986+
type: "question-and-answer";
987+
children: [Question, Answer, ...Answer[]];
988+
}
989+
interface Question extends Parent {
990+
type: "question";
991+
displayName?: string;
992+
children: (Paragraph | Exclude<Phrasing, Link | FindOutMoreLink>)[];
993+
}
994+
interface Answer extends Parent {
995+
type: "answer";
996+
author: Byline;
997+
children: (Paragraph | Phrasing)[];
998+
}
941999
type ImageSetPicture = {
9421000
layoutWidth: string;
9431001
imageType: "image" | "graphic";
@@ -1244,6 +1302,12 @@ export declare namespace ContentTree {
12441302
pixelWidth?: number;
12451303
videoCodec?: string;
12461304
};
1305+
interface Byline extends Node {
1306+
type: "byline";
1307+
title?: string;
1308+
displayName?: string;
1309+
headshotUrl?: string;
1310+
}
12471311
interface Node {
12481312
type: string;
12491313
data?: any;
@@ -1320,7 +1384,7 @@ export declare namespace ContentTree {
13201384
type: "blockquote";
13211385
children: (Paragraph | Phrasing)[];
13221386
}
1323-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
1387+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | QuestionAndAnswer | Question | Answer;
13241388
interface Pullquote extends Node {
13251389
type: "pullquote";
13261390
text: string;
@@ -1332,6 +1396,20 @@ export declare namespace ContentTree {
13321396
picture?: ImageSetPicture;
13331397
fragmentIdentifier?: string;
13341398
}
1399+
interface QuestionAndAnswer extends Parent {
1400+
type: "question-and-answer";
1401+
children: [Question, Answer, ...Answer[]];
1402+
}
1403+
interface Question extends Parent {
1404+
type: "question";
1405+
displayName?: string;
1406+
children: (Paragraph | Exclude<Phrasing, Link | FindOutMoreLink>)[];
1407+
}
1408+
interface Answer extends Parent {
1409+
type: "answer";
1410+
author: Byline;
1411+
children: (Paragraph | Phrasing)[];
1412+
}
13351413
type ImageSetPicture = {
13361414
layoutWidth: string;
13371415
imageType: "image" | "graphic";

0 commit comments

Comments
 (0)