@ethlete/contentful 3.9.0 → 4.0.0-next.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ethlete/contentful
|
|
2
2
|
|
|
3
|
+
## 4.0.0-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`d8f381f`](https://github.com/ethlete-io/ethdk/commit/d8f381f39710db99c2f26af64dbf9e4df75c8a49), [`ca6cdfb`](https://github.com/ethlete-io/ethdk/commit/ca6cdfbaa99430a89244024a8810249bb99e3d91), [`99b3f64`](https://github.com/ethlete-io/ethdk/commit/99b3f646701cb763512e7148592457dc509f55e5), [`d8f381f`](https://github.com/ethlete-io/ethdk/commit/d8f381f39710db99c2f26af64dbf9e4df75c8a49), [`5503fbb`](https://github.com/ethlete-io/ethdk/commit/5503fbb21d948d4e2d59928afa4be9846eb2102d), [`e4a7c6f`](https://github.com/ethlete-io/ethdk/commit/e4a7c6ff868e6dd541d4533e509b30821f6c83b5), [`d8f381f`](https://github.com/ethlete-io/ethdk/commit/d8f381f39710db99c2f26af64dbf9e4df75c8a49), [`d080bb2`](https://github.com/ethlete-io/ethdk/commit/d080bb2cc246d4559ffcbf88c319b9437133d377), [`ca6cdfb`](https://github.com/ethlete-io/ethdk/commit/ca6cdfbaa99430a89244024a8810249bb99e3d91), [`3d7f302`](https://github.com/ethlete-io/ethdk/commit/3d7f30253502adada00825fda3653441c01071da), [`ca6cdfb`](https://github.com/ethlete-io/ethdk/commit/ca6cdfbaa99430a89244024a8810249bb99e3d91), [`58678e9`](https://github.com/ethlete-io/ethdk/commit/58678e9d57f7ff85e2a3159657bda15f06b8e5cd), [`f5ad487`](https://github.com/ethlete-io/ethdk/commit/f5ad4879061917e91bebf144889774226202308b), [`27aa7a8`](https://github.com/ethlete-io/ethdk/commit/27aa7a825573a12c3360530d1d32df7c4690e7e8), [`3d7f302`](https://github.com/ethlete-io/ethdk/commit/3d7f30253502adada00825fda3653441c01071da), [`d8f381f`](https://github.com/ethlete-io/ethdk/commit/d8f381f39710db99c2f26af64dbf9e4df75c8a49), [`3d7f302`](https://github.com/ethlete-io/ethdk/commit/3d7f30253502adada00825fda3653441c01071da), [`6816054`](https://github.com/ethlete-io/ethdk/commit/68160548e8df8cd8fbaff61afa684442f7f7a7e5), [`ca6cdfb`](https://github.com/ethlete-io/ethdk/commit/ca6cdfbaa99430a89244024a8810249bb99e3d91), [`f4847d4`](https://github.com/ethlete-io/ethdk/commit/f4847d4eb25b70706a4ee8c81addcd58a7d99995), [`451e170`](https://github.com/ethlete-io/ethdk/commit/451e170f2df1c49fca07bde053efa75bd23ca22f), [`3d7f302`](https://github.com/ethlete-io/ethdk/commit/3d7f30253502adada00825fda3653441c01071da), [`f5ad487`](https://github.com/ethlete-io/ethdk/commit/f5ad4879061917e91bebf144889774226202308b), [`55dc627`](https://github.com/ethlete-io/ethdk/commit/55dc627a6a49f3a8a5c8f80f63f163e443e07099), [`ca6cdfb`](https://github.com/ethlete-io/ethdk/commit/ca6cdfbaa99430a89244024a8810249bb99e3d91), [`5d7ae57`](https://github.com/ethlete-io/ethdk/commit/5d7ae57859077357e2e8a1761286c4744e58d4b9), [`ee5014f`](https://github.com/ethlete-io/ethdk/commit/ee5014f33dc7d79b43774aaafc2fd187073871be), [`da0ef0a`](https://github.com/ethlete-io/ethdk/commit/da0ef0a6425c1ac40c42fd13906af49860418a29), [`7e0f4d9`](https://github.com/ethlete-io/ethdk/commit/7e0f4d943abe6ae61719fcb7003cc8c19496320e), [`d080bb2`](https://github.com/ethlete-io/ethdk/commit/d080bb2cc246d4559ffcbf88c319b9437133d377), [`3d7f302`](https://github.com/ethlete-io/ethdk/commit/3d7f30253502adada00825fda3653441c01071da), [`5e764b9`](https://github.com/ethlete-io/ethdk/commit/5e764b92cbcc6b6ec288a84b397d291f0b1138fb), [`d8f381f`](https://github.com/ethlete-io/ethdk/commit/d8f381f39710db99c2f26af64dbf9e4df75c8a49), [`e4a7c6f`](https://github.com/ethlete-io/ethdk/commit/e4a7c6ff868e6dd541d4533e509b30821f6c83b5), [`d8f381f`](https://github.com/ethlete-io/ethdk/commit/d8f381f39710db99c2f26af64dbf9e4df75c8a49), [`d8f381f`](https://github.com/ethlete-io/ethdk/commit/d8f381f39710db99c2f26af64dbf9e4df75c8a49), [`ca6cdfb`](https://github.com/ethlete-io/ethdk/commit/ca6cdfbaa99430a89244024a8810249bb99e3d91), [`6816054`](https://github.com/ethlete-io/ethdk/commit/68160548e8df8cd8fbaff61afa684442f7f7a7e5), [`6e41e09`](https://github.com/ethlete-io/ethdk/commit/6e41e09668d2077fba27de1e11bacc98480becfe), [`8a85984`](https://github.com/ethlete-io/ethdk/commit/8a859841acaf7c10c876c7eb921f4c7e25e41764), [`5e764b9`](https://github.com/ethlete-io/ethdk/commit/5e764b92cbcc6b6ec288a84b397d291f0b1138fb), [`d080bb2`](https://github.com/ethlete-io/ethdk/commit/d080bb2cc246d4559ffcbf88c319b9437133d377), [`e4a7c6f`](https://github.com/ethlete-io/ethdk/commit/e4a7c6ff868e6dd541d4533e509b30821f6c83b5), [`5e764b9`](https://github.com/ethlete-io/ethdk/commit/5e764b92cbcc6b6ec288a84b397d291f0b1138fb)]:
|
|
8
|
+
- @ethlete/cdk@5.0.0-next.0
|
|
9
|
+
- @ethlete/core@5.0.0-next.0
|
|
10
|
+
- @ethlete/query@6.0.0-next.0
|
|
11
|
+
|
|
3
12
|
## 3.9.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -136,7 +145,6 @@
|
|
|
136
145
|
### Major Changes
|
|
137
146
|
|
|
138
147
|
- [`ef63100`](https://github.com/ethlete-io/ethdk/commit/ef6310039b70c0321021a532b5818822518f47c6) Thanks [@TomTomB](https://github.com/TomTomB)! - The `rich-text-renderer` component was rebuild from scratch.
|
|
139
|
-
|
|
140
148
|
- The `richText` input was renamed to `content` and is required.
|
|
141
149
|
- The value of the `content` input should be a `ContentfulCollection` object. This can be directly fetched using the Contentful REST API. Do not use their GraphQL API for this purpose.
|
|
142
150
|
- A `richTextPath` input was added to allow for the customization of the path to the `richText` field in the `ContentfulCollection` object. It is required and should point to the start of the rich text object inside the `ContentfulCollection` object. The start contains a `nodeType` property with the value `document`.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { NgClass, DOCUMENT } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, InjectionToken, inject, numberAttribute, booleanAttribute, isDevMode, ViewContainerRef,
|
|
3
|
+
import { input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, InjectionToken, inject, numberAttribute, booleanAttribute, isDevMode, ViewContainerRef, ElementRef } from '@angular/core';
|
|
4
4
|
import { gql } from '@ethlete/query';
|
|
5
5
|
import { normalizePictureSizes, PictureComponent } from '@ethlete/cdk';
|
|
6
6
|
import { toSignal, toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
7
|
import { INLINES, BLOCKS } from '@contentful/rich-text-types';
|
|
8
|
-
import { RuntimeError, isObject, getObjectProperty } from '@ethlete/core';
|
|
8
|
+
import { RuntimeError, isObject, injectRenderer, getObjectProperty } from '@ethlete/core';
|
|
9
9
|
import { startWith, pairwise, tap } from 'rxjs';
|
|
10
10
|
|
|
11
11
|
const GQL_FRAGMENT_CONTENTFUL_ASSET = gql `
|
|
@@ -29,10 +29,10 @@ const isContentfulGqlAsset = (asset) => {
|
|
|
29
29
|
|
|
30
30
|
class ContentfulAudioComponent {
|
|
31
31
|
constructor() {
|
|
32
|
-
this.asset = input.required();
|
|
33
|
-
this.audioClass = input(null);
|
|
34
|
-
this.figureClass = input(null);
|
|
35
|
-
this.figcaptionClass = input(null);
|
|
32
|
+
this.asset = input.required(...(ngDevMode ? [{ debugName: "asset" }] : []));
|
|
33
|
+
this.audioClass = input(null, ...(ngDevMode ? [{ debugName: "audioClass" }] : []));
|
|
34
|
+
this.figureClass = input(null, ...(ngDevMode ? [{ debugName: "figureClass" }] : []));
|
|
35
|
+
this.figcaptionClass = input(null, ...(ngDevMode ? [{ debugName: "figcaptionClass" }] : []));
|
|
36
36
|
this.data = computed(() => {
|
|
37
37
|
const asset = this.asset();
|
|
38
38
|
if (!asset) {
|
|
@@ -48,10 +48,10 @@ class ContentfulAudioComponent {
|
|
|
48
48
|
url: asset.fields.file.url,
|
|
49
49
|
title: asset.fields.title,
|
|
50
50
|
};
|
|
51
|
-
});
|
|
51
|
+
}, ...(ngDevMode ? [{ debugName: "data" }] : []));
|
|
52
52
|
}
|
|
53
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
54
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
53
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
54
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: ContentfulAudioComponent, isStandalone: true, selector: "et-contentful-audio", inputs: { asset: { classPropertyName: "asset", publicName: "asset", isSignal: true, isRequired: true, transformFunction: null }, audioClass: { classPropertyName: "audioClass", publicName: "audioClass", isSignal: true, isRequired: false, transformFunction: null }, figureClass: { classPropertyName: "figureClass", publicName: "figureClass", isSignal: true, isRequired: false, transformFunction: null }, figcaptionClass: { classPropertyName: "figcaptionClass", publicName: "figcaptionClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
55
55
|
@if (data(); as data) {
|
|
56
56
|
<figure [ngClass]="figureClass()">
|
|
57
57
|
<figcaption [ngClass]="figcaptionClass()">{{ data.title }}</figcaption>
|
|
@@ -60,7 +60,7 @@ class ContentfulAudioComponent {
|
|
|
60
60
|
}
|
|
61
61
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
62
62
|
}
|
|
63
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
63
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
|
|
64
64
|
type: Component,
|
|
65
65
|
args: [{
|
|
66
66
|
selector: 'et-contentful-audio',
|
|
@@ -76,12 +76,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImpor
|
|
|
76
76
|
encapsulation: ViewEncapsulation.None,
|
|
77
77
|
imports: [NgClass],
|
|
78
78
|
}]
|
|
79
|
-
}] });
|
|
79
|
+
}], propDecorators: { asset: [{ type: i0.Input, args: [{ isSignal: true, alias: "asset", required: true }] }], audioClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "audioClass", required: false }] }], figureClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "figureClass", required: false }] }], figcaptionClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "figcaptionClass", required: false }] }] } });
|
|
80
80
|
|
|
81
81
|
class ContentfulFileComponent {
|
|
82
82
|
constructor() {
|
|
83
|
-
this.asset = input.required();
|
|
84
|
-
this.fileClass = input(null);
|
|
83
|
+
this.asset = input.required(...(ngDevMode ? [{ debugName: "asset" }] : []));
|
|
84
|
+
this.fileClass = input(null, ...(ngDevMode ? [{ debugName: "fileClass" }] : []));
|
|
85
85
|
this.data = computed(() => {
|
|
86
86
|
const asset = this.asset();
|
|
87
87
|
if (!asset) {
|
|
@@ -101,10 +101,10 @@ class ContentfulFileComponent {
|
|
|
101
101
|
size: asset.fields.file.details.size,
|
|
102
102
|
title: asset.fields.title,
|
|
103
103
|
};
|
|
104
|
-
});
|
|
104
|
+
}, ...(ngDevMode ? [{ debugName: "data" }] : []));
|
|
105
105
|
}
|
|
106
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
107
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
106
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
107
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: ContentfulFileComponent, isStandalone: true, selector: "et-contentful-file", inputs: { asset: { classPropertyName: "asset", publicName: "asset", isSignal: true, isRequired: true, transformFunction: null }, fileClass: { classPropertyName: "fileClass", publicName: "fileClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
108
108
|
@if (data(); as data) {
|
|
109
109
|
<a [href]="data.url" [ngClass]="fileClass()" class="underline" target="_blank">
|
|
110
110
|
{{ data.title }} ({{ data.size }} Bytes)
|
|
@@ -112,7 +112,7 @@ class ContentfulFileComponent {
|
|
|
112
112
|
}
|
|
113
113
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
114
114
|
}
|
|
115
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
115
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulFileComponent, decorators: [{
|
|
116
116
|
type: Component,
|
|
117
117
|
args: [{
|
|
118
118
|
selector: 'et-contentful-file',
|
|
@@ -127,7 +127,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImpor
|
|
|
127
127
|
encapsulation: ViewEncapsulation.None,
|
|
128
128
|
imports: [NgClass],
|
|
129
129
|
}]
|
|
130
|
-
}] });
|
|
130
|
+
}], propDecorators: { asset: [{ type: i0.Input, args: [{ isSignal: true, alias: "asset", required: true }] }], fileClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileClass", required: false }] }] } });
|
|
131
131
|
|
|
132
132
|
const CONTENTFUL_CONFIG = new InjectionToken('ContentfulConfig');
|
|
133
133
|
|
|
@@ -233,20 +233,18 @@ const generateContentfulImageSources = (data, srcsetSizes, backgroundColor, qual
|
|
|
233
233
|
class ContentfulImageComponent {
|
|
234
234
|
constructor() {
|
|
235
235
|
this._contentfulConfig = inject(CONTENTFUL_CONFIG);
|
|
236
|
-
this.asset = input.required();
|
|
237
|
-
this.backgroundColor = input(null);
|
|
238
|
-
this.srcsetSizes = input(this._contentfulConfig.imageOptions.srcsetSizes);
|
|
239
|
-
this.quality = input(null, { transform: numberAttribute });
|
|
240
|
-
this.focusArea = input(null);
|
|
241
|
-
this.resizeBehavior = input(null);
|
|
242
|
-
this.hasPriority = input(false, { transform: booleanAttribute });
|
|
243
|
-
this.imgClass = input(null);
|
|
244
|
-
this.figureClass = input(null);
|
|
245
|
-
this.figcaptionClass = input(null);
|
|
246
|
-
this.pictureClass = input(null);
|
|
247
|
-
this.sizes = input(normalizePictureSizes(this._contentfulConfig.imageOptions.sizes), {
|
|
248
|
-
transform: (v) => normalizePictureSizes(v),
|
|
249
|
-
});
|
|
236
|
+
this.asset = input.required(...(ngDevMode ? [{ debugName: "asset" }] : []));
|
|
237
|
+
this.backgroundColor = input(null, ...(ngDevMode ? [{ debugName: "backgroundColor" }] : []));
|
|
238
|
+
this.srcsetSizes = input(this._contentfulConfig.imageOptions.srcsetSizes, ...(ngDevMode ? [{ debugName: "srcsetSizes" }] : []));
|
|
239
|
+
this.quality = input(null, { ...(ngDevMode ? { debugName: "quality" } : {}), transform: numberAttribute });
|
|
240
|
+
this.focusArea = input(null, ...(ngDevMode ? [{ debugName: "focusArea" }] : []));
|
|
241
|
+
this.resizeBehavior = input(null, ...(ngDevMode ? [{ debugName: "resizeBehavior" }] : []));
|
|
242
|
+
this.hasPriority = input(false, { ...(ngDevMode ? { debugName: "hasPriority" } : {}), transform: booleanAttribute });
|
|
243
|
+
this.imgClass = input(null, ...(ngDevMode ? [{ debugName: "imgClass" }] : []));
|
|
244
|
+
this.figureClass = input(null, ...(ngDevMode ? [{ debugName: "figureClass" }] : []));
|
|
245
|
+
this.figcaptionClass = input(null, ...(ngDevMode ? [{ debugName: "figcaptionClass" }] : []));
|
|
246
|
+
this.pictureClass = input(null, ...(ngDevMode ? [{ debugName: "pictureClass" }] : []));
|
|
247
|
+
this.sizes = input(normalizePictureSizes(this._contentfulConfig.imageOptions.sizes), { ...(ngDevMode ? { debugName: "sizes" } : {}), transform: (v) => normalizePictureSizes(v) });
|
|
250
248
|
this.normalizedAsset = computed(() => {
|
|
251
249
|
const asset = this.asset();
|
|
252
250
|
if (isContentfulGqlAsset(asset)) {
|
|
@@ -265,7 +263,7 @@ class ContentfulImageComponent {
|
|
|
265
263
|
height: asset?.fields?.file?.details?.image?.height ?? null,
|
|
266
264
|
};
|
|
267
265
|
}
|
|
268
|
-
});
|
|
266
|
+
}, ...(ngDevMode ? [{ debugName: "normalizedAsset" }] : []));
|
|
269
267
|
this._sources = computed(() => {
|
|
270
268
|
const asset = this.asset();
|
|
271
269
|
const backgroundColor = this.backgroundColor();
|
|
@@ -277,14 +275,14 @@ class ContentfulImageComponent {
|
|
|
277
275
|
return [];
|
|
278
276
|
}
|
|
279
277
|
return generateContentfulImageSources(asset, srcsetSizes, backgroundColor, quality, focusArea, resizeBehavior);
|
|
280
|
-
});
|
|
278
|
+
}, ...(ngDevMode ? [{ debugName: "_sources" }] : []));
|
|
281
279
|
this._defaultSrc = computed(() => {
|
|
282
280
|
const asset = this.asset();
|
|
283
281
|
return asset ? generateDefaultContentfulImageSource(asset) : null;
|
|
284
|
-
});
|
|
282
|
+
}, ...(ngDevMode ? [{ debugName: "_defaultSrc" }] : []));
|
|
285
283
|
}
|
|
286
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
287
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
284
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
285
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.1", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { asset: { classPropertyName: "asset", publicName: "asset", isSignal: true, isRequired: true, transformFunction: null }, backgroundColor: { classPropertyName: "backgroundColor", publicName: "backgroundColor", isSignal: true, isRequired: false, transformFunction: null }, srcsetSizes: { classPropertyName: "srcsetSizes", publicName: "srcsetSizes", isSignal: true, isRequired: false, transformFunction: null }, quality: { classPropertyName: "quality", publicName: "quality", isSignal: true, isRequired: false, transformFunction: null }, focusArea: { classPropertyName: "focusArea", publicName: "focusArea", isSignal: true, isRequired: false, transformFunction: null }, resizeBehavior: { classPropertyName: "resizeBehavior", publicName: "resizeBehavior", isSignal: true, isRequired: false, transformFunction: null }, hasPriority: { classPropertyName: "hasPriority", publicName: "hasPriority", isSignal: true, isRequired: false, transformFunction: null }, imgClass: { classPropertyName: "imgClass", publicName: "imgClass", isSignal: true, isRequired: false, transformFunction: null }, figureClass: { classPropertyName: "figureClass", publicName: "figureClass", isSignal: true, isRequired: false, transformFunction: null }, figcaptionClass: { classPropertyName: "figcaptionClass", publicName: "figcaptionClass", isSignal: true, isRequired: false, transformFunction: null }, pictureClass: { classPropertyName: "pictureClass", publicName: "pictureClass", isSignal: true, isRequired: false, transformFunction: null }, sizes: { classPropertyName: "sizes", publicName: "sizes", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "et-contentful-image" }, ngImport: i0, template: `
|
|
288
286
|
<et-picture
|
|
289
287
|
[imgClass]="imgClass()"
|
|
290
288
|
[hasPriority]="hasPriority()"
|
|
@@ -301,7 +299,7 @@ class ContentfulImageComponent {
|
|
|
301
299
|
/>
|
|
302
300
|
`, isInline: true, dependencies: [{ kind: "component", type: PictureComponent, selector: "et-picture", inputs: ["sources", "hasPriority", "imgClass", "figureClass", "figcaptionClass", "pictureClass", "defaultSrc", "alt", "figcaption", "width", "height", "sizes"], outputs: ["imgLoaded", "imgError"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
303
301
|
}
|
|
304
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
302
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulImageComponent, decorators: [{
|
|
305
303
|
type: Component,
|
|
306
304
|
args: [{
|
|
307
305
|
selector: 'et-contentful-image',
|
|
@@ -328,12 +326,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImpor
|
|
|
328
326
|
class: 'et-contentful-image',
|
|
329
327
|
},
|
|
330
328
|
}]
|
|
331
|
-
}] });
|
|
329
|
+
}], propDecorators: { asset: [{ type: i0.Input, args: [{ isSignal: true, alias: "asset", required: true }] }], backgroundColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "backgroundColor", required: false }] }], srcsetSizes: [{ type: i0.Input, args: [{ isSignal: true, alias: "srcsetSizes", required: false }] }], quality: [{ type: i0.Input, args: [{ isSignal: true, alias: "quality", required: false }] }], focusArea: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusArea", required: false }] }], resizeBehavior: [{ type: i0.Input, args: [{ isSignal: true, alias: "resizeBehavior", required: false }] }], hasPriority: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasPriority", required: false }] }], imgClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "imgClass", required: false }] }], figureClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "figureClass", required: false }] }], figcaptionClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "figcaptionClass", required: false }] }], pictureClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "pictureClass", required: false }] }], sizes: [{ type: i0.Input, args: [{ isSignal: true, alias: "sizes", required: false }] }] } });
|
|
332
330
|
|
|
333
331
|
class ContentfulVideoComponent {
|
|
334
332
|
constructor() {
|
|
335
|
-
this.asset = input.required();
|
|
336
|
-
this.videoClass = input(null);
|
|
333
|
+
this.asset = input.required(...(ngDevMode ? [{ debugName: "asset" }] : []));
|
|
334
|
+
this.videoClass = input(null, ...(ngDevMode ? [{ debugName: "videoClass" }] : []));
|
|
337
335
|
this.data = computed(() => {
|
|
338
336
|
const asset = this.asset();
|
|
339
337
|
if (!asset) {
|
|
@@ -349,10 +347,10 @@ class ContentfulVideoComponent {
|
|
|
349
347
|
url: asset.fields.file.url,
|
|
350
348
|
contentType: asset.fields.file.contentType,
|
|
351
349
|
};
|
|
352
|
-
});
|
|
350
|
+
}, ...(ngDevMode ? [{ debugName: "data" }] : []));
|
|
353
351
|
}
|
|
354
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
355
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
352
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulVideoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
353
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: ContentfulVideoComponent, isStandalone: true, selector: "et-contentful-video", inputs: { asset: { classPropertyName: "asset", publicName: "asset", isSignal: true, isRequired: true, transformFunction: null }, videoClass: { classPropertyName: "videoClass", publicName: "videoClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
356
354
|
@if (data(); as data) {
|
|
357
355
|
<video [ngClass]="videoClass()" controls>
|
|
358
356
|
<source src="{{ data.url }}" type="{{ data.contentType }}" />
|
|
@@ -360,7 +358,7 @@ class ContentfulVideoComponent {
|
|
|
360
358
|
}
|
|
361
359
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
362
360
|
}
|
|
363
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
361
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
|
|
364
362
|
type: Component,
|
|
365
363
|
args: [{
|
|
366
364
|
selector: 'et-contentful-video',
|
|
@@ -375,7 +373,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImpor
|
|
|
375
373
|
encapsulation: ViewEncapsulation.None,
|
|
376
374
|
imports: [NgClass],
|
|
377
375
|
}]
|
|
378
|
-
}] });
|
|
376
|
+
}], propDecorators: { asset: [{ type: i0.Input, args: [{ isSignal: true, alias: "asset", required: true }] }], videoClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "videoClass", required: false }] }] } });
|
|
379
377
|
|
|
380
378
|
const createContentfulConfig = (config = {}) => ({
|
|
381
379
|
// This default config must be inline and not saved inside a const for some weird webpack reason
|
|
@@ -466,7 +464,7 @@ const translateContentfulNodeTypeToHtmlTag = (nodeType) => {
|
|
|
466
464
|
return 'span';
|
|
467
465
|
// Will be ignored by the renderer
|
|
468
466
|
case 'document':
|
|
469
|
-
return '
|
|
467
|
+
return 'div';
|
|
470
468
|
case BLOCKS.EMBEDDED_ENTRY:
|
|
471
469
|
return 'div';
|
|
472
470
|
case INLINES.EMBEDDED_ENTRY:
|
|
@@ -633,7 +631,7 @@ const createContentfulIncludeMap = (config) => {
|
|
|
633
631
|
class ContentfulRichTextRendererComponent {
|
|
634
632
|
constructor() {
|
|
635
633
|
this._viewContainerRef = inject(ViewContainerRef);
|
|
636
|
-
this._renderer =
|
|
634
|
+
this._renderer = injectRenderer();
|
|
637
635
|
this._elementRef = inject(ElementRef);
|
|
638
636
|
this._document = inject(DOCUMENT);
|
|
639
637
|
this._config = inject(CONTENTFUL_CONFIG, { optional: true }) ?? createContentfulConfig();
|
|
@@ -647,12 +645,12 @@ class ContentfulRichTextRendererComponent {
|
|
|
647
645
|
* The contentful response gotten via their REST api.
|
|
648
646
|
* @see https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entries-collection
|
|
649
647
|
*/
|
|
650
|
-
this.content = input.required();
|
|
648
|
+
this.content = input.required(...(ngDevMode ? [{ debugName: "content" }] : []));
|
|
651
649
|
/**
|
|
652
650
|
* The path to where the rich text field is inside the contentful response. Dot and array notation is allowed.
|
|
653
651
|
* @example "items[0].fields.html"
|
|
654
652
|
*/
|
|
655
|
-
this.richTextPath = input.required();
|
|
653
|
+
this.richTextPath = input.required(...(ngDevMode ? [{ debugName: "richTextPath" }] : []));
|
|
656
654
|
/**
|
|
657
655
|
* A map of all includes in the contentful response.
|
|
658
656
|
* This is useful for looking up assets and entries that are referenced in the rich text without having to use loops.
|
|
@@ -662,7 +660,7 @@ class ContentfulRichTextRendererComponent {
|
|
|
662
660
|
const assets = content?.includes.Asset;
|
|
663
661
|
const entries = content?.includes.Entry;
|
|
664
662
|
return createContentfulIncludeMap({ assets: assets ?? [], entries: entries ?? [] });
|
|
665
|
-
});
|
|
663
|
+
}, ...(ngDevMode ? [{ debugName: "contentIncludesMap" }] : []));
|
|
666
664
|
/**
|
|
667
665
|
* The rich text data that should be rendered.
|
|
668
666
|
*/
|
|
@@ -680,14 +678,14 @@ class ContentfulRichTextRendererComponent {
|
|
|
680
678
|
throw richTextRendererError('rich_text_wrong_type', false, { content, richTextPath });
|
|
681
679
|
}
|
|
682
680
|
return richText;
|
|
683
|
-
});
|
|
681
|
+
}, ...(ngDevMode ? [{ debugName: "richTextData" }] : []));
|
|
684
682
|
this.renderCommands = computed(() => {
|
|
685
683
|
const richTextData = this.richTextData();
|
|
686
684
|
if (!richTextData) {
|
|
687
685
|
return [];
|
|
688
686
|
}
|
|
689
687
|
return this._createRenderCommands(richTextData);
|
|
690
|
-
});
|
|
688
|
+
}, ...(ngDevMode ? [{ debugName: "renderCommands" }] : []));
|
|
691
689
|
this.renderCommandHistory = toSignal(toObservable(this.renderCommands).pipe(startWith([]), pairwise()), { initialValue: [[], []] });
|
|
692
690
|
this.previousRenderCommandMap = computed(() => {
|
|
693
691
|
const [prevCommands] = this.renderCommandHistory();
|
|
@@ -696,7 +694,7 @@ class ContentfulRichTextRendererComponent {
|
|
|
696
694
|
map.set(getRenderCommandId(command), command);
|
|
697
695
|
}
|
|
698
696
|
return map;
|
|
699
|
-
});
|
|
697
|
+
}, ...(ngDevMode ? [{ debugName: "previousRenderCommandMap" }] : []));
|
|
700
698
|
this.renderInstructions = computed(() => {
|
|
701
699
|
const commands = this.renderCommands();
|
|
702
700
|
const previousRenderCommandMap = new Map(this.previousRenderCommandMap());
|
|
@@ -762,7 +760,7 @@ class ContentfulRichTextRendererComponent {
|
|
|
762
760
|
}
|
|
763
761
|
}
|
|
764
762
|
return instructions;
|
|
765
|
-
});
|
|
763
|
+
}, ...(ngDevMode ? [{ debugName: "renderInstructions" }] : []));
|
|
766
764
|
toObservable(this.renderInstructions)
|
|
767
765
|
.pipe(takeUntilDestroyed(), tap((instructions) => {
|
|
768
766
|
this._execInstructions(instructions);
|
|
@@ -1088,7 +1086,9 @@ class ContentfulRichTextRendererComponent {
|
|
|
1088
1086
|
}
|
|
1089
1087
|
const rootNode = cached.element;
|
|
1090
1088
|
const oldParentElement = cached.element.parentElement;
|
|
1091
|
-
|
|
1089
|
+
if (oldParentElement) {
|
|
1090
|
+
this._renderer.removeChild(oldParentElement, rootNode);
|
|
1091
|
+
}
|
|
1092
1092
|
const newParentElement = this._findParent(command);
|
|
1093
1093
|
const nextElement = this._findFollowingElement(command);
|
|
1094
1094
|
this._renderInsertOrAppend(rootNode, newParentElement, nextElement);
|
|
@@ -1115,10 +1115,14 @@ class ContentfulRichTextRendererComponent {
|
|
|
1115
1115
|
cached.componentRef?.destroy();
|
|
1116
1116
|
}
|
|
1117
1117
|
else if (isTextRenderCommand(command)) {
|
|
1118
|
-
|
|
1118
|
+
if (cached.element?.parentElement) {
|
|
1119
|
+
this._renderer.removeChild(cached.element.parentElement, cached.element);
|
|
1120
|
+
}
|
|
1119
1121
|
}
|
|
1120
1122
|
else if (isHtmlOpenRenderCommand(command)) {
|
|
1121
|
-
|
|
1123
|
+
if (cached.element?.parentElement) {
|
|
1124
|
+
this._renderer.removeChild(cached.element.parentElement, cached.element);
|
|
1125
|
+
}
|
|
1122
1126
|
}
|
|
1123
1127
|
this._executedCommandsCache.delete(id);
|
|
1124
1128
|
}
|
|
@@ -1135,7 +1139,7 @@ class ContentfulRichTextRendererComponent {
|
|
|
1135
1139
|
_findParent(command) {
|
|
1136
1140
|
const hostElement = this._elementRef.nativeElement;
|
|
1137
1141
|
const nestingLevel = command[RENDER_COMMAND_POSITION.NESTING_LEVEL];
|
|
1138
|
-
let parentElement
|
|
1142
|
+
let parentElement;
|
|
1139
1143
|
if (nestingLevel === 0) {
|
|
1140
1144
|
parentElement = hostElement;
|
|
1141
1145
|
}
|
|
@@ -1194,22 +1198,21 @@ class ContentfulRichTextRendererComponent {
|
|
|
1194
1198
|
this._renderer.appendChild(parentElement, nodeToRender);
|
|
1195
1199
|
}
|
|
1196
1200
|
}
|
|
1197
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1198
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
1201
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1202
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.1", type: ContentfulRichTextRendererComponent, isStandalone: true, selector: "et-contentful-rich-text-renderer", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, richTextPath: { classPropertyName: "richTextPath", publicName: "richTextPath", isSignal: true, isRequired: true, transformFunction: null } }, host: { classAttribute: "et-contentful-rich-text-renderer" }, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
1199
1203
|
}
|
|
1200
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
|
|
1201
1205
|
type: Component,
|
|
1202
1206
|
args: [{
|
|
1203
1207
|
selector: 'et-contentful-rich-text-renderer',
|
|
1204
1208
|
template: ``,
|
|
1205
1209
|
encapsulation: ViewEncapsulation.None,
|
|
1206
1210
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1207
|
-
standalone: true,
|
|
1208
1211
|
host: {
|
|
1209
1212
|
class: 'et-contentful-rich-text-renderer',
|
|
1210
1213
|
},
|
|
1211
1214
|
}]
|
|
1212
|
-
}], ctorParameters: () => [] });
|
|
1215
|
+
}], ctorParameters: () => [], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: true }] }], richTextPath: [{ type: i0.Input, args: [{ isSignal: true, alias: "richTextPath", required: true }] }] } });
|
|
1213
1216
|
|
|
1214
1217
|
const ContentfulImports = [
|
|
1215
1218
|
ContentfulAudioComponent,
|