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
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ type LayoutWidth =
### `Phrasing`

```ts
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link | Subscript | Superscript
```

A phrasing node cannot have ancestor of the same type.
Expand Down Expand Up @@ -283,6 +283,28 @@ interface Strikethrough extends Parent {

**Strikethrough** represents a piece of text that has been stricken.

### `Subscript`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: If I'm not mistaken the json schemas will need to be updated.
For context, the C&M team will allow publishing of content tree next year and those schemas will be our source of truth for validation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON schemas get automatically generated as part of the build step

I think what's missing (and why the JSON schemas haven't been updated yet) is that the new types need to be included as things that can be "Phrasing" - https://github.com/Financial-Times/content-tree/pull/57/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R130

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just added Subscript and Superscript to the Phrasing types, and re-built the schema 👍


```ts
interface Subscript extends Parent {
type: "subscript"
children: Phrasing[]
}
```

**Subscript** represents a piece of text that has a lowered baseline.

### `Superscript`

```ts
interface Superscript extends Parent {
type: "superscript"
children: Phrasing[]
}
```

**Superscript** represents a piece of text with a raised baseline.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ Add support for new subscript (<sub>) and superscript (<sup>) formatted text to Content Tree.

### `Link`

```ts
Expand Down
40 changes: 36 additions & 4 deletions content-tree.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export declare namespace ContentTree {
type BodyBlock = Paragraph | Heading | ImageSet | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | Tweet | Video | YoutubeVideo;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link | Subscript | Superscript;
interface Node {
type: string;
data?: any;
Expand Down Expand Up @@ -49,6 +49,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
interface Link extends Parent {
type: "link";
url: string;
Expand Down Expand Up @@ -274,7 +282,7 @@ export declare namespace ContentTree {
namespace full {
type BodyBlock = Paragraph | Heading | ImageSet | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | Tweet | Video | YoutubeVideo;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link | Subscript | Superscript;
interface Node {
type: string;
data?: any;
Expand Down Expand Up @@ -322,6 +330,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
interface Link extends Parent {
type: "link";
url: string;
Expand Down Expand Up @@ -548,7 +564,7 @@ export declare namespace ContentTree {
namespace transit {
type BodyBlock = Paragraph | Heading | ImageSet | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | Tweet | Video | YoutubeVideo;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link | Subscript | Superscript;
interface Node {
type: string;
data?: any;
Expand Down Expand Up @@ -596,6 +612,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
interface Link extends Parent {
type: "link";
url: string;
Expand Down Expand Up @@ -809,7 +833,7 @@ export declare namespace ContentTree {
namespace loose {
type BodyBlock = Paragraph | Heading | ImageSet | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | Tweet | Video | YoutubeVideo;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link | Subscript | Superscript;
interface Node {
type: string;
data?: any;
Expand Down Expand Up @@ -857,6 +881,14 @@ export declare namespace ContentTree {
type: "strikethrough";
children: Phrasing[];
}
interface Subscript extends Parent {
type: "subscript";
children: Phrasing[];
}
interface Superscript extends Parent {
type: "superscript";
children: Phrasing[];
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ All changes in this file are autogenerated from changes to README.md.

interface Link extends Parent {
type: "link";
url: string;
Expand Down
16 changes: 16 additions & 0 deletions libraries/from-bodyxml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ export let defaultTransformers = {
type: "strikethrough",
}
},
/**
* @type {Transformer<ContentTree.transit.Subscript>}
*/
sub(sub) {
return {
type: "subscript",
}
},
/**
* @type {Transformer<ContentTree.transit.Superscript>}
*/
sup(sup) {
return {
type: "superscript",
}
},
/**
* @type {Transformer<ContentTree.transit.Break>}
*/
Expand Down
50 changes: 50 additions & 0 deletions schemas/body-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
},
{
"$ref": "#/definitions/ContentTree.transit.Link"
},
{
"$ref": "#/definitions/ContentTree.transit.Subscript"
},
{
"$ref": "#/definitions/ContentTree.transit.Superscript"
}
]
},
Expand Down Expand Up @@ -374,6 +380,12 @@
},
{
"$ref": "#/definitions/ContentTree.transit.Link"
},
{
"$ref": "#/definitions/ContentTree.transit.Subscript"
},
{
"$ref": "#/definitions/ContentTree.transit.Superscript"
}
]
},
Expand Down Expand Up @@ -422,6 +434,12 @@
},
{
"$ref": "#/definitions/ContentTree.transit.Link"
},
{
"$ref": "#/definitions/ContentTree.transit.Subscript"
},
{
"$ref": "#/definitions/ContentTree.transit.Superscript"
}
]
},
Expand Down Expand Up @@ -623,6 +641,38 @@
},
"type": "object"
},
"ContentTree.transit.Subscript": {
"properties": {
"children": {
"items": {
"$ref": "#/definitions/ContentTree.transit.Phrasing"
},
"type": "array"
},
"data": {},
"type": {
"const": "subscript",
"type": "string"
}
},
"type": "object"
},
"ContentTree.transit.Superscript": {
"properties": {
"children": {
"items": {
"$ref": "#/definitions/ContentTree.transit.Phrasing"
},
"type": "array"
},
"data": {},
"type": {
"const": "superscript",
"type": "string"
}
},
"type": "object"
},
"ContentTree.transit.Table": {
"properties": {
"children": {
Expand Down
50 changes: 50 additions & 0 deletions schemas/content-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
},
{
"$ref": "#/definitions/ContentTree.full.Link"
},
{
"$ref": "#/definitions/ContentTree.full.Subscript"
},
{
"$ref": "#/definitions/ContentTree.full.Superscript"
}
]
},
Expand Down Expand Up @@ -653,6 +659,12 @@
},
{
"$ref": "#/definitions/ContentTree.full.Link"
},
{
"$ref": "#/definitions/ContentTree.full.Subscript"
},
{
"$ref": "#/definitions/ContentTree.full.Superscript"
}
]
},
Expand Down Expand Up @@ -701,6 +713,12 @@
},
{
"$ref": "#/definitions/ContentTree.full.Link"
},
{
"$ref": "#/definitions/ContentTree.full.Subscript"
},
{
"$ref": "#/definitions/ContentTree.full.Superscript"
}
]
},
Expand Down Expand Up @@ -1170,6 +1188,38 @@
},
"type": "object"
},
"ContentTree.full.Subscript": {
"properties": {
"children": {
"items": {
"$ref": "#/definitions/ContentTree.full.Phrasing"
},
"type": "array"
},
"data": {},
"type": {
"const": "subscript",
"type": "string"
}
},
"type": "object"
},
"ContentTree.full.Superscript": {
"properties": {
"children": {
"items": {
"$ref": "#/definitions/ContentTree.full.Phrasing"
},
"type": "array"
},
"data": {},
"type": {
"const": "superscript",
"type": "string"
}
},
"type": "object"
},
"ContentTree.full.Table": {
"properties": {
"children": {
Expand Down
50 changes: 50 additions & 0 deletions schemas/transit-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
},
{
"$ref": "#/definitions/ContentTree.transit.Link"
},
{
"$ref": "#/definitions/ContentTree.transit.Subscript"
},
{
"$ref": "#/definitions/ContentTree.transit.Superscript"
}
]
},
Expand Down Expand Up @@ -393,6 +399,12 @@
},
{
"$ref": "#/definitions/ContentTree.transit.Link"
},
{
"$ref": "#/definitions/ContentTree.transit.Subscript"
},
{
"$ref": "#/definitions/ContentTree.transit.Superscript"
}
]
},
Expand Down Expand Up @@ -441,6 +453,12 @@
},
{
"$ref": "#/definitions/ContentTree.transit.Link"
},
{
"$ref": "#/definitions/ContentTree.transit.Subscript"
},
{
"$ref": "#/definitions/ContentTree.transit.Superscript"
}
]
},
Expand Down Expand Up @@ -642,6 +660,38 @@
},
"type": "object"
},
"ContentTree.transit.Subscript": {
"properties": {
"children": {
"items": {
"$ref": "#/definitions/ContentTree.transit.Phrasing"
},
"type": "array"
},
"data": {},
"type": {
"const": "subscript",
"type": "string"
}
},
"type": "object"
},
"ContentTree.transit.Superscript": {
"properties": {
"children": {
"items": {
"$ref": "#/definitions/ContentTree.transit.Phrasing"
},
"type": "array"
},
"data": {},
"type": {
"const": "superscript",
"type": "string"
}
},
"type": "object"
},
"ContentTree.transit.Table": {
"properties": {
"children": {
Expand Down
Loading
Loading