Skip to content

Commit

Permalink
MARP-1689 Add library to update Readme content for !NOTE or !IMPORTAN…
Browse files Browse the repository at this point in the history
…T...
  • Loading branch information
tvtphuc-axonivy committed Dec 20, 2024
1 parent e781fda commit 675309e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
5 changes: 4 additions & 1 deletion marketplace-ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.scss",
"node_modules/@fortawesome/fontawesome-free/css/all.min.css"
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
"node_modules/markdown-it-github-alerts/styles/github-base.css",
"node_modules/markdown-it-github-alerts/styles/github-colors-dark-media.css",
"node_modules/markdown-it-github-alerts/styles/github-colors-light.css"
],
"scripts": [
"node_modules/emoji-toolkit/lib/js/joypixels.min.js",
Expand Down
2 changes: 2 additions & 0 deletions marketplace-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"emoji-toolkit": "^9.0.0",
"jwt-decode": "^4.0.0",
"karma-viewport": "^1.0.9",
"markdown-it-github-alerts": "^0.3.0",
"marked": "^12.0.0",
"ngx-cookie-service": "^18.0.0",
"ngx-markdown": "^18.0.0",
Expand All @@ -47,6 +48,7 @@
"@types/bootstrap": "^5.2.10",
"@types/jasmine": "~5.1.0",
"@types/node": "^18.18.0",
"@types/markdown-it": "^14.1.2",
"jasmine": "^5.1.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,8 @@ <h4 class="analysis-title text-primary text-capitalize mb-0">
[selectedVersion]="selectedVersion">
</app-product-detail-maven-content>
} @else {
<markdown emoji
[lang]="languageService.selectedLanguage()"
class="readme-content"
[data]="
getProductModuleContentValue(displayedTab)
| multilingualism: languageService.selectedLanguage()
"></markdown>
<div class="readme-content" [innerHtml]="renderGithubAlert(getProductModuleContentValue(displayedTab)
| multilingualism: languageService.selectedLanguage())"></div>
}
</div>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CommonModule, NgOptimizedImage } from '@angular/common';
import MarkdownIt from 'markdown-it';
import MarkdownItGitHubAlerts from 'markdown-it-github-alerts';
import {
Component,
ElementRef,
Expand Down Expand Up @@ -49,7 +51,7 @@ import { ProductStarRatingNumberComponent } from './product-star-rating-number/p
import { DisplayValue } from '../../../shared/models/display-value.model';
import { CookieService } from 'ngx-cookie-service';
import { ROUTER } from '../../../shared/constants/router.constant';
import { Title } from '@angular/platform-browser';
import { SafeHtml, Title ,DomSanitizer} from '@angular/platform-browser';
import { API_URI } from '../../../shared/constants/api.constant';

export interface DetailTab {
Expand Down Expand Up @@ -132,7 +134,7 @@ export class ProductDetailComponent {
this.updateDropdownSelection();
}

constructor(private readonly titleService: Title) {
constructor(private readonly titleService: Title, private sanitizer: DomSanitizer) {
this.scrollToTop();
this.resizeObserver = new ResizeObserver(() => {
this.updateDropdownSelection();
Expand Down Expand Up @@ -417,4 +419,11 @@ export class ProductDetailComponent {

return productDetail;
}

renderGithubAlert(value : string ): SafeHtml {
const md = MarkdownIt();
md.use(MarkdownItGitHubAlerts);
const result = md.render(value)
return this.sanitizer.bypassSecurityTrustHtml(result);
}
}

0 comments on commit 675309e

Please sign in to comment.