@foblex/m-render 2.6.6 → 2.6.8

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.
@@ -8,13 +8,13 @@ import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
8
8
  import { Overlay, CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
9
9
  import { Router, RouterLink, NavigationEnd, ActivatedRoute, RouterOutlet } from '@angular/router';
10
10
  import { DOCUMENT, TitleCasePipe } from '@angular/common';
11
- import { __decorate } from 'tslib';
12
- import { FExecutionRegister, FMediator } from '@foblex/mediator';
13
11
  import { deepClone } from '@foblex/utils';
14
12
  import { createHighlighter } from 'shiki';
15
13
  import MarkdownIt from 'markdown-it';
16
14
  import { DomSanitizer } from '@angular/platform-browser';
17
15
  import container from 'markdown-it-container';
16
+ import { __decorate } from 'tslib';
17
+ import { FExecutionRegister, FMediator } from '@foblex/mediator';
18
18
 
19
19
  let uniqueId$1 = 0;
20
20
  class FCheckboxComponent {
@@ -583,34 +583,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
583
583
  args: [{ providedIn: 'root' }]
584
584
  }] });
585
585
 
586
- class HandleNavigationLinksRequest {
587
- event;
588
- constructor(event) {
589
- this.event = event;
590
- }
591
- }
592
-
593
- let HandleNavigationLinksHandler = class HandleNavigationLinksHandler {
594
- _router = inject(Router);
595
- _browser = inject(BrowserService);
586
+ class HandleNavigationLinksHandler {
596
587
  handle(request) {
597
588
  const target = this._getClosestAnchorTag(this._getTargetElement(request.event));
598
589
  if (target && this._hasHref(target)) {
599
590
  request.event.preventDefault();
600
591
  const href = target.getAttribute('href');
601
592
  if (!this._isExternalLink(href)) {
602
- this._navigateInternalLink(href);
593
+ this._navigateInternalLink(href, request.router);
603
594
  }
604
595
  else {
605
- this._navigateExternalLink(href);
596
+ this._navigateExternalLink(href, request.browser);
606
597
  }
607
598
  }
608
599
  }
609
600
  _getTargetElement(event) {
610
- return event.target;
601
+ return event?.target;
611
602
  }
612
603
  _getClosestAnchorTag(element) {
613
- return element.closest('a');
604
+ return element?.closest('a');
614
605
  }
615
606
  _hasHref(element) {
616
607
  return element.hasAttribute('href');
@@ -618,24 +609,27 @@ let HandleNavigationLinksHandler = class HandleNavigationLinksHandler {
618
609
  _isExternalLink(href) {
619
610
  return href.startsWith('www') || href.startsWith('http');
620
611
  }
621
- _navigateInternalLink(href) {
612
+ _navigateInternalLink(href, router) {
622
613
  if (href.startsWith('/')) {
623
614
  href = href.substring(1);
624
615
  }
625
- this._router.navigate([href]).then();
616
+ router.navigate([href]).then();
626
617
  }
627
- _navigateExternalLink(href) {
628
- this._browser.window.open(href, '_blank');
618
+ _navigateExternalLink(href, browser) {
619
+ browser.window.open(href, '_blank');
629
620
  }
630
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: HandleNavigationLinksHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
631
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: HandleNavigationLinksHandler });
632
- };
633
- HandleNavigationLinksHandler = __decorate([
634
- FExecutionRegister(HandleNavigationLinksRequest)
635
- ], HandleNavigationLinksHandler);
636
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: HandleNavigationLinksHandler, decorators: [{
637
- type: Injectable
638
- }] });
621
+ }
622
+
623
+ class HandleNavigationLinksRequest {
624
+ event;
625
+ browser;
626
+ router;
627
+ constructor(event, browser, router) {
628
+ this.event = event;
629
+ this.browser = browser;
630
+ this.router = router;
631
+ }
632
+ }
639
633
 
640
634
  function provide404Markdown(notFoundMarkdown) {
641
635
  return {
@@ -656,7 +650,7 @@ function provideComponents(components) {
656
650
  }
657
651
  function extractComponent(loader) {
658
652
  return loader().then(module => {
659
- const component = Object.values(module).find((v) => typeof v === 'function' && v.ɵcmp);
653
+ const component = Object.values(module).find((v) => typeof v === 'function' && Object.prototype.hasOwnProperty.call(v, 'ɵcmp'));
660
654
  if (!component) {
661
655
  throw new Error('Component not found');
662
656
  }
@@ -924,9 +918,9 @@ class NavigationPanelComponent {
924
918
  optional: true,
925
919
  });
926
920
  _router = inject(Router);
927
- _mediator = inject(FMediator);
928
921
  _changeDetectorRef = inject(ChangeDetectorRef);
929
922
  _destroyRef = inject(DestroyRef);
923
+ _browser = inject(BrowserService);
930
924
  value;
931
925
  navigation = this._provider.getNavigation();
932
926
  title = this._provider.getTitle();
@@ -972,7 +966,7 @@ class NavigationPanelComponent {
972
966
  });
973
967
  }
974
968
  _onDocumentClick(event) {
975
- this._mediator.execute(new HandleNavigationLinksRequest(event));
969
+ new HandleNavigationLinksHandler().handle(new HandleNavigationLinksRequest(event, this._browser, this._router));
976
970
  }
977
971
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NavigationPanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
978
972
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: NavigationPanelComponent, isStandalone: true, selector: "f-navigation-panel", host: { listeners: { "click": "_onDocumentClick($event)" } }, ngImport: i0, template: "<a routerLink class=\"navigation-header\">\n <img [src]=\"image\" width=\"24\" height=\"24\" alt=\"logo\" class=\"logo\"/> {{ title }}\n</a>\n\n@for (group of navigation; track group) {\n <f-navigation-group [title]=\"group.text\">\n @for (item of group.items; track item.link) {\n <a f-navigation-item [href]=\"item.link\" [class.active]=\"item.link === value\">\n <div class=\"text-ellipsis\">{{ item.text }}</div>\n @if (item.badge) {\n <span class=\"f-badge {{ item.badge.type }}\">{{ item.badge.text }}</span>\n }\n </a>\n }\n </f-navigation-group>\n}\n", styles: [":host{height:100%;flex-direction:column;justify-content:flex-start;align-items:flex-start;padding:0 var(--navigation-panel-padding);background-color:var(--navigation-panel-background);overflow:hidden;overflow-y:auto;position:fixed;width:var(--navigation-panel-width);top:0;left:calc(-1 * var(--navigation-panel-width));transition:transform .2s ease-in-out;z-index:var(--z-index-navigation);transform:none}@media (min-width: 960px){:host{position:unset;display:flex;min-width:var(--navigation-panel-width);width:fit-content;transform:none!important}}@media (min-width: 1440px){:host{min-width:calc((100% - (var(--layout-max-width) - 64px)) / 3 + var(--navigation-panel-width) - var(--navigation-panel-padding))}}:host.visible{transform:translate(var(--navigation-panel-width))}.navigation-header{display:flex;justify-content:flex-start;align-items:center;padding:20px 0;font-weight:600;color:var(--primary-text);height:var(--header-height);width:100%;max-width:240px;margin-left:auto;cursor:pointer}.navigation-header img{margin-right:8px}\n"], dependencies: [{ kind: "component", type: FNavigationItemComponent, selector: "a[f-navigation-item]" }, { kind: "component", type: NavigationGroupComponent, selector: "f-navigation-group", inputs: ["title"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
@@ -2031,12 +2025,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
2031
2025
  }] });
2032
2026
 
2033
2027
  class FMarkdownFooterComponent {
2034
- _mediator = inject(FMediator);
2035
2028
  _provider = inject(DocumentationStore);
2036
2029
  _router = inject(Router);
2037
2030
  _activatedRoute = inject(ActivatedRoute);
2038
2031
  _changeDetectorRef = inject(ChangeDetectorRef);
2039
2032
  _destroyRef = inject(DestroyRef);
2033
+ _browser = inject(BrowserService);
2040
2034
  navigation = {};
2041
2035
  editLink;
2042
2036
  previousLink;
@@ -2077,7 +2071,7 @@ class FMarkdownFooterComponent {
2077
2071
  return this._activatedRoute.snapshot.url.map((x) => x.path).join('/');
2078
2072
  }
2079
2073
  _onDocumentClick(event) {
2080
- this._mediator.execute(new HandleNavigationLinksRequest(event));
2074
+ new HandleNavigationLinksHandler().handle(new HandleNavigationLinksRequest(event, this._browser, this._router));
2081
2075
  }
2082
2076
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FMarkdownFooterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2083
2077
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: FMarkdownFooterComponent, isStandalone: true, selector: "footer [f-markdown-footer]", host: { listeners: { "click": "_onDocumentClick($event)" } }, ngImport: i0, template: "@if (editLink) {\n <f-footer-edit-information>\n <a f-footer-edit-link [href]=\"editLink\">\n {{ navigation.editLink?.text || 'Edit this page on GitHub' }}\n </a>\n\n<!-- <f-footer-last-updated>-->\n<!-- Last updated: <span>111</span>-->\n<!-- </f-footer-last-updated>-->\n </f-footer-edit-information>\n}\n\n@if (previousLink || nextLink) {\n <nav f-footer-navigation>\n @if (previousLink) {\n <a f-footer-navigation-button\n [href]=\"previousLink.link\"\n [description]=\"navigation.previous\"\n [link]=\"previousLink\">\n </a>\n }\n @if (nextLink) {\n <a f-footer-navigation-button class=\"next\"\n [href]=\"nextLink.link\"\n [description]=\"navigation.next\"\n [link]=\"nextLink\">\n </a>\n }\n </nav>\n}\n\n", styles: [":host{display:block;margin-top:64px}\n"], dependencies: [{ kind: "component", type: FFooterNavigationComponent, selector: "nav[f-footer-navigation]" }, { kind: "component", type: FFooterNavigationButtonComponent, selector: "a[f-footer-navigation-button]", inputs: ["description", "link"] }, { kind: "component", type: FFooterEditInformationComponent, selector: "f-footer-edit-information" }, { kind: "component", type: FFooterEditLinkComponent, selector: "a[f-footer-edit-link]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
@@ -2734,7 +2728,10 @@ class FMarkdownRendererComponent {
2734
2728
  }
2735
2729
  _subscribeOnRouteChanges() {
2736
2730
  this._router.events
2737
- .pipe(startWith(null), debounceTime(50), switchMap(() => this._markdown.parse(this._provider.getMarkdownUrl(this._markdownPath))), tap((x) => this.value.set(x)), catchError((e, data) => data), takeUntilDestroyed(this._destroyRef))
2731
+ .pipe(startWith(null), debounceTime(50), switchMap(() => this._markdown.parse(this._provider.getMarkdownUrl(this._markdownPath))), tap((x) => this.value.set(x)), catchError((e, data) => {
2732
+ console.error('[MarkdownRenderer] parse error:', e);
2733
+ return of(data);
2734
+ }), takeUntilDestroyed(this._destroyRef))
2738
2735
  .subscribe();
2739
2736
  }
2740
2737
  _updateRenderDependencies() {
@@ -2742,7 +2739,7 @@ class FMarkdownRendererComponent {
2742
2739
  const html = this.value();
2743
2740
  if (html && this._browser.isBrowser()) {
2744
2741
  untracked(() => {
2745
- requestAnimationFrame(() => {
2742
+ raf(() => {
2746
2743
  this._mediator.execute(new RenderDynamicComponentsRequest(this._hostElement));
2747
2744
  this._mediator.execute(new CalculateTableOfContentDataRequest(this._hostElement));
2748
2745
  });
@@ -2751,7 +2748,7 @@ class FMarkdownRendererComponent {
2751
2748
  }, { injector: this._injector });
2752
2749
  }
2753
2750
  _onDocumentClick(event) {
2754
- this._mediator.execute(new HandleNavigationLinksRequest(event));
2751
+ new HandleNavigationLinksHandler().handle(new HandleNavigationLinksRequest(event, this._browser, this._router));
2755
2752
  }
2756
2753
  ngOnDestroy() {
2757
2754
  this._provider.disposeDComponents();
@@ -2772,6 +2769,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
2772
2769
  type: HostListener,
2773
2770
  args: ['click', ['$event']]
2774
2771
  }] } });
2772
+ const raf = typeof requestAnimationFrame === 'function'
2773
+ ? requestAnimationFrame
2774
+ : (fn) => setTimeout(fn);
2775
2775
 
2776
2776
  class MarkdownContainerComponent {
2777
2777
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: MarkdownContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -2958,7 +2958,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
2958
2958
  GetPreviousNextPageNavigationRequest: GetPreviousNextPageNavigationRequest,
2959
2959
  GetPreviousNextPageNavigationResponse: GetPreviousNextPageNavigationResponse,
2960
2960
  HamburgerButtonComponent: HamburgerButtonComponent,
2961
- get HandleNavigationLinksHandler () { return HandleNavigationLinksHandler; },
2961
+ HandleNavigationLinksHandler: HandleNavigationLinksHandler,
2962
2962
  HandleNavigationLinksRequest: HandleNavigationLinksRequest,
2963
2963
  HeaderComponent: HeaderComponent,
2964
2964
  HighlightComponent: HighlightComponent,