@foblex/m-render 2.7.4 → 2.7.6

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.
@@ -1668,7 +1668,7 @@ class MarkdownService {
1668
1668
  _httpClient = inject(HttpClient);
1669
1669
  _domSanitizer = inject(DomSanitizer);
1670
1670
  _router = inject(Router);
1671
- _provider = inject(F_PREVIEW_NAVIGATION_PROVIDER);
1671
+ _provider = inject(F_PREVIEW_NAVIGATION_PROVIDER, { optional: true });
1672
1672
  constructor() {
1673
1673
  this._markdown
1674
1674
  .use((x) => new ParseSingleCodeItem().render(x))
@@ -1679,12 +1679,15 @@ class MarkdownService {
1679
1679
  .use(...new ParseAlerts().render(EMarkdownContainerType.ALERT_DANGER, this._markdown))
1680
1680
  .use(...new ParseAlerts().render(EMarkdownContainerType.ALERT_SUCCESS, this._markdown))
1681
1681
  .use(...new ParseGroupedCodeItems().render())
1682
- .use(...new ParsePreviewGroup(this._provider.getNavigation()).render())
1682
+ .use(...new ParsePreviewGroup(this._provider?.getNavigation() || []).render())
1683
1683
  .use(...new ParseAngularExampleWithCodeLinks().render());
1684
1684
  }
1685
- parse(src) {
1685
+ parseUrl(src) {
1686
1686
  return this._httpClient.get(src, { responseType: 'text' }).pipe(take(1), catchError(() => of(''))).pipe(switchMap((text) => of(this._markdown.render(text))), switchMap((x) => of(this._cleanupEmptyParagraphs(x))), switchMap((x) => of(this._cleanupWasteParagraphFromExampleView(x))), switchMap((x) => of(this._cleanupWasteParagraphFromPreviewGroup(x))), switchMap((x) => of(this._normalizeLinks(x))), switchMap((x) => of(this._domSanitizer.bypassSecurityTrustHtml(x))));
1687
1687
  }
1688
+ parseText(value) {
1689
+ return of(this._markdown.render(value)).pipe(switchMap((x) => of(this._cleanupEmptyParagraphs(x))), switchMap((x) => of(this._cleanupWasteParagraphFromExampleView(x))), switchMap((x) => of(this._cleanupWasteParagraphFromPreviewGroup(x))), switchMap((x) => of(this._normalizeLinks(x))), switchMap((x) => of(this._domSanitizer.bypassSecurityTrustHtml(x))));
1690
+ }
1688
1691
  _normalizeLinks(html) {
1689
1692
  const currentPath = this._router.url;
1690
1693
  const prefix = currentPath.substring(0, currentPath.lastIndexOf('/'));
@@ -2718,7 +2721,7 @@ class FMarkdownRendererComponent {
2718
2721
  }
2719
2722
  _subscribeOnRouteChanges() {
2720
2723
  this._router.events
2721
- .pipe(startWith(null), debounceTime(50), switchMap(() => this._markdown.parse(this._provider.getMarkdownUrl(this._markdownPath))), tap((x) => this.value.set(x)), catchError((e, data) => {
2724
+ .pipe(startWith(null), debounceTime(50), switchMap(() => this._markdown.parseUrl(this._provider.getMarkdownUrl(this._markdownPath))), tap((x) => this.value.set(x)), catchError((e, data) => {
2722
2725
  console.error('[MarkdownRenderer] parse error:', e);
2723
2726
  return of(data);
2724
2727
  }), takeUntilDestroyed(this._destroyRef))