markstream-angular 2.0.6 → 2.0.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.
@@ -2377,7 +2377,7 @@ function scrubSvgElement(svgEl) {
2377
2377
  }
2378
2378
  }
2379
2379
  }
2380
- function toSafeSvgMarkup(svg) {
2380
+ function toSafeSvgMarkup(svg, rootClass) {
2381
2381
  if (typeof DOMParser === 'undefined')
2382
2382
  return '';
2383
2383
  if (!svg)
@@ -2389,6 +2389,8 @@ function toSafeSvgMarkup(svg) {
2389
2389
  return '';
2390
2390
  const svgElement = svgEl;
2391
2391
  scrubSvgElement(svgElement);
2392
+ if (rootClass)
2393
+ svgElement.classList.add(rootClass);
2392
2394
  return svgElement.outerHTML;
2393
2395
  }
2394
2396
  function extractRenderedSvg(renderResult) {
@@ -2547,8 +2549,12 @@ class D2BlockNodeComponent {
2547
2549
  return this.mergedProps.showTooltips;
2548
2550
  return this.context?.showTooltips !== false;
2549
2551
  }
2550
- get resolvedMaxHeight() {
2551
- return resolveCssSize(this.mergedProps.maxHeight, '500px');
2552
+ get resolvedRenderStyle() {
2553
+ const maxHeight = this.mergedProps.maxHeight;
2554
+ if (maxHeight == null || maxHeight === '')
2555
+ return null;
2556
+ const max = resolveCssSize(maxHeight);
2557
+ return `max-height: ${max}; --ms-d2-render-max-height: ${max}`;
2552
2558
  }
2553
2559
  get resolvedLoading() {
2554
2560
  if (typeof this.mergedProps.loading === 'boolean')
@@ -2658,7 +2664,7 @@ class D2BlockNodeComponent {
2658
2664
  const renderResult = await instance.render(diagram, renderOptions);
2659
2665
  if (this.destroyed || token !== this.renderToken)
2660
2666
  return;
2661
- const safeSvg = toSafeSvgMarkup(extractRenderedSvg(renderResult));
2667
+ const safeSvg = toSafeSvgMarkup(extractRenderedSvg(renderResult), 'markstream-d2-root-svg');
2662
2668
  if (!safeSvg)
2663
2669
  throw new Error('D2 render returned empty output.');
2664
2670
  this.svgMarkup = safeSvg;
@@ -2757,7 +2763,7 @@ class D2BlockNodeComponent {
2757
2763
  </div>
2758
2764
  </div>
2759
2765
 
2760
- <div *ngIf="!collapsed" class="markstream-angular-enhanced-block__body d2-block-body" [style.maxHeight]="resolvedMaxHeight">
2766
+ <div *ngIf="!collapsed" class="markstream-angular-enhanced-block__body d2-block-body" [style]="resolvedRenderStyle">
2761
2767
  <div *ngIf="rendering && !showSource" class="mermaid-loading">
2762
2768
  <span class="mermaid-spinner" aria-hidden="true"></span>
2763
2769
  <span>Rendering D2...</span>
@@ -2846,7 +2852,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.26", ngImpo
2846
2852
  </div>
2847
2853
  </div>
2848
2854
 
2849
- <div *ngIf="!collapsed" class="markstream-angular-enhanced-block__body d2-block-body" [style.maxHeight]="resolvedMaxHeight">
2855
+ <div *ngIf="!collapsed" class="markstream-angular-enhanced-block__body d2-block-body" [style]="resolvedRenderStyle">
2850
2856
  <div *ngIf="rendering && !showSource" class="mermaid-loading">
2851
2857
  <span class="mermaid-spinner" aria-hidden="true"></span>
2852
2858
  <span>Rendering D2...</span>
@@ -4461,7 +4467,20 @@ class InfographicBlockNodeComponent {
4461
4467
  return resolveCssSize(this.mergedProps.maxHeight, '500px');
4462
4468
  }
4463
4469
  get estimatedPreviewHeightPx() {
4464
- return clampPreviewHeight(parsePositiveNumber(this.mergedProps.estimatedPreviewHeightPx) ?? estimateInfographicPreviewHeight(this.code), undefined, this.maxPreviewHeight);
4470
+ return clampPreviewHeight(parsePositiveNumber(this.mergedProps.estimatedPreviewHeightPx) ?? estimateInfographicPreviewHeight(this.code), this.resolveDiagramMinHeight(), this.maxPreviewHeight);
4471
+ }
4472
+ /**
4473
+ * Resolve the diagram preview minimum height from the density CSS token
4474
+ * (--ms-size-diagram-min-height), falling back to the built-in default.
4475
+ * Mirrors MermaidBlockNode's resolveDiagramMinHeight; SSR falls back to the
4476
+ * constant because getComputedStyle is browser-only.
4477
+ */
4478
+ resolveDiagramMinHeight() {
4479
+ const el = this.previewHost?.nativeElement;
4480
+ if (!el || typeof window === 'undefined' || typeof window.getComputedStyle !== 'function')
4481
+ return INFOGRAPHIC_PREVIEW_MIN_HEIGHT;
4482
+ const raw = window.getComputedStyle(el).getPropertyValue('--ms-size-diagram-min-height').trim();
4483
+ return parsePositiveNumber(raw) ?? INFOGRAPHIC_PREVIEW_MIN_HEIGHT;
4465
4484
  }
4466
4485
  get resolvedContainerMinHeight() {
4467
4486
  return this.containerMinHeight || `${this.estimatedPreviewHeightPx}px`;
@@ -6826,7 +6845,20 @@ class MermaidBlockNodeComponent {
6826
6845
  return resolveCssSize(this.mergedProps.maxHeight, '500px');
6827
6846
  }
6828
6847
  get estimatedPreviewHeightPx() {
6829
- return clampPreviewHeight(parsePositiveNumber(this.mergedProps.estimatedPreviewHeightPx) ?? estimateMermaidPreviewHeight(this.code), undefined, this.maxPreviewHeight);
6848
+ return clampPreviewHeight(parsePositiveNumber(this.mergedProps.estimatedPreviewHeightPx) ?? estimateMermaidPreviewHeight(this.code), this.resolveDiagramMinHeight(), this.maxPreviewHeight);
6849
+ }
6850
+ /**
6851
+ * Resolve the diagram preview minimum height from the density CSS token
6852
+ * (--ms-size-diagram-min-height), falling back to the built-in default.
6853
+ * Mirrors the vue3 renderer's resolveMinContainerHeight; SSR falls back to
6854
+ * the constant because getComputedStyle is browser-only.
6855
+ */
6856
+ resolveDiagramMinHeight() {
6857
+ const el = this.previewHost?.nativeElement;
6858
+ if (!el || typeof window === 'undefined' || typeof window.getComputedStyle !== 'function')
6859
+ return MERMAID_PREVIEW_MIN_HEIGHT;
6860
+ const raw = window.getComputedStyle(el).getPropertyValue('--ms-size-diagram-min-height').trim();
6861
+ return parsePositiveNumber(raw) ?? MERMAID_PREVIEW_MIN_HEIGHT;
6830
6862
  }
6831
6863
  get maxPreviewHeight() {
6832
6864
  if (this.mergedProps.maxHeight == null || this.mergedProps.maxHeight === 'none')