@dotcms/angular 1.6.0 → 1.7.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/README.md +84 -65
- package/fesm2022/dotcms-angular.mjs +501 -257
- package/fesm2022/dotcms-angular.mjs.map +1 -1
- package/lib/components/dotcms-block-editor-renderer/blocks/table.component.d.ts +6 -1
- package/lib/components/dotcms-block-editor-renderer/blocks/table.component.d.ts.map +1 -1
- package/lib/components/dotcms-block-editor-renderer/dotcms-block-editor-renderer.component.d.ts +9 -0
- package/lib/components/dotcms-block-editor-renderer/dotcms-block-editor-renderer.component.d.ts.map +1 -1
- package/lib/components/dotcms-block-editor-renderer-semantic/blocks/semantic-blocks.component.d.ts +40 -0
- package/lib/components/dotcms-block-editor-renderer-semantic/blocks/semantic-blocks.component.d.ts.map +1 -0
- package/lib/components/dotcms-block-editor-renderer-semantic/dotcms-block-editor-renderer-native.component.d.ts +73 -0
- package/lib/components/dotcms-block-editor-renderer-semantic/dotcms-block-editor-renderer-native.component.d.ts.map +1 -0
- package/lib/components/dotcms-editable-text/dotcms-editable-text.component.d.ts.map +1 -1
- package/lib/components/dotcms-layout-body/components/container/container.component.d.ts +1 -5
- package/lib/components/dotcms-layout-body/components/container/container.component.d.ts.map +1 -1
- package/lib/components/dotcms-layout-body/components/contentlet/contentlet.component.d.ts +6 -12
- package/lib/components/dotcms-layout-body/components/contentlet/contentlet.component.d.ts.map +1 -1
- package/lib/store/dotcms.store.d.ts +16 -1
- package/lib/store/dotcms.store.d.ts.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +1 -0
- package/public_api.d.ts.map +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)
|
|
@@ -17,7 +20,7 @@ The `@dotcms/angular` SDK is the DotCMS official Angular library. It empowers An
|
|
|
17
20
|
- [SDK Reference](#sdk-reference)
|
|
18
21
|
- [DotCMSLayoutBody](#dotcmslayoutbody)
|
|
19
22
|
- [DotCMSEditableText](#dotcmseditabletext)
|
|
20
|
-
- [
|
|
23
|
+
- [DotCMSBlockEditorRendererNative](#dotcmsblockeditorrenderernative)
|
|
21
24
|
- [DotCMSShowWhen](#dotcmsshowwhen)
|
|
22
25
|
- [DotCMSEditablePageService](#dotcmseditablepageservice)
|
|
23
26
|
- [Troubleshooting](#troubleshooting)
|
|
@@ -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,24 +539,30 @@ 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.
|
|
543
|
+
|
|
544
|
+
### DotCMSBlockEditorRendererNative
|
|
545
|
+
|
|
546
|
+
`DotCMSBlockEditorRendererNative` is the recommended renderer for [Block Editor](https://dev.dotcms.com/docs/block-editor) content. It emits **clean semantic HTML** — `<ul><li><p>…</p></li></ul>` — with no custom wrapper elements between semantic tags.
|
|
539
547
|
|
|
540
|
-
|
|
548
|
+
> The original `DotCMSBlockEditorRenderer` is deprecated and retained for backward compatibility. See the component's TSDoc and [`MIGRATION.md`](./MIGRATION.md#migrating-to-the-semantic-block-editor-renderer) for the migration path — it's a one-line swap.
|
|
541
549
|
|
|
542
|
-
|
|
550
|
+
#### Why it matters
|
|
551
|
+
|
|
552
|
+
The host element is the real semantic tag (`<ul>`, `<li>`, `<p>`, `<h1>`–`<h6>`, ...) and recursion is done through `ng-template` outlets that render as HTML comment nodes (invisible to the accessibility tree), so `<li>` stays a true DOM child of `<ul>` — the relationship the HTML spec and assistive technology require, and that accessibility scanners flag when broken. This applies inside table cells and grid columns too: `<td><ul><li>…` stays intact.
|
|
543
553
|
|
|
544
554
|
| Input | Type | Required | Description |
|
|
545
555
|
|-------------------|----------------------|----------|------------------------------------------------------------------------------------------------------------|
|
|
546
|
-
| `blocks` | `
|
|
547
|
-
| `customRenderers` | `CustomRenderer`
|
|
548
|
-
| `
|
|
549
|
-
| `style` | `
|
|
556
|
+
| `blocks` | `BlockEditorNode` | ✅ | The [Block Editor](https://dev.dotcms.com/docs/block-editor) content to render |
|
|
557
|
+
| `customRenderers` | `CustomRenderer` | ❌ | Custom rendering functions for specific [block types](https://dev.dotcms.com/docs/block-editor#BlockTypes) |
|
|
558
|
+
| `class` | `string` | ❌ | CSS class to apply to the container |
|
|
559
|
+
| `style` | `string \| Record<string, string>` | ❌ | Inline styles for the container |
|
|
550
560
|
|
|
551
561
|
#### Usage
|
|
552
562
|
|
|
553
563
|
```typescript
|
|
554
564
|
import { DotCMSBasicContentlet } from '@dotcms/types';
|
|
555
|
-
import {
|
|
565
|
+
import { DotCMSBlockEditorRendererNativeComponent } from '@dotcms/angular';
|
|
556
566
|
|
|
557
567
|
const CUSTOM_RENDERERS = {
|
|
558
568
|
customBlock: import('./custom-block.component').then((c) => c.CustomBlockComponent),
|
|
@@ -561,9 +571,9 @@ const CUSTOM_RENDERERS = {
|
|
|
561
571
|
|
|
562
572
|
@Component({
|
|
563
573
|
selector: 'app-your-component',
|
|
564
|
-
imports: [
|
|
574
|
+
imports: [DotCMSBlockEditorRendererNativeComponent],
|
|
565
575
|
template: `
|
|
566
|
-
<dotcms-block-editor-renderer
|
|
576
|
+
<dotcms-block-editor-renderer-native
|
|
567
577
|
[blocks]="contentlet.myBlockEditorField"
|
|
568
578
|
[customRenderers]="customRenderers()" />
|
|
569
579
|
`
|
|
@@ -576,12 +586,8 @@ export class MyBannerComponent {
|
|
|
576
586
|
|
|
577
587
|
#### Recommendations
|
|
578
588
|
|
|
579
|
-
- Should not be used with [`DotCMSEditableText`](#dotcmseditabletext)
|
|
580
|
-
-
|
|
581
|
-
- `DotCMSBlockEditorRenderer` only works with [Block Editor fields](https://dev.dotcms.com/docs/block-editor). For other fields, use [`DotCMSEditableText`](#dotcmseditabletext).
|
|
582
|
-
|
|
583
|
-
📘 For advanced examples, customization options, and best practices, refer to the [DotCMSBlockEditorRenderer README](https://github.com/dotCMS/core/tree/master/core-web/libs/sdk/angular/src/lib/components/DotCMSBlockEditorRenderer).
|
|
584
|
-
|
|
589
|
+
- Should not be used with [`DotCMSEditableText`](#dotcmseditabletext).
|
|
590
|
+
- Keep in mind that the CSS cascade can affect the look and feel of your blocks.
|
|
585
591
|
|
|
586
592
|
### DotCMSShowWhen
|
|
587
593
|
|
|
@@ -594,20 +600,24 @@ export class MyBannerComponent {
|
|
|
594
600
|
#### Usage
|
|
595
601
|
|
|
596
602
|
```typescript
|
|
603
|
+
import { Component } from '@angular/core';
|
|
604
|
+
|
|
605
|
+
import { DotCMSShowWhenDirective } from '@dotcms/angular';
|
|
597
606
|
import { UVE_MODE } from '@dotcms/types';
|
|
598
|
-
import { DotCMSShowWhen } from '@dotcms/angular';
|
|
599
607
|
|
|
600
608
|
@Component({
|
|
601
609
|
selector: 'app-your-component',
|
|
602
|
-
imports: [
|
|
610
|
+
imports: [DotCMSShowWhenDirective],
|
|
603
611
|
template: `
|
|
604
|
-
<div *dotCMSShowWhen="
|
|
612
|
+
<div *dotCMSShowWhen="uveMode.EDIT">Only visible in edit mode</div>
|
|
605
613
|
`
|
|
606
614
|
})
|
|
607
|
-
export class YourComponent {
|
|
615
|
+
export class YourComponent {
|
|
616
|
+
readonly uveMode = UVE_MODE;
|
|
617
|
+
}
|
|
608
618
|
```
|
|
609
619
|
|
|
610
|
-
📚 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).
|
|
611
621
|
|
|
612
622
|
### DotCMSEditablePageService
|
|
613
623
|
|
|
@@ -639,14 +649,22 @@ import { Component, OnDestroy, OnInit, signal, inject } from '@angular/core';
|
|
|
639
649
|
|
|
640
650
|
import { getUVEState } from '@dotcms/uve';
|
|
641
651
|
import { DotCMSPageAsset } from '@dotcms/types';
|
|
642
|
-
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
|
+
};
|
|
643
661
|
|
|
644
662
|
@Component({
|
|
645
|
-
imports: [
|
|
663
|
+
imports: [DotCMSLayoutBodyComponent],
|
|
646
664
|
providers: [DotCMSEditablePageService],
|
|
647
665
|
template: `
|
|
648
666
|
@if (pageAsset()) {
|
|
649
|
-
<dotcms-layout-body [page]="pageAsset()" [components]="components()" />
|
|
667
|
+
<dotcms-layout-body [page]="pageAsset()!" [components]="components()" />
|
|
650
668
|
} @else {
|
|
651
669
|
<div>Loading...</div>
|
|
652
670
|
}
|
|
@@ -654,12 +672,13 @@ import { DotCMSLayoutBody, DotCMSEditablePageService, DotCMSClient } from '@dotc
|
|
|
654
672
|
})
|
|
655
673
|
export class PageComponent implements OnInit, OnDestroy {
|
|
656
674
|
private subscription?: Subscription;
|
|
657
|
-
private readonly dotCMSClient = inject(
|
|
675
|
+
private readonly dotCMSClient = inject(DotCMSClient);
|
|
658
676
|
private readonly editablePageService = inject(DotCMSEditablePageService);
|
|
677
|
+
readonly components = signal(DYNAMIC_COMPONENTS);
|
|
659
678
|
readonly pageAsset = signal<DotCMSPageAsset | null>(null);
|
|
660
679
|
|
|
661
680
|
ngOnInit() {
|
|
662
|
-
this.dotCMSClient.page.get(
|
|
681
|
+
this.dotCMSClient.page.get('/about-us').then((pageResponse) => {
|
|
663
682
|
// Only subscribe to changes when in the editor
|
|
664
683
|
if (getUVEState()) {
|
|
665
684
|
this.subscription = this.editablePageService
|
|
@@ -779,7 +798,7 @@ We offer multiple channels to get help with the dotCMS Angular SDK:
|
|
|
779
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.
|
|
780
799
|
- **Community Forum**: Join our [community discussions](https://community.dotcms.com/) to ask questions and share solutions.
|
|
781
800
|
- **Stack Overflow**: Use the tag `dotcms-angular` when posting questions.
|
|
782
|
-
- **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).
|
|
783
802
|
|
|
784
803
|
When reporting issues, please include:
|
|
785
804
|
|
|
@@ -844,8 +863,8 @@ provideDotCMSClient({
|
|
|
844
863
|
|
|
845
864
|
## Licensing
|
|
846
865
|
|
|
847
|
-
dotCMS
|
|
866
|
+
dotCMS is available under either the [Business Source License 1.1 (BSL)](https://www.dotcms.com/bsl) or a commercial license.
|
|
848
867
|
|
|
849
|
-
|
|
868
|
+
Under the BSL, dotCMS can be used at no cost by individual developers, small businesses or agencies under $5M in total finances, and by larger organizations in non-production environments. Every BSL release automatically converts to GPL v3 four years after its release date. For full terms and FAQs, visit [dotcms.com/bsl](https://www.dotcms.com/bsl) and [dotcms.com/bsl-faq](https://www.dotcms.com/bsl-faq).
|
|
850
869
|
|
|
851
|
-
|
|
870
|
+
Production use in larger organizations, along with access to managed cloud, SLAs, support, and enterprise capabilities, is available under a commercial license from dotCMS. For details on commercial plans, features, and support options, see [dotcms.com/pricing](https://www.dotcms.com/pricing).
|