Skip to content

Commit cbdbb36

Browse files
committed
add HTMLProcessor and HTMLUtils
1 parent 27779a6 commit cbdbb36

32 files changed

+1145
-207
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @code.store/arcxp-sdk-ts
22

3+
## 4.36.0
4+
5+
### Minor Changes
6+
7+
- add HTMLProcessor and HTMLUtils
8+
39
## 4.35.0
410

511
### Minor Changes

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code.store/arcxp-sdk-ts",
3-
"version": "4.35.0",
3+
"version": "4.36.0",
44
"description": "A strongly typed set of ArcXP API's and utilities reduce the amount of work required to develop with ArcXP, starting with reducing the boilerplate code you have to write.",
55
"type": "commonjs",
66
"main": "./dist/index.js",
@@ -38,6 +38,8 @@
3838
"axios-rate-limit": "^1.3.0",
3939
"base32-encode": "^1.2.0",
4040
"form-data": "^4.0.0",
41+
"html-entities": "^2.5.2",
42+
"node-html-parser": "^7.0.1",
4143
"uuid": "^9.0.1",
4244
"ws": "^8.14.0"
4345
},

pnpm-lock.yaml

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/content/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type GetStoryParams = {
55
_id: string;
66
published: boolean;
77
website: string;
8+
website_url: string;
89
included_fields?: string;
910
};
1011

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
import type { CElement } from '../types/content-elements';
2+
import type { Alignment, AnImage } from '../types/story';
3+
4+
export const ContentElement = {
5+
divider: () => {
6+
return {
7+
type: 'divider' as const,
8+
};
9+
},
10+
text: (content: string, alignment: Alignment = 'left') => {
11+
return {
12+
type: 'text' as const,
13+
content,
14+
alignment,
15+
};
16+
},
17+
quote: (items: CElement[], citation = '', subtype: 'blockquote' | 'pullquote' = 'pullquote') => {
18+
return {
19+
type: 'quote' as const,
20+
subtype,
21+
citation: {
22+
type: 'text' as const,
23+
content: citation,
24+
},
25+
content_elements: items,
26+
};
27+
},
28+
interstitial_link: (url: string, content: string) => {
29+
return {
30+
type: 'interstitial_link' as const,
31+
url,
32+
content,
33+
};
34+
},
35+
header: (content: string, level: number) => {
36+
return {
37+
type: 'header' as const,
38+
content,
39+
level,
40+
};
41+
},
42+
raw_html: (content: string) => {
43+
return {
44+
type: 'raw_html' as const,
45+
content,
46+
};
47+
},
48+
gallery: (id: string) => {
49+
return {
50+
type: 'reference' as const,
51+
referent: {
52+
type: 'gallery' as const,
53+
id,
54+
},
55+
};
56+
},
57+
list: (type: 'ordered' | 'unordered', items: CElement[]) => {
58+
return {
59+
type: 'list' as const,
60+
list_type: type,
61+
items,
62+
};
63+
},
64+
link_list: (title: string, links: { content: string; url: string }[]) => {
65+
return {
66+
type: 'link_list' as const,
67+
title,
68+
items: links.map(({ content, url }) => {
69+
return {
70+
type: 'interstitial_link' as const,
71+
content,
72+
url,
73+
};
74+
}),
75+
};
76+
},
77+
image: (id: string, properties?: AnImage) => {
78+
return {
79+
referent: {
80+
id,
81+
type: 'image' as const,
82+
referent_properties: {
83+
_id: id,
84+
type: 'image' as const,
85+
...properties,
86+
},
87+
},
88+
type: 'reference' as const,
89+
};
90+
},
91+
jwPlayer: (id: string) => {
92+
return {
93+
embed: {
94+
config: {},
95+
id,
96+
url: 'https://cdn.jwplayer.com/players',
97+
},
98+
subtype: 'jw_player' as const,
99+
type: 'custom_embed' as const,
100+
};
101+
},
102+
twitter: (id: string, provider = 'https://publish.twitter.com/oembed?url=') => {
103+
return {
104+
referent: {
105+
id,
106+
provider,
107+
service: 'oembed' as const,
108+
type: 'twitter' as const,
109+
},
110+
type: 'reference' as const,
111+
};
112+
},
113+
youtube: (id: string, provider = 'https://www.youtube.com/oembed?url=') => {
114+
return {
115+
referent: {
116+
id,
117+
provider,
118+
service: 'oembed',
119+
type: 'youtube',
120+
},
121+
type: 'reference' as const,
122+
};
123+
},
124+
facebook_video: (id: string, provider = 'https://www.facebook.com/plugins/post/oembed.json/?url=') => {
125+
return {
126+
referent: {
127+
id,
128+
provider,
129+
service: 'oembed',
130+
type: 'facebook-video',
131+
},
132+
type: 'reference' as const,
133+
};
134+
},
135+
facebook_post: (id: string, provider = 'https://www.facebook.com/plugins/post/oembed.json/?url=') => {
136+
return {
137+
referent: {
138+
id,
139+
provider,
140+
service: 'oembed',
141+
type: 'facebook-post',
142+
},
143+
type: 'reference' as const,
144+
};
145+
},
146+
soundcloud: (id: string, provider = 'https://soundcloud.com/oembed.json/?url=') => {
147+
return {
148+
referent: {
149+
id,
150+
provider,
151+
service: 'oembed',
152+
type: 'soundcloud',
153+
},
154+
type: 'reference' as const,
155+
};
156+
},
157+
vimeo: (id: string, provider = 'https://vimeo.com/api/oembed.json?url=') => {
158+
return {
159+
referent: {
160+
id,
161+
provider,
162+
service: 'oembed',
163+
type: 'vimeo',
164+
},
165+
type: 'reference' as const,
166+
};
167+
},
168+
instagram: (id: string, provider = 'https://api.instagram.com/oembed?url=') => {
169+
return {
170+
referent: {
171+
id,
172+
provider,
173+
service: 'oembed',
174+
type: 'instagram',
175+
},
176+
type: 'reference' as const,
177+
};
178+
},
179+
dailymotion: (id: string, provider = 'https://www.dailymotion.com/services/oembed?url=') => {
180+
return {
181+
referent: {
182+
id,
183+
provider,
184+
service: 'oembed',
185+
type: 'dailymotion',
186+
},
187+
type: 'reference' as const,
188+
};
189+
},
190+
tiktok: (id: string, provider = 'https://www.tiktok.com/oembed?url=') => {
191+
return {
192+
referent: {
193+
id,
194+
provider,
195+
service: 'oembed',
196+
type: 'tiktok',
197+
},
198+
type: 'reference' as const,
199+
};
200+
},
201+
};

0 commit comments

Comments
 (0)