Skip to content

Commit c702b0f

Browse files
Merge pull request #1777 from rocket-admin/ai-ddl-improvements
fix: configure mermaid via provideMarkdown to resolve ngx-markdown warning
2 parents 2c6f263 + d993072 commit c702b0f

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

frontend/src/app/components/edit-database-schema/edit-database-schema.component.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, signal, inject, computed } from '@angular/core';
1+
import { Component, EventEmitter, Input, OnInit, Output, signal, inject, computed } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { FormsModule } from '@angular/forms';
44
import { MatButtonModule } from '@angular/material/button';
@@ -32,7 +32,7 @@ interface ChatMessage {
3232
RouterModule,
3333
],
3434
})
35-
export class EditDatabaseSchemaComponent implements OnInit, AfterViewInit {
35+
export class EditDatabaseSchemaComponent implements OnInit {
3636
@Input() connectionID: string;
3737
@Input() showClose: boolean = false;
3838
@Output() schemaApplied = new EventEmitter<void>();
@@ -60,18 +60,6 @@ export class EditDatabaseSchemaComponent implements OnInit, AfterViewInit {
6060
return null;
6161
});
6262

63-
async ngAfterViewInit() {
64-
const mermaid = await import('mermaid');
65-
const mermaidAPI = (mermaid.default ?? mermaid) as { initialize: (config: Record<string, unknown>) => void };
66-
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
67-
mermaidAPI.initialize({
68-
startOnLoad: false,
69-
theme: isDark ? 'dark' : 'default',
70-
});
71-
//@ts-expect-error dynamic load of mermaid
72-
window.mermaid = mermaidAPI;
73-
}
74-
7563
ngOnInit(): void {
7664
if (!this.connectionID) {
7765
const id = this._route.snapshot.paramMap.get('connection-id');

frontend/src/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,14 @@ bootstrapApplication(AppComponent, {
125125
NotificationsService,
126126
TablesService,
127127
CookieService,
128-
provideMarkdown(),
128+
provideMarkdown({
129+
mermaidOptions: {
130+
useValue: {
131+
startOnLoad: false,
132+
theme: window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default',
133+
},
134+
},
135+
}),
129136
Title,
130137
{
131138
provide: HTTP_INTERCEPTORS,

0 commit comments

Comments
 (0)