@code.store/arcxp-sdk-ts 4.34.1 → 4.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/content/types.d.ts +1 -0
- package/dist/api/draft/index.d.ts +2 -1
- package/dist/api/draft/index.js +4 -0
- package/dist/api/draft/index.js.map +1 -1
- package/dist/api/draft/types.d.ts +5 -0
- package/dist/content-elements/content-elements.d.ts +212 -0
- package/dist/content-elements/content-elements.js +202 -0
- package/dist/content-elements/content-elements.js.map +1 -0
- package/dist/content-elements/html/html.constants.d.ts +1 -0
- package/dist/content-elements/html/html.constants.js +40 -0
- package/dist/content-elements/html/html.constants.js.map +1 -0
- package/dist/content-elements/html/html.processor.d.ts +106 -0
- package/dist/content-elements/html/html.processor.js +359 -0
- package/dist/content-elements/html/html.processor.js.map +1 -0
- package/dist/content-elements/html/html.utils.d.ts +15 -0
- package/dist/content-elements/html/html.utils.js +69 -0
- package/dist/content-elements/html/html.utils.js.map +1 -0
- package/dist/content-elements/html/index.d.ts +3 -0
- package/dist/content-elements/html/index.js +31 -0
- package/dist/content-elements/html/index.js.map +1 -0
- package/dist/content-elements/index.d.ts +2 -213
- package/dist/content-elements/index.js +29 -199
- package/dist/content-elements/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/mapper/doc.d.ts +2 -2
- package/dist/tests/content-elements/html.processor.test.d.ts +1 -0
- package/dist/tests/content-elements/html.processor.test.js +35 -0
- package/dist/tests/content-elements/html.processor.test.js.map +1 -0
- package/dist/types/content-elements.d.ts +4 -0
- package/dist/types/content-elements.js +3 -0
- package/dist/types/content-elements.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/arc/content.d.ts +2 -1
- package/dist/utils/arc/content.js +3 -1
- package/dist/utils/arc/content.js.map +1 -1
- package/package.json +10 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api';
|
|
2
|
-
import type { CreateDocumentRedirectPayload, CreateExternalRedirectPayload, CreateRedirectPayload, Document, DocumentRedirect, ExternalRedirect, Revision, UpdateDraftRevisionPayload } from './types';
|
|
2
|
+
import type { Circulations, CreateDocumentRedirectPayload, CreateExternalRedirectPayload, CreateRedirectPayload, Document, DocumentRedirect, ExternalRedirect, Revision, UpdateDraftRevisionPayload } from './types';
|
|
3
3
|
export declare class ArcDraft extends ArcAbstractAPI {
|
|
4
4
|
constructor(options: ArcAPIOptions);
|
|
5
5
|
generateId(id: string): Promise<string>;
|
|
@@ -8,6 +8,7 @@ export declare class ArcDraft extends ArcAbstractAPI {
|
|
|
8
8
|
deleteDocument(id: string, type?: string): Promise<Document>;
|
|
9
9
|
getPublishedRevision(id: string, type?: string): Promise<Revision>;
|
|
10
10
|
getDraftRevision(id: string, type?: string): Promise<Revision>;
|
|
11
|
+
getCirculations(id: string, type?: string, after?: string): Promise<Circulations>;
|
|
11
12
|
createRedirect<P extends CreateRedirectPayload, R = P extends CreateExternalRedirectPayload ? ExternalRedirect : P extends CreateDocumentRedirectPayload ? DocumentRedirect : never>(website: string, websiteUrl: string, payload: P): Promise<R>;
|
|
12
13
|
getRedirect(website: string, websiteUrl: string): Promise<DocumentRedirect | ExternalRedirect>;
|
|
13
14
|
updateDraftRevision(id: string, payload: UpdateDraftRevisionPayload, type?: string): Promise<Revision>;
|
package/dist/api/draft/index.js
CHANGED
|
@@ -30,6 +30,10 @@ class ArcDraft extends abstract_api_1.ArcAbstractAPI {
|
|
|
30
30
|
const { data } = await this.client.get(`/${type}/${id}/revision/draft`);
|
|
31
31
|
return data;
|
|
32
32
|
}
|
|
33
|
+
async getCirculations(id, type = 'story', after) {
|
|
34
|
+
const { data } = await this.client.get(`/${type}/${id}/circulation`, { params: { after } });
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
33
37
|
async createRedirect(website, websiteUrl, payload) {
|
|
34
38
|
const { data } = await this.client.post(`/redirect/${website}/${websiteUrl}`, payload);
|
|
35
39
|
return data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/draft/index.ts"],"names":[],"mappings":";;;AAAA,kDAAqE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/draft/index.ts"],"names":[],"mappings":";;;AAAA,kDAAqE;AAarE,MAAa,QAAS,SAAQ,6BAAc;IAC1C,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAiB,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACvF,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,EAAU,EAAE,IAAI,GAAG,OAAO;QAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAW,IAAI,IAAI,IAAI,EAAE,qBAAqB,CAAC,CAAC;QACvF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,EAAU,EAAE,IAAI,GAAG,OAAO;QAChD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAW,IAAI,IAAI,IAAI,EAAE,qBAAqB,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAU,EAAE,IAAI,GAAG,OAAO;QAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM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AAC;IACd,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,EAAU,EAAE,OAAmC,EAAE,IAAI,GAAG,OAAO;QACvF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAW,IAAI,IAAI,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAC3F,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7DD,4BA6DC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AStory } from '../../types/story';
|
|
2
|
+
import type { CirculationReference } from '../migration-center/types';
|
|
2
3
|
export type CreateExternalRedirectPayload = {
|
|
3
4
|
redirect_to: string;
|
|
4
5
|
document_id?: undefined;
|
|
@@ -44,4 +45,8 @@ export type UpdateDraftRevisionPayload = {
|
|
|
44
45
|
ans: AStory;
|
|
45
46
|
type: 'DRAFT';
|
|
46
47
|
};
|
|
48
|
+
export type Circulations = {
|
|
49
|
+
circulations: CirculationReference[];
|
|
50
|
+
last?: string;
|
|
51
|
+
};
|
|
47
52
|
export {};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { CElement } from '../types/content-elements';
|
|
2
|
+
import type { Alignment, AnImage } from '../types/story';
|
|
3
|
+
export declare const ContentElement: {
|
|
4
|
+
divider: () => {
|
|
5
|
+
type: "divider";
|
|
6
|
+
};
|
|
7
|
+
text: (content: string, alignment?: Alignment) => {
|
|
8
|
+
type: "text";
|
|
9
|
+
content: string;
|
|
10
|
+
alignment: Alignment;
|
|
11
|
+
};
|
|
12
|
+
quote: (items: CElement[], citation?: string, subtype?: 'blockquote' | 'pullquote') => {
|
|
13
|
+
type: "quote";
|
|
14
|
+
subtype: "blockquote" | "pullquote";
|
|
15
|
+
citation: {
|
|
16
|
+
type: "text";
|
|
17
|
+
content: string;
|
|
18
|
+
};
|
|
19
|
+
content_elements: import("../types/story").AnElementThatCanBeListedAsPartOfContentElements[];
|
|
20
|
+
};
|
|
21
|
+
interstitial_link: (url: string, content: string) => {
|
|
22
|
+
type: "interstitial_link";
|
|
23
|
+
url: string;
|
|
24
|
+
content: string;
|
|
25
|
+
};
|
|
26
|
+
header: (content: string, level: number) => {
|
|
27
|
+
type: "header";
|
|
28
|
+
content: string;
|
|
29
|
+
level: number;
|
|
30
|
+
};
|
|
31
|
+
raw_html: (content: string) => {
|
|
32
|
+
type: "raw_html";
|
|
33
|
+
content: string;
|
|
34
|
+
};
|
|
35
|
+
gallery: (id: string) => {
|
|
36
|
+
type: "reference";
|
|
37
|
+
referent: {
|
|
38
|
+
type: "gallery";
|
|
39
|
+
id: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
list: (type: 'ordered' | 'unordered', items: CElement[]) => {
|
|
43
|
+
type: "list";
|
|
44
|
+
list_type: "ordered" | "unordered";
|
|
45
|
+
items: import("../types/story").AnElementThatCanBeListedAsPartOfContentElements[];
|
|
46
|
+
};
|
|
47
|
+
link_list: (title: string, links: {
|
|
48
|
+
content: string;
|
|
49
|
+
url: string;
|
|
50
|
+
}[]) => {
|
|
51
|
+
type: "link_list";
|
|
52
|
+
title: string;
|
|
53
|
+
items: {
|
|
54
|
+
type: "interstitial_link";
|
|
55
|
+
content: string;
|
|
56
|
+
url: string;
|
|
57
|
+
}[];
|
|
58
|
+
};
|
|
59
|
+
image: (id: string, properties?: AnImage) => {
|
|
60
|
+
referent: {
|
|
61
|
+
id: string;
|
|
62
|
+
type: "image";
|
|
63
|
+
referent_properties: {
|
|
64
|
+
type: "image";
|
|
65
|
+
_id: string;
|
|
66
|
+
version?: "0.10.10" | undefined;
|
|
67
|
+
subtype?: string | undefined;
|
|
68
|
+
channels?: import("../types/story").ChannelTrait | undefined;
|
|
69
|
+
alignment?: Alignment | undefined;
|
|
70
|
+
language?: string | undefined;
|
|
71
|
+
copyright?: string | undefined;
|
|
72
|
+
canonical_url?: string | undefined;
|
|
73
|
+
short_url?: string | undefined;
|
|
74
|
+
created_date?: string | undefined;
|
|
75
|
+
last_updated_date?: string | undefined;
|
|
76
|
+
publish_date?: string | undefined;
|
|
77
|
+
first_publish_date?: string | undefined;
|
|
78
|
+
display_date?: string | undefined;
|
|
79
|
+
location?: string | undefined;
|
|
80
|
+
geo?: import("../types/story").Geo | undefined;
|
|
81
|
+
address?: import("../types/story").Address | undefined;
|
|
82
|
+
editor_note?: string | undefined;
|
|
83
|
+
status?: string | undefined;
|
|
84
|
+
headlines?: import("../types/story").Headlines | undefined;
|
|
85
|
+
subheadlines?: import("../types/story").SubHeadlines | undefined;
|
|
86
|
+
description?: import("../types/story").Description | undefined;
|
|
87
|
+
credits?: import("../types/story").CreditTrait | undefined;
|
|
88
|
+
vanity_credits?: import("../types/story").VanityCreditsTrait | undefined;
|
|
89
|
+
taxonomy?: import("../types/story").Taxonomy | undefined;
|
|
90
|
+
promo_items?: import("../types/story").PromoItems | undefined;
|
|
91
|
+
related_content?: import("../types/story").Related_Content | undefined;
|
|
92
|
+
owner?: import("../types/story").OwnerInformation | undefined;
|
|
93
|
+
planning?: import("../types/story").SchedulingInformation | undefined;
|
|
94
|
+
workflow?: import("../types/story").WorkflowInformation | undefined;
|
|
95
|
+
pitches?: import("../types/story").Pitches | undefined;
|
|
96
|
+
revision?: import("../types/story").Revision | undefined;
|
|
97
|
+
syndication?: import("../types/story").Syndication | undefined;
|
|
98
|
+
source?: import("../types/story").Source | undefined;
|
|
99
|
+
distributor?: import("../types/story").Distributor | undefined;
|
|
100
|
+
tracking?: import("../types/story").Tracking | undefined;
|
|
101
|
+
comments?: import("../types/story").Comments | undefined;
|
|
102
|
+
label?: import("../types/story").Label | undefined;
|
|
103
|
+
slug?: string | undefined;
|
|
104
|
+
content_restrictions?: import("../types/story").ContentRestrictions | undefined;
|
|
105
|
+
image_type?: string | undefined;
|
|
106
|
+
alt_text?: string | undefined;
|
|
107
|
+
focal_point?: import("../types/story").FocalPoint | undefined;
|
|
108
|
+
auth?: import("../types/story").Auth | undefined;
|
|
109
|
+
seo_filename?: string | undefined;
|
|
110
|
+
additional_properties?: import("../types/story").HasAdditionalProperties | undefined;
|
|
111
|
+
subtitle?: string | undefined;
|
|
112
|
+
caption?: string | undefined;
|
|
113
|
+
url?: string | undefined;
|
|
114
|
+
width?: number | undefined;
|
|
115
|
+
height?: number | undefined;
|
|
116
|
+
licensable?: boolean | undefined;
|
|
117
|
+
contributors?: import("../types/story").Contributors | undefined;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
type: "reference";
|
|
121
|
+
};
|
|
122
|
+
jwPlayer: (id: string) => {
|
|
123
|
+
embed: {
|
|
124
|
+
config: {};
|
|
125
|
+
id: string;
|
|
126
|
+
url: string;
|
|
127
|
+
};
|
|
128
|
+
subtype: "jw_player";
|
|
129
|
+
type: "custom_embed";
|
|
130
|
+
};
|
|
131
|
+
twitter: (id: string, provider?: string) => {
|
|
132
|
+
referent: {
|
|
133
|
+
id: string;
|
|
134
|
+
provider: string;
|
|
135
|
+
service: "oembed";
|
|
136
|
+
type: "twitter";
|
|
137
|
+
};
|
|
138
|
+
type: "reference";
|
|
139
|
+
};
|
|
140
|
+
youtube: (id: string, provider?: string) => {
|
|
141
|
+
referent: {
|
|
142
|
+
id: string;
|
|
143
|
+
provider: string;
|
|
144
|
+
service: string;
|
|
145
|
+
type: string;
|
|
146
|
+
};
|
|
147
|
+
type: "reference";
|
|
148
|
+
};
|
|
149
|
+
facebook_video: (id: string, provider?: string) => {
|
|
150
|
+
referent: {
|
|
151
|
+
id: string;
|
|
152
|
+
provider: string;
|
|
153
|
+
service: string;
|
|
154
|
+
type: string;
|
|
155
|
+
};
|
|
156
|
+
type: "reference";
|
|
157
|
+
};
|
|
158
|
+
facebook_post: (id: string, provider?: string) => {
|
|
159
|
+
referent: {
|
|
160
|
+
id: string;
|
|
161
|
+
provider: string;
|
|
162
|
+
service: string;
|
|
163
|
+
type: string;
|
|
164
|
+
};
|
|
165
|
+
type: "reference";
|
|
166
|
+
};
|
|
167
|
+
soundcloud: (id: string, provider?: string) => {
|
|
168
|
+
referent: {
|
|
169
|
+
id: string;
|
|
170
|
+
provider: string;
|
|
171
|
+
service: string;
|
|
172
|
+
type: string;
|
|
173
|
+
};
|
|
174
|
+
type: "reference";
|
|
175
|
+
};
|
|
176
|
+
vimeo: (id: string, provider?: string) => {
|
|
177
|
+
referent: {
|
|
178
|
+
id: string;
|
|
179
|
+
provider: string;
|
|
180
|
+
service: string;
|
|
181
|
+
type: string;
|
|
182
|
+
};
|
|
183
|
+
type: "reference";
|
|
184
|
+
};
|
|
185
|
+
instagram: (id: string, provider?: string) => {
|
|
186
|
+
referent: {
|
|
187
|
+
id: string;
|
|
188
|
+
provider: string;
|
|
189
|
+
service: string;
|
|
190
|
+
type: string;
|
|
191
|
+
};
|
|
192
|
+
type: "reference";
|
|
193
|
+
};
|
|
194
|
+
dailymotion: (id: string, provider?: string) => {
|
|
195
|
+
referent: {
|
|
196
|
+
id: string;
|
|
197
|
+
provider: string;
|
|
198
|
+
service: string;
|
|
199
|
+
type: string;
|
|
200
|
+
};
|
|
201
|
+
type: "reference";
|
|
202
|
+
};
|
|
203
|
+
tiktok: (id: string, provider?: string) => {
|
|
204
|
+
referent: {
|
|
205
|
+
id: string;
|
|
206
|
+
provider: string;
|
|
207
|
+
service: string;
|
|
208
|
+
type: string;
|
|
209
|
+
};
|
|
210
|
+
type: "reference";
|
|
211
|
+
};
|
|
212
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentElement = void 0;
|
|
4
|
+
exports.ContentElement = {
|
|
5
|
+
divider: () => {
|
|
6
|
+
return {
|
|
7
|
+
type: 'divider',
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
text: (content, alignment = 'left') => {
|
|
11
|
+
return {
|
|
12
|
+
type: 'text',
|
|
13
|
+
content,
|
|
14
|
+
alignment,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
quote: (items, citation = '', subtype = 'pullquote') => {
|
|
18
|
+
return {
|
|
19
|
+
type: 'quote',
|
|
20
|
+
subtype,
|
|
21
|
+
citation: {
|
|
22
|
+
type: 'text',
|
|
23
|
+
content: citation,
|
|
24
|
+
},
|
|
25
|
+
content_elements: items,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
interstitial_link: (url, content) => {
|
|
29
|
+
return {
|
|
30
|
+
type: 'interstitial_link',
|
|
31
|
+
url,
|
|
32
|
+
content,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
header: (content, level) => {
|
|
36
|
+
return {
|
|
37
|
+
type: 'header',
|
|
38
|
+
content,
|
|
39
|
+
level,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
raw_html: (content) => {
|
|
43
|
+
return {
|
|
44
|
+
type: 'raw_html',
|
|
45
|
+
content,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
gallery: (id) => {
|
|
49
|
+
return {
|
|
50
|
+
type: 'reference',
|
|
51
|
+
referent: {
|
|
52
|
+
type: 'gallery',
|
|
53
|
+
id,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
list: (type, items) => {
|
|
58
|
+
return {
|
|
59
|
+
type: 'list',
|
|
60
|
+
list_type: type,
|
|
61
|
+
items,
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
link_list: (title, links) => {
|
|
65
|
+
return {
|
|
66
|
+
type: 'link_list',
|
|
67
|
+
title,
|
|
68
|
+
items: links.map(({ content, url }) => {
|
|
69
|
+
return {
|
|
70
|
+
type: 'interstitial_link',
|
|
71
|
+
content,
|
|
72
|
+
url,
|
|
73
|
+
};
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
image: (id, properties) => {
|
|
78
|
+
return {
|
|
79
|
+
referent: {
|
|
80
|
+
id,
|
|
81
|
+
type: 'image',
|
|
82
|
+
referent_properties: {
|
|
83
|
+
_id: id,
|
|
84
|
+
type: 'image',
|
|
85
|
+
...properties,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
type: 'reference',
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
jwPlayer: (id) => {
|
|
92
|
+
return {
|
|
93
|
+
embed: {
|
|
94
|
+
config: {},
|
|
95
|
+
id,
|
|
96
|
+
url: 'https://cdn.jwplayer.com/players',
|
|
97
|
+
},
|
|
98
|
+
subtype: 'jw_player',
|
|
99
|
+
type: 'custom_embed',
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
twitter: (id, provider = 'https://publish.twitter.com/oembed?url=') => {
|
|
103
|
+
return {
|
|
104
|
+
referent: {
|
|
105
|
+
id,
|
|
106
|
+
provider,
|
|
107
|
+
service: 'oembed',
|
|
108
|
+
type: 'twitter',
|
|
109
|
+
},
|
|
110
|
+
type: 'reference',
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
youtube: (id, 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',
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
facebook_video: (id, 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',
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
facebook_post: (id, 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',
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
soundcloud: (id, 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',
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
vimeo: (id, 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',
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
instagram: (id, 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',
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
dailymotion: (id, 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',
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
tiktok: (id, 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',
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
//# sourceMappingURL=content-elements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-elements.js","sourceRoot":"","sources":["../../src/content-elements/content-elements.ts"],"names":[],"mappings":";;;AAGa,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,GAAG,EAAE;QACZ,OAAO;YACL,IAAI,EAAE,SAAkB;SACzB,CAAC;IACJ,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,YAAuB,MAAM,EAAE,EAAE;QACvD,OAAO;YACL,IAAI,EAAE,MAAe;YACrB,OAAO;YACP,SAAS;SACV,CAAC;IACJ,CAAC;IACD,KAAK,EAAE,CAAC,KAAiB,EAAE,QAAQ,GAAG,EAAE,EAAE,UAAsC,WAAW,EAAE,EAAE;QAC7F,OAAO;YACL,IAAI,EAAE,OAAgB;YACtB,OAAO;YACP,QAAQ,EAAE;gBACR,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE,QAAQ;aAClB;YACD,gBAAgB,EAAE,KAAK;SACxB,CAAC;IACJ,CAAC;IACD,iBAAiB,EAAE,CAAC,GAAW,EAAE,OAAe,EAAE,EAAE;QAClD,OAAO;YACL,IAAI,EAAE,mBAA4B;YAClC,GAAG;YACH,OAAO;SACR,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,CAAC,OAAe,EAAE,KAAa,EAAE,EAAE;QACzC,OAAO;YACL,IAAI,EAAE,QAAiB;YACvB,OAAO;YACP,KAAK;SACN,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,CAAC,OAAe,EAAE,EAAE;QAC5B,OAAO;YACL,IAAI,EAAE,UAAmB;YACzB,OAAO;SACR,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC,EAAU,EAAE,EAAE;QACtB,OAAO;YACL,IAAI,EAAE,WAAoB;YAC1B,QAAQ,EAAE;gBACR,IAAI,EAAE,SAAkB;gBACxB,EAAE;aACH;SACF,CAAC;IACJ,CAAC;IACD,IAAI,EAAE,C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;gBACjB,IAAI,EAAE,WAAW;aAClB;YACD,IAAI,EAAE,WAAoB;SAC3B,CAAC;IACJ,CAAC;IACD,WAAW,EAAE,CAAC,EAAU,EAAE,QAAQ,GAAG,kDAAkD,EAAE,EAAE;QACzF,OAAO;YACL,QAAQ,EAAE;gBACR,EAAE;gBACF,QAAQ;gBACR,OAAO,EAAE,QAAQ;gBACjB,IAAI,EAAE,aAAa;aACpB;YACD,IAAI,EAAE,WAAoB;SAC3B,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,CAAC,EAAU,EAAE,QAAQ,GAAG,oCAAoC,EAAE,EAAE;QACtE,OAAO;YACL,QAAQ,EAAE;gBACR,EAAE;gBACF,QAAQ;gBACR,OAAO,EAAE,QAAQ;gBACjB,IAAI,EAAE,QAAQ;aACf;YACD,IAAI,EAAE,WAAoB;SAC3B,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BLOCK_ELEMENT_TAGS: string[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BLOCK_ELEMENT_TAGS = void 0;
|
|
4
|
+
exports.BLOCK_ELEMENT_TAGS = [
|
|
5
|
+
'ADDRESS',
|
|
6
|
+
'ARTICLE',
|
|
7
|
+
'ASIDE',
|
|
8
|
+
'BLOCKQUOTE',
|
|
9
|
+
'DETAILS',
|
|
10
|
+
'DIV',
|
|
11
|
+
'DL',
|
|
12
|
+
'FIELDSET',
|
|
13
|
+
'FIGCAPTION',
|
|
14
|
+
'FIGURE',
|
|
15
|
+
'FOOTER',
|
|
16
|
+
'FORM',
|
|
17
|
+
'H1',
|
|
18
|
+
'H2',
|
|
19
|
+
'H3',
|
|
20
|
+
'H4',
|
|
21
|
+
'H5',
|
|
22
|
+
'H6',
|
|
23
|
+
'HEADER',
|
|
24
|
+
'HR',
|
|
25
|
+
'LINE',
|
|
26
|
+
'MAIN',
|
|
27
|
+
'MENU',
|
|
28
|
+
'NAV',
|
|
29
|
+
'OL',
|
|
30
|
+
'P',
|
|
31
|
+
'PARAGRAPH',
|
|
32
|
+
'PRE',
|
|
33
|
+
'SECTION',
|
|
34
|
+
'TABLE',
|
|
35
|
+
'UL',
|
|
36
|
+
'LI',
|
|
37
|
+
'BODY',
|
|
38
|
+
'HTML',
|
|
39
|
+
];
|
|
40
|
+
//# sourceMappingURL=html.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.constants.js","sourceRoot":"","sources":["../../../src/content-elements/html/html.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAChC,SAAS;IACT,SAAS;IACT,OAAO;IACP,YAAY;IACZ,SAAS;IACT,KAAK;IACL,IAAI;IACJ,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,IAAI;IACJ,GAAG;IACH,WAAW;IACX,KAAK;IACL,SAAS;IACT,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,MAAM;CACP,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type CommentNode, type HTMLElement, type Node } from 'node-html-parser';
|
|
2
|
+
import type { CElement, ContentElementType } from '../../types/content-elements';
|
|
3
|
+
import type { MaybePromise } from '../../types/utils';
|
|
4
|
+
export type NodeHandler = (node: Node) => MaybePromise<CElement[] | undefined>;
|
|
5
|
+
export type WrapHandler = (node: Node, content: ContentElementType<'text'>) => ContentElementType<'text'> | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* HTMLProcessor is responsible for parsing HTML content into structured content elements.
|
|
8
|
+
* It provides a flexible way to handle different HTML nodes and wrap text content.
|
|
9
|
+
*
|
|
10
|
+
* The processor can be extended with custom handlers for specific node types and
|
|
11
|
+
* wrappers for text content.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Create and initialize processor
|
|
16
|
+
* const processor = new HTMLProcessor();
|
|
17
|
+
* processor.init();
|
|
18
|
+
*
|
|
19
|
+
* // Parse HTML content
|
|
20
|
+
* const html = '<div><p>Some text</p><img src="image.jpg"></div>';
|
|
21
|
+
* const elements = await processor.parse(html);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* The processor comes with built-in handlers for common HTML elements like links,
|
|
25
|
+
* text formatting (i, u, strong), and block elements. Custom handlers can be added
|
|
26
|
+
* using the `handle()` and `wrap()` methods.
|
|
27
|
+
*/
|
|
28
|
+
export declare class HTMLProcessor {
|
|
29
|
+
protected handlers: {
|
|
30
|
+
node: Map<string, NodeHandler>;
|
|
31
|
+
wrap: Map<string, WrapHandler>;
|
|
32
|
+
};
|
|
33
|
+
init(): void;
|
|
34
|
+
protected handle(name: string, handler: NodeHandler): void;
|
|
35
|
+
protected wrap(name: string, handler: WrapHandler): void;
|
|
36
|
+
parse(html: string): Promise<import("../../types/story").AnElementThatCanBeListedAsPartOfContentElements[]>;
|
|
37
|
+
protected addTextAdditionalProperties(c: ContentElementType<any>, parent: Node): any;
|
|
38
|
+
/**
|
|
39
|
+
* Wraps text content elements with additional properties and handlers.
|
|
40
|
+
* This method iterates through an array of content elements and applies
|
|
41
|
+
* wrappers to text elements.
|
|
42
|
+
*
|
|
43
|
+
* @param node - The HTML node containing the text elements
|
|
44
|
+
**/
|
|
45
|
+
protected wrapChildrenTextNodes(node: Node, elements: CElement[]): import("../../types/story").AnElementThatCanBeListedAsPartOfContentElements[];
|
|
46
|
+
/**
|
|
47
|
+
* Handles nested nodes by processing their children and merging text elements.
|
|
48
|
+
* This method recursively processes the children of a given HTML node and
|
|
49
|
+
* returns a list of content elements.
|
|
50
|
+
*
|
|
51
|
+
* @param node - The HTML node to process
|
|
52
|
+
**/
|
|
53
|
+
protected handleNested(node: Node): Promise<import("../../types/story").AnElementThatCanBeListedAsPartOfContentElements[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Processes a single HTML node and converts it into content elements.
|
|
56
|
+
* This method iterates through registered node handlers and attempts to process the node.
|
|
57
|
+
* If a handler successfully processes the node, it returns an array of content elements.
|
|
58
|
+
*
|
|
59
|
+
* @param node - The HTML node to process
|
|
60
|
+
* @returns Promise resolving to an array of content elements, or undefined if node cannot be processed
|
|
61
|
+
*/
|
|
62
|
+
protected process(node: Node): Promise<import("../../types/story").AnElementThatCanBeListedAsPartOfContentElements[] | undefined>;
|
|
63
|
+
/**
|
|
64
|
+
* Merges adjacent text content elements into a single paragraph.
|
|
65
|
+
* This method iterates through an array of content elements and combines
|
|
66
|
+
* adjacent text elements into a single paragraph.
|
|
67
|
+
*
|
|
68
|
+
* @param items - The array of content elements to merge
|
|
69
|
+
**/
|
|
70
|
+
private mergeParagraphs;
|
|
71
|
+
protected handleComment(_: CommentNode): MaybePromise<CElement[]>;
|
|
72
|
+
protected handleTable(node: Node): Promise<{
|
|
73
|
+
type: "raw_html";
|
|
74
|
+
content: string;
|
|
75
|
+
}[]>;
|
|
76
|
+
protected handleIframe(node: Node): Promise<{
|
|
77
|
+
type: "raw_html";
|
|
78
|
+
content: string;
|
|
79
|
+
}[]>;
|
|
80
|
+
protected handleImage(node: Node): Promise<{
|
|
81
|
+
type: "raw_html";
|
|
82
|
+
content: string;
|
|
83
|
+
}[]>;
|
|
84
|
+
protected handleBreak(_: Node): Promise<{
|
|
85
|
+
type: "divider";
|
|
86
|
+
}[]>;
|
|
87
|
+
protected createQuote(node: Node): Promise<{
|
|
88
|
+
type: "quote";
|
|
89
|
+
subtype: "blockquote" | "pullquote";
|
|
90
|
+
citation: {
|
|
91
|
+
type: "text";
|
|
92
|
+
content: string;
|
|
93
|
+
};
|
|
94
|
+
content_elements: import("../../types/story").AnElementThatCanBeListedAsPartOfContentElements[];
|
|
95
|
+
}[]>;
|
|
96
|
+
protected createText(node: Node): Promise<CElement[]>;
|
|
97
|
+
protected filterListItems(items: ContentElementType<any>[]): any[];
|
|
98
|
+
protected createList(node: Node, type: 'ordered' | 'unordered'): Promise<ContentElementType<any>[]>;
|
|
99
|
+
protected createHeader(node: HTMLElement): Promise<{
|
|
100
|
+
type: "header";
|
|
101
|
+
content: string;
|
|
102
|
+
level: number;
|
|
103
|
+
}[]>;
|
|
104
|
+
protected isBlockElement(node: Node): boolean;
|
|
105
|
+
protected warn(metadata: Record<string, any>, message: string): void;
|
|
106
|
+
}
|