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