@dtducas/wh-forge-viewer 1.0.3 → 1.0.5

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.
@@ -0,0 +1,89 @@
1
+ // Type definitions for @dtducas/wh-forge-viewer
2
+ // Project: https://github.com/DTDucas/wh-forge-viewer
3
+ // Definitions by: Duong Tran Quang <https://github.com/DTDucas>
4
+
5
+ /// <reference types="react" />
6
+
7
+ declare module '@dtducas/wh-forge-viewer' {
8
+ import { FC } from 'react';
9
+
10
+ /**
11
+ * Supported file extensions for the Forge Viewer
12
+ */
13
+ export type TSupportedFileExtension = 'pdf' | 'dwf' | 'dwfx';
14
+
15
+ /**
16
+ * Autodesk Forge Viewer namespace
17
+ * For full type definitions, see Autodesk Forge Viewer documentation
18
+ */
19
+ export namespace Autodesk {
20
+ export namespace Viewing {
21
+ export class GuiViewer3D {
22
+ // Add minimal type stubs for commonly used methods
23
+ start(): void;
24
+ loadExtension(extensionId: string, options?: any): Promise<any>;
25
+ loadModel(url: string, options?: any, onSuccess?: Function): void;
26
+ loadDocumentNode(document: any, node: any): Promise<any>;
27
+ addEventListener(event: string, callback: Function): void;
28
+ removeEventListener(event: string, callback: Function): void;
29
+ setReverseZoomDirection(value: boolean): void;
30
+ getExtension(extensionId: string): any;
31
+ setTool(toolName: string): void;
32
+ toolbar: any;
33
+ model: any;
34
+ }
35
+
36
+ export interface Extension {
37
+ load(): boolean;
38
+ unload(): boolean;
39
+ }
40
+
41
+ // Common event constants
42
+ export const GEOMETRY_LOADED_EVENT: string;
43
+ export const MODEL_ADDED_EVENT: string;
44
+ export const TOOLBAR_CREATED_EVENT: string;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Props for ViewerForgePDF component
50
+ */
51
+ export interface IViewerForgePDFProps {
52
+ /**
53
+ * URL/path to the document to load
54
+ */
55
+ filePath: string;
56
+
57
+ /**
58
+ * File extension (pdf, dwf, dwfx)
59
+ */
60
+ fileExt: TSupportedFileExtension;
61
+
62
+ /**
63
+ * Callback to receive viewer instance when initialized
64
+ */
65
+ setViewer?: (viewer: Autodesk.Viewing.GuiViewer3D | null) => void;
66
+ }
67
+
68
+ /**
69
+ * ViewerForgePDF - React component for displaying PDF and CAD files using Autodesk Forge Viewer
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * import { ViewerForgePDF } from '@dtducas/wh-forge-viewer';
74
+ *
75
+ * function MyApp() {
76
+ * const [viewer, setViewer] = useState<Autodesk.Viewing.GuiViewer3D | null>(null);
77
+ *
78
+ * return (
79
+ * <ViewerForgePDF
80
+ * filePath="https://example.com/document.pdf"
81
+ * fileExt="pdf"
82
+ * setViewer={setViewer}
83
+ * />
84
+ * );
85
+ * }
86
+ * ```
87
+ */
88
+ export const ViewerForgePDF: FC<IViewerForgePDFProps>;
89
+ }
package/dist/index.esm.js CHANGED
@@ -192,6 +192,7 @@ function registerToolbarExtension(Autodesk) {
192
192
  this.paginationGroup = null;
193
193
  this.viewables = [];
194
194
  this.currentIndex = 0;
195
+ this.docBrowserShouldBeOpen = false; // Track if doc browser should remain open
195
196
  }
196
197
  ToolbarExtension.prototype = Object.create(Autodesk.Viewing.Extension.prototype);
197
198
  ToolbarExtension.prototype.constructor = ToolbarExtension;
@@ -218,6 +219,10 @@ function registerToolbarExtension(Autodesk) {
218
219
  var _this = this;
219
220
  this.viewables = viewables;
220
221
  this.currentIndex = 0;
222
+ // If multiple pages, document browser will be auto-opened
223
+ if (viewables.length > 1) {
224
+ this.docBrowserShouldBeOpen = true;
225
+ }
221
226
  this.updatePaginationState();
222
227
  this.viewer.addEventListener(Autodesk.Viewing.MODEL_ADDED_EVENT, function (e) {
223
228
  _this.updateCurrentIndexFromModel();
@@ -240,6 +245,23 @@ function registerToolbarExtension(Autodesk) {
240
245
  };
241
246
  ToolbarExtension.prototype.updatePaginationState = function () {
242
247
  if (!this.paginationGroup) return;
248
+
249
+ // Hide pagination group if there's only 1 page or no pages
250
+ if (this.viewables.length <= 1) {
251
+ this.paginationGroup.setVisible(false);
252
+ // Also hide the container via CSS to ensure it's completely hidden
253
+ if (this.paginationGroup.container) {
254
+ this.paginationGroup.container.style.display = 'none';
255
+ }
256
+ return;
257
+ }
258
+
259
+ // Show pagination group for multi-page documents
260
+ this.paginationGroup.setVisible(true);
261
+ // Ensure container is visible
262
+ if (this.paginationGroup.container) {
263
+ this.paginationGroup.container.style.display = '';
264
+ }
243
265
  var totalBtn = this.paginationGroup.getControl('total-page-label');
244
266
  if (totalBtn) {
245
267
  var current = this.viewables.length > 0 ? this.currentIndex + 1 : 0;
@@ -256,6 +278,26 @@ function registerToolbarExtension(Autodesk) {
256
278
  if (this.viewables.length > 0 && this.viewables[this.currentIndex]) {
257
279
  var viewer = this.viewer;
258
280
  var toolbar = viewer.toolbar;
281
+ var self = this;
282
+
283
+ // Store Document Browser panel state before loading new page
284
+ var docBrowserExt = viewer.getExtension('Autodesk.DocumentBrowser');
285
+ var isCurrentlyOpen = docBrowserExt && docBrowserExt.ui && docBrowserExt.ui.panel && docBrowserExt.ui.panel.isVisible();
286
+
287
+ // Update flag - if currently open or flag is already set, keep it open
288
+ if (isCurrentlyOpen) {
289
+ this.docBrowserShouldBeOpen = true;
290
+ }
291
+
292
+ // Add one-time listener for geometry loaded to restore states
293
+ var _onGeometryLoaded = function onGeometryLoaded() {
294
+ viewer.removeEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, _onGeometryLoaded);
295
+ // Restore after geometry is fully loaded
296
+ setTimeout(function () {
297
+ self.restoreButtonStates(self.docBrowserShouldBeOpen);
298
+ }, 200);
299
+ };
300
+ viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, _onGeometryLoaded);
259
301
  viewer.loadDocumentNode(viewer.model.getDocumentNode().getDocument(), this.viewables[this.currentIndex]).then(function () {
260
302
  var defaultGroups = ['settingsTools', 'modelTools', 'navTools'];
261
303
  defaultGroups.forEach(function (id) {
@@ -274,11 +316,170 @@ function registerToolbarExtension(Autodesk) {
274
316
  if (_this2.paginationGroup) _this2.paginationGroup.setVisible(true);
275
317
  toolbar.setVisible(true);
276
318
  _this2.updatePaginationState();
319
+
320
+ // Also restore immediately (may work for cached pages)
321
+ _this2.restoreButtonStates(_this2.docBrowserShouldBeOpen);
277
322
  })["catch"](function (err) {
278
323
  return console.error('Error loading viewable:', err);
279
324
  });
280
325
  }
281
326
  };
327
+ ToolbarExtension.prototype.restoreButtonStates = function (shouldOpenDocBrowser) {
328
+ var viewer = this.viewer;
329
+ var toolbar = viewer.toolbar;
330
+ if (!toolbar) return;
331
+ var self = this;
332
+
333
+ // Restore Document Browser state
334
+ var openDocBrowser = /*#__PURE__*/function () {
335
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
336
+ var docBrowserExt, _t;
337
+ return _regenerator().w(function (_context) {
338
+ while (1) switch (_context.p = _context.n) {
339
+ case 0:
340
+ if (shouldOpenDocBrowser) {
341
+ _context.n = 1;
342
+ break;
343
+ }
344
+ return _context.a(2);
345
+ case 1:
346
+ docBrowserExt = viewer.getExtension('Autodesk.DocumentBrowser'); // If extension is null, it was unloaded - we need to reload it
347
+ if (docBrowserExt) {
348
+ _context.n = 5;
349
+ break;
350
+ }
351
+ _context.p = 2;
352
+ _context.n = 3;
353
+ return viewer.loadExtension('Autodesk.DocumentBrowser');
354
+ case 3:
355
+ docBrowserExt = _context.v;
356
+ // After loading, we need to wait for the extension to fully initialize
357
+ // and then open the panel
358
+ setTimeout(function () {
359
+ if (docBrowserExt && docBrowserExt.ui) {
360
+ docBrowserExt.ui.togglePanel();
361
+ setTimeout(function () {
362
+ self.applyDocBrowserStyling();
363
+ self.checkButtonState();
364
+ }, 150);
365
+ }
366
+ }, 200);
367
+ return _context.a(2);
368
+ case 4:
369
+ _context.p = 4;
370
+ _t = _context.v;
371
+ console.error('[ToolbarExt] Failed to reload DocumentBrowser:', _t);
372
+ return _context.a(2);
373
+ case 5:
374
+ if (docBrowserExt.ui) {
375
+ _context.n = 6;
376
+ break;
377
+ }
378
+ return _context.a(2);
379
+ case 6:
380
+ if (!docBrowserExt.ui.panel) {
381
+ _context.n = 8;
382
+ break;
383
+ }
384
+ if (!docBrowserExt.ui.panel.isVisible()) {
385
+ _context.n = 7;
386
+ break;
387
+ }
388
+ self.applyDocBrowserStyling();
389
+ self.checkButtonState();
390
+ return _context.a(2);
391
+ case 7:
392
+ // Use setVisible(true) directly on the panel
393
+ docBrowserExt.ui.panel.setVisible(true);
394
+ setTimeout(function () {
395
+ self.applyDocBrowserStyling();
396
+ self.checkButtonState();
397
+ }, 100);
398
+ return _context.a(2);
399
+ case 8:
400
+ // If panel doesn't exist yet, use togglePanel to create it
401
+ if (typeof docBrowserExt.ui.togglePanel === 'function') {
402
+ docBrowserExt.ui.togglePanel();
403
+ setTimeout(function () {
404
+ self.applyDocBrowserStyling();
405
+ self.checkButtonState();
406
+ }, 150);
407
+ }
408
+ case 9:
409
+ return _context.a(2);
410
+ }
411
+ }, _callee, null, [[2, 4]]);
412
+ }));
413
+ return function openDocBrowser() {
414
+ return _ref.apply(this, arguments);
415
+ };
416
+ }();
417
+
418
+ // Restore Pan tool active state
419
+ var restorePanTool = function restorePanTool() {
420
+ self.activatePanTool();
421
+ };
422
+
423
+ // Call restore at multiple intervals to ensure it works
424
+ // Use longer delays since geometry needs to fully load
425
+ setTimeout(openDocBrowser, 300);
426
+ setTimeout(openDocBrowser, 600);
427
+ setTimeout(openDocBrowser, 1000);
428
+ setTimeout(restorePanTool, 100);
429
+ setTimeout(restorePanTool, 300);
430
+ };
431
+ ToolbarExtension.prototype.applyDocBrowserStyling = function () {
432
+ var viewer = this.viewer;
433
+ var ext = viewer.getExtension('Autodesk.DocumentBrowser');
434
+ if (ext && ext.ui && ext.ui.panel && ext.ui.panel.container) {
435
+ ext.ui.panel.container.style.top = '0';
436
+ ext.ui.panel.container.style.left = 'unset';
437
+ ext.ui.panel.container.style.right = '0px';
438
+ ext.ui.panel.container.style.width = '200px';
439
+ ext.ui.panel.container.style.height = '80%';
440
+ }
441
+
442
+ // Switch to Thumbnail tab
443
+ this.switchToThumbnailTab();
444
+ };
445
+ ToolbarExtension.prototype.switchToThumbnailTab = function () {
446
+ // Try multiple selectors to find the thumbnail tab button
447
+ var thumbnailTab = document.querySelector('.docking-panel-thumbnail-view') || document.querySelector('[data-i18n="Thumbnails"]') || Array.from(document.querySelectorAll('.adsk-control-group .adsk-button')).find(function (btn) {
448
+ return btn.textContent.includes('Thumbnails') || btn.title.includes('Thumbnails');
449
+ });
450
+ if (thumbnailTab && !thumbnailTab.classList.contains('active')) {
451
+ thumbnailTab.click();
452
+ }
453
+ };
454
+ ToolbarExtension.prototype.activatePanTool = function () {
455
+ var viewer = this.viewer;
456
+ var toolbar = viewer.toolbar;
457
+ if (!toolbar) return;
458
+
459
+ // Activate pan tool using viewer API
460
+ try {
461
+ viewer.setActiveNavigationTool('pan');
462
+ } catch (e) {
463
+ // Fallback: click the original pan button
464
+ var originalPanBtn = document.getElementById('toolbar-panTool');
465
+ if (originalPanBtn) {
466
+ originalPanBtn.click();
467
+ }
468
+ }
469
+
470
+ // Update custom pan button visual state
471
+ var toolGroup = toolbar.getControl('custom-tool-group');
472
+ if (toolGroup) {
473
+ var panBtn = toolGroup.getControl('custom-pan-btn');
474
+ if (panBtn) {
475
+ panBtn.setState(Autodesk.Viewing.UI.Button.State.ACTIVE);
476
+ if (panBtn.container) {
477
+ panBtn.container.classList.add('active');
478
+ panBtn.container.classList.remove('inactive');
479
+ }
480
+ }
481
+ }
482
+ };
282
483
  ToolbarExtension.prototype.onToolbarCreated = function (toolbar) {
283
484
  var _this3 = this;
284
485
  this.refreshToolbar();
@@ -301,9 +502,53 @@ function registerToolbarExtension(Autodesk) {
301
502
  if (!toolGroup || !pagGroup) {
302
503
  _this3.refreshToolbar();
303
504
  }
505
+ _this3.checkButtonState();
304
506
  }
305
507
  }, 200);
306
508
  };
509
+ ToolbarExtension.prototype.checkButtonState = function () {
510
+ var viewer = this.viewer;
511
+ if (!viewer.toolbar) return;
512
+ var toolGroup = viewer.toolbar.getControl('custom-tool-group');
513
+ if (!toolGroup) return;
514
+
515
+ // Check Document Browser button state
516
+ var docBtn = toolGroup.getControl('custom-doc-browser-btn');
517
+ if (docBtn) {
518
+ var ext = viewer.getExtension('Autodesk.DocumentBrowser');
519
+ var isVisible = ext && ext.ui && ext.ui.panel && ext.ui.panel.isVisible();
520
+ var newState = isVisible ? Autodesk.Viewing.UI.Button.State.ACTIVE : Autodesk.Viewing.UI.Button.State.INACTIVE;
521
+ if (docBtn.getState() !== newState) {
522
+ docBtn.setState(newState);
523
+ }
524
+
525
+ // Force CSS class update to ensure visual state is correct
526
+ if (docBtn.container) {
527
+ if (isVisible) {
528
+ docBtn.container.classList.add('active');
529
+ docBtn.container.classList.remove('inactive');
530
+ } else {
531
+ docBtn.container.classList.remove('active');
532
+ docBtn.container.classList.add('inactive');
533
+ }
534
+ }
535
+ }
536
+
537
+ // Check Pan button state - ensure it stays active
538
+ var panBtn = toolGroup.getControl('custom-pan-btn');
539
+ if (panBtn) {
540
+ // Check if pan tool is the active tool
541
+ var activeTool = viewer.getActiveNavigationTool();
542
+ var isPanActive = activeTool === 'pan';
543
+ if (isPanActive) {
544
+ panBtn.setState(Autodesk.Viewing.UI.Button.State.ACTIVE);
545
+ if (panBtn.container) {
546
+ panBtn.container.classList.add('active');
547
+ panBtn.container.classList.remove('inactive');
548
+ }
549
+ }
550
+ }
551
+ };
307
552
  var originalUnload = ToolbarExtension.prototype.unload;
308
553
  ToolbarExtension.prototype.unload = function () {
309
554
  if (this._toolbarInterval) {
@@ -343,7 +588,7 @@ function registerToolbarExtension(Autodesk) {
343
588
  }
344
589
  this.createPaginationGroup(toolbar);
345
590
  } else {
346
- pagGroup.setVisible(true);
591
+ // Don't force visibility here - let updatePaginationState handle it
347
592
  this.paginationGroup = pagGroup;
348
593
  }
349
594
  toolbar.setVisible(true);
@@ -358,45 +603,62 @@ function registerToolbarExtension(Autodesk) {
358
603
  panBtn.setIcon('adsk-icon-pan');
359
604
  panBtn.setToolTip('Pan');
360
605
  panBtn.onClick = function () {
361
- return viewer.setTool('pan');
606
+ var originalPanBtn = document.getElementById('toolbar-panTool');
607
+ if (originalPanBtn) {
608
+ originalPanBtn.click();
609
+ }
610
+
611
+ // Set this button to active state
612
+ if (panBtn.container) {
613
+ panBtn.container.classList.add('active');
614
+ panBtn.container.classList.remove('inactive');
615
+ }
616
+ panBtn.setState(Autodesk.Viewing.UI.Button.State.ACTIVE);
362
617
  };
363
618
  this.subToolbar.addControl(panBtn);
364
619
  var docBrowserBtn = new Autodesk.Viewing.UI.Button('custom-doc-browser-btn');
365
620
  docBrowserBtn.setIcon('adsk-icon-documentModels');
366
621
  docBrowserBtn.setToolTip('Document Browser');
622
+ var self = this;
367
623
  docBrowserBtn.onClick = function () {
368
624
  var ext = viewer.getExtension('Autodesk.DocumentBrowser');
369
- if (ext && ext.ui) ext.ui.togglePanel();
625
+ if (ext && ext.ui) {
626
+ ext.ui.togglePanel();
627
+ // Update flag based on new state
628
+ setTimeout(function () {
629
+ self.docBrowserShouldBeOpen = ext.ui.panel && ext.ui.panel.isVisible();
630
+ }, 50);
631
+ }
370
632
  };
371
633
  this.subToolbar.addControl(docBrowserBtn);
372
634
  var downloadBtn = new Autodesk.Viewing.UI.Button('custom-download-btn');
373
635
  downloadBtn.setIcon('adsk-icon-custom-download');
374
636
  downloadBtn.setToolTip('Download File');
375
- downloadBtn.onClick = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
376
- var fileUrl, response, blob, urlPath, filename, blobUrl, anchor, _t;
377
- return _regenerator().w(function (_context) {
378
- while (1) switch (_context.p = _context.n) {
637
+ downloadBtn.onClick = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
638
+ var fileUrl, response, blob, urlPath, filename, blobUrl, anchor, _t2;
639
+ return _regenerator().w(function (_context2) {
640
+ while (1) switch (_context2.p = _context2.n) {
379
641
  case 0:
380
642
  if (!(_this4.options && _this4.options.filePath)) {
381
- _context.n = 7;
643
+ _context2.n = 7;
382
644
  break;
383
645
  }
384
- _context.p = 1;
646
+ _context2.p = 1;
385
647
  fileUrl = _this4.options.filePath;
386
- _context.n = 2;
648
+ _context2.n = 2;
387
649
  return fetch(fileUrl);
388
650
  case 2:
389
- response = _context.v;
651
+ response = _context2.v;
390
652
  if (response.ok) {
391
- _context.n = 3;
653
+ _context2.n = 3;
392
654
  break;
393
655
  }
394
656
  throw new Error("HTTP error! status: ".concat(response.status));
395
657
  case 3:
396
- _context.n = 4;
658
+ _context2.n = 4;
397
659
  return response.blob();
398
660
  case 4:
399
- blob = _context.v;
661
+ blob = _context2.v;
400
662
  urlPath = new URL(fileUrl).pathname;
401
663
  filename = decodeURIComponent(urlPath.split('/').pop()) || 'document.pdf';
402
664
  blobUrl = URL.createObjectURL(blob);
@@ -408,23 +670,23 @@ function registerToolbarExtension(Autodesk) {
408
670
  anchor.click();
409
671
  document.body.removeChild(anchor);
410
672
  URL.revokeObjectURL(blobUrl);
411
- _context.n = 6;
673
+ _context2.n = 6;
412
674
  break;
413
675
  case 5:
414
- _context.p = 5;
415
- _t = _context.v;
416
- console.error('Download error:', _t);
417
- alert('Unable to download file: ' + _t.message);
676
+ _context2.p = 5;
677
+ _t2 = _context2.v;
678
+ console.error('Download error:', _t2);
679
+ alert('Unable to download file: ' + _t2.message);
418
680
  case 6:
419
- _context.n = 8;
681
+ _context2.n = 8;
420
682
  break;
421
683
  case 7:
422
684
  console.warn('FilePath not available in extension options');
423
685
  alert('File path not available for download');
424
686
  case 8:
425
- return _context.a(2);
687
+ return _context2.a(2);
426
688
  }
427
- }, _callee, null, [[1, 5]]);
689
+ }, _callee2, null, [[1, 5]]);
428
690
  }));
429
691
  this.subToolbar.addControl(downloadBtn);
430
692
  };
@@ -550,7 +812,7 @@ function styleInject(css, ref) {
550
812
  }
551
813
  }
552
814
 
553
- var css_248z$1 = "#navTools,\n#modelTools,\n#settingsTools,\n#measureTools {\n display: none !important;\n visibility: hidden !important;\n}\n#guiviewer3d-toolbar {\n display: flex !important;\n align-items: center !important;\n justify-content: center !important;\n gap: 20px;\n position: fixed !important;\n bottom: 10px !important;\n left: 50% !important;\n transform: translateX(-50%) !important;\n width: auto !important;\n border-radius: 4px !important;\n padding: 8px 12px !important;\n}\n#custom-tool-group {\n display: flex !important;\n margin: 0 !important;\n padding: 0 !important;\n}\n#custom-pagination-group {\n display: flex !important;\n position: relative !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n left: auto !important;\n}\n";
815
+ var css_248z$1 = "#navTools,\n#modelTools,\n#settingsTools,\n#measureTools {\n display: none !important;\n visibility: hidden !important;\n}\n#guiviewer3d-toolbar {\n display: flex !important;\n align-items: center !important;\n justify-content: center !important;\n gap: 20px;\n position: fixed !important;\n bottom: 10px !important;\n left: 50% !important;\n transform: translateX(-50%) !important;\n width: auto !important;\n border-radius: 4px !important;\n padding: 8px 12px !important;\n}\n#custom-tool-group {\n display: flex !important;\n margin: 0 !important;\n padding: 0 !important;\n}\n#custom-pagination-group {\n display: flex;\n position: relative !important;\n margin: 0 !important;\n padding: 0 !important;\n transform: none !important;\n left: auto !important;\n}\n\n/* Document Browser Panel Styling */\n.docking-panel.document-browser-panel,\n.adsk-viewing-viewer .docking-panel.document-browser-panel {\n min-height: 400px !important;\n height: 80% !important;\n max-height: 80vh !important;\n}\n\n/* Ensure thumbnail container has proper height */\n.docking-panel.document-browser-panel .docking-panel-container-solid-color-a,\n.document-browser-panel .treeview,\n.document-browser-panel .thumbnails-container {\n height: calc(100% - 50px) !important;\n min-height: 350px !important;\n overflow-y: auto !important;\n}\n\n/* Thumbnail cards styling */\n.document-browser-panel .thumbnail-item,\n.document-browser-panel .thumbnail {\n display: flex !important;\n visibility: visible !important;\n}\n\n/* Ensure thumbnail images are visible */\n.document-browser-panel .thumbnail img,\n.document-browser-panel .thumbnail-item img {\n display: block !important;\n visibility: visible !important;\n max-width: 100% !important;\n height: auto !important;\n}\n";
554
816
  styleInject(css_248z$1);
555
817
 
556
818
  var css_248z = "/* Custom icon styles for toolbar using SVG */\n\n/* Download icon - custom SVG */\n.adsk-icon-custom-download::before {\n content: '';\n display: inline-block;\n width: 24px;\n height: 24px;\n background-image: url('data:image/svg+xml;utf8,\\\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\\\n<path fill=\"%23FFFFFF\" d=\"M9.293 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.707A1 1 0 0 0 13.707 4L10 .293A1 1 0 0 0 9.293 0M9.5 3.5v-2l3 3h-2a1 1 0 0 1-1-1m-1 4v3.793l1.146-1.147a.5.5 0 0 1 .708.708l-2 2a.5.5 0 0 1-.708 0l-2-2a.5.5 0 0 1 .708-.708L7.5 11.293V7.5a.5.5 0 0 1 1 0\"/>\\\n</svg>');\n background-repeat: no-repeat;\n background-position: center;\n background-size: 16px 16px;\n}\n\n/* Previous page icon - Font Awesome chevron left */\n.adsk-icon-custom-prev::before {\n content: '';\n display: inline-block;\n width: 24px;\n height: 24px;\n background-image: url('data:image/svg+xml;utf8,\\\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\\\n<path fill=\"%23FFFFFF\" d=\"M16 14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2zm-4.5-6.5H5.707l2.147-2.146a.5.5 0 1 0-.708-.708l-3 3a.5.5 0 0 0 0 .708l3 3a.5.5 0 0 0 .708-.708L5.707 8.5H11.5a.5.5 0 0 0 0-1\"/>\\\n</svg>');\n background-repeat: no-repeat;\n background-position: center;\n background-size: 16px 16px;\n}\n\n/* Next page icon - Font Awesome chevron right */\n.adsk-icon-custom-next::before {\n content: '';\n display: inline-block;\n width: 24px;\n height: 24px;\n background-image: url('data:image/svg+xml;utf8,\\\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\\\n<path fill=\"%23FFFFFF\" d=\"M0 14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2a2 2 0 0 0-2 2zm4.5-6.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5a.5.5 0 0 1 0-1\"/>\\\n</svg>');\n background-repeat: no-repeat;\n background-position: center;\n background-size: 16px 16px;\n}\n\n/* Fallback for adsk-icon-caret-left and adsk-icon-caret-right if not defined */\n.adsk-icon-caret-left::before {\n content: '[';\n font-family: 'adsk-viewing';\n}\n\n.adsk-icon-caret-right::before {\n content: ']';\n font-family: 'adsk-viewing';\n}\n\n/* Comment icon - custom SVG (Smiley) */\n.adsk-icon-custom-comment::before {\n content: '';\n display: inline-block;\n width: 24px;\n height: 24px;\n background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%23FFFFFF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"></circle><path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path><line x1=\"9\" y1=\"9\" x2=\"9.01\" y2=\"9\"></line><line x1=\"15\" y1=\"9\" x2=\"15.01\" y2=\"9\"></line></svg>');\n background-repeat: no-repeat;\n background-position: center;\n background-size: contain;\n}\n\n/* Save icon - custom SVG */\n.adsk-icon-custom-save::before {\n content: '';\n display: inline-block;\n width: 24px;\n height: 24px;\n background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%23FFFFFF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z\"></path><polyline points=\"17 21 17 13 7 13 7 21\"></polyline><polyline points=\"7 3 7 8 15 8\"></polyline></svg>');\n background-repeat: no-repeat;\n background-position: center;\n background-size: contain;\n}\n";
@@ -623,16 +885,57 @@ var ViewerForgePDF = function ViewerForgePDF(_ref) {
623
885
  viewer.toolbar.setVisible(true);
624
886
  }
625
887
  if (viewables.length > 1) {
626
- var documentBrowser = viewer.getExtension('Autodesk.DocumentBrowser');
627
- if (documentBrowser) {
628
- if (documentBrowser.ui.panel) {
629
- documentBrowser.ui.panel.container.style.top = 0;
888
+ // Auto-open Document Browser by clicking the original button
889
+ setTimeout(function () {
890
+ var originalDocBtn = document.getElementById('toolbar-documentModels');
891
+ if (originalDocBtn && !originalDocBtn.classList.contains('active')) {
892
+ originalDocBtn.click();
893
+ }
894
+
895
+ // Apply custom styling to the panel
896
+ var documentBrowser = viewer.getExtension('Autodesk.DocumentBrowser');
897
+ if (documentBrowser && documentBrowser.ui && documentBrowser.ui.panel) {
898
+ documentBrowser.ui.panel.container.style.top = '0';
630
899
  documentBrowser.ui.panel.container.style.left = 'unset';
631
900
  documentBrowser.ui.panel.container.style.right = '0px';
632
901
  documentBrowser.ui.panel.container.style.width = '200px';
902
+ documentBrowser.ui.panel.container.style.height = '80%';
903
+ documentBrowser.ui.panel.container.style.minHeight = '400px';
633
904
  }
634
- }
905
+
906
+ // Switch to Thumbnail tab after a short delay
907
+ setTimeout(function () {
908
+ // Try multiple selectors to find the thumbnail tab button
909
+ var thumbnailTab = document.querySelector('.docking-panel-thumbnail-view') || document.querySelector('[data-i18n="Thumbnails"]') || Array.from(document.querySelectorAll('.adsk-control-group .adsk-button')).find(function (btn) {
910
+ return btn.textContent.includes('Thumbnails') || btn.title.includes('Thumbnails');
911
+ });
912
+ if (thumbnailTab && !thumbnailTab.classList.contains('active')) {
913
+ thumbnailTab.click();
914
+ }
915
+ }, 200);
916
+ }, 500);
635
917
  }
918
+
919
+ // Ensure Custom Pan tool is active by default
920
+ setTimeout(function () {
921
+ var customPanBtn = document.getElementById('custom-pan-btn');
922
+ if (customPanBtn) {
923
+ customPanBtn.click();
924
+ // Double check visual state
925
+ if (!customPanBtn.classList.contains('active')) {
926
+ customPanBtn.classList.add('active');
927
+ customPanBtn.classList.remove('inactive');
928
+ }
929
+ } else {
930
+ var _viewer$toolbar;
931
+ // Fallback if custom button not found immediately, try accessing via viewer toolbar
932
+ var toolGroup = (_viewer$toolbar = viewer.toolbar) === null || _viewer$toolbar === void 0 ? void 0 : _viewer$toolbar.getControl('custom-tool-group');
933
+ var panBtnConf = toolGroup === null || toolGroup === void 0 ? void 0 : toolGroup.getControl('custom-pan-btn');
934
+ if (panBtnConf) {
935
+ panBtnConf.setState(1); // ACTIVE
936
+ }
937
+ }
938
+ }, 600);
636
939
  if (setViewer) setViewer(viewer);
637
940
  } catch (err) {
638
941
  console.error('Error in handleLoadSuccess:', err);
@@ -659,7 +962,8 @@ var ViewerForgePDF = function ViewerForgePDF(_ref) {
659
962
  }, _callee);
660
963
  })));
661
964
  }
662
- }, [status, filePath, fileExt, setViewer]);
965
+ // eslint-disable-next-line react-hooks/exhaustive-deps
966
+ }, [status, filePath, fileExt]);
663
967
  return /*#__PURE__*/jsx("div", {
664
968
  style: {
665
969
  position: 'relative',