Skip to content

Commit 2ce13c2

Browse files
Implement Question and Answer nodes
1 parent 3af1726 commit 2ce13c2

6 files changed

Lines changed: 909 additions & 4 deletions

File tree

SPEC.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,27 @@ type VideoSource = AVSource & {
6363
6464
`VideoSource` extends AVSource to add in the properties relevant just to videos
6565
66+
### `Author`
67+
68+
```ts
69+
interface Author {
70+
title?: string
71+
conceptId?: string
72+
}
73+
```
74+
75+
`Author` defines author attribution for `Answer` nodes and stores an optional snapshot `title` and optional `conceptId` reference
76+
77+
### `DisplayName`
78+
79+
```ts
80+
interface DisplayName {
81+
displayName?: string
82+
}
83+
```
84+
85+
`DisplayName` defines display-name attribution
86+
6687
## Core Nodes
6788

6889
### `Node`
@@ -342,6 +363,9 @@ type StoryBlock =
342363
| Definition
343364
| InfoBox
344365
| InfoPair
366+
| QuestionAndAnswer
367+
| Question
368+
| Answer
345369
```
346370
347371
`StoryBlock` nodes are things that can be inserted into an article body.
@@ -375,6 +399,41 @@ interface ImageSet extends Node {
375399
}
376400
```
377401

402+
### `QuestionAndAnswer`
403+
404+
```ts
405+
interface QuestionAndAnswer extends Parent {
406+
type: "question-and-answer"
407+
children: [Question, Answer, ...Answer[]]
408+
}
409+
```
410+
411+
`QuestionAndAnswer` defines a container grouping a `Question` followed by one or more `Answer` nodes
412+
413+
### `Question`
414+
415+
```ts
416+
interface Question extends Parent {
417+
type: "question"
418+
author?: DisplayName
419+
children: (Paragraph | Exclude<Phrasing, Link>)[]
420+
}
421+
```
422+
423+
`Question` defines the question copy with an optional `DisplayName`, disallowing inline `Link` nodes
424+
425+
### `Answer`
426+
427+
```ts
428+
interface Answer extends Parent {
429+
type: "answer"
430+
author: Author
431+
children: (Paragraph | Phrasing)[]
432+
}
433+
```
434+
435+
`Answer` defines an authored reply that requires an `Author`
436+
378437
#### Image types
379438

380439
##### `ImageSetPicture`

content-tree.d.ts

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export declare namespace ContentTree {
1212
pixelWidth?: number;
1313
videoCodec?: string;
1414
};
15+
interface Author {
16+
title?: string;
17+
conceptId?: string;
18+
}
19+
interface DisplayName {
20+
displayName?: string;
21+
}
1522
interface Node {
1623
type: string;
1724
data?: any;
@@ -88,7 +95,7 @@ export declare namespace ContentTree {
8895
type: "blockquote";
8996
children: (Paragraph | Phrasing)[];
9097
}
91-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
98+
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;
9299
interface Pullquote extends Node {
93100
type: "pullquote";
94101
text: string;
@@ -100,6 +107,20 @@ export declare namespace ContentTree {
100107
picture: ImageSetPicture;
101108
fragmentIdentifier?: string;
102109
}
110+
interface QuestionAndAnswer extends Parent {
111+
type: "question-and-answer";
112+
children: [Question, Answer, ...Answer[]];
113+
}
114+
interface Question extends Parent {
115+
type: "question";
116+
author?: DisplayName;
117+
children: (Paragraph | Exclude<Phrasing, Link>)[];
118+
}
119+
interface Answer extends Parent {
120+
type: "answer";
121+
author: Author;
122+
children: (Paragraph | Phrasing)[];
123+
}
103124
type ImageSetPicture = {
104125
layoutWidth: string;
105126
imageType: "image" | "graphic";
@@ -431,6 +452,13 @@ export declare namespace ContentTree {
431452
pixelWidth?: number;
432453
videoCodec?: string;
433454
};
455+
interface Author {
456+
title?: string;
457+
conceptId?: string;
458+
}
459+
interface DisplayName {
460+
displayName?: string;
461+
}
434462
interface Node {
435463
type: string;
436464
data?: any;
@@ -507,7 +535,7 @@ export declare namespace ContentTree {
507535
type: "blockquote";
508536
children: (Paragraph | Phrasing)[];
509537
}
510-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
538+
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;
511539
interface Pullquote extends Node {
512540
type: "pullquote";
513541
text: string;
@@ -519,6 +547,20 @@ export declare namespace ContentTree {
519547
picture: ImageSetPicture;
520548
fragmentIdentifier?: string;
521549
}
550+
interface QuestionAndAnswer extends Parent {
551+
type: "question-and-answer";
552+
children: [Question, Answer, ...Answer[]];
553+
}
554+
interface Question extends Parent {
555+
type: "question";
556+
author?: DisplayName;
557+
children: (Paragraph | Exclude<Phrasing, Link>)[];
558+
}
559+
interface Answer extends Parent {
560+
type: "answer";
561+
author: Author;
562+
children: (Paragraph | Phrasing)[];
563+
}
522564
type ImageSetPicture = {
523565
layoutWidth: string;
524566
imageType: "image" | "graphic";
@@ -851,6 +893,13 @@ export declare namespace ContentTree {
851893
pixelWidth?: number;
852894
videoCodec?: string;
853895
};
896+
interface Author {
897+
title?: string;
898+
conceptId?: string;
899+
}
900+
interface DisplayName {
901+
displayName?: string;
902+
}
854903
interface Node {
855904
type: string;
856905
data?: any;
@@ -927,7 +976,7 @@ export declare namespace ContentTree {
927976
type: "blockquote";
928977
children: (Paragraph | Phrasing)[];
929978
}
930-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
979+
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;
931980
interface Pullquote extends Node {
932981
type: "pullquote";
933982
text: string;
@@ -938,6 +987,20 @@ export declare namespace ContentTree {
938987
id: string;
939988
fragmentIdentifier?: string;
940989
}
990+
interface QuestionAndAnswer extends Parent {
991+
type: "question-and-answer";
992+
children: [Question, Answer, ...Answer[]];
993+
}
994+
interface Question extends Parent {
995+
type: "question";
996+
author?: DisplayName;
997+
children: (Paragraph | Exclude<Phrasing, Link>)[];
998+
}
999+
interface Answer extends Parent {
1000+
type: "answer";
1001+
author: Author;
1002+
children: (Paragraph | Phrasing)[];
1003+
}
9411004
type ImageSetPicture = {
9421005
layoutWidth: string;
9431006
imageType: "image" | "graphic";
@@ -1244,6 +1307,13 @@ export declare namespace ContentTree {
12441307
pixelWidth?: number;
12451308
videoCodec?: string;
12461309
};
1310+
interface Author {
1311+
title?: string;
1312+
conceptId?: string;
1313+
}
1314+
interface DisplayName {
1315+
displayName?: string;
1316+
}
12471317
interface Node {
12481318
type: string;
12491319
data?: any;
@@ -1320,7 +1390,7 @@ export declare namespace ContentTree {
13201390
type: "blockquote";
13211391
children: (Paragraph | Phrasing)[];
13221392
}
1323-
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
1393+
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;
13241394
interface Pullquote extends Node {
13251395
type: "pullquote";
13261396
text: string;
@@ -1332,6 +1402,20 @@ export declare namespace ContentTree {
13321402
picture?: ImageSetPicture;
13331403
fragmentIdentifier?: string;
13341404
}
1405+
interface QuestionAndAnswer extends Parent {
1406+
type: "question-and-answer";
1407+
children: [Question, Answer, ...Answer[]];
1408+
}
1409+
interface Question extends Parent {
1410+
type: "question";
1411+
author?: DisplayName;
1412+
children: (Paragraph | Exclude<Phrasing, Link>)[];
1413+
}
1414+
interface Answer extends Parent {
1415+
type: "answer";
1416+
author: Author;
1417+
children: (Paragraph | Phrasing)[];
1418+
}
13351419
type ImageSetPicture = {
13361420
layoutWidth: string;
13371421
imageType: "image" | "graphic";

0 commit comments

Comments
 (0)