@dtducas/wh-forge-viewer 1.0.6 → 1.0.7

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.
package/dist/index.js CHANGED
@@ -657,7 +657,8 @@ class DocumentBrowserManager {
657
657
  }
658
658
  autoOpenIfMultiPage(isMultiPage) {
659
659
  return __awaiter(this, void 0, void 0, function* () {
660
- if (!isMultiPage || !this.config.autoOpen) {
660
+ // Auto-open Document Browser for both single and multi-page documents
661
+ if (!this.config.autoOpen) {
661
662
  return;
662
663
  }
663
664
  setTimeout(() => {
@@ -767,9 +768,58 @@ class DocumentBrowserManager {
767
768
  const ext = this.viewer.getExtension('Autodesk.DocumentBrowser');
768
769
  if ((_b = (_a = ext === null || ext === void 0 ? void 0 : ext.ui) === null || _a === void 0 ? void 0 : _a.panel) === null || _b === void 0 ? void 0 : _b.container) {
769
770
  applyStyles(ext.ui.panel.container, DOCUMENT_BROWSER_STYLES);
771
+ // Adjust panel height based on number of thumbnails
772
+ this.adjustPanelHeight();
770
773
  }
771
774
  }, TOOLBAR_REFRESH_INTERVALS.DOM_SETTLE);
772
775
  }
776
+ /**
777
+ * Adjust Document Browser panel height based on content
778
+ */
779
+ adjustPanelHeight() {
780
+ setTimeout(() => {
781
+ var _a, _b;
782
+ const ext = this.viewer.getExtension('Autodesk.DocumentBrowser');
783
+ if (!((_b = (_a = ext === null || ext === void 0 ? void 0 : ext.ui) === null || _a === void 0 ? void 0 : _a.panel) === null || _b === void 0 ? void 0 : _b.container)) {
784
+ return;
785
+ }
786
+ const panel = ext.ui.panel;
787
+ const scrollContainer = panel.container.querySelector('.docking-panel-scroll');
788
+ if (!scrollContainer) {
789
+ return;
790
+ }
791
+ // Count thumbnails
792
+ const thumbnails = scrollContainer.querySelectorAll('.viewer-ext-docbrowser-thumbnail');
793
+ const thumbnailCount = thumbnails.length;
794
+ if (thumbnailCount === 0) {
795
+ return;
796
+ }
797
+ // Get thumbnail dimensions (typically 200x200 + label)
798
+ const firstThumbnail = thumbnails[0];
799
+ const thumbnailHeight = (firstThumbnail === null || firstThumbnail === void 0 ? void 0 : firstThumbnail.offsetHeight) || 220; // Default 220 if can't get
800
+ // Calculate optimal height
801
+ // For 1 thumbnail: just the thumbnail height + some padding
802
+ // For multiple: use a reasonable max height
803
+ const headerHeight = 110; // Panel header + tabs
804
+ const padding = 40; // Extra padding for aesthetics
805
+ let optimalHeight;
806
+ if (thumbnailCount === 1) {
807
+ // Single thumbnail: compact size
808
+ optimalHeight = thumbnailHeight + headerHeight + padding;
809
+ }
810
+ else {
811
+ // Multiple thumbnails: calculate based on count but cap at viewport height
812
+ const maxViewportHeight = window.innerHeight * 0.8; // Max 80% of viewport
813
+ const calculatedHeight = Math.min(thumbnailCount * thumbnailHeight + headerHeight + padding, maxViewportHeight);
814
+ optimalHeight = calculatedHeight;
815
+ }
816
+ // Apply the height
817
+ panel.container.style.height = `${optimalHeight}px`;
818
+ // Update scroll container height
819
+ const scrollHeight = optimalHeight - headerHeight;
820
+ scrollContainer.style.height = `${scrollHeight}px`;
821
+ }, TOOLBAR_REFRESH_INTERVALS.DOM_SETTLE + 50);
822
+ }
773
823
  switchToThumbnailTab() {
774
824
  return __awaiter(this, void 0, void 0, function* () {
775
825
  if (this.config.defaultTab !== 'thumbnails')
@@ -1249,7 +1299,7 @@ class ToolbarManager {
1249
1299
  this.config = config;
1250
1300
  this.eventBus = EventBus.getInstance();
1251
1301
  }
1252
- createToolbar() {
1302
+ createToolbar(isMultiPage = false) {
1253
1303
  const toolbar = this.viewer.toolbar;
1254
1304
  if (!toolbar)
1255
1305
  return;
@@ -1529,9 +1579,9 @@ function registerToolbarExtension(Autodesk) {
1529
1579
  // Process pending viewables if any
1530
1580
  if (this._pendingViewables) {
1531
1581
  this.paginationManager.setViewables(this._pendingViewables);
1532
- if (this._pendingViewables.length > 1) {
1533
- this.docBrowserManager.autoOpenIfMultiPage(true);
1534
- }
1582
+ // Auto-open Document Browser for all documents (single or multi-page)
1583
+ var isMultiPage = this._pendingViewables.length > 1;
1584
+ this.docBrowserManager.autoOpenIfMultiPage(isMultiPage);
1535
1585
  this._pendingViewables = null;
1536
1586
  }
1537
1587
  // Show toolbar
@@ -1639,11 +1689,10 @@ function registerToolbarExtension(Autodesk) {
1639
1689
  if (this._toolbarReady) {
1640
1690
  // Toolbar ready - set viewables immediately
1641
1691
  this.paginationManager.setViewables(data.viewables);
1642
- // Auto-open Document Browser if multi-page
1643
- if (data.viewables.length > 1) {
1644
- GLOBAL_STATE.docBrowserShouldBeOpen = true;
1645
- this.docBrowserManager.autoOpenIfMultiPage(true);
1646
- }
1692
+ // Auto-open Document Browser for all documents
1693
+ var isMultiPage = data.viewables.length > 1;
1694
+ GLOBAL_STATE.docBrowserShouldBeOpen = true;
1695
+ this.docBrowserManager.autoOpenIfMultiPage(isMultiPage);
1647
1696
  } else {
1648
1697
  // Toolbar not ready yet - store viewables for later
1649
1698
  this._pendingViewables = data.viewables;
@@ -1785,7 +1834,6 @@ function registerToolbarExtension(Autodesk) {
1785
1834
  * Handle Download button click
1786
1835
  */
1787
1836
  ToolbarExtension.prototype.handleDownloadClick = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1788
- var _t;
1789
1837
  return _regenerator().w(function (_context) {
1790
1838
  while (1) switch (_context.p = _context.n) {
1791
1839
  case 0:
@@ -1797,8 +1845,7 @@ function registerToolbarExtension(Autodesk) {
1797
1845
  break;
1798
1846
  case 2:
1799
1847
  _context.p = 2;
1800
- _t = _context.v;
1801
- console.error('Download failed:', _t);
1848
+ _context.v;
1802
1849
  case 3:
1803
1850
  return _context.a(2);
1804
1851
  }