Skip to content
Merged
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ interface Heading extends Parent {
type: "heading"
children: Text[]
level: "chapter" | "subheading" | "label"
blockIdentifier?: string
}
```

Expand Down Expand Up @@ -354,6 +355,7 @@ interface ImageSet extends Node {
type: "image-set"
id: string
external picture: ImageSetPicture
blockIdentifier?: string
}
```

Expand Down Expand Up @@ -512,6 +514,7 @@ interface Flourish extends Node {
description?: string
timestamp?: string
external fallbackImage?: Image
blockIdentifier?: string
}
```

Expand Down
12 changes: 12 additions & 0 deletions content-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export declare namespace ContentTree {
type: "heading";
children: Text[];
level: "chapter" | "subheading" | "label";
blockIdentifier?: string;
}
interface Strong extends Parent {
type: "strong";
Expand Down Expand Up @@ -77,6 +78,7 @@ export declare namespace ContentTree {
type: "image-set";
id: string;
picture: ImageSetPicture;
blockIdentifier?: string;
}
type ImageSetPicture = {
layoutWidth: string;
Expand Down Expand Up @@ -156,6 +158,7 @@ export declare namespace ContentTree {
description?: string;
timestamp?: string;
fallbackImage?: Image;
blockIdentifier?: string;
}
interface BigNumber extends Node {
type: "big-number";
Expand Down Expand Up @@ -309,6 +312,7 @@ export declare namespace ContentTree {
type: "heading";
children: Text[];
level: "chapter" | "subheading" | "label";
blockIdentifier?: string;
}
interface Strong extends Parent {
type: "strong";
Expand Down Expand Up @@ -350,6 +354,7 @@ export declare namespace ContentTree {
type: "image-set";
id: string;
picture: ImageSetPicture;
blockIdentifier?: string;
}
type ImageSetPicture = {
layoutWidth: string;
Expand Down Expand Up @@ -429,6 +434,7 @@ export declare namespace ContentTree {
description?: string;
timestamp?: string;
fallbackImage?: Image;
blockIdentifier?: string;
}
interface BigNumber extends Node {
type: "big-number";
Expand Down Expand Up @@ -583,6 +589,7 @@ export declare namespace ContentTree {
type: "heading";
children: Text[];
level: "chapter" | "subheading" | "label";
blockIdentifier?: string;
}
interface Strong extends Parent {
type: "strong";
Expand Down Expand Up @@ -623,6 +630,7 @@ export declare namespace ContentTree {
interface ImageSet extends Node {
type: "image-set";
id: string;
blockIdentifier?: string;
}
type ImageSetPicture = {
layoutWidth: string;
Expand Down Expand Up @@ -699,6 +707,7 @@ export declare namespace ContentTree {
flourishType: string;
description?: string;
timestamp?: string;
blockIdentifier?: string;
}
interface BigNumber extends Node {
type: "big-number";
Expand Down Expand Up @@ -842,6 +851,7 @@ export declare namespace ContentTree {
type: "heading";
children: Text[];
level: "chapter" | "subheading" | "label";
blockIdentifier?: string;
}
interface Strong extends Parent {
type: "strong";
Expand Down Expand Up @@ -883,6 +893,7 @@ export declare namespace ContentTree {
type: "image-set";
id: string;
picture?: ImageSetPicture;
blockIdentifier?: string;
}
type ImageSetPicture = {
layoutWidth: string;
Expand Down Expand Up @@ -962,6 +973,7 @@ export declare namespace ContentTree {
description?: string;
timestamp?: string;
fallbackImage?: Image;
blockIdentifier?: string;
}
interface BigNumber extends Node {
type: "big-number";
Expand Down
29 changes: 16 additions & 13 deletions content_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type ColumnSettingsItems struct {

type BigNumber struct {
Type string `json:"type"`
Data interface{} `json:"data,omitempty"`
Data interface{} `json:"data,omitempty"`
Description string `json:"description,omitempty"`
Number string `json:"number,omitempty"`
}
Expand Down Expand Up @@ -586,14 +586,15 @@ func (n *Emphasis) GetChildren() []Node {
}

type Flourish struct {
Type string `json:"type"`
Data interface{} `json:"data,omitempty"`
Description string `json:"description,omitempty"`
FallbackImage *FlourishFallbackImage `json:"fallbackImage,omitempty"`
FlourishType string `json:"flourishType,omitempty"`
Id string `json:"id,omitempty"`
LayoutWidth string `json:"layoutWidth,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Type string `json:"type"`
Data interface{} `json:"data,omitempty"`
Description string `json:"description,omitempty"`
FallbackImage *FlourishFallbackImage `json:"fallbackImage,omitempty"`
FlourishType string `json:"flourishType,omitempty"`
Id string `json:"id,omitempty"`
LayoutWidth string `json:"layoutWidth,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
BlockIdentifier string `json:"blockIdentifier,omitempty"`
}

func (n *Flourish) GetType() string {
Expand Down Expand Up @@ -628,6 +629,7 @@ type Heading struct {
Children []*Text `json:"children,omitempty"`
Data interface{} `json:"data,omitempty"`
Level string `json:"level,omitempty"`
BlockIdentifier string `json:"blockIdentifier,omitempty"`
}

func (n *Heading) GetType() string {
Expand All @@ -647,10 +649,11 @@ func (n *Heading) GetChildren() []Node {
}

type ImageSet struct {
Type string `json:"type"`
Data interface{} `json:"data,omitempty"`
ID string `json:"id,omitempty"`
Picture *Picture `json:"picture,omitempty"`
Type string `json:"type"`
Data interface{} `json:"data,omitempty"`
ID string `json:"id,omitempty"`
Picture *Picture `json:"picture,omitempty"`
BlockIdentifier string `json:"blockIdentifier,omitempty"`
}

func (n *ImageSet) GetType() string {
Expand Down
12 changes: 12 additions & 0 deletions libraries/from-bodyxml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,44 @@ export let defaultTransformers = {
* @type {Transformer<ContentTree.transit.Heading>}
*/
h1(h1) {
const blockId = h1.attributes["data-fragment-id"] || h1.attributes["id"];
return {
type: "heading",
level: "chapter",
...(blockId && { blockIdentifier: blockId }),
};
},
/**
* @type {Transformer<ContentTree.transit.Heading>}
*/
h2(h2) {
const blockId = h2.attributes["data-fragment-id"] || h2.attributes["id"];
return {
type: "heading",
level: "subheading",
...(blockId && { blockIdentifier: blockId }),
};
},
/**
* @type {Transformer<ContentTree.transit.Heading>}
*/
h3(h3) {
const blockId = h3.attributes["data-fragment-id"] || h3.attributes["id"];
return {
type: "heading",
level: "subheading",
...(blockId && { blockIdentifier: blockId }),
};
},
/**
* @type {Transformer<ContentTree.transit.Heading>}
*/
h4(h4) {
const blockId = h4.attributes["data-fragment-id"] || h4.attributes["id"];
return {
type: "heading",
level: "label",
...(blockId && { blockIdentifier: blockId }),
};
},
/**
Expand Down Expand Up @@ -237,9 +245,11 @@ export let defaultTransformers = {
* @type {Transformer<ContentTree.transit.ImageSet>}
*/
[ContentType.imageset](content) {
const blockId = content.attributes["data-fragment-id"] || content.attributes["id"];
return {
type: "image-set",
id: content.attributes.url ?? "",
...(blockId && { blockIdentifier: blockId }),
children: null,
};
},
Expand All @@ -260,6 +270,7 @@ export let defaultTransformers = {
[ContentType.content](content) {
const id = content.attributes.url ?? "";
const uuid = id.split("/").pop();
const blockId = content.attributes["data-fragment-id"] || content.attributes["id"];

if (content.attributes["data-asset-type"] == "flourish") {
return /** @type {ContentTree.transit.Flourish} */ ({
Expand All @@ -271,6 +282,7 @@ export let defaultTransformers = {
),
description: content.attributes["alt"] || "",
timestamp: content.attributes["data-time-stamp"] || "",
...(blockId && { blockIdentifier: blockId }),
children: null,
});
}
Expand Down
9 changes: 9 additions & 0 deletions schemas/body-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
"ContentTree.transit.Flourish": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"data": {},
"description": {
"type": "string"
Expand Down Expand Up @@ -217,6 +220,9 @@
"ContentTree.transit.Heading": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"children": {
"items": {
"$ref": "#/definitions/ContentTree.transit.Text"
Expand Down Expand Up @@ -247,6 +253,9 @@
"ContentTree.transit.ImageSet": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"data": {},
"id": {
"type": "string"
Expand Down
9 changes: 9 additions & 0 deletions schemas/content-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@
"ContentTree.full.Flourish": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"data": {},
"description": {
"type": "string"
Expand Down Expand Up @@ -328,6 +331,9 @@
"ContentTree.full.Heading": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"children": {
"items": {
"$ref": "#/definitions/ContentTree.full.Text"
Expand Down Expand Up @@ -358,6 +364,9 @@
"ContentTree.full.ImageSet": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"data": {},
"id": {
"type": "string"
Expand Down
9 changes: 9 additions & 0 deletions schemas/transit-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@
"ContentTree.transit.Flourish": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"data": {},
"description": {
"type": "string"
Expand Down Expand Up @@ -242,6 +245,9 @@
"ContentTree.transit.Heading": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"children": {
"items": {
"$ref": "#/definitions/ContentTree.transit.Text"
Expand Down Expand Up @@ -272,6 +278,9 @@
"ContentTree.transit.ImageSet": {
"additionalProperties": false,
"properties": {
"blockIdentifier": {
"type": "string"
},
"data": {},
"id": {
"type": "string"
Expand Down
Loading