@code.store/arcxp-sdk-ts 4.35.0 → 4.37.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.
Files changed (47) hide show
  1. package/dist/api/content/types.d.ts +1 -0
  2. package/dist/content-elements/content-elements.d.ts +212 -0
  3. package/dist/content-elements/content-elements.js +202 -0
  4. package/dist/content-elements/content-elements.js.map +1 -0
  5. package/dist/content-elements/html/html.constants.d.ts +1 -0
  6. package/dist/content-elements/html/html.constants.js +40 -0
  7. package/dist/content-elements/html/html.constants.js.map +1 -0
  8. package/dist/content-elements/html/html.processor.d.ts +106 -0
  9. package/dist/content-elements/html/html.processor.js +359 -0
  10. package/dist/content-elements/html/html.processor.js.map +1 -0
  11. package/dist/content-elements/html/html.utils.d.ts +15 -0
  12. package/dist/content-elements/html/html.utils.js +69 -0
  13. package/dist/content-elements/html/html.utils.js.map +1 -0
  14. package/dist/content-elements/html/index.d.ts +3 -0
  15. package/dist/content-elements/html/index.js +31 -0
  16. package/dist/content-elements/html/index.js.map +1 -0
  17. package/dist/content-elements/index.d.ts +2 -213
  18. package/dist/content-elements/index.js +29 -199
  19. package/dist/content-elements/index.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +2 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/mapper/doc.d.ts +2 -2
  24. package/dist/tests/api/utils.test.js +7 -7
  25. package/dist/tests/api/utils.test.js.map +1 -1
  26. package/dist/tests/content-elements/html.processor.test.d.ts +1 -0
  27. package/dist/tests/content-elements/html.processor.test.js +35 -0
  28. package/dist/tests/content-elements/html.processor.test.js.map +1 -0
  29. package/dist/types/content-elements.d.ts +4 -0
  30. package/dist/types/content-elements.js +3 -0
  31. package/dist/types/content-elements.js.map +1 -0
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/index.js +2 -1
  34. package/dist/types/index.js.map +1 -1
  35. package/dist/utils/arc/content.d.ts +2 -1
  36. package/dist/utils/arc/content.js +3 -1
  37. package/dist/utils/arc/content.js.map +1 -1
  38. package/dist/utils/arc/id.d.ts +17 -0
  39. package/dist/utils/arc/id.js +40 -0
  40. package/dist/utils/arc/id.js.map +1 -0
  41. package/dist/utils/arc/index.d.ts +6 -7
  42. package/dist/utils/arc/index.js +6 -8
  43. package/dist/utils/arc/index.js.map +1 -1
  44. package/package.json +8 -4
  45. package/dist/utils/arc/generate-id.d.ts +0 -1
  46. package/dist/utils/arc/generate-id.js +0 -15
  47. package/dist/utils/arc/generate-id.js.map +0 -1
@@ -4,6 +4,7 @@ export type GetStoryParams = {
4
4
  _id: string;
5
5
  published: boolean;
6
6
  website: string;
7
+ website_url: string;
7
8
  included_fields?: string;
8
9
  };
9
10
  export type GetStoriesByIdsParams = {
@@ -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,mBAA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R,OAAO,EAAE,QAAQ;gBACjB,IAAI,EAAE,YAAY;aACnB;YACD,IAAI,EAAE,WAAoB;SAC3B,CAAC;IACJ,CAAC;IACD,KAAK,EAAE,CAAC,EAAU,EAAE,QAAQ,GAAG,wCAAwC,EAAE,EAAE;QACzE,OAAO;YACL,QAAQ,EAAE;gBACR,EAAE;gBACF,QAAQ;gBACR,OAAO,EAAE,QAAQ;gBACjB,IAAI,EAAE,OAAO;aACd;YACD,IAAI,EAAE,WAAoB;SAC3B,CAAC;IACJ,CAAC;IACD,SAAS,EAAE,CAAC,EAAU,EAAE,QAAQ,GAAG,uCAAuC,EAAE,EAAE;QAC5E,OAAO;YACL,QAAQ,EAAE;gBACR,EAAE;gBACF,QAAQ;gBACR,OAAO,EAAE,QAAQ;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
+ }