box-content-preview 3.67.0 → 3.69.0

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![Mergify Status](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/box/box-content-preview&style=flat)](https://mergify.io)
3
3
  [![Styled With Prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
4
4
  [![build status](https://img.shields.io/travis/box/box-content-preview/master.svg?style=flat-square)](https://travis-ci.org/box/box-content-preview)
5
- [![version](https://img.shields.io/badge/version-v3.67.0-blue.svg?style=flat-square)](https://github.com/box/box-content-preview)
5
+ [![version](https://img.shields.io/badge/version-v3.69.0-blue.svg?style=flat-square)](https://github.com/box/box-content-preview)
6
6
  [![npm version](https://img.shields.io/npm/v/box-ui-elements.svg?style=flat-square)](https://www.npmjs.com/package/box-ui-elements)
7
7
 
8
8
  # [Box Content Preview](https://developer.box.com/docs/box-content-preview)
@@ -22,11 +22,11 @@ We encourage all users to update their applications to utilize modern browsers f
22
22
 
23
23
  ## Current Version
24
24
 
25
- - Version: v3.67.0
25
+ - Version: v3.69.0
26
26
  - Locale: en-US
27
27
 
28
- https://cdn01.boxcdn.net/platform/preview/3.67.0/en-US/preview.js
29
- https://cdn01.boxcdn.net/platform/preview/3.67.0/en-US/preview.css
28
+ https://cdn01.boxcdn.net/platform/preview/3.69.0/en-US/preview.js
29
+ https://cdn01.boxcdn.net/platform/preview/3.69.0/en-US/preview.css
30
30
 
31
31
  ## Supported Locales
32
32
 
@@ -52,10 +52,10 @@ You can self-host the Box Content Preview library or reference the versions avai
52
52
  <title>Box Content Preview Demo</title>
53
53
 
54
54
  <!-- Latest version of Preview SDK for your locale -->
55
- <script src="https://cdn01.boxcdn.net/platform/preview/3.67.0/en-US/preview.js"></script>
55
+ <script src="https://cdn01.boxcdn.net/platform/preview/3.69.0/en-US/preview.js"></script>
56
56
  <link
57
57
  rel="stylesheet"
58
- href="https://cdn01.boxcdn.net/platform/preview/3.67.0/en-US/preview.css"
58
+ href="https://cdn01.boxcdn.net/platform/preview/3.69.0/en-US/preview.css"
59
59
  />
60
60
  </head>
61
61
  <body>
@@ -76,7 +76,7 @@ To self-host the Box Content Preview library, follow these steps:
76
76
 
77
77
  1. Either fork the repo and check out the version you want to host or download the specific version as a zip:
78
78
 
79
- - Check out a specific version with `git checkout v3.67.0`
79
+ - Check out a specific version with `git checkout v3.69.0`
80
80
  - Download a specific version as a zip from https://github.com/box/box-content-preview/releases
81
81
 
82
82
  2. Install dependencies and build the library with `yarn install && yarn build:i18n && yarn build:prod`
package/dist/lib/index.js CHANGED
@@ -17416,7 +17416,7 @@ function util_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var
17416
17416
  const CLIENT_NAME = "box-content-preview"; // eslint-disable-line no-undef
17417
17417
  const CLIENT_NAME_KEY = 'box_client_name';
17418
17418
  const CLIENT_VERSION_KEY = 'box_client_version';
17419
- const CLIENT_VERSION = "3.67.0"; // eslint-disable-line no-undef
17419
+ const CLIENT_VERSION = "3.69.0"; // eslint-disable-line no-undef
17420
17420
  const HEADER_CLIENT_NAME = 'X-Box-Client-Name';
17421
17421
  const HEADER_CLIENT_VERSION = 'X-Box-Client-Version';
17422
17422
  const PROMISE_MAP = {};
@@ -19141,7 +19141,7 @@ class Browser {
19141
19141
  ;// ./src/lib/Logger.js
19142
19142
  /* eslint-disable no-undef */
19143
19143
  const Logger_CLIENT_NAME = "box-content-preview";
19144
- const Logger_CLIENT_VERSION = "3.67.0";
19144
+ const Logger_CLIENT_VERSION = "3.69.0";
19145
19145
  /* eslint-enable no-undef */
19146
19146
 
19147
19147
  class Logger {
@@ -22861,7 +22861,7 @@ function AnnotationsControls(_ref) {
22861
22861
  title: "Markup"
22862
22862
  }, /*#__PURE__*/__WEBPACK_EXTERNAL_MODULE_react_default__.createElement(icons_IconPencilScribbleMedium24, {
22863
22863
  style: {
22864
- color: annotationColor
22864
+ color: isDrawingActive ? annotationColor : __WEBPACK_EXTERNAL_MODULE_box_ui_elements_es_styles_variables_c815ce80_white__
22865
22865
  }
22866
22866
  })), /*#__PURE__*/__WEBPACK_EXTERNAL_MODULE_react_default__.createElement(annotations_AnnotationsTargetedTooltip, {
22867
22867
  isEnabled: showRegion
@@ -39525,6 +39525,9 @@ class Thumbnail {
39525
39525
  return Promise.resolve(null);
39526
39526
  }
39527
39527
  return pdfDocument.getPage(1).then(page => {
39528
+ if (!this.thumbnailImageCache) {
39529
+ return null;
39530
+ }
39528
39531
  const rotation = ((this.pdfViewer.pagesRotation || 0) + page.rotate) % 360;
39529
39532
  const viewport = page.getViewport({
39530
39533
  scale: 1,
@@ -39586,6 +39589,9 @@ class Thumbnail {
39586
39589
  * @return {Promise} - promise reolves with the image HTMLElement or null if generation is in progress
39587
39590
  */
39588
39591
  createThumbnailImage(itemIndex, thumbOptions) {
39592
+ if (!this.thumbnailImageCache) {
39593
+ return Promise.resolve(null);
39594
+ }
39589
39595
  const cacheEntry = this.getImageFromCache(itemIndex);
39590
39596
  // If this thumbnail has already been cached, use it
39591
39597
  if (cacheEntry && cacheEntry.image) {
@@ -39602,8 +39608,10 @@ class Thumbnail {
39602
39608
  inProgress: true
39603
39609
  }));
39604
39610
  return this.getThumbnailDataURL(itemIndex + 1, thumbOptions).then(dataUrl => {
39605
- return this.createImageEl(dataUrl, thumbOptions);
39606
- }).then(imageEl => {
39611
+ if (!this.thumbnailImageCache) {
39612
+ return null;
39613
+ }
39614
+ const imageEl = this.createImageEl(dataUrl, thumbOptions);
39607
39615
  // Cache this image element for future use
39608
39616
  this.thumbnailImageCache.set(itemIndex, {
39609
39617
  inProgress: false,
@@ -39611,6 +39619,9 @@ class Thumbnail {
39611
39619
  });
39612
39620
  return imageEl;
39613
39621
  }).catch(() => {
39622
+ if (!this.thumbnailImageCache) {
39623
+ return null;
39624
+ }
39614
39625
  this.thumbnailImageCache.set(itemIndex, Thumbnail_objectSpread(Thumbnail_objectSpread({}, this.getImageFromCache(itemIndex)), {}, {
39615
39626
  inProgress: false
39616
39627
  }));
@@ -39625,7 +39636,7 @@ class Thumbnail {
39625
39636
  * @return {Promise} - promise reolves with the image HTMLElement or null if generation is in progress
39626
39637
  */
39627
39638
  getImageFromCache(itemIndex) {
39628
- return this.thumbnailImageCache.get(itemIndex);
39639
+ return this.thumbnailImageCache?.get(itemIndex) || null;
39629
39640
  }
39630
39641
 
39631
39642
  /**
@@ -39644,6 +39655,9 @@ class Thumbnail {
39644
39655
  const canvas = document.createElement('canvas');
39645
39656
  const thumbnailImageWidth = thumbOptions && thumbOptions.thumbMaxWidth ? thumbOptions.thumbMaxWidth : THUMBNAIL_IMAGE_WIDTH;
39646
39657
  return pdfDocument.getPage(pageNum).then(page => {
39658
+ if (!this.thumbnailImageCache) {
39659
+ return null;
39660
+ }
39647
39661
  const rotation = ((this.pdfViewer.pagesRotation || 0) + page.rotate) % 360;
39648
39662
  const viewport = page.getViewport({
39649
39663
  scale: 1,
@@ -41302,11 +41316,16 @@ class ThumbnailsSidebar {
41302
41316
  this.virtualScroller.destroy();
41303
41317
  this.virtualScroller = null;
41304
41318
  }
41319
+ if (this.thumbnail) {
41320
+ this.thumbnail.destroy();
41321
+ this.thumbnail = null;
41322
+ }
41305
41323
  this.pdfViewer = null;
41306
41324
  this.currentThumbnails = [];
41307
41325
  this.currentPage = null;
41308
41326
  this.preloader = null;
41309
41327
  this.anchorEl.removeEventListener('click', this.thumbnailClickHandler);
41328
+ this.anchorEl.removeEventListener('keydown', this.onKeydown);
41310
41329
  }
41311
41330
 
41312
41331
  /**
@@ -41377,6 +41396,9 @@ class ThumbnailsSidebar {
41377
41396
  * @return {void}
41378
41397
  */
41379
41398
  renderNextThumbnailImage() {
41399
+ if (!this.thumbnail || !this.virtualScroller) {
41400
+ return;
41401
+ }
41380
41402
  const scrollerNotInited = this.virtualScroller && this.virtualScroller instanceof lib_VirtualScroller && typeof this.virtualScroller.totalItems === 'undefined';
41381
41403
  if (scrollerNotInited) {
41382
41404
  this.thumbnail.init().then(this.initVirtualScrollerIfReady);
@@ -41450,6 +41472,9 @@ class ThumbnailsSidebar {
41450
41472
  * @return {void}
41451
41473
  */
41452
41474
  requestThumbnailImage(itemIndex, thumbnailEl) {
41475
+ if (!this.thumbnail) {
41476
+ return;
41477
+ }
41453
41478
  const requestId = requestAnimationFrame(() => {
41454
41479
  this.animationFrameRequestIds = this.animationFrameRequestIds.filter(id => id !== requestId);
41455
41480
  this.thumbnail.createThumbnailImage(itemIndex).then(imageEl => {
@@ -41556,7 +41581,7 @@ class ThumbnailsSidebar {
41556
41581
  }
41557
41582
  refresh() {
41558
41583
  if (!this.virtualScroller) {
41559
- return;
41584
+ return Promise.resolve();
41560
41585
  }
41561
41586
  this.virtualScroller.destroy();
41562
41587
  this.virtualScroller = new lib_VirtualScroller(this.anchorEl);
@@ -41567,7 +41592,10 @@ class ThumbnailsSidebar {
41567
41592
  // Skip preloader path since preloader dimensions are unrotated
41568
41593
  const savedPreloader = this.thumbnail.preloader;
41569
41594
  this.thumbnail.preloader = null;
41570
- this.thumbnail.init().then(thumbnailHeight => {
41595
+ return this.thumbnail.init().then(thumbnailHeight => {
41596
+ if (!this.thumbnail || !this.virtualScroller) {
41597
+ return;
41598
+ }
41571
41599
  this.thumbnail.preloader = savedPreloader;
41572
41600
  if (thumbnailHeight) {
41573
41601
  const count = this.pdfViewer?.pagesCount || this.preloader?.numPages;
@@ -41847,6 +41875,13 @@ class DocBaseViewer extends viewers_BaseViewer {
41847
41875
  if (this.galleryController) {
41848
41876
  this.galleryController.destroy();
41849
41877
  }
41878
+ if (this.thumbnailsSidebar) {
41879
+ this.thumbnailsSidebar.destroy();
41880
+ }
41881
+ if (this.advancedInsightsThumbs) {
41882
+ this.advancedInsightsThumbs.destroy();
41883
+ this.advancedInsightsThumbs = null;
41884
+ }
41850
41885
 
41851
41886
  // Clean up PDF network requests
41852
41887
  if (this.pdfLoadingTask) {
@@ -41857,16 +41892,19 @@ class DocBaseViewer extends viewers_BaseViewer {
41857
41892
  }
41858
41893
  }
41859
41894
 
41860
- // Clean up viewer
41895
+ // Clean up and detach the PDF.js document so retained viewer instances
41896
+ // do not keep page views and document resources alive.
41861
41897
  if (this.pdfViewer) {
41862
41898
  this.pdfViewer.cleanup();
41899
+ this.pdfViewer.setDocument(null);
41900
+ }
41901
+ if (this.pdfLinkService) {
41902
+ this.pdfLinkService.setDocument(null);
41863
41903
  }
41904
+ this.doc = null;
41864
41905
  if (this.printPopup) {
41865
41906
  this.printPopup.destroy();
41866
41907
  }
41867
- if (this.thumbnailsSidebar) {
41868
- this.thumbnailsSidebar.destroy();
41869
- }
41870
41908
  if (this.thumbnailsSidebarEl) {
41871
41909
  // Since we are cleaning up make sure the thumbnails open class is
41872
41910
  // removed so that the content div shifts back left
@@ -42614,6 +42652,10 @@ class DocBaseViewer extends viewers_BaseViewer {
42614
42652
  this.pageTracker.addListener('page_tracker_report', this.handleAdvancedInsightsReport);
42615
42653
  }
42616
42654
  return this.pdfLoadingTask.promise.then(doc => {
42655
+ if (this.isDestroyed()) {
42656
+ return null;
42657
+ }
42658
+
42617
42659
  // Only check operations for .numbers and .xlsx files
42618
42660
  if (file.extension === 'numbers' || file.extension === 'xlsx') {
42619
42661
  return countPdfOperations(doc, MAX_OPERATION_PAGES).then(opCount => {
@@ -42625,6 +42667,9 @@ class DocBaseViewer extends viewers_BaseViewer {
42625
42667
  }
42626
42668
  return doc;
42627
42669
  }).then(doc => {
42670
+ if (this.isDestroyed()) {
42671
+ return;
42672
+ }
42628
42673
  this.pdfLinkService.setDocument(doc, pdfUrl);
42629
42674
  this.pdfViewer.setDocument(doc);
42630
42675
  if (this.shouldThumbnailsBeToggled()) {
@@ -42635,6 +42680,9 @@ class DocBaseViewer extends viewers_BaseViewer {
42635
42680
  // store a reference to the doc for docfirstpages
42636
42681
  this.doc = doc;
42637
42682
  }).catch(err => {
42683
+ if (this.isDestroyed()) {
42684
+ return;
42685
+ }
42638
42686
  console.error(err); // eslint-disable-line
42639
42687
 
42640
42688
  // pdf.js gives us the status code in their error message
@@ -43084,12 +43132,23 @@ class DocBaseViewer extends viewers_BaseViewer {
43084
43132
  this.docEl.addEventListener('keydown', this.handleDocElKeydown);
43085
43133
  this.docEl.addEventListener('scroll', this.throttledScrollHandler);
43086
43134
  if (this.hasTouch) {
43087
- this.docEl.addEventListener('touchstart', this.pinchToZoomStartHandler);
43088
- this.docEl.addEventListener('touchmove', this.pinchToZoomChangeHandler);
43135
+ const searchParams = new URLSearchParams(window.location.search);
43136
+ const disableNativePinchToZoom = searchParams.has('disableNativePinchToZoom');
43137
+ const disableAllTouchActions = searchParams.has('disableAllTouchActions');
43138
+ const forceNonPassiveTouchListeners = searchParams.has('forceNonPassiveTouchListeners');
43139
+ if (disableAllTouchActions) {
43140
+ this.docEl.style.touchAction = 'none';
43141
+ } else if (disableNativePinchToZoom) {
43142
+ this.docEl.style.touchAction = 'pan-x pan-y';
43143
+ }
43144
+ const passiveOption = forceNonPassiveTouchListeners ? {
43145
+ passive: false
43146
+ } : undefined;
43147
+ this.docEl.addEventListener('touchstart', this.pinchToZoomStartHandler, passiveOption);
43148
+ this.docEl.addEventListener('touchmove', this.pinchToZoomChangeHandler, passiveOption);
43089
43149
  this.docEl.addEventListener('touchend', this.pinchToZoomEndHandler);
43090
43150
  }
43091
- const disableMobileWheelZoom = new URLSearchParams(window.location.search).has('disableMobileWheelZoom');
43092
- if (this.featureEnabled('pinchToZoom.enabled') && !(this.isMobile && disableMobileWheelZoom)) {
43151
+ if (this.featureEnabled('pinchToZoom.enabled')) {
43093
43152
  this.docEl.addEventListener('wheel', this.trackpadPinchToZoomHandler, {
43094
43153
  passive: false
43095
43154
  });
@@ -43111,8 +43170,7 @@ class DocBaseViewer extends viewers_BaseViewer {
43111
43170
  this.docEl.removeEventListener('touchmove', this.pinchToZoomChangeHandler);
43112
43171
  this.docEl.removeEventListener('touchend', this.pinchToZoomEndHandler);
43113
43172
  }
43114
- const disableMobileWheelZoom = new URLSearchParams(window.location.search).has('disableMobileWheelZoom');
43115
- if (this.featureEnabled('pinchToZoom.enabled') && !(this.isMobile && disableMobileWheelZoom)) {
43173
+ if (this.featureEnabled('pinchToZoom.enabled')) {
43116
43174
  this.docEl.removeEventListener('wheel', this.trackpadPinchToZoomHandler);
43117
43175
  }
43118
43176
  }
@@ -43779,9 +43837,12 @@ class DocBaseViewer extends viewers_BaseViewer {
43779
43837
  * Get a thumbnail image element
43780
43838
  *
43781
43839
  * @param {number} pageNumber - the page number
43782
- * @return {Promise} - promise resolves with the image HTMLElement or null if generation is in progress
43840
+ * @return {Promise} - promise resolves with the image HTMLElement or null if unavailable or in progress
43783
43841
  */
43784
43842
  getThumbnail(pageNumber) {
43843
+ if (this.isDestroyed()) {
43844
+ return Promise.resolve(null);
43845
+ }
43785
43846
  if (!this.advancedInsightsThumbs) {
43786
43847
  this.advancedInsightsThumbs = new lib_Thumbnail(this.pdfViewer);
43787
43848
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "box-content-preview",
3
- "version": "3.67.0",
3
+ "version": "3.69.0",
4
4
  "description": "Box Content Preview UI Element",
5
5
  "author": "Box (https://www.box.com/)",
6
6
  "license": "SEE LICENSE IN LICENSE",