@ethlete/contentful 0.1.0-next.8 → 1.0.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/esm2020/lib/components/audio/contentful-audio.component.mjs +3 -3
- package/esm2020/lib/components/file/contentful-file.component.mjs +3 -3
- package/esm2020/lib/components/image/contentful-image.component.mjs +94 -47
- package/esm2020/lib/components/image/contentful-image.component.utils.mjs +86 -0
- package/esm2020/lib/components/image/index.mjs +2 -0
- package/esm2020/lib/components/image/public-api.mjs +2 -1
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.component.mjs +16 -8
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.util.mjs +13 -10
- package/esm2020/lib/components/video/contentful-video.component.mjs +3 -3
- package/esm2020/lib/contentful.imports.mjs +9 -0
- package/esm2020/lib/gql/asset.fragments.mjs +32 -0
- package/esm2020/lib/gql/public-api.mjs +2 -0
- package/esm2020/lib/public-api.mjs +3 -2
- package/esm2020/lib/types/contentful.types.mjs +1 -1
- package/esm2020/lib/utils/contentful-config.mjs +6 -1
- package/esm2020/lib/utils/contentful.util.mjs +7 -1
- package/esm2020/lib/utils/index.mjs +2 -0
- package/fesm2015/ethlete-contentful.mjs +307 -152
- package/fesm2015/ethlete-contentful.mjs.map +1 -1
- package/fesm2020/ethlete-contentful.mjs +304 -151
- package/fesm2020/ethlete-contentful.mjs.map +1 -1
- package/lib/components/image/contentful-image.component.d.ts +20 -12
- package/lib/components/image/contentful-image.component.utils.d.ts +16 -0
- package/lib/components/image/index.d.ts +1 -0
- package/lib/components/image/public-api.d.ts +1 -0
- package/lib/components/rich-text-renderer/rich-text-renderer.component.d.ts +1 -1
- package/lib/components/rich-text-renderer/rich-text-renderer.util.d.ts +2 -3
- package/lib/contentful.imports.d.ts +2 -0
- package/lib/gql/asset.fragments.d.ts +2 -0
- package/lib/gql/public-api.d.ts +1 -0
- package/lib/public-api.d.ts +2 -1
- package/lib/types/contentful.types.d.ts +41 -2
- package/lib/utils/contentful.util.d.ts +3 -1
- package/lib/utils/index.d.ts +1 -0
- package/package.json +3 -2
- package/esm2020/lib/contentful.module.mjs +0 -40
- package/lib/contentful.module.d.ts +0 -11
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NgIf, NgClass, NgOptimizedImage, DOCUMENT } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, inject,
|
|
3
|
+
import { InjectionToken, inject, ChangeDetectorRef, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Renderer2, ElementRef, ComponentFactoryResolver, ApplicationRef, Injector } from '@angular/core';
|
|
4
4
|
import { DomPortalOutlet, ComponentPortal } from '@angular/cdk/portal';
|
|
5
|
-
import
|
|
5
|
+
import * as i1 from '@ethlete/components';
|
|
6
|
+
import { PictureDataDirective, PictureComponent } from '@ethlete/components';
|
|
6
7
|
import { BLOCKS, INLINES } from '@contentful/rich-text-types';
|
|
8
|
+
import { gql } from '@ethlete/query';
|
|
7
9
|
|
|
8
10
|
const CONTENTFUL_CONFIG = new InjectionToken('ContentfulConfig');
|
|
9
11
|
|
|
@@ -16,19 +18,249 @@ const createContentfulConfig = (config = {}) => (Object.assign({
|
|
|
16
18
|
video: ContentfulVideoComponent,
|
|
17
19
|
},
|
|
18
20
|
customComponents: {},
|
|
21
|
+
imageOptions: {
|
|
22
|
+
srcsetSizes: ['375w', '1280w', '1920w', '2560w'],
|
|
23
|
+
sizes: [],
|
|
24
|
+
backgroundColor: null,
|
|
25
|
+
},
|
|
19
26
|
}, (config || {})));
|
|
20
27
|
|
|
21
28
|
const RICH_TEXT_RENDERER_COMPONENT_DATA = new InjectionToken('RICH_TEXT_RENDERER_COMPONENT_DATA');
|
|
22
29
|
|
|
30
|
+
const provideContentfulConfig = (contentfulConfig = {}) => {
|
|
31
|
+
return { provide: CONTENTFUL_CONFIG, useValue: createContentfulConfig(contentfulConfig) };
|
|
32
|
+
};
|
|
33
|
+
const isContentfulImage = (v) => {
|
|
34
|
+
return !!v && 'asset' in v && 'alt' in v && 'resizeBehavior' in v && 'focusArea' in v;
|
|
35
|
+
};
|
|
36
|
+
const isContentfulAsset = (v) => {
|
|
37
|
+
return !!v && 'contentType' in v && 'description' in v && 'height' in v && 'url' in v && 'width' in v;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const generateDefaultContentfulImageSource = (data) => {
|
|
41
|
+
const { url, contentType } = data;
|
|
42
|
+
return {
|
|
43
|
+
type: contentType,
|
|
44
|
+
srcset: url,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Parses source set sizes into an object containing with and height. Eg.
|
|
49
|
+
* - `"400"` - 400px width
|
|
50
|
+
* - `"400x300"` - 400px width and 300px height
|
|
51
|
+
* - `"400w"` - 400px width
|
|
52
|
+
* - `"400h"` - 400px height
|
|
53
|
+
* - `"400wx300h"` - 400px width and 300px height
|
|
54
|
+
**/
|
|
55
|
+
const parseContentfulImageSize = (size) => {
|
|
56
|
+
let width = null;
|
|
57
|
+
let height = null;
|
|
58
|
+
if (size.includes('x')) {
|
|
59
|
+
const [w, h] = size.split('x');
|
|
60
|
+
width = w;
|
|
61
|
+
height = h;
|
|
62
|
+
}
|
|
63
|
+
else if (size.includes('h')) {
|
|
64
|
+
height = size;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
width = size;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
width: width ? parseInt(width, 10) : null,
|
|
71
|
+
height: height ? parseInt(height, 10) : null,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const generateContentfulImageSources = (data, srcsetSizes, backgroundColor) => {
|
|
75
|
+
const assetData = isContentfulImage(data) ? data.asset : data;
|
|
76
|
+
const imageData = isContentfulImage(data) ? data : null;
|
|
77
|
+
if (!assetData) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
const sources = [];
|
|
81
|
+
const SOURCE_TYPES = ['image/avif', 'image/webp', 'image/png', 'image/jpg'];
|
|
82
|
+
for (const type of SOURCE_TYPES) {
|
|
83
|
+
const baseUrl = assetData.url;
|
|
84
|
+
const sourceSets = [];
|
|
85
|
+
const queryParams = [];
|
|
86
|
+
// Set the format (e.g. 'fm=webp')
|
|
87
|
+
queryParams.push(`fm=${type.split('/')[1]}`);
|
|
88
|
+
if (backgroundColor) {
|
|
89
|
+
queryParams.push(`bg=rgb:${backgroundColor}`);
|
|
90
|
+
}
|
|
91
|
+
if (imageData) {
|
|
92
|
+
if (imageData.quality) {
|
|
93
|
+
queryParams.push(`q=${imageData.quality}`);
|
|
94
|
+
}
|
|
95
|
+
if (imageData.focusArea) {
|
|
96
|
+
queryParams.push(`f=${imageData.focusArea}`);
|
|
97
|
+
}
|
|
98
|
+
if (imageData.resizeBehavior) {
|
|
99
|
+
queryParams.push(`fit=${imageData.resizeBehavior}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (srcsetSizes === null || srcsetSizes === void 0 ? void 0 : srcsetSizes.length) {
|
|
103
|
+
const urlWithParams = `${baseUrl}?${queryParams.join('&')}`;
|
|
104
|
+
for (const size of srcsetSizes) {
|
|
105
|
+
const { width, height } = parseContentfulImageSize(size);
|
|
106
|
+
if (width && height) {
|
|
107
|
+
sourceSets.push(`${urlWithParams}&w=${width}&h=${height} ${width}w`);
|
|
108
|
+
}
|
|
109
|
+
else if (width) {
|
|
110
|
+
sourceSets.push(`${urlWithParams}&w=${width} ${width}w`);
|
|
111
|
+
}
|
|
112
|
+
else if (height) {
|
|
113
|
+
sourceSets.push(`${urlWithParams}&h=${height} ${height}h`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
sources.push({
|
|
118
|
+
type,
|
|
119
|
+
srcset: sourceSets.length ? sourceSets.join(', ') : `${baseUrl}?${queryParams.join('&')}`,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return sources;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
class ContentfulImageComponent {
|
|
126
|
+
constructor() {
|
|
127
|
+
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, {
|
|
128
|
+
optional: true,
|
|
129
|
+
});
|
|
130
|
+
this.pictureData = inject(PictureDataDirective);
|
|
131
|
+
this._cdr = inject(ChangeDetectorRef);
|
|
132
|
+
this._data = null;
|
|
133
|
+
this._sizes = [];
|
|
134
|
+
this._srcsetSizes = [];
|
|
135
|
+
this._backgroundColor = null;
|
|
136
|
+
this.sources = [];
|
|
137
|
+
}
|
|
138
|
+
get data() {
|
|
139
|
+
return this._data;
|
|
140
|
+
}
|
|
141
|
+
set data(v) {
|
|
142
|
+
var _a, _b, _c, _d, _e;
|
|
143
|
+
const assetData = isContentfulImage(v) ? v.asset : v;
|
|
144
|
+
const imageData = isContentfulImage(v) ? v : null;
|
|
145
|
+
if (assetData && !assetData.contentType) {
|
|
146
|
+
this._data = null;
|
|
147
|
+
console.warn('The provided asset is invalid', v);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (assetData && !assetData.contentType.startsWith('image/')) {
|
|
151
|
+
throw new Error('The provided asset is not an image');
|
|
152
|
+
}
|
|
153
|
+
this._data = v !== null && v !== void 0 ? v : null;
|
|
154
|
+
this.pictureData.defaultSrc = assetData ? generateDefaultContentfulImageSource(assetData) : null;
|
|
155
|
+
this.pictureData.alt = (_b = (_a = imageData === null || imageData === void 0 ? void 0 : imageData.alt) !== null && _a !== void 0 ? _a : assetData === null || assetData === void 0 ? void 0 : assetData.description) !== null && _b !== void 0 ? _b : null;
|
|
156
|
+
this.pictureData.width = (_c = assetData === null || assetData === void 0 ? void 0 : assetData.width) !== null && _c !== void 0 ? _c : null;
|
|
157
|
+
this.pictureData.height = (_d = assetData === null || assetData === void 0 ? void 0 : assetData.height) !== null && _d !== void 0 ? _d : null;
|
|
158
|
+
this.pictureData.figcaption = (_e = imageData === null || imageData === void 0 ? void 0 : imageData.caption) !== null && _e !== void 0 ? _e : null;
|
|
159
|
+
this.updateSizes();
|
|
160
|
+
}
|
|
161
|
+
get sizes() {
|
|
162
|
+
return this._sizes;
|
|
163
|
+
}
|
|
164
|
+
set sizes(v) {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
this._sizes = v;
|
|
167
|
+
this.pictureData.sizes = (_b = (_a = this.sizes) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : null;
|
|
168
|
+
}
|
|
169
|
+
get srcsetSizes() {
|
|
170
|
+
return this._srcsetSizes;
|
|
171
|
+
}
|
|
172
|
+
set srcsetSizes(v) {
|
|
173
|
+
this._srcsetSizes = v;
|
|
174
|
+
this.updateSizes();
|
|
175
|
+
}
|
|
176
|
+
get backgroundColor() {
|
|
177
|
+
return this._backgroundColor;
|
|
178
|
+
}
|
|
179
|
+
set backgroundColor(v) {
|
|
180
|
+
this._backgroundColor = v;
|
|
181
|
+
this.updateSizes();
|
|
182
|
+
}
|
|
183
|
+
ngOnInit() {
|
|
184
|
+
if (this._richTextData && !this.data) {
|
|
185
|
+
this.data = this._richTextData;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
updateSizes() {
|
|
189
|
+
this.sources = this._data ? generateContentfulImageSources(this._data, this.srcsetSizes, this.backgroundColor) : [];
|
|
190
|
+
this._cdr.markForCheck();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
194
|
+
ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", sizes: "sizes", srcsetSizes: "srcsetSizes", backgroundColor: "backgroundColor" }, host: { classAttribute: "et-contentful-image" }, hostDirectives: [{ directive: i1.PictureDataDirective, inputs: ["imgClass", "imgClass", "hasPriority", "hasPriority", "figureClass", "figureClass", "pictureClass", "pictureClass", "figcaptionClass", "figcaptionClass"] }], ngImport: i0, template: `
|
|
195
|
+
<et-picture
|
|
196
|
+
[imgClass]="pictureData.imgClass"
|
|
197
|
+
[hasPriority]="pictureData.hasPriority"
|
|
198
|
+
[figureClass]="pictureData.figureClass"
|
|
199
|
+
[pictureClass]="pictureData.pictureClass"
|
|
200
|
+
[figcaptionClass]="pictureData.figcaptionClass"
|
|
201
|
+
[defaultSrc]="pictureData.defaultSrc"
|
|
202
|
+
[alt]="pictureData.alt"
|
|
203
|
+
[figcaption]="pictureData.figcaption"
|
|
204
|
+
[width]="pictureData.width"
|
|
205
|
+
[height]="pictureData.height"
|
|
206
|
+
[sizes]="pictureData.sizes"
|
|
207
|
+
[sources]="sources"
|
|
208
|
+
/>
|
|
209
|
+
`, isInline: true, dependencies: [{ kind: "component", type: PictureComponent, selector: "et-picture", inputs: ["sources"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulImageComponent, decorators: [{
|
|
211
|
+
type: Component,
|
|
212
|
+
args: [{
|
|
213
|
+
selector: 'et-contentful-image',
|
|
214
|
+
template: `
|
|
215
|
+
<et-picture
|
|
216
|
+
[imgClass]="pictureData.imgClass"
|
|
217
|
+
[hasPriority]="pictureData.hasPriority"
|
|
218
|
+
[figureClass]="pictureData.figureClass"
|
|
219
|
+
[pictureClass]="pictureData.pictureClass"
|
|
220
|
+
[figcaptionClass]="pictureData.figcaptionClass"
|
|
221
|
+
[defaultSrc]="pictureData.defaultSrc"
|
|
222
|
+
[alt]="pictureData.alt"
|
|
223
|
+
[figcaption]="pictureData.figcaption"
|
|
224
|
+
[width]="pictureData.width"
|
|
225
|
+
[height]="pictureData.height"
|
|
226
|
+
[sizes]="pictureData.sizes"
|
|
227
|
+
[sources]="sources"
|
|
228
|
+
/>
|
|
229
|
+
`,
|
|
230
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
231
|
+
encapsulation: ViewEncapsulation.None,
|
|
232
|
+
standalone: true,
|
|
233
|
+
imports: [NgIf, NgClass, NgOptimizedImage, PictureComponent],
|
|
234
|
+
hostDirectives: [
|
|
235
|
+
{
|
|
236
|
+
directive: PictureDataDirective,
|
|
237
|
+
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
|
238
|
+
inputs: ['imgClass', 'hasPriority', 'figureClass', 'pictureClass', 'figcaptionClass'],
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
host: {
|
|
242
|
+
class: 'et-contentful-image',
|
|
243
|
+
},
|
|
244
|
+
}]
|
|
245
|
+
}], propDecorators: { data: [{
|
|
246
|
+
type: Input
|
|
247
|
+
}], sizes: [{
|
|
248
|
+
type: Input
|
|
249
|
+
}], srcsetSizes: [{
|
|
250
|
+
type: Input
|
|
251
|
+
}], backgroundColor: [{
|
|
252
|
+
type: Input
|
|
253
|
+
}] } });
|
|
254
|
+
|
|
23
255
|
const createRenderCommandsFromContentfulRichText = (options) => {
|
|
24
256
|
const { data, config } = options;
|
|
25
257
|
const commands = [];
|
|
26
258
|
const resourceMap = createContentfulResourceMap(data.links);
|
|
27
|
-
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config
|
|
259
|
+
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config);
|
|
28
260
|
return commands;
|
|
29
261
|
};
|
|
30
|
-
const createContentfulRenderCommand = (node, parent, resourceMap,
|
|
31
|
-
var _a, _b, _c, _d;
|
|
262
|
+
const createContentfulRenderCommand = (node, parent, resourceMap, config) => {
|
|
263
|
+
var _a, _b, _c, _d, _e;
|
|
32
264
|
const { nodeType, data: nodeData } = node;
|
|
33
265
|
const { children, marks, value } = getContentfulNodeProps(node);
|
|
34
266
|
const command = {
|
|
@@ -36,7 +268,7 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
36
268
|
data: value,
|
|
37
269
|
attributes: Object.assign(Object.assign({}, (marks
|
|
38
270
|
? {
|
|
39
|
-
class: transformContentfulMarks(marks, useTailwindClasses),
|
|
271
|
+
class: transformContentfulMarks(marks, config.useTailwindClasses),
|
|
40
272
|
}
|
|
41
273
|
: {})), (nodeData['uri'] ? { href: nodeData['uri'], target: '_blank' } : {})),
|
|
42
274
|
children: [],
|
|
@@ -50,16 +282,16 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
50
282
|
const isAudio = asset.contentType.startsWith('audio/');
|
|
51
283
|
command.data = asset;
|
|
52
284
|
if (isImage) {
|
|
53
|
-
command.payload =
|
|
285
|
+
command.payload = config.components.image;
|
|
54
286
|
}
|
|
55
287
|
else if (isVideo) {
|
|
56
|
-
command.payload =
|
|
288
|
+
command.payload = config.components.video;
|
|
57
289
|
}
|
|
58
290
|
else if (isAudio) {
|
|
59
|
-
command.payload =
|
|
291
|
+
command.payload = config.components.audio;
|
|
60
292
|
}
|
|
61
293
|
else {
|
|
62
|
-
command.payload =
|
|
294
|
+
command.payload = config.components.file;
|
|
63
295
|
}
|
|
64
296
|
}
|
|
65
297
|
else {
|
|
@@ -70,7 +302,9 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
70
302
|
const entry = (_c = resourceMap.entriesBlock.get(entryId)) !== null && _c !== void 0 ? _c : resourceMap.entriesInline.get(entryId);
|
|
71
303
|
if (entry) {
|
|
72
304
|
const type = (_d = entry === null || entry === void 0 ? void 0 : entry.__typename) !== null && _d !== void 0 ? _d : 'ET_UNKNOWN';
|
|
73
|
-
|
|
305
|
+
// "Image" is a special wrapper content model for contentful assets.
|
|
306
|
+
// It must be created by the user.
|
|
307
|
+
const component = type === 'Image' ? ContentfulImageComponent : (_e = config.customComponents) === null || _e === void 0 ? void 0 : _e[type];
|
|
74
308
|
if (component) {
|
|
75
309
|
command.payload = component;
|
|
76
310
|
command.data = entry;
|
|
@@ -85,7 +319,7 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
85
319
|
}
|
|
86
320
|
if (children && (children.length !== 1 || children[0].nodeType !== 'text')) {
|
|
87
321
|
children.forEach((child) => {
|
|
88
|
-
createContentfulRenderCommand(child, command, resourceMap,
|
|
322
|
+
createContentfulRenderCommand(child, command, resourceMap, config);
|
|
89
323
|
});
|
|
90
324
|
}
|
|
91
325
|
parent.children.push(command);
|
|
@@ -213,7 +447,6 @@ class ContentfulRichTextRendererComponent {
|
|
|
213
447
|
this._richText = null;
|
|
214
448
|
this._renderer = inject(Renderer2);
|
|
215
449
|
this._elementRef = inject(ElementRef);
|
|
216
|
-
this._viewContainerRef = inject(ViewContainerRef);
|
|
217
450
|
this._componentFactoryResolver = inject(ComponentFactoryResolver);
|
|
218
451
|
this._document = inject(DOCUMENT);
|
|
219
452
|
this._appRef = inject(ApplicationRef);
|
|
@@ -225,15 +458,18 @@ class ContentfulRichTextRendererComponent {
|
|
|
225
458
|
}
|
|
226
459
|
set richText(v) {
|
|
227
460
|
this._richText = v !== null && v !== void 0 ? v : null;
|
|
461
|
+
this.resetAndRender();
|
|
462
|
+
}
|
|
463
|
+
resetAndRender() {
|
|
228
464
|
// clear childNodes to prevent appending new richtext elements to existing one
|
|
229
465
|
const childElements = this._elementRef.nativeElement.childNodes;
|
|
230
466
|
for (const child of childElements) {
|
|
231
467
|
this._renderer.removeChild(this._elementRef.nativeElement, child);
|
|
232
468
|
}
|
|
233
|
-
if (!
|
|
469
|
+
if (!this._richText) {
|
|
234
470
|
return;
|
|
235
471
|
}
|
|
236
|
-
const commands = createRenderCommandsFromContentfulRichText({ data:
|
|
472
|
+
const commands = createRenderCommandsFromContentfulRichText({ data: this._richText, config: this._config });
|
|
237
473
|
this._render(commands);
|
|
238
474
|
}
|
|
239
475
|
_render(commands) {
|
|
@@ -277,6 +513,11 @@ class ContentfulRichTextRendererComponent {
|
|
|
277
513
|
const portal = new DomPortalOutlet(parent, this._componentFactoryResolver, this._appRef, injector, this._document);
|
|
278
514
|
const comp = new ComponentPortal(command.payload);
|
|
279
515
|
const ref = comp.attach(portal);
|
|
516
|
+
if (ref.instance instanceof ContentfulImageComponent) {
|
|
517
|
+
ref.instance.sizes = this._config.imageOptions.sizes;
|
|
518
|
+
ref.instance.srcsetSizes = this._config.imageOptions.srcsetSizes;
|
|
519
|
+
ref.instance.backgroundColor = this._config.imageOptions.backgroundColor;
|
|
520
|
+
}
|
|
280
521
|
element = ref.location.nativeElement;
|
|
281
522
|
}
|
|
282
523
|
}
|
|
@@ -286,9 +527,9 @@ class ContentfulRichTextRendererComponent {
|
|
|
286
527
|
}
|
|
287
528
|
}
|
|
288
529
|
}
|
|
289
|
-
ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
290
|
-
ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
291
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
530
|
+
ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
531
|
+
ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", 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 });
|
|
532
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
|
|
292
533
|
type: Component,
|
|
293
534
|
args: [{
|
|
294
535
|
selector: 'et-contentful-rich-text-renderer',
|
|
@@ -332,14 +573,14 @@ class ContentfulAudioComponent {
|
|
|
332
573
|
}
|
|
333
574
|
}
|
|
334
575
|
}
|
|
335
|
-
ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
336
|
-
ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
576
|
+
ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
577
|
+
ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: ContentfulAudioComponent, isStandalone: true, selector: "et-contentful-audio", inputs: { data: "data", audioClass: "audioClass", figureClass: "figureClass", figcaptionClass: "figcaptionClass" }, ngImport: i0, template: `
|
|
337
578
|
<figure *ngIf="data" [ngClass]="figureClass">
|
|
338
579
|
<figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
|
|
339
580
|
<audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
|
|
340
581
|
</figure>
|
|
341
582
|
`, 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 });
|
|
342
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
583
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
|
|
343
584
|
type: Component,
|
|
344
585
|
args: [{
|
|
345
586
|
selector: 'et-contentful-audio',
|
|
@@ -387,13 +628,13 @@ class ContentfulFileComponent {
|
|
|
387
628
|
}
|
|
388
629
|
}
|
|
389
630
|
}
|
|
390
|
-
ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
391
|
-
ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
631
|
+
ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
632
|
+
ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: ContentfulFileComponent, isStandalone: true, selector: "et-contentful-file", inputs: { data: "data", fileClass: "fileClass" }, ngImport: i0, template: `
|
|
392
633
|
<a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
|
|
393
634
|
{{ data.title }} ({{ data.size }} Bytes)
|
|
394
635
|
</a>
|
|
395
636
|
`, 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 });
|
|
396
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
637
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulFileComponent, decorators: [{
|
|
397
638
|
type: Component,
|
|
398
639
|
args: [{
|
|
399
640
|
selector: 'et-contentful-file',
|
|
@@ -413,90 +654,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
|
|
|
413
654
|
type: Input
|
|
414
655
|
}] } });
|
|
415
656
|
|
|
416
|
-
class ContentfulImageComponent {
|
|
417
|
-
constructor() {
|
|
418
|
-
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
419
|
-
this._data = null;
|
|
420
|
-
this.imgClass = null;
|
|
421
|
-
this.pictureClass = null;
|
|
422
|
-
this._priority = false;
|
|
423
|
-
}
|
|
424
|
-
get data() {
|
|
425
|
-
return this._data;
|
|
426
|
-
}
|
|
427
|
-
set data(v) {
|
|
428
|
-
if (v && !v.contentType) {
|
|
429
|
-
this._data = null;
|
|
430
|
-
console.warn('The provided asset is invalid', v);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (v && !v.contentType.startsWith('image/')) {
|
|
434
|
-
throw new Error('The provided asset is not an image');
|
|
435
|
-
}
|
|
436
|
-
this._data = v !== null && v !== void 0 ? v : null;
|
|
437
|
-
}
|
|
438
|
-
get priority() {
|
|
439
|
-
return this._priority;
|
|
440
|
-
}
|
|
441
|
-
set priority(value) {
|
|
442
|
-
this._priority = coerceBooleanProperty(value);
|
|
443
|
-
}
|
|
444
|
-
ngOnInit() {
|
|
445
|
-
if (this._richTextData && !this.data) {
|
|
446
|
-
this.data = this._richTextData;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
451
|
-
ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", imgClass: "imgClass", pictureClass: "pictureClass", priority: "priority" }, ngImport: i0, template: `
|
|
452
|
-
<picture *ngIf="data" [ngClass]="pictureClass">
|
|
453
|
-
<source srcset="{{ data.url }}?fm=avif" type="image/avif" />
|
|
454
|
-
<source srcset="{{ data.url }}?fm=webp" type="image/webp" />
|
|
455
|
-
<source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
|
|
456
|
-
<img
|
|
457
|
-
[attr.alt]="data.description ?? undefined"
|
|
458
|
-
[width]="data.width ?? undefined"
|
|
459
|
-
[height]="data.height ?? undefined"
|
|
460
|
-
[priority]="data.priority ?? priority"
|
|
461
|
-
[ngClass]="imgClass"
|
|
462
|
-
ngSrc="{{ data.url }}"
|
|
463
|
-
/>
|
|
464
|
-
</picture>
|
|
465
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgOptimizedImage, selector: "img[ngSrc]", inputs: ["ngSrc", "ngSrcset", "sizes", "width", "height", "loading", "priority", "disableOptimizedSrcset", "fill", "src", "srcset"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
466
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, decorators: [{
|
|
467
|
-
type: Component,
|
|
468
|
-
args: [{
|
|
469
|
-
selector: 'et-contentful-image',
|
|
470
|
-
template: `
|
|
471
|
-
<picture *ngIf="data" [ngClass]="pictureClass">
|
|
472
|
-
<source srcset="{{ data.url }}?fm=avif" type="image/avif" />
|
|
473
|
-
<source srcset="{{ data.url }}?fm=webp" type="image/webp" />
|
|
474
|
-
<source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
|
|
475
|
-
<img
|
|
476
|
-
[attr.alt]="data.description ?? undefined"
|
|
477
|
-
[width]="data.width ?? undefined"
|
|
478
|
-
[height]="data.height ?? undefined"
|
|
479
|
-
[priority]="data.priority ?? priority"
|
|
480
|
-
[ngClass]="imgClass"
|
|
481
|
-
ngSrc="{{ data.url }}"
|
|
482
|
-
/>
|
|
483
|
-
</picture>
|
|
484
|
-
`,
|
|
485
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
486
|
-
encapsulation: ViewEncapsulation.None,
|
|
487
|
-
standalone: true,
|
|
488
|
-
imports: [NgIf, NgClass, NgOptimizedImage],
|
|
489
|
-
}]
|
|
490
|
-
}], propDecorators: { data: [{
|
|
491
|
-
type: Input
|
|
492
|
-
}], imgClass: [{
|
|
493
|
-
type: Input
|
|
494
|
-
}], pictureClass: [{
|
|
495
|
-
type: Input
|
|
496
|
-
}], priority: [{
|
|
497
|
-
type: Input
|
|
498
|
-
}] } });
|
|
499
|
-
|
|
500
657
|
class ContentfulVideoComponent {
|
|
501
658
|
constructor() {
|
|
502
659
|
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
@@ -523,13 +680,13 @@ class ContentfulVideoComponent {
|
|
|
523
680
|
}
|
|
524
681
|
}
|
|
525
682
|
}
|
|
526
|
-
ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
527
|
-
ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
683
|
+
ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulVideoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
684
|
+
ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: ContentfulVideoComponent, isStandalone: true, selector: "et-contentful-video", inputs: { data: "data", videoClass: "videoClass" }, ngImport: i0, template: `
|
|
528
685
|
<video *ngIf="data" [ngClass]="videoClass" controls>
|
|
529
686
|
<source src="{{ data.url }}" type="{{ data.contentType }}" />
|
|
530
687
|
</video>
|
|
531
688
|
`, 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 });
|
|
532
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
|
|
533
690
|
type: Component,
|
|
534
691
|
args: [{
|
|
535
692
|
selector: 'et-contentful-video',
|
|
@@ -549,50 +706,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
|
|
|
549
706
|
type: Input
|
|
550
707
|
}] } });
|
|
551
708
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
ContentfulRichTextRendererComponent], exports: [ContentfulAudioComponent,
|
|
560
|
-
ContentfulFileComponent,
|
|
561
|
-
ContentfulImageComponent,
|
|
562
|
-
ContentfulVideoComponent,
|
|
563
|
-
ContentfulRichTextRendererComponent] });
|
|
564
|
-
ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
|
|
565
|
-
ContentfulFileComponent,
|
|
566
|
-
ContentfulImageComponent,
|
|
567
|
-
ContentfulVideoComponent,
|
|
568
|
-
ContentfulRichTextRendererComponent] });
|
|
569
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, decorators: [{
|
|
570
|
-
type: NgModule,
|
|
571
|
-
args: [{
|
|
572
|
-
imports: [
|
|
573
|
-
ContentfulAudioComponent,
|
|
574
|
-
ContentfulFileComponent,
|
|
575
|
-
ContentfulImageComponent,
|
|
576
|
-
ContentfulVideoComponent,
|
|
577
|
-
ContentfulRichTextRendererComponent,
|
|
578
|
-
],
|
|
579
|
-
exports: [
|
|
580
|
-
ContentfulAudioComponent,
|
|
581
|
-
ContentfulFileComponent,
|
|
582
|
-
ContentfulImageComponent,
|
|
583
|
-
ContentfulVideoComponent,
|
|
584
|
-
ContentfulRichTextRendererComponent,
|
|
585
|
-
],
|
|
586
|
-
}]
|
|
587
|
-
}] });
|
|
709
|
+
const ContentfulImports = [
|
|
710
|
+
ContentfulAudioComponent,
|
|
711
|
+
ContentfulFileComponent,
|
|
712
|
+
ContentfulImageComponent,
|
|
713
|
+
ContentfulVideoComponent,
|
|
714
|
+
ContentfulRichTextRendererComponent,
|
|
715
|
+
];
|
|
588
716
|
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
|
|
717
|
+
const GQL_FRAGMENT_CONTENTFUL_ASSET = gql `
|
|
718
|
+
fragment AssetData on Asset {
|
|
719
|
+
sys {
|
|
720
|
+
id
|
|
721
|
+
}
|
|
722
|
+
url
|
|
723
|
+
title
|
|
724
|
+
width
|
|
725
|
+
height
|
|
726
|
+
description
|
|
727
|
+
contentType
|
|
728
|
+
size
|
|
729
|
+
}
|
|
730
|
+
`;
|
|
731
|
+
const GQL_FRAGMENT_CONTENTFUL_IMAGE = gql `
|
|
732
|
+
fragment ImageData on Image {
|
|
733
|
+
sys {
|
|
734
|
+
id
|
|
735
|
+
}
|
|
736
|
+
asset {
|
|
737
|
+
...AssetData
|
|
738
|
+
}
|
|
739
|
+
alt
|
|
740
|
+
caption
|
|
741
|
+
resizeBehavior
|
|
742
|
+
focusArea
|
|
743
|
+
quality
|
|
744
|
+
__typename
|
|
745
|
+
}
|
|
746
|
+
`;
|
|
592
747
|
|
|
593
748
|
/**
|
|
594
749
|
* Generated bundle index. Do not edit.
|
|
595
750
|
*/
|
|
596
751
|
|
|
597
|
-
export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent,
|
|
752
|
+
export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulImports, ContentfulRichTextRendererComponent, ContentfulVideoComponent, GQL_FRAGMENT_CONTENTFUL_ASSET, GQL_FRAGMENT_CONTENTFUL_IMAGE, RICH_TEXT_RENDERER_COMPONENT_DATA, createContentfulConfig, createContentfulMap, createContentfulRenderCommand, createContentfulResourceMap, createRenderCommandsFromContentfulRichText, generateContentfulImageSources, generateDefaultContentfulImageSource, getContentfulNodeProps, isContentfulAsset, isContentfulImage, parseContentfulImageSize, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
|
|
598
753
|
//# sourceMappingURL=ethlete-contentful.mjs.map
|