Skip to content

Commit

Permalink
add markdown support to banner message
Browse files Browse the repository at this point in the history
Signed-off-by: Ankur Kothiwal <[email protected]>
  • Loading branch information
Ankur Kothiwal committed Mar 6, 2025
1 parent 4565907 commit bd42cb4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/portal/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
NgModule,
APP_INITIALIZER,
CUSTOM_ELEMENTS_SCHEMA,
SecurityContext,
} from '@angular/core';
import { AppComponent } from './app.component';
import { InterceptHttpService } from './services/intercept-http.service';
Expand All @@ -40,6 +41,7 @@ import {
import { ErrorHandler } from './shared/units/error-handler';
import { MessageHandlerService } from './shared/services/message-handler.service';
import { HarborTranslateLoaderService } from './services/harbor-translate-loader.service';
import { MarkdownModule } from 'ngx-markdown';

function initConfig(
configService: AppConfigService,
Expand Down Expand Up @@ -76,6 +78,7 @@ class MyMissingTranslationHandler implements MissingTranslationHandler {
HttpClientModule,
HarborRoutingModule,
CookieModule.forRoot(),
MarkdownModule.forRoot({ sanitize: SecurityContext.HTML }),
],
providers: [
AppConfigService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
[(clrAlertClosed)]="bannerMessageClosed"
[clrAlertClosable]="getBannerMessageClosable()">
<clr-alert-item>
<span class="alert-text banner-message">{{
getBannerMessage()
}}</span>
<span class="alert-text banner-message">
<markdown [data]="getBannerMessage()"></markdown>
</span>
</clr-alert-item>
</clr-alert>
<clr-alert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@
.banner-message {
min-width: 0;
word-break: break-word;

::ng-deep :is(markdown) * {
color: inherit !important;
margin: 0;
display: inline;

&[href] {
text-decoration: underline;
}
}
}

0 comments on commit bd42cb4

Please sign in to comment.