Skip to content

Commit 975f4b8

Browse files
feat: distinguish between formatting blocks and story blocks
1 parent 2890ea8 commit 975f4b8

File tree

5 files changed

+146
-54
lines changed

5 files changed

+146
-54
lines changed

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,37 @@ It is the state of the tree in the network that we call "in transit".
9191
These abstract helper types define special types a [Parent](#parent) can use as
9292
[children][term-child].
9393

94-
### `BodyBlock`
94+
### FormattingBlock
9595

9696
```ts
97-
type BodyBlock =
97+
type FormattingBlock =
9898
| Paragraph
9999
| Heading
100+
| List
101+
| Blockquote
102+
| ThematicBreak
103+
| Text
104+
```
105+
106+
`FormattingBlock` nodes contains only text-structured blocks used for formatting textual content.
107+
108+
### `StoryBlock`
109+
110+
```ts
111+
type StoryBlock =
100112
| ImageSet
101113
| Flourish
102114
| BigNumber
103115
| CustomCodeComponent
104116
| Layout
105-
| List
106-
| Blockquote
107117
| Pullquote
108118
| ScrollyBlock
109-
| ThematicBreak
110119
| Table
111120
| Recommended
112121
| RecommendedList
113122
| Tweet
114123
| Video
115124
| YoutubeVideo
116-
| Text
117125
| Timeline
118126
| ImagePair
119127
| InNumbers
@@ -122,6 +130,16 @@ type BodyBlock =
122130
| InfoPair
123131
```
124132
133+
`StoryBlock` nodes are things that can be inserted into an article body.
134+
135+
### BodyBlock
136+
137+
```ts
138+
type BodyBlock =
139+
| FormattingBlock
140+
| StoryBlock
141+
```
142+
125143
`BodyBlock` nodes are the only things that are valid as the top level of a `Body`.
126144
127145
### `LayoutWidth`
@@ -862,7 +880,7 @@ interface Card extends Parent {
862880
type: "card"
863881
/** The title of this card */
864882
title?: string
865-
children: (ImageSet)[]
883+
children: (ImageSet | FormattingBlock)[]
866884
}
867885
```
868886

content-tree.d.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export declare namespace ContentTree {
2-
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
2+
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
3+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
4+
type BodyBlock = FormattingBlock | StoryBlock;
35
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
46
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
57
interface Node {
@@ -332,7 +334,7 @@ export declare namespace ContentTree {
332334
type: "card";
333335
/** The title of this card */
334336
title?: string;
335-
children: (ImageSet)[];
337+
children: (ImageSet | FormattingBlock)[];
336338
}
337339
/**
338340
* Allowed layout widths for an InfoBox.
@@ -357,7 +359,9 @@ export declare namespace ContentTree {
357359
children: [Card, Card];
358360
}
359361
namespace full {
360-
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
362+
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
363+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
364+
type BodyBlock = FormattingBlock | StoryBlock;
361365
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
362366
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
363367
interface Node {
@@ -690,7 +694,7 @@ export declare namespace ContentTree {
690694
type: "card";
691695
/** The title of this card */
692696
title?: string;
693-
children: (ImageSet)[];
697+
children: (ImageSet | FormattingBlock)[];
694698
}
695699
/**
696700
* Allowed layout widths for an InfoBox.
@@ -716,7 +720,9 @@ export declare namespace ContentTree {
716720
}
717721
}
718722
namespace transit {
719-
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
723+
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
724+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
725+
type BodyBlock = FormattingBlock | StoryBlock;
720726
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
721727
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
722728
interface Node {
@@ -1034,7 +1040,7 @@ export declare namespace ContentTree {
10341040
type: "card";
10351041
/** The title of this card */
10361042
title?: string;
1037-
children: (ImageSet)[];
1043+
children: (ImageSet | FormattingBlock)[];
10381044
}
10391045
/**
10401046
* Allowed layout widths for an InfoBox.
@@ -1060,7 +1066,9 @@ export declare namespace ContentTree {
10601066
}
10611067
}
10621068
namespace loose {
1063-
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
1069+
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
1070+
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
1071+
type BodyBlock = FormattingBlock | StoryBlock;
10641072
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
10651073
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
10661074
interface Node {
@@ -1393,7 +1401,7 @@ export declare namespace ContentTree {
13931401
type: "card";
13941402
/** The title of this card */
13951403
title?: string;
1396-
children: (ImageSet)[];
1404+
children: (ImageSet | FormattingBlock)[];
13971405
}
13981406
/**
13991407
* Allowed layout widths for an InfoBox.

schemas/body-tree.schema.json

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@
7575
{
7676
"$ref": "#/definitions/ContentTree.transit.Heading"
7777
},
78+
{
79+
"$ref": "#/definitions/ContentTree.transit.List"
80+
},
81+
{
82+
"$ref": "#/definitions/ContentTree.transit.Blockquote"
83+
},
84+
{
85+
"$ref": "#/definitions/ContentTree.transit.ThematicBreak"
86+
},
87+
{
88+
"$ref": "#/definitions/ContentTree.transit.Text"
89+
},
7890
{
7991
"$ref": "#/definitions/ContentTree.transit.ImageSet"
8092
},
@@ -90,21 +102,12 @@
90102
{
91103
"$ref": "#/definitions/ContentTree.transit.Layout"
92104
},
93-
{
94-
"$ref": "#/definitions/ContentTree.transit.List"
95-
},
96-
{
97-
"$ref": "#/definitions/ContentTree.transit.Blockquote"
98-
},
99105
{
100106
"$ref": "#/definitions/ContentTree.transit.Pullquote"
101107
},
102108
{
103109
"$ref": "#/definitions/ContentTree.transit.ScrollyBlock"
104110
},
105-
{
106-
"$ref": "#/definitions/ContentTree.transit.ThematicBreak"
107-
},
108111
{
109112
"$ref": "#/definitions/ContentTree.transit.Table"
110113
},
@@ -123,9 +126,6 @@
123126
{
124127
"$ref": "#/definitions/ContentTree.transit.YoutubeVideo"
125128
},
126-
{
127-
"$ref": "#/definitions/ContentTree.transit.Text"
128-
},
129129
{
130130
"$ref": "#/definitions/ContentTree.transit.Timeline"
131131
},
@@ -166,7 +166,29 @@
166166
"properties": {
167167
"children": {
168168
"items": {
169-
"$ref": "#/definitions/ContentTree.transit.ImageSet"
169+
"anyOf": [
170+
{
171+
"$ref": "#/definitions/ContentTree.transit.Paragraph"
172+
},
173+
{
174+
"$ref": "#/definitions/ContentTree.transit.Heading"
175+
},
176+
{
177+
"$ref": "#/definitions/ContentTree.transit.List"
178+
},
179+
{
180+
"$ref": "#/definitions/ContentTree.transit.Blockquote"
181+
},
182+
{
183+
"$ref": "#/definitions/ContentTree.transit.ThematicBreak"
184+
},
185+
{
186+
"$ref": "#/definitions/ContentTree.transit.Text"
187+
},
188+
{
189+
"$ref": "#/definitions/ContentTree.transit.ImageSet"
190+
}
191+
]
170192
},
171193
"type": "array"
172194
},

schemas/content-tree.schema.json

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@
100100
{
101101
"$ref": "#/definitions/ContentTree.full.Heading"
102102
},
103+
{
104+
"$ref": "#/definitions/ContentTree.full.List"
105+
},
106+
{
107+
"$ref": "#/definitions/ContentTree.full.Blockquote"
108+
},
109+
{
110+
"$ref": "#/definitions/ContentTree.full.ThematicBreak"
111+
},
112+
{
113+
"$ref": "#/definitions/ContentTree.full.Text"
114+
},
103115
{
104116
"$ref": "#/definitions/ContentTree.full.ImageSet"
105117
},
@@ -115,21 +127,12 @@
115127
{
116128
"$ref": "#/definitions/ContentTree.full.Layout"
117129
},
118-
{
119-
"$ref": "#/definitions/ContentTree.full.List"
120-
},
121-
{
122-
"$ref": "#/definitions/ContentTree.full.Blockquote"
123-
},
124130
{
125131
"$ref": "#/definitions/ContentTree.full.Pullquote"
126132
},
127133
{
128134
"$ref": "#/definitions/ContentTree.full.ScrollyBlock"
129135
},
130-
{
131-
"$ref": "#/definitions/ContentTree.full.ThematicBreak"
132-
},
133136
{
134137
"$ref": "#/definitions/ContentTree.full.Table"
135138
},
@@ -148,9 +151,6 @@
148151
{
149152
"$ref": "#/definitions/ContentTree.full.YoutubeVideo"
150153
},
151-
{
152-
"$ref": "#/definitions/ContentTree.full.Text"
153-
},
154154
{
155155
"$ref": "#/definitions/ContentTree.full.Timeline"
156156
},
@@ -191,7 +191,29 @@
191191
"properties": {
192192
"children": {
193193
"items": {
194-
"$ref": "#/definitions/ContentTree.full.ImageSet"
194+
"anyOf": [
195+
{
196+
"$ref": "#/definitions/ContentTree.full.Paragraph"
197+
},
198+
{
199+
"$ref": "#/definitions/ContentTree.full.Heading"
200+
},
201+
{
202+
"$ref": "#/definitions/ContentTree.full.List"
203+
},
204+
{
205+
"$ref": "#/definitions/ContentTree.full.Blockquote"
206+
},
207+
{
208+
"$ref": "#/definitions/ContentTree.full.ThematicBreak"
209+
},
210+
{
211+
"$ref": "#/definitions/ContentTree.full.Text"
212+
},
213+
{
214+
"$ref": "#/definitions/ContentTree.full.ImageSet"
215+
}
216+
]
195217
},
196218
"type": "array"
197219
},

schemas/transit-tree.schema.json

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@
100100
{
101101
"$ref": "#/definitions/ContentTree.transit.Heading"
102102
},
103+
{
104+
"$ref": "#/definitions/ContentTree.transit.List"
105+
},
106+
{
107+
"$ref": "#/definitions/ContentTree.transit.Blockquote"
108+
},
109+
{
110+
"$ref": "#/definitions/ContentTree.transit.ThematicBreak"
111+
},
112+
{
113+
"$ref": "#/definitions/ContentTree.transit.Text"
114+
},
103115
{
104116
"$ref": "#/definitions/ContentTree.transit.ImageSet"
105117
},
@@ -115,21 +127,12 @@
115127
{
116128
"$ref": "#/definitions/ContentTree.transit.Layout"
117129
},
118-
{
119-
"$ref": "#/definitions/ContentTree.transit.List"
120-
},
121-
{
122-
"$ref": "#/definitions/ContentTree.transit.Blockquote"
123-
},
124130
{
125131
"$ref": "#/definitions/ContentTree.transit.Pullquote"
126132
},
127133
{
128134
"$ref": "#/definitions/ContentTree.transit.ScrollyBlock"
129135
},
130-
{
131-
"$ref": "#/definitions/ContentTree.transit.ThematicBreak"
132-
},
133136
{
134137
"$ref": "#/definitions/ContentTree.transit.Table"
135138
},
@@ -148,9 +151,6 @@
148151
{
149152
"$ref": "#/definitions/ContentTree.transit.YoutubeVideo"
150153
},
151-
{
152-
"$ref": "#/definitions/ContentTree.transit.Text"
153-
},
154154
{
155155
"$ref": "#/definitions/ContentTree.transit.Timeline"
156156
},
@@ -191,7 +191,29 @@
191191
"properties": {
192192
"children": {
193193
"items": {
194-
"$ref": "#/definitions/ContentTree.transit.ImageSet"
194+
"anyOf": [
195+
{
196+
"$ref": "#/definitions/ContentTree.transit.Paragraph"
197+
},
198+
{
199+
"$ref": "#/definitions/ContentTree.transit.Heading"
200+
},
201+
{
202+
"$ref": "#/definitions/ContentTree.transit.List"
203+
},
204+
{
205+
"$ref": "#/definitions/ContentTree.transit.Blockquote"
206+
},
207+
{
208+
"$ref": "#/definitions/ContentTree.transit.ThematicBreak"
209+
},
210+
{
211+
"$ref": "#/definitions/ContentTree.transit.Text"
212+
},
213+
{
214+
"$ref": "#/definitions/ContentTree.transit.ImageSet"
215+
}
216+
]
195217
},
196218
"type": "array"
197219
},

0 commit comments

Comments
 (0)