-
Notifications
You must be signed in to change notification settings - Fork 480
Expand file tree
/
Copy pathapp.module.ts
More file actions
79 lines (69 loc) · 2.26 KB
/
Copy pathapp.module.ts
File metadata and controls
79 lines (69 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';
import { firstValueFrom } from 'rxjs';
import { provideHttpClient } from '@angular/common/http';
import {
DoBootstrap,
inject,
Injector,
NgModule,
provideAppInitializer,
Type
} from '@angular/core';
import { createCustomElement } from '@angular/elements';
import { BrowserModule } from '@angular/platform-browser';
import { provideAnimations } from '@angular/platform-browser/animations';
import {
DotMessageService,
DotUploadService,
DotWorkflowActionsFireService
} from '@dotcms/data-access';
import { DotBinaryFieldCeBridgeComponent } from '@dotcms/edit-content';
import { provideDotCMSTheme } from '@dotcms/ui';
import { AppComponent } from './app.component';
interface ContenttypeFieldElement {
tag: string;
component: Type<DotBinaryFieldCeBridgeComponent>;
}
const CONTENTTYPE_FIELDS: ContenttypeFieldElement[] = [
{
tag: 'dotcms-binary-field',
component: DotBinaryFieldCeBridgeComponent
}
];
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, DotBinaryFieldCeBridgeComponent, MonacoEditorModule],
providers: [
provideHttpClient(),
provideAnimations(),
DotMessageService,
DotUploadService,
DotWorkflowActionsFireService,
provideDotCMSTheme(),
provideAppInitializer(() => {
const dotMessageService = inject(DotMessageService);
return firstValueFrom(dotMessageService.init());
})
]
})
export class AppModule implements DoBootstrap {
constructor(private readonly injector: Injector) {}
ngDoBootstrap(): void {
try {
CONTENTTYPE_FIELDS.forEach(({ tag, component }) => {
// prevent 'has already been defined as a custom element' error
if (customElements.get(tag)) {
return;
}
// create custom elements from angular components
const el = createCustomElement(component, {
injector: this.injector
});
// define in browser registry
customElements.define(tag, el);
});
} catch (err) {
console.error(err);
}
}
}