@dotcms/angular 1.5.5-next.2180 → 1.5.5-next.2245
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/README.md +64 -47
- package/fesm2022/dotcms-angular.mjs +144 -144
- package/fesm2022/dotcms-angular.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# dotCMS Angular SDK
|
|
2
2
|
|
|
3
|
-
The `@dotcms/angular` SDK is the
|
|
3
|
+
The `@dotcms/angular` SDK is the official dotCMS Angular library. It empowers Angular developers to build powerful, editable websites and applications in no time.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
- [Prerequisites & Setup](#prerequisites--setup)
|
|
8
|
-
- [dotCMS
|
|
9
|
-
- [Create a dotCMS API Key](#create-a-dotcms-api-key)
|
|
8
|
+
- [Get a dotCMS Environment](#get-a-dotcms-environment)
|
|
10
9
|
- [Configure The Universal Visual Editor App](#configure-the-universal-visual-editor-app)
|
|
10
|
+
- [Create a dotCMS API Key](#create-a-dotcms-api-key)
|
|
11
11
|
- [Installation](#installation)
|
|
12
|
-
|
|
12
|
+
- [Configuration](#configuration)
|
|
13
|
+
- [Basic Configuration](#basic-configuration)
|
|
14
|
+
- [Custom HTTP Client Configuration](#custom-http-client-configuration)
|
|
15
|
+
- [Using the Client](#using-the-client)
|
|
13
16
|
- [Proxy Configuration for Static Assets](#proxy-configuration-for-static-assets)
|
|
14
17
|
- [Using dotCMS Images with Angular's `NgOptimizedImage` Directive (Recommended)](#using-dotcms-images-with-angulars-ngoptimizedimage-directive-recommended)
|
|
15
18
|
- [Quickstart: Render a Page with dotCMS](#quickstart-render-a-page-with-dotcms)
|
|
@@ -160,7 +163,7 @@ export class MyComponent {
|
|
|
160
163
|
|
|
161
164
|
ngOnInit() {
|
|
162
165
|
this.dotcmsClient.page
|
|
163
|
-
.get(
|
|
166
|
+
.get('/about-us')
|
|
164
167
|
.then(({ pageAsset }) => {
|
|
165
168
|
console.log(pageAsset);
|
|
166
169
|
});
|
|
@@ -345,13 +348,15 @@ The following example demonstrates how to quickly set up a basic dotCMS page ren
|
|
|
345
348
|
|
|
346
349
|
```typescript
|
|
347
350
|
// /src/app/pages/dotcms-page.component.ts
|
|
348
|
-
import { Component, signal } from '@angular/core';
|
|
351
|
+
import { Component, inject, OnInit, signal } from '@angular/core';
|
|
349
352
|
|
|
350
|
-
import {
|
|
353
|
+
import {
|
|
354
|
+
DotCMSClient,
|
|
355
|
+
DotCMSEditablePageService,
|
|
356
|
+
DotCMSLayoutBodyComponent
|
|
357
|
+
} from '@dotcms/angular';
|
|
351
358
|
import { getUVEState } from '@dotcms/uve';
|
|
352
|
-
import { DotCMSPageAsset } from '@dotcms/types';
|
|
353
|
-
|
|
354
|
-
import { DOTCMS_CLIENT_TOKEN } from './app.config';
|
|
359
|
+
import { DotCMSPageAsset, DotCMSPageResponse } from '@dotcms/types';
|
|
355
360
|
|
|
356
361
|
const DYNAMIC_COMPONENTS = {
|
|
357
362
|
Blog: import('./blog.component').then(c => c.BlogComponent),
|
|
@@ -361,12 +366,12 @@ const DYNAMIC_COMPONENTS = {
|
|
|
361
366
|
@Component({
|
|
362
367
|
selector: 'app-pages',
|
|
363
368
|
standalone: true,
|
|
364
|
-
imports: [
|
|
365
|
-
providers: [DotCMSEditablePageService
|
|
369
|
+
imports: [DotCMSLayoutBodyComponent],
|
|
370
|
+
providers: [DotCMSEditablePageService],
|
|
366
371
|
template: `
|
|
367
372
|
@if (pageAsset()) {
|
|
368
373
|
<dotcms-layout-body
|
|
369
|
-
[
|
|
374
|
+
[page]="pageAsset()!"
|
|
370
375
|
[components]="components()"
|
|
371
376
|
/>
|
|
372
377
|
} @else {
|
|
@@ -374,29 +379,29 @@ const DYNAMIC_COMPONENTS = {
|
|
|
374
379
|
}
|
|
375
380
|
`
|
|
376
381
|
})
|
|
377
|
-
export class PagesComponent {
|
|
378
|
-
private readonly dotCMSClient
|
|
382
|
+
export class PagesComponent implements OnInit {
|
|
383
|
+
private readonly dotCMSClient = inject(DotCMSClient);
|
|
379
384
|
private readonly editablePageService = inject(DotCMSEditablePageService);
|
|
380
385
|
readonly components = signal(DYNAMIC_COMPONENTS);
|
|
381
386
|
readonly pageAsset = signal<DotCMSPageAsset | null>(null);
|
|
382
387
|
|
|
383
388
|
ngOnInit() {
|
|
384
389
|
this.dotCMSClient.page
|
|
385
|
-
.get(
|
|
386
|
-
.then((
|
|
387
|
-
if(getUVEState()) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
390
|
+
.get('/my-page')
|
|
391
|
+
.then((pageResponse) => {
|
|
392
|
+
if (getUVEState()) {
|
|
393
|
+
this.#subscribeToPageUpdates(pageResponse);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
391
396
|
|
|
392
|
-
this.pageAsset.set(pageAsset);
|
|
397
|
+
this.pageAsset.set(pageResponse.pageAsset);
|
|
393
398
|
});
|
|
394
399
|
}
|
|
395
400
|
|
|
396
|
-
#subscribeToPageUpdates(
|
|
401
|
+
#subscribeToPageUpdates(pageResponse: DotCMSPageResponse) {
|
|
397
402
|
this.editablePageService
|
|
398
|
-
.listen(
|
|
399
|
-
.subscribe({ pageAsset } => this.pageAsset.set(pageAsset));
|
|
403
|
+
.listen(pageResponse)
|
|
404
|
+
.subscribe(({ pageAsset }) => this.pageAsset.set(pageAsset));
|
|
400
405
|
}
|
|
401
406
|
}
|
|
402
407
|
```
|
|
@@ -433,26 +438,25 @@ All components, directives, and services should be imported from `@dotcms/angula
|
|
|
433
438
|
#### Usage
|
|
434
439
|
|
|
435
440
|
```typescript
|
|
436
|
-
import { Component, signal } from '@angular/core';
|
|
441
|
+
import { Component, inject, OnInit, signal } from '@angular/core';
|
|
437
442
|
import { DotCMSPageAsset } from '@dotcms/types';
|
|
438
|
-
import {
|
|
439
|
-
|
|
440
|
-
import { DOTCMS_CLIENT_TOKEN } from './app.config';
|
|
443
|
+
import { DotCMSClient, DotCMSLayoutBodyComponent } from '@dotcms/angular';
|
|
441
444
|
|
|
442
445
|
@Component({
|
|
446
|
+
imports: [DotCMSLayoutBodyComponent],
|
|
443
447
|
template: `
|
|
444
|
-
<dotcms-layout-body [page]="pageAsset()" [components]="components()" mode="development" />
|
|
448
|
+
<dotcms-layout-body [page]="pageAsset()!" [components]="components()" mode="development" />
|
|
445
449
|
`
|
|
446
450
|
})
|
|
447
|
-
export class MyPageComponent {
|
|
451
|
+
export class MyPageComponent implements OnInit {
|
|
448
452
|
protected readonly components = signal({
|
|
449
453
|
Blog: import('./blog.component').then((c) => c.BlogComponent)
|
|
450
454
|
});
|
|
451
455
|
protected readonly pageAsset = signal<DotCMSPageAsset | null>(null);
|
|
452
|
-
private readonly dotCMSClient = inject(
|
|
456
|
+
private readonly dotCMSClient = inject(DotCMSClient);
|
|
453
457
|
|
|
454
458
|
ngOnInit() {
|
|
455
|
-
this.dotCMSClient.page.get(
|
|
459
|
+
this.dotCMSClient.page.get('/my-page').then(({ pageAsset }) => {
|
|
456
460
|
this.pageAsset.set(pageAsset);
|
|
457
461
|
});
|
|
458
462
|
}
|
|
@@ -491,7 +495,7 @@ const DYNAMIC_COMPONENTS = {
|
|
|
491
495
|
|--------------|---------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
492
496
|
| `contentlet` | `T extends DotCMSBasicContentlet` | ✅ | The contentlet containing the editable field |
|
|
493
497
|
| `fieldName` | `keyof T` | ✅ | Name of the field to edit, which must be a valid key of the contentlet type `T` |
|
|
494
|
-
| `mode` | `'plain' \| 'full'` | ❌ | `plain` (default):
|
|
498
|
+
| `mode` | `'plain' \| 'full'` | ❌ | `plain` (default): Supports text editing. Does not show style controls. <br/> `full`: Enables a bubble menu with style options. This mode only works with [`WYSIWYG` fields](https://dev.dotcms.com/docs/the-wysiwyg-field). |
|
|
495
499
|
| `format` | `'text' \| 'html'` | ❌ | `text` (default): Renders HTML tags as plain text <br/> `html`: Interprets and renders HTML markup |
|
|
496
500
|
|
|
497
501
|
#### Usage
|
|
@@ -535,7 +539,7 @@ export class MyBannerComponent {
|
|
|
535
539
|
#### Editor Integration
|
|
536
540
|
|
|
537
541
|
- Detects UVE edit mode and enables inline TinyMCE editing
|
|
538
|
-
- Triggers a `Save` [workflow action](https://dev.dotcms.com/docs/workflows) on blur without needing full content dialog.
|
|
542
|
+
- Triggers a `Save` [workflow action](https://dev.dotcms.com/docs/workflows) on blur without needing the full content dialog.
|
|
539
543
|
|
|
540
544
|
### DotCMSBlockEditorRendererNative
|
|
541
545
|
|
|
@@ -583,7 +587,7 @@ export class MyBannerComponent {
|
|
|
583
587
|
#### Recommendations
|
|
584
588
|
|
|
585
589
|
- Should not be used with [`DotCMSEditableText`](#dotcmseditabletext).
|
|
586
|
-
-
|
|
590
|
+
- Keep in mind that the CSS cascade can affect the look and feel of your blocks.
|
|
587
591
|
|
|
588
592
|
### DotCMSShowWhen
|
|
589
593
|
|
|
@@ -596,20 +600,24 @@ export class MyBannerComponent {
|
|
|
596
600
|
#### Usage
|
|
597
601
|
|
|
598
602
|
```typescript
|
|
603
|
+
import { Component } from '@angular/core';
|
|
604
|
+
|
|
605
|
+
import { DotCMSShowWhenDirective } from '@dotcms/angular';
|
|
599
606
|
import { UVE_MODE } from '@dotcms/types';
|
|
600
|
-
import { DotCMSShowWhen } from '@dotcms/angular';
|
|
601
607
|
|
|
602
608
|
@Component({
|
|
603
609
|
selector: 'app-your-component',
|
|
604
|
-
imports: [
|
|
610
|
+
imports: [DotCMSShowWhenDirective],
|
|
605
611
|
template: `
|
|
606
|
-
<div *dotCMSShowWhen="
|
|
612
|
+
<div *dotCMSShowWhen="uveMode.EDIT">Only visible in edit mode</div>
|
|
607
613
|
`
|
|
608
614
|
})
|
|
609
|
-
export class YourComponent {
|
|
615
|
+
export class YourComponent {
|
|
616
|
+
readonly uveMode = UVE_MODE;
|
|
617
|
+
}
|
|
610
618
|
```
|
|
611
619
|
|
|
612
|
-
📚 Learn more about the `UVE_MODE` enum in the [dotCMS UVE Package Documentation](https://dev.dotcms.com/docs/
|
|
620
|
+
📚 Learn more about the `UVE_MODE` enum in the [dotCMS UVE Package Documentation](https://dev.dotcms.com/docs/universal-visual-editor).
|
|
613
621
|
|
|
614
622
|
### DotCMSEditablePageService
|
|
615
623
|
|
|
@@ -641,14 +649,22 @@ import { Component, OnDestroy, OnInit, signal, inject } from '@angular/core';
|
|
|
641
649
|
|
|
642
650
|
import { getUVEState } from '@dotcms/uve';
|
|
643
651
|
import { DotCMSPageAsset } from '@dotcms/types';
|
|
644
|
-
import {
|
|
652
|
+
import {
|
|
653
|
+
DotCMSClient,
|
|
654
|
+
DotCMSEditablePageService,
|
|
655
|
+
DotCMSLayoutBodyComponent
|
|
656
|
+
} from '@dotcms/angular';
|
|
657
|
+
|
|
658
|
+
const DYNAMIC_COMPONENTS = {
|
|
659
|
+
Blog: import('./blog.component').then((c) => c.BlogComponent)
|
|
660
|
+
};
|
|
645
661
|
|
|
646
662
|
@Component({
|
|
647
|
-
imports: [
|
|
663
|
+
imports: [DotCMSLayoutBodyComponent],
|
|
648
664
|
providers: [DotCMSEditablePageService],
|
|
649
665
|
template: `
|
|
650
666
|
@if (pageAsset()) {
|
|
651
|
-
<dotcms-layout-body [page]="pageAsset()" [components]="components()" />
|
|
667
|
+
<dotcms-layout-body [page]="pageAsset()!" [components]="components()" />
|
|
652
668
|
} @else {
|
|
653
669
|
<div>Loading...</div>
|
|
654
670
|
}
|
|
@@ -656,12 +672,13 @@ import { DotCMSLayoutBody, DotCMSEditablePageService, DotCMSClient } from '@dotc
|
|
|
656
672
|
})
|
|
657
673
|
export class PageComponent implements OnInit, OnDestroy {
|
|
658
674
|
private subscription?: Subscription;
|
|
659
|
-
private readonly dotCMSClient = inject(
|
|
675
|
+
private readonly dotCMSClient = inject(DotCMSClient);
|
|
660
676
|
private readonly editablePageService = inject(DotCMSEditablePageService);
|
|
677
|
+
readonly components = signal(DYNAMIC_COMPONENTS);
|
|
661
678
|
readonly pageAsset = signal<DotCMSPageAsset | null>(null);
|
|
662
679
|
|
|
663
680
|
ngOnInit() {
|
|
664
|
-
this.dotCMSClient.page.get(
|
|
681
|
+
this.dotCMSClient.page.get('/about-us').then((pageResponse) => {
|
|
665
682
|
// Only subscribe to changes when in the editor
|
|
666
683
|
if (getUVEState()) {
|
|
667
684
|
this.subscription = this.editablePageService
|
|
@@ -781,7 +798,7 @@ We offer multiple channels to get help with the dotCMS Angular SDK:
|
|
|
781
798
|
- **GitHub Issues**: For bug reports and feature requests, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository.
|
|
782
799
|
- **Community Forum**: Join our [community discussions](https://community.dotcms.com/) to ask questions and share solutions.
|
|
783
800
|
- **Stack Overflow**: Use the tag `dotcms-angular` when posting questions.
|
|
784
|
-
- **Enterprise Support**: Enterprise customers can access premium support through the [dotCMS Support Portal](https://
|
|
801
|
+
- **Enterprise Support**: Enterprise customers can access premium support through the [dotCMS Support Portal](https://www.dotcms.com/support).
|
|
785
802
|
|
|
786
803
|
When reporting issues, please include:
|
|
787
804
|
|