@dotcms/angular 0.0.1-alpha.37 → 0.0.1-alpha.39

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.
Files changed (81) hide show
  1. package/.eslintrc.json +18 -0
  2. package/README.md +128 -78
  3. package/jest.config.ts +22 -0
  4. package/ng-package.json +7 -0
  5. package/package.json +4 -21
  6. package/project.json +33 -0
  7. package/{index.d.ts → src/index.ts} +0 -1
  8. package/src/lib/components/dot-editable-text/dot-editable-text.component.css +4 -0
  9. package/src/lib/components/dot-editable-text/dot-editable-text.component.html +8 -0
  10. package/src/lib/components/dot-editable-text/dot-editable-text.component.spec.ts +424 -0
  11. package/src/lib/components/dot-editable-text/dot-editable-text.component.ts +269 -0
  12. package/src/lib/components/dot-editable-text/utils.ts +51 -0
  13. package/src/lib/components/no-component/no-component.component.css +3 -0
  14. package/src/lib/components/no-component/no-component.component.spec.ts +24 -0
  15. package/src/lib/components/no-component/no-component.component.ts +31 -0
  16. package/src/lib/layout/column/column.component.css +99 -0
  17. package/src/lib/layout/column/column.component.spec.ts +33 -0
  18. package/src/lib/layout/column/column.component.ts +49 -0
  19. package/src/lib/layout/container/container.component.css +9 -0
  20. package/src/lib/layout/container/container.component.html +26 -0
  21. package/src/lib/layout/container/container.component.spec.ts +205 -0
  22. package/src/lib/layout/container/container.component.ts +140 -0
  23. package/src/lib/layout/contentlet/contentlet.component.spec.ts +22 -0
  24. package/src/lib/layout/contentlet/contentlet.component.ts +101 -0
  25. package/src/lib/layout/dotcms-layout/dotcms-layout.component.css +3 -0
  26. package/src/lib/layout/dotcms-layout/dotcms-layout.component.spec.ts +195 -0
  27. package/src/lib/layout/dotcms-layout/dotcms-layout.component.ts +150 -0
  28. package/src/lib/layout/row/row.component.css +6 -0
  29. package/src/lib/layout/row/row.component.spec.ts +28 -0
  30. package/src/lib/layout/row/row.component.ts +32 -0
  31. package/{lib/models/dotcms.model.d.ts → src/lib/models/dotcms.model.ts} +21 -3
  32. package/src/lib/models/index.ts +47 -0
  33. package/{lib/services/dotcms-context/page-context.service.d.ts → src/lib/services/dotcms-context/page-context.service.ts} +41 -12
  34. package/src/lib/services/dotcms-context/page-context.spec.ts +80 -0
  35. package/src/lib/utils/index.ts +92 -0
  36. package/src/lib/utils/testing.utils.ts +1019 -0
  37. package/src/test-setup.ts +8 -0
  38. package/tsconfig.json +29 -0
  39. package/tsconfig.lib.json +12 -0
  40. package/tsconfig.lib.prod.json +9 -0
  41. package/tsconfig.spec.json +11 -0
  42. package/dotcms-angular.d.ts.map +0 -1
  43. package/esm2022/dotcms-angular.mjs +0 -5
  44. package/esm2022/index.mjs +0 -5
  45. package/esm2022/lib/components/dot-editable-text/dot-editable-text.component.mjs +0 -225
  46. package/esm2022/lib/components/dot-editable-text/utils.mjs +0 -43
  47. package/esm2022/lib/components/no-component/no-component.component.mjs +0 -27
  48. package/esm2022/lib/layout/column/column.component.mjs +0 -33
  49. package/esm2022/lib/layout/container/container.component.mjs +0 -78
  50. package/esm2022/lib/layout/contentlet/contentlet.component.mjs +0 -65
  51. package/esm2022/lib/layout/dotcms-layout/dotcms-layout.component.mjs +0 -87
  52. package/esm2022/lib/layout/row/row.component.mjs +0 -23
  53. package/esm2022/lib/models/dotcms.model.mjs +0 -3
  54. package/esm2022/lib/models/index.mjs +0 -3
  55. package/esm2022/lib/services/dotcms-context/page-context.service.mjs +0 -75
  56. package/esm2022/lib/utils/index.mjs +0 -57
  57. package/fesm2022/dotcms-angular.mjs +0 -697
  58. package/fesm2022/dotcms-angular.mjs.map +0 -1
  59. package/index.d.ts.map +0 -1
  60. package/lib/components/dot-editable-text/dot-editable-text.component.d.ts +0 -129
  61. package/lib/components/dot-editable-text/dot-editable-text.component.d.ts.map +0 -1
  62. package/lib/components/dot-editable-text/utils.d.ts +0 -7
  63. package/lib/components/dot-editable-text/utils.d.ts.map +0 -1
  64. package/lib/components/no-component/no-component.component.d.ts +0 -13
  65. package/lib/components/no-component/no-component.component.d.ts.map +0 -1
  66. package/lib/layout/column/column.component.d.ts +0 -11
  67. package/lib/layout/column/column.component.d.ts.map +0 -1
  68. package/lib/layout/container/container.component.d.ts +0 -34
  69. package/lib/layout/container/container.component.d.ts.map +0 -1
  70. package/lib/layout/contentlet/contentlet.component.d.ts +0 -19
  71. package/lib/layout/contentlet/contentlet.component.d.ts.map +0 -1
  72. package/lib/layout/dotcms-layout/dotcms-layout.component.d.ts +0 -54
  73. package/lib/layout/dotcms-layout/dotcms-layout.component.d.ts.map +0 -1
  74. package/lib/layout/row/row.component.d.ts +0 -8
  75. package/lib/layout/row/row.component.d.ts.map +0 -1
  76. package/lib/models/dotcms.model.d.ts.map +0 -1
  77. package/lib/models/index.d.ts +0 -11
  78. package/lib/models/index.d.ts.map +0 -1
  79. package/lib/services/dotcms-context/page-context.service.d.ts.map +0 -1
  80. package/lib/utils/index.d.ts +0 -49
  81. package/lib/utils/index.d.ts.map +0 -1
package/.eslintrc.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": ["../../../.eslintrc.base.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
+ "rules": {}
8
+ },
9
+ {
10
+ "files": ["*.ts", "*.tsx"],
11
+ "rules": {}
12
+ },
13
+ {
14
+ "files": ["*.js", "*.jsx"],
15
+ "rules": {}
16
+ }
17
+ ]
18
+ }
package/README.md CHANGED
@@ -1,17 +1,31 @@
1
1
  # @dotcms/angular
2
2
 
3
- `@dotcms/angular` is the official set of Angular components, services and resolver designed to work seamlessly with dotCMS, making it easy to render dotCMS pages an use the page builder
3
+ `@dotcms/angular` is the official Angular library designed to work seamlessly with dotCMS. This library simplifies the process of rendering dotCMS pages and integrating with the [Universal Visual Editor](dotcms.com/docs/latest/universal-visual-editor) in your Angular applications.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Features](#features)
8
+ - [Installation](#installation)
9
+ - [Configuration](#provider-setup)
10
+ - [Provider Setup](#provider-setup)
11
+ - [Client Usage](#client-usage)
12
+ - [Components](#components)
13
+ - [DotcmsLayoutComponent](#dotcmslayoutcomponent)
14
+ - [Best Practices](#best-practices)
15
+ - [Troubleshooting](#troubleshooting)
16
+ - [Contributing](#contributing)
17
+ - [Licensing](#licensing)
4
18
 
5
19
  ## Features
6
20
 
7
- - A collection of Angular components, services and resolver tailored to render
8
- dotCMS pages.
9
- - Streamlined integration with dotCMS page editor.
10
- - Improved development experience with comprehensive TypeScript typings.
21
+ - A set of Angular components developer for dotCMS page rendering and editor integration.
22
+ - Enhanced development workflow with full TypeScript support.
23
+ - Optimized performance for efficient rendering of dotCMS pages in Angular applications.
24
+ - Flexible customization options to adapt to various project requirements.
11
25
 
12
26
  ## Installation
13
27
 
14
- Install the package via npm:
28
+ Install the package using npm:
15
29
 
16
30
  ```bash
17
31
  npm install @dotcms/angular
@@ -23,111 +37,147 @@ Or using Yarn:
23
37
  yarn add @dotcms/angular
24
38
  ```
25
39
 
26
- ## Provider
27
- ```
40
+ ## Configutarion
41
+ ### Provider Setup
42
+ We need to provide the information of our dotCMS instance
43
+
44
+ ```javascript
45
+
46
+ import { ClientConfig } from '@dotcms/client';
47
+
28
48
  const DOTCMS_CLIENT_CONFIG: ClientConfig = {
29
49
  dotcmsUrl: environment.dotcmsUrl,
30
50
  authToken: environment.authToken,
31
51
  siteId: environment.siteId
32
52
  };
33
53
  ```
34
- Add the dotcms config in the Angular app ApplicationConfig
35
- ```
54
+ And add this config in the Angular app ApplicationConfig.
55
+
56
+ `src/app/app.config.ts`
57
+ ```javascript
58
+ import { InjectionToken } from '@angular/core';
59
+ import { ClientConfig, DotCmsClient } from '@dotcms/client';
60
+
61
+ export const DOTCMS_CLIENT_TOKEN = new InjectionToken<DotCmsClient>('DOTCMS_CLIENT');
62
+
36
63
  export const appConfig: ApplicationConfig = {
37
64
  providers: [
38
- provideDotcmsClient(DOTCMS_CLIENT_CONFIG),
39
65
  provideRouter(routes),
66
+ {
67
+ provide: DOTCMS_CLIENT_TOKEN,
68
+ useValue: DotCmsClient.init(DOTCMS_CLIENT_CONFIG),
69
+ }
40
70
  ],
41
71
  };
42
72
  ```
43
- ## Resolver
44
- ```javascript
45
- export const routes: Routes = [
46
- {
47
- path: '**',
48
- resolve: {
49
- // This should be called `context`.
50
- context: DotCMSPageResolver,
51
- },
52
- component: DotCMSPagesComponent,
53
- runGuardsAndResolvers: 'always' // Run the resolver on every navigation. Even if the URL hasn't changed.
54
- },
55
- ];
56
- ```
73
+ This way, we will have access to `DOTCMS_CLIENT_TOKEN` from anywhere in our application.
57
74
 
58
- Then, in your component, you can read the data using
75
+ ### Client Usage
76
+ To interact with the client and obtain information from, for example, our pages
59
77
 
60
78
  ```javascript
61
- protected readonly context = signal(null);
62
-
63
- ngOnInit() {
64
- // Get the context data from the route
65
- this.route.data.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(data => {
66
- this.context.set(data['context']);
67
- });
68
- }
79
+ private readonly client = inject(DOTCMS_CLIENT_TOKEN);
80
+
81
+ this.client.page
82
+ .get({ ...pageParams })
83
+ .then((response) => {
84
+ // Use your response
85
+ })
86
+ .catch((e) => {
87
+ const error: PageError = {
88
+ message: e.message,
89
+ status: e.status,
90
+ };
91
+ // Use the error response
92
+ })
69
93
  ```
70
- ## Components
94
+ For more information to how to use DotCms Client, you can visit the [documentation](https://github.com/dotCMS/core/blob/master/core-web/libs/sdk/client/README.md)
71
95
 
72
- ### `DotcmsLayoutComponent`
96
+ ## DotCMS Page API
73
97
 
74
- A component that renders a layout for a dotCMS page.
98
+ The `DotcmsLayoutComponent` requires a `DotCMSPageAsset` object to be passed in to it. This object represents a dotCMS page and can be fetched using the `@dotcms/client` library.
75
99
 
76
- #### Inputs
100
+ - [DotCMS Official Angular Example](https://github.com/dotCMS/core/tree/master/examples/angular)
101
+ - [`@dotcms/client` documentation](https://www.npmjs.com/package/@dotcms/client)
102
+ - [Page API documentation](https://dotcms.com/docs/latest/page-api)
77
103
 
78
- - **entity**: The context for a dotCMS page.
79
- - **components**: An object with the relation of contentlets and the component to render each.
104
+ ## Components
80
105
 
106
+ ### DotcmsLayoutComponent
81
107
 
82
- #### Usage
108
+ The `DotcmsLayoutComponent` is a crucial component for rendering dotCMS page layouts in your Angular application.
83
109
 
84
- ```javascript
85
- <dotcms-layout [entity]="pageAsset" [components]="components()" />
86
-
87
- DYNAMIC_COMPONENTS: { [key: string]: DynamicComponentEntity } = {
88
- Activity: import('../pages/content-types/activity/activity.component').then(
89
- (c) => c.ActivityComponent,
90
- ),
91
- Banner: import('../pages/content-types/banner/banner.component').then(
92
- (c) => c.BannerComponent,
93
- ),
94
- Image: import('../pages/content-types/image/image.component').then(
95
- (c) => c.ImageComponent,
96
- ),
97
- webPageContent: import(
98
- '../pages/content-types/web-page-content/web-page-content.component'
99
- ).then((c) => c.WebPageContentComponent),
100
- Product: import('../pages/content-types/product/product.component').then(
101
- (c) => c.ProductComponent,
102
- ),
110
+ #### Inputs
111
+
112
+ | Name | Type | Description |
113
+ |--------------|----------------------|-----------------------------------------------------------------------|
114
+ | `pageAsset` | `DotCMSPageAsset` | The object representing a dotCMS page from PageAPI response. |
115
+ | `components` | `DotCMSPageComponent`| An object mapping contentlets to their respective render components. |
116
+ | `editor` | `EditorConfig` | Configuration for data fetching in Edit Mode. |
117
+
118
+ #### Usage Example
119
+
120
+ In your component file (e.g., `pages.component.ts`):
121
+
122
+ ```typescript
123
+ import { Component, signal } from '@angular/core';
124
+ import { DotCMSPageComponent, EditorConfig } from '@dotcms/angular';
125
+
126
+ @Component({
127
+ selector: 'app-pages',
128
+ templateUrl: './pages.component.html',
129
+ })
130
+ export class PagesComponent {
131
+ DYNAMIC_COMPONENTS: DotCMSPageComponent = {
132
+ Activity: import('../pages/content-types/activity/activity.component').then(
133
+ (c) => c.ActivityComponent
134
+ ),
135
+ Banner: import('../pages/content-types/banner/banner.component').then(
136
+ (c) => c.BannerComponent
137
+ ),
138
+ // Add other components as needed
103
139
  };
140
+
141
+ components = signal(this.DYNAMIC_COMPONENTS);
142
+ editorConfig = signal<EditorConfig>({ params: { depth: 2 } });
143
+
144
+ // Assume pageAsset is fetched or provided somehow
145
+ pageAsset: DotCMSPageAsset;
146
+ }
147
+ ```
104
148
 
105
- components = signal(DYNAMIC_COMPONENTS);
149
+ In your template file (e.g., `pages.component.html`):
150
+
151
+ ```html
152
+ <dotcms-layout
153
+ [pageAsset]="pageAsset"
154
+ [components]="components()"
155
+ [editor]="editorConfig()"
156
+ />
106
157
  ```
107
158
 
108
- ## Contributing
159
+ This setup allows for dynamic rendering of different content types on your dotCMS pages.
109
160
 
110
- GitHub pull requests are the preferred method to contribute code to dotCMS. Before any pull requests can be accepted, an automated tool will ask you to agree to the [dotCMS Contributor's Agreement](https://gist.github.com/wezell/85ef45298c48494b90d92755b583acb3).
161
+ ## Best Practices
111
162
 
112
- ## Licensing
163
+ 1. **Lazy Loading**: Use dynamic imports for components to improve initial load times.
164
+ 2. **Error Handling**: Implement robust error handling for API calls and component rendering.
165
+ 3. **Type Safety**: Leverage TypeScript's type system to ensure proper usage of dotCMS structures.
166
+ 4. **Performance Optimization**: Monitor and optimize the performance of rendered components.
113
167
 
114
- dotCMS comes in multiple editions and as such is dual licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds a number of enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://dotcms.com/cms-platform/features).
168
+ ## Troubleshooting
115
169
 
116
- ## Support
170
+ If you encounter issues:
117
171
 
118
- If you need help or have any questions, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository.
172
+ 1. Ensure all dependencies are correctly installed and up to date.
173
+ 2. Verify that your dotCMS configuration (URL, auth token, site ID) is correct.
174
+ 3. Check the browser console for any error messages.
175
+ 4. Refer to the [dotCMS documentation](https://dotcms.com/docs/) for additional guidance.
119
176
 
120
- ## Documentation
177
+ ## Contributing
121
178
 
122
- Always refer to the official [DotCMS documentation](https://www.dotcms.com/docs/latest/) for comprehensive guides and API references.
179
+ GitHub pull requests are the preferred method to contribute code to dotCMS. Before any pull requests can be accepted, an automated tool will ask you to agree to the [dotCMS Contributor's Agreement](https://gist.github.com/wezell/85ef45298c48494b90d92755b583acb3).
123
180
 
124
- ## Getting Help
181
+ ## Licensing
125
182
 
126
- | Source | Location |
127
- | --------------- | ------------------------------------------------------------------- |
128
- | Installation | [Installation](https://dotcms.com/docs/latest/installation) |
129
- | Documentation | [Documentation](https://dotcms.com/docs/latest/table-of-contents) |
130
- | Videos | [Helpful Videos](http://dotcms.com/videos/) |
131
- | Forums/Listserv | [via Google Groups](https://groups.google.com/forum/#!forum/dotCMS) |
132
- | Twitter | @dotCMS |
133
- | Main Site | [dotCMS.com](https://dotcms.com/) |
183
+ dotCMS comes in multiple editions and as such is dual licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds a number of enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://dotcms.com/cms-platform/features).
package/jest.config.ts ADDED
@@ -0,0 +1,22 @@
1
+ /* eslint-disable */
2
+ export default {
3
+ displayName: 'sdk-angular',
4
+ preset: '../../../jest.preset.js',
5
+ setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6
+ coverageDirectory: '../../../coverage/libs/sdk/angular',
7
+ transform: {
8
+ '^.+\\.(ts|mjs|js|html)$': [
9
+ 'jest-preset-angular',
10
+ {
11
+ tsconfig: '<rootDir>/tsconfig.spec.json',
12
+ stringifyContentPathRegex: '\\.(html|svg)$'
13
+ }
14
+ ]
15
+ },
16
+ transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17
+ snapshotSerializers: [
18
+ 'jest-preset-angular/build/serializers/no-ng-attributes',
19
+ 'jest-preset-angular/build/serializers/ng-snapshot',
20
+ 'jest-preset-angular/build/serializers/html-comment'
21
+ ]
22
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../../dist/libs/sdk/angular",
4
+ "lib": {
5
+ "entryFile": "src/index.ts"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dotcms/angular",
3
- "version": "0.0.1-alpha.37",
3
+ "version": "0.0.1-alpha.39",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^17.1.0",
6
6
  "@angular/core": "^17.1.0",
7
7
  "@angular/router": "^17.1.0",
8
- "@dotcms/client": "0.0.1-alpha.37",
8
+ "@dotcms/client": "0.0.1-alpha.39",
9
9
  "@tinymce/tinymce-angular": "^8.0.0",
10
10
  "rxjs": "^7.8.0"
11
11
  },
@@ -28,22 +28,5 @@
28
28
  "bugs": {
29
29
  "url": "https://github.com/dotCMS/core/issues"
30
30
  },
31
- "homepage": "https://github.com/dotCMS/core/tree/master/core-web/libs/sdk/angular/README.md",
32
- "module": "fesm2022/dotcms-angular.mjs",
33
- "typings": "index.d.ts",
34
- "exports": {
35
- "./package.json": {
36
- "default": "./package.json"
37
- },
38
- ".": {
39
- "types": "./index.d.ts",
40
- "esm2022": "./esm2022/dotcms-angular.mjs",
41
- "esm": "./esm2022/dotcms-angular.mjs",
42
- "default": "./fesm2022/dotcms-angular.mjs"
43
- }
44
- },
45
- "sideEffects": false,
46
- "dependencies": {
47
- "tslib": "^2.3.0"
48
- }
49
- }
31
+ "homepage": "https://github.com/dotCMS/core/tree/master/core-web/libs/sdk/angular/README.md"
32
+ }
package/project.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "sdk-angular",
3
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "libs/sdk/angular/src",
5
+ "prefix": "lib",
6
+ "tags": [],
7
+ "projectType": "library",
8
+ "targets": {
9
+ "build": {
10
+ "executor": "@nx/angular:package",
11
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12
+ "options": {
13
+ "project": "libs/sdk/angular/ng-package.json"
14
+ },
15
+ "configurations": {
16
+ "production": {
17
+ "tsConfig": "libs/sdk/angular/tsconfig.lib.prod.json"
18
+ },
19
+ "development": {
20
+ "tsConfig": "libs/sdk/angular/tsconfig.lib.json"
21
+ }
22
+ },
23
+ "defaultConfiguration": "production"
24
+ },
25
+ "test": {
26
+ "executor": "@nx/jest:jest",
27
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
28
+ "options": {
29
+ "jestConfig": "libs/sdk/angular/jest.config.ts"
30
+ }
31
+ }
32
+ }
33
+ }
@@ -2,4 +2,3 @@ export * from './lib/components/dot-editable-text/dot-editable-text.component';
2
2
  export * from './lib/layout/dotcms-layout/dotcms-layout.component';
3
3
  export * from './lib/services/dotcms-context/page-context.service';
4
4
  export * from './lib/models';
5
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ :host ::ng-deep .mce-content-body:not(.mce-edit-focus):hover {
2
+ outline: 2px solid #006ce7;
3
+ border-radius: 4px;
4
+ }
@@ -0,0 +1,8 @@
1
+ @if (isInsideEditor) {
2
+ <editor
3
+ #tinyEditor
4
+ [init]="init"
5
+ [initialValue]="content"
6
+ (onMouseDown)="onMouseDown($event)"
7
+ (onFocusOut)="onFocusOut()" />
8
+ }