@ethlete/contentful 0.1.0-next.2 → 0.1.0-next.3
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/esm2020/lib/components/audio/contentful-audio.component.mjs +12 -5
- package/esm2020/lib/components/file/contentful-file.component.mjs +12 -5
- package/esm2020/lib/components/image/contentful-image.component.mjs +12 -5
- package/esm2020/lib/components/rich-text-renderer/index.mjs +2 -0
- package/esm2020/lib/components/rich-text-renderer/public-api.mjs +3 -2
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.component.mjs +15 -9
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.constants.mjs +3 -0
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.types.mjs +1 -1
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.util.mjs +43 -15
- package/esm2020/lib/components/video/contentful-video.component.mjs +12 -5
- package/esm2020/lib/contentful.module.mjs +4 -4
- package/esm2020/lib/types/contentful.types.mjs +1 -1
- package/fesm2015/ethlete-contentful.mjs +173 -112
- package/fesm2015/ethlete-contentful.mjs.map +1 -1
- package/fesm2020/ethlete-contentful.mjs +170 -111
- package/fesm2020/ethlete-contentful.mjs.map +1 -1
- package/lib/components/audio/contentful-audio.component.d.ts +4 -1
- package/lib/components/file/contentful-file.component.d.ts +4 -1
- package/lib/components/image/contentful-image.component.d.ts +4 -1
- package/lib/components/rich-text-renderer/index.d.ts +1 -0
- package/lib/components/rich-text-renderer/public-api.d.ts +2 -1
- package/lib/components/rich-text-renderer/rich-text-renderer.constants.d.ts +2 -0
- package/lib/components/rich-text-renderer/rich-text-renderer.types.d.ts +6 -0
- package/lib/components/rich-text-renderer/rich-text-renderer.util.d.ts +5 -3
- package/lib/components/video/contentful-video.component.d.ts +4 -1
- package/lib/types/contentful.types.d.ts +14 -2
- package/package.json +2 -2
|
@@ -1,65 +1,38 @@
|
|
|
1
1
|
import { NgIf, NgClass, DOCUMENT } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Component, ChangeDetectionStrategy, ViewEncapsulation, Input,
|
|
3
|
+
import { InjectionToken, inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Renderer2, ElementRef, ViewContainerRef, ComponentFactoryResolver, ApplicationRef, Injector, NgModule } from '@angular/core';
|
|
4
4
|
import { DomPortalOutlet, ComponentPortal } from '@angular/cdk/portal';
|
|
5
5
|
import { BLOCKS, INLINES } from '@contentful/rich-text-types';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const CONTENTFUL_CONFIG = new InjectionToken('TooltipConfig');
|
|
8
|
+
|
|
9
|
+
class ContentfulConfig {
|
|
8
10
|
constructor() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (v && !v.contentType.startsWith('audio/')) {
|
|
24
|
-
throw new Error('The provided asset is not an audio');
|
|
25
|
-
}
|
|
26
|
-
this._data = v !== null && v !== void 0 ? v : null;
|
|
11
|
+
/**
|
|
12
|
+
* Default components for rendering contentful assets
|
|
13
|
+
*/
|
|
14
|
+
this.components = {
|
|
15
|
+
file: ContentfulFileComponent,
|
|
16
|
+
image: ContentfulImageComponent,
|
|
17
|
+
video: ContentfulVideoComponent,
|
|
18
|
+
audio: ContentfulAudioComponent,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Determines if the contentful rich text renderer should render the contentful rich text with tailwind css classes
|
|
22
|
+
*/
|
|
23
|
+
this.useTailwindClasses = false;
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
|
|
37
|
-
type: Component,
|
|
38
|
-
args: [{
|
|
39
|
-
selector: 'et-contentful-audio',
|
|
40
|
-
template: `
|
|
41
|
-
<figure *ngIf="data" [ngClass]="figureClass">
|
|
42
|
-
<figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
|
|
43
|
-
<audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
|
|
44
|
-
</figure>
|
|
45
|
-
`,
|
|
46
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
47
|
-
encapsulation: ViewEncapsulation.None,
|
|
48
|
-
standalone: true,
|
|
49
|
-
imports: [NgIf, NgClass],
|
|
50
|
-
}]
|
|
51
|
-
}], propDecorators: { data: [{
|
|
52
|
-
type: Input
|
|
53
|
-
}], audioClass: [{
|
|
54
|
-
type: Input
|
|
55
|
-
}], figureClass: [{
|
|
56
|
-
type: Input
|
|
57
|
-
}], figcaptionClass: [{
|
|
58
|
-
type: Input
|
|
59
|
-
}] } });
|
|
26
|
+
|
|
27
|
+
const provideContentfulConfig = (contentfulConfig) => {
|
|
28
|
+
return { provide: CONTENTFUL_CONFIG, useValue: contentfulConfig };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const RICH_TEXT_RENDERER_COMPONENT_DATA = new InjectionToken('RICH_TEXT_RENDERER_COMPONENT_DATA');
|
|
60
32
|
|
|
61
33
|
class ContentfulFileComponent {
|
|
62
34
|
constructor() {
|
|
35
|
+
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
63
36
|
this._data = null;
|
|
64
37
|
this.fileClass = null;
|
|
65
38
|
}
|
|
@@ -74,14 +47,19 @@ class ContentfulFileComponent {
|
|
|
74
47
|
}
|
|
75
48
|
this._data = v !== null && v !== void 0 ? v : null;
|
|
76
49
|
}
|
|
50
|
+
ngOnInit() {
|
|
51
|
+
if (this._richTextData) {
|
|
52
|
+
this.data = this._richTextData;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
77
55
|
}
|
|
78
|
-
ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
79
|
-
ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.
|
|
56
|
+
ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
57
|
+
ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulFileComponent, isStandalone: true, selector: "et-contentful-file", inputs: { data: "data", fileClass: "fileClass" }, ngImport: i0, template: `
|
|
80
58
|
<a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
|
|
81
59
|
{{ data.title }} ({{ data.size }} Bytes)
|
|
82
60
|
</a>
|
|
83
61
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
84
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulFileComponent, decorators: [{
|
|
85
63
|
type: Component,
|
|
86
64
|
args: [{
|
|
87
65
|
selector: 'et-contentful-file',
|
|
@@ -103,6 +81,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
103
81
|
|
|
104
82
|
class ContentfulImageComponent {
|
|
105
83
|
constructor() {
|
|
84
|
+
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
106
85
|
this._data = null;
|
|
107
86
|
this.imgClass = null;
|
|
108
87
|
this.pictureClass = null;
|
|
@@ -121,9 +100,14 @@ class ContentfulImageComponent {
|
|
|
121
100
|
}
|
|
122
101
|
this._data = v !== null && v !== void 0 ? v : null;
|
|
123
102
|
}
|
|
103
|
+
ngOnInit() {
|
|
104
|
+
if (this._richTextData) {
|
|
105
|
+
this.data = this._richTextData;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
124
108
|
}
|
|
125
|
-
ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
126
|
-
ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.
|
|
109
|
+
ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
110
|
+
ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", imgClass: "imgClass", pictureClass: "pictureClass" }, ngImport: i0, template: `
|
|
127
111
|
<picture *ngIf="data" [ngClass]="pictureClass">
|
|
128
112
|
<source srcset="{{ data.url }}?fm=avif" />
|
|
129
113
|
<source srcset="{{ data.url }}?fm=webp" />
|
|
@@ -137,7 +121,7 @@ ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0
|
|
|
137
121
|
/>
|
|
138
122
|
</picture>
|
|
139
123
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
140
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
124
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulImageComponent, decorators: [{
|
|
141
125
|
type: Component,
|
|
142
126
|
args: [{
|
|
143
127
|
selector: 'et-contentful-image',
|
|
@@ -168,32 +152,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
168
152
|
type: Input
|
|
169
153
|
}] } });
|
|
170
154
|
|
|
171
|
-
const CONTENTFUL_CONFIG = new InjectionToken('TooltipConfig');
|
|
172
|
-
|
|
173
|
-
class ContentfulConfig {
|
|
174
|
-
constructor() {
|
|
175
|
-
/**
|
|
176
|
-
* Default components for rendering contentful assets
|
|
177
|
-
*/
|
|
178
|
-
this.components = {
|
|
179
|
-
file: ContentfulFileComponent,
|
|
180
|
-
image: ContentfulImageComponent,
|
|
181
|
-
video: ContentfulVideoComponent,
|
|
182
|
-
audio: ContentfulAudioComponent,
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Determines if the contentful rich text renderer should render the contentful rich text with tailwind css classes
|
|
186
|
-
*/
|
|
187
|
-
this.useTailwindClasses = false;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const provideContentfulConfig = (contentfulConfig) => {
|
|
192
|
-
return { provide: CONTENTFUL_CONFIG, useValue: contentfulConfig };
|
|
193
|
-
};
|
|
194
|
-
|
|
195
155
|
class ContentfulVideoComponent {
|
|
196
156
|
constructor() {
|
|
157
|
+
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
197
158
|
this._data = null;
|
|
198
159
|
this.videoClass = null;
|
|
199
160
|
}
|
|
@@ -211,14 +172,19 @@ class ContentfulVideoComponent {
|
|
|
211
172
|
}
|
|
212
173
|
this._data = v !== null && v !== void 0 ? v : null;
|
|
213
174
|
}
|
|
175
|
+
ngOnInit() {
|
|
176
|
+
if (this._richTextData) {
|
|
177
|
+
this.data = this._richTextData;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
214
180
|
}
|
|
215
|
-
ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
216
|
-
ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.
|
|
181
|
+
ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulVideoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
182
|
+
ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulVideoComponent, isStandalone: true, selector: "et-contentful-video", inputs: { data: "data", videoClass: "videoClass" }, ngImport: i0, template: `
|
|
217
183
|
<video *ngIf="data" [ngClass]="videoClass" controls>
|
|
218
184
|
<source src="{{ data.url }}" type="{{ data.contentType }}" />
|
|
219
185
|
</video>
|
|
220
186
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
221
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
187
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
|
|
222
188
|
type: Component,
|
|
223
189
|
args: [{
|
|
224
190
|
selector: 'et-contentful-video',
|
|
@@ -241,16 +207,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
241
207
|
const createRenderCommandsFromContentfulRichText = (options) => {
|
|
242
208
|
const { data, config } = options;
|
|
243
209
|
const commands = [];
|
|
244
|
-
const assetMap = new Map();
|
|
245
210
|
const assetComponents = getAssetComponentsFromConfig(config);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, assetMap, config.useTailwindClasses, assetComponents, config.customComponents);
|
|
211
|
+
const resourceMap = createContentfulResourceMap(data.links);
|
|
212
|
+
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config.useTailwindClasses, assetComponents, config.customComponents);
|
|
250
213
|
return commands;
|
|
251
214
|
};
|
|
252
|
-
const createContentfulRenderCommand = (node, parent,
|
|
253
|
-
var _a, _b, _c, _d
|
|
215
|
+
const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindClasses, assetComponents, customComponents) => {
|
|
216
|
+
var _a, _b, _c, _d;
|
|
254
217
|
const { nodeType, data: nodeData } = node;
|
|
255
218
|
const { children, marks, value } = getContentfulNodeProps(node);
|
|
256
219
|
const command = {
|
|
@@ -263,8 +226,9 @@ const createContentfulRenderCommand = (node, parent, assetMap, useTailwindClasse
|
|
|
263
226
|
: {})), (nodeData['uri'] ? { href: nodeData['uri'], target: '_blank' } : {})),
|
|
264
227
|
children: [],
|
|
265
228
|
};
|
|
229
|
+
const entryId = (_b = (_a = nodeData['target']) === null || _a === void 0 ? void 0 : _a.sys) === null || _b === void 0 ? void 0 : _b.id;
|
|
266
230
|
if (nodeType === BLOCKS.EMBEDDED_ASSET) {
|
|
267
|
-
const asset =
|
|
231
|
+
const asset = resourceMap.assetsBlock.get(entryId);
|
|
268
232
|
if (asset) {
|
|
269
233
|
const isImage = asset.contentType.startsWith('image/');
|
|
270
234
|
const isVideo = asset.contentType.startsWith('video/');
|
|
@@ -283,21 +247,30 @@ const createContentfulRenderCommand = (node, parent, assetMap, useTailwindClasse
|
|
|
283
247
|
command.payload = assetComponents.file;
|
|
284
248
|
}
|
|
285
249
|
}
|
|
250
|
+
else {
|
|
251
|
+
console.warn(`No asset found for entry id "${entryId}"!`, nodeData);
|
|
252
|
+
}
|
|
286
253
|
}
|
|
287
254
|
else if (nodeType === BLOCKS.EMBEDDED_ENTRY || nodeType === INLINES.EMBEDDED_ENTRY) {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
255
|
+
const entry = (_c = resourceMap.entriesBlock.get(entryId)) !== null && _c !== void 0 ? _c : resourceMap.entriesInline.get(entryId);
|
|
256
|
+
if (entry) {
|
|
257
|
+
const type = (_d = entry === null || entry === void 0 ? void 0 : entry.__typename) !== null && _d !== void 0 ? _d : 'ET_UNKNOWN';
|
|
258
|
+
const component = customComponents === null || customComponents === void 0 ? void 0 : customComponents[type];
|
|
259
|
+
if (component) {
|
|
260
|
+
command.payload = component;
|
|
261
|
+
command.data = entry;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
command.data = `ERROR: No component found for embedded entry "${type}" as "${nodeType}"!`;
|
|
265
|
+
}
|
|
293
266
|
}
|
|
294
267
|
else {
|
|
295
|
-
|
|
268
|
+
console.warn(`No entry found for entry id "${entryId}"!`, nodeData);
|
|
296
269
|
}
|
|
297
270
|
}
|
|
298
271
|
if (children && (children.length !== 1 || children[0].nodeType !== 'text')) {
|
|
299
272
|
children.forEach((child) => {
|
|
300
|
-
createContentfulRenderCommand(child, command,
|
|
273
|
+
createContentfulRenderCommand(child, command, resourceMap, useTailwindClasses, assetComponents, customComponents);
|
|
301
274
|
});
|
|
302
275
|
}
|
|
303
276
|
parent.children.push(command);
|
|
@@ -405,6 +378,29 @@ const translateContentfulNodeTypeToHtmlTag = (nodeType) => {
|
|
|
405
378
|
return 'div';
|
|
406
379
|
}
|
|
407
380
|
};
|
|
381
|
+
const createContentfulResourceMap = (links) => {
|
|
382
|
+
var _a, _b, _c;
|
|
383
|
+
const resourceMap = {
|
|
384
|
+
assetsBlock: createContentfulMap((_a = links === null || links === void 0 ? void 0 : links.assets) === null || _a === void 0 ? void 0 : _a.block),
|
|
385
|
+
entriesInline: createContentfulMap((_b = links === null || links === void 0 ? void 0 : links.entries) === null || _b === void 0 ? void 0 : _b.inline),
|
|
386
|
+
entriesBlock: createContentfulMap((_c = links === null || links === void 0 ? void 0 : links.entries) === null || _c === void 0 ? void 0 : _c.block),
|
|
387
|
+
};
|
|
388
|
+
return resourceMap;
|
|
389
|
+
};
|
|
390
|
+
const createContentfulMap = (links) => {
|
|
391
|
+
var _a;
|
|
392
|
+
const assetMap = new Map();
|
|
393
|
+
if (links) {
|
|
394
|
+
for (const link of links) {
|
|
395
|
+
if (!((_a = link === null || link === void 0 ? void 0 : link.sys) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
396
|
+
console.warn('Link has no sys.id property. Please include it inside your query.', link);
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
assetMap.set(link.sys.id, link);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return assetMap;
|
|
403
|
+
};
|
|
408
404
|
|
|
409
405
|
class ContentfulRichTextRendererComponent {
|
|
410
406
|
constructor() {
|
|
@@ -461,13 +457,18 @@ class ContentfulRichTextRendererComponent {
|
|
|
461
457
|
this._renderer.appendChild(parent, element);
|
|
462
458
|
}
|
|
463
459
|
else {
|
|
464
|
-
const
|
|
460
|
+
const injector = Injector.create({
|
|
461
|
+
providers: [
|
|
462
|
+
{
|
|
463
|
+
provide: RICH_TEXT_RENDERER_COMPONENT_DATA,
|
|
464
|
+
useValue: data,
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
parent: this._injector,
|
|
468
|
+
});
|
|
469
|
+
const portal = new DomPortalOutlet(parent, this._componentFactoryResolver, this._appRef, injector, this._document);
|
|
465
470
|
const comp = new ComponentPortal(command.payload);
|
|
466
471
|
const ref = comp.attach(portal);
|
|
467
|
-
if (command.data) {
|
|
468
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
469
|
-
ref.instance.data = command.data;
|
|
470
|
-
}
|
|
471
472
|
element = ref.location.nativeElement;
|
|
472
473
|
}
|
|
473
474
|
}
|
|
@@ -477,9 +478,9 @@ class ContentfulRichTextRendererComponent {
|
|
|
477
478
|
}
|
|
478
479
|
}
|
|
479
480
|
}
|
|
480
|
-
ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
481
|
-
ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.
|
|
482
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
481
|
+
ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
482
|
+
ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulRichTextRendererComponent, isStandalone: true, selector: "et-contentful-rich-text-renderer", inputs: { richText: "richText" }, host: { classAttribute: "et-contentful-rich-text-renderer" }, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
483
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
|
|
483
484
|
type: Component,
|
|
484
485
|
args: [{
|
|
485
486
|
selector: 'et-contentful-rich-text-renderer',
|
|
@@ -495,10 +496,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
495
496
|
type: Input
|
|
496
497
|
}] } });
|
|
497
498
|
|
|
499
|
+
class ContentfulAudioComponent {
|
|
500
|
+
constructor() {
|
|
501
|
+
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
502
|
+
this._data = null;
|
|
503
|
+
this.audioClass = null;
|
|
504
|
+
this.figureClass = null;
|
|
505
|
+
this.figcaptionClass = null;
|
|
506
|
+
}
|
|
507
|
+
get data() {
|
|
508
|
+
return this._data;
|
|
509
|
+
}
|
|
510
|
+
set data(v) {
|
|
511
|
+
if (v && !v.contentType) {
|
|
512
|
+
this._data = null;
|
|
513
|
+
console.warn('The provided asset is invalid', v);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (v && !v.contentType.startsWith('audio/')) {
|
|
517
|
+
throw new Error('The provided asset is not an audio');
|
|
518
|
+
}
|
|
519
|
+
this._data = v !== null && v !== void 0 ? v : null;
|
|
520
|
+
}
|
|
521
|
+
ngOnInit() {
|
|
522
|
+
if (this._richTextData) {
|
|
523
|
+
this.data = this._richTextData;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
528
|
+
ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.9", type: ContentfulAudioComponent, isStandalone: true, selector: "et-contentful-audio", inputs: { data: "data", audioClass: "audioClass", figureClass: "figureClass", figcaptionClass: "figcaptionClass" }, ngImport: i0, template: `
|
|
529
|
+
<figure *ngIf="data" [ngClass]="figureClass">
|
|
530
|
+
<figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
|
|
531
|
+
<audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
|
|
532
|
+
</figure>
|
|
533
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
534
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
|
|
535
|
+
type: Component,
|
|
536
|
+
args: [{
|
|
537
|
+
selector: 'et-contentful-audio',
|
|
538
|
+
template: `
|
|
539
|
+
<figure *ngIf="data" [ngClass]="figureClass">
|
|
540
|
+
<figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
|
|
541
|
+
<audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
|
|
542
|
+
</figure>
|
|
543
|
+
`,
|
|
544
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
545
|
+
encapsulation: ViewEncapsulation.None,
|
|
546
|
+
standalone: true,
|
|
547
|
+
imports: [NgIf, NgClass],
|
|
548
|
+
}]
|
|
549
|
+
}], propDecorators: { data: [{
|
|
550
|
+
type: Input
|
|
551
|
+
}], audioClass: [{
|
|
552
|
+
type: Input
|
|
553
|
+
}], figureClass: [{
|
|
554
|
+
type: Input
|
|
555
|
+
}], figcaptionClass: [{
|
|
556
|
+
type: Input
|
|
557
|
+
}] } });
|
|
558
|
+
|
|
498
559
|
class ContentfulModule {
|
|
499
560
|
}
|
|
500
|
-
ContentfulModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
501
|
-
ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
561
|
+
ContentfulModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
562
|
+
ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
|
|
502
563
|
ContentfulFileComponent,
|
|
503
564
|
ContentfulImageComponent,
|
|
504
565
|
ContentfulVideoComponent,
|
|
@@ -507,12 +568,12 @@ ContentfulModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", versio
|
|
|
507
568
|
ContentfulImageComponent,
|
|
508
569
|
ContentfulVideoComponent,
|
|
509
570
|
ContentfulRichTextRendererComponent] });
|
|
510
|
-
ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.
|
|
571
|
+
ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
|
|
511
572
|
ContentfulFileComponent,
|
|
512
573
|
ContentfulImageComponent,
|
|
513
574
|
ContentfulVideoComponent,
|
|
514
575
|
ContentfulRichTextRendererComponent] });
|
|
515
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
576
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: ContentfulModule, decorators: [{
|
|
516
577
|
type: NgModule,
|
|
517
578
|
args: [{
|
|
518
579
|
imports: [
|
|
@@ -536,5 +597,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
536
597
|
* Generated bundle index. Do not edit.
|
|
537
598
|
*/
|
|
538
599
|
|
|
539
|
-
export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulConfig, ContentfulFileComponent, ContentfulImageComponent, ContentfulModule, ContentfulRichTextRendererComponent, ContentfulVideoComponent, createContentfulRenderCommand, createRenderCommandsFromContentfulRichText, getAssetComponentsFromConfig, getContentfulNodeProps, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
|
|
600
|
+
export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulConfig, ContentfulFileComponent, ContentfulImageComponent, ContentfulModule, ContentfulRichTextRendererComponent, ContentfulVideoComponent, RICH_TEXT_RENDERER_COMPONENT_DATA, createContentfulMap, createContentfulRenderCommand, createContentfulResourceMap, createRenderCommandsFromContentfulRichText, getAssetComponentsFromConfig, getContentfulNodeProps, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
|
|
540
601
|
//# sourceMappingURL=ethlete-contentful.mjs.map
|