box-content-preview 3.42.0 → 3.43.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 +7 -7
- package/dist/lib/index.js +65 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
[](https://mergify.io)
|
|
3
3
|
[](https://github.com/prettier/prettier)
|
|
4
4
|
[](https://travis-ci.org/box/box-content-preview)
|
|
5
|
-
[](https://github.com/box/box-content-preview)
|
|
6
6
|
[](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.
|
|
25
|
+
- Version: v3.43.0
|
|
26
26
|
- Locale: en-US
|
|
27
27
|
|
|
28
|
-
https://cdn01.boxcdn.net/platform/preview/3.
|
|
29
|
-
https://cdn01.boxcdn.net/platform/preview/3.
|
|
28
|
+
https://cdn01.boxcdn.net/platform/preview/3.43.0/en-US/preview.js
|
|
29
|
+
https://cdn01.boxcdn.net/platform/preview/3.43.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.
|
|
55
|
+
<script src="https://cdn01.boxcdn.net/platform/preview/3.43.0/en-US/preview.js"></script>
|
|
56
56
|
<link
|
|
57
57
|
rel="stylesheet"
|
|
58
|
-
href="https://cdn01.boxcdn.net/platform/preview/3.
|
|
58
|
+
href="https://cdn01.boxcdn.net/platform/preview/3.43.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.
|
|
79
|
+
- Check out a specific version with `git checkout v3.43.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
|
@@ -9340,7 +9340,7 @@ function util_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var
|
|
|
9340
9340
|
const CLIENT_NAME = "box-content-preview"; // eslint-disable-line no-undef
|
|
9341
9341
|
const CLIENT_NAME_KEY = 'box_client_name';
|
|
9342
9342
|
const CLIENT_VERSION_KEY = 'box_client_version';
|
|
9343
|
-
const CLIENT_VERSION = "3.
|
|
9343
|
+
const CLIENT_VERSION = "3.43.0"; // eslint-disable-line no-undef
|
|
9344
9344
|
const HEADER_CLIENT_NAME = 'X-Box-Client-Name';
|
|
9345
9345
|
const HEADER_CLIENT_VERSION = 'X-Box-Client-Version';
|
|
9346
9346
|
const PROMISE_MAP = {};
|
|
@@ -11058,7 +11058,7 @@ class Browser {
|
|
|
11058
11058
|
;// ./src/lib/Logger.js
|
|
11059
11059
|
/* eslint-disable no-undef */
|
|
11060
11060
|
const Logger_CLIENT_NAME = "box-content-preview";
|
|
11061
|
-
const Logger_CLIENT_VERSION = "3.
|
|
11061
|
+
const Logger_CLIENT_VERSION = "3.43.0";
|
|
11062
11062
|
/* eslint-enable no-undef */
|
|
11063
11063
|
|
|
11064
11064
|
class Logger {
|
|
@@ -13752,6 +13752,7 @@ class ControlsRoot {
|
|
|
13752
13752
|
let {
|
|
13753
13753
|
className = 'bp-ControlsRoot',
|
|
13754
13754
|
containerEl,
|
|
13755
|
+
fileExtension,
|
|
13755
13756
|
fileId,
|
|
13756
13757
|
onHide = (noop_default()),
|
|
13757
13758
|
onShow = (noop_default())
|
|
@@ -13783,6 +13784,7 @@ class ControlsRoot {
|
|
|
13783
13784
|
this.controlsEl.setAttribute('data-testid', 'bp-controls');
|
|
13784
13785
|
this.controlsEl.setAttribute('data-resin-component', 'toolbar');
|
|
13785
13786
|
this.controlsEl.setAttribute('data-resin-fileid', fileId);
|
|
13787
|
+
this.controlsEl.setAttribute('data-resin-fileextension', fileExtension || '');
|
|
13786
13788
|
this.containerEl = containerEl;
|
|
13787
13789
|
this.containerEl.addEventListener('mousemove', this.handleMouseMove);
|
|
13788
13790
|
this.containerEl.addEventListener('touchstart', this.handleTouchStart);
|
|
@@ -14028,6 +14030,7 @@ class ImageBaseViewer extends viewers_BaseViewer {
|
|
|
14028
14030
|
loadUI() {
|
|
14029
14031
|
this.controls = new ControlsRoot({
|
|
14030
14032
|
containerEl: this.containerEl,
|
|
14033
|
+
fileExtension: this.options.file.extension,
|
|
14031
14034
|
fileId: this.options.file.id
|
|
14032
14035
|
});
|
|
14033
14036
|
}
|
|
@@ -14174,6 +14177,13 @@ class ImageBaseViewer extends viewers_BaseViewer {
|
|
|
14174
14177
|
return;
|
|
14175
14178
|
}
|
|
14176
14179
|
this.isPinching = true;
|
|
14180
|
+
this.options.resin?.recordAction({
|
|
14181
|
+
action: 'programmatic',
|
|
14182
|
+
component: 'toolbar',
|
|
14183
|
+
target: event.deltaY > 0 ? 'zoomOut' : 'zoomIn',
|
|
14184
|
+
fileId: this.options.file.id,
|
|
14185
|
+
fileExtension: this.options.file.extension
|
|
14186
|
+
});
|
|
14177
14187
|
}
|
|
14178
14188
|
|
|
14179
14189
|
// Reset pinch session after a brief idle (no explicit "pinch end" event exists)
|
|
@@ -19428,8 +19438,23 @@ class TextBaseViewer extends viewers_BaseViewer {
|
|
|
19428
19438
|
wheelZoomHandler(event) {
|
|
19429
19439
|
const textEl = this.containerEl && this.containerEl.querySelector('.bp-text');
|
|
19430
19440
|
if (!event.ctrlKey || !textEl) {
|
|
19441
|
+
this.isPinching = false;
|
|
19431
19442
|
return;
|
|
19432
19443
|
}
|
|
19444
|
+
if (!this.isPinching) {
|
|
19445
|
+
this.isPinching = true;
|
|
19446
|
+
this.options.resin?.recordAction({
|
|
19447
|
+
action: 'programmatic',
|
|
19448
|
+
component: 'toolbar',
|
|
19449
|
+
target: event.deltaY > 0 ? 'zoomOut' : 'zoomIn',
|
|
19450
|
+
fileId: this.options.file.id,
|
|
19451
|
+
fileExtension: this.options.file.extension
|
|
19452
|
+
});
|
|
19453
|
+
}
|
|
19454
|
+
clearTimeout(this.pinchIdleTimer);
|
|
19455
|
+
this.pinchIdleTimer = setTimeout(() => {
|
|
19456
|
+
this.isPinching = false;
|
|
19457
|
+
}, 200);
|
|
19433
19458
|
event.preventDefault();
|
|
19434
19459
|
const scaleDelta = -event.deltaY * WHEEL_ZOOM_SCALE_FACTOR;
|
|
19435
19460
|
const newScale = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, this.scale + scaleDelta));
|
|
@@ -19550,6 +19575,7 @@ class TextBaseViewer extends viewers_BaseViewer {
|
|
|
19550
19575
|
loadUI() {
|
|
19551
19576
|
this.controls = new ControlsRoot({
|
|
19552
19577
|
containerEl: this.containerEl,
|
|
19578
|
+
fileExtension: this.options.file.extension,
|
|
19553
19579
|
fileId: this.options.file.id
|
|
19554
19580
|
});
|
|
19555
19581
|
this.bindDOMListeners();
|
|
@@ -32064,9 +32090,24 @@ class DocBaseViewer extends viewers_BaseViewer {
|
|
|
32064
32090
|
* Loads the viewer assets as opposed to just prefetching them as a performance optimization. This means that the libraries will be loaded
|
|
32065
32091
|
* into memory eliminating the need to load them when a preview is clicked.
|
|
32066
32092
|
*
|
|
32093
|
+
* @param {Object} [options]
|
|
32094
|
+
* @param {boolean} [options.isUseNpmPdfjsEnabled] - Warm up the npm-bundled
|
|
32095
|
+
* pdfjs chunks instead of the legacy CDN scripts so this matches what
|
|
32096
|
+
* `load()` will use when the flag is on.
|
|
32067
32097
|
* @return {void}
|
|
32068
32098
|
*/
|
|
32069
32099
|
loadViewerAssets() {
|
|
32100
|
+
let {
|
|
32101
|
+
isUseNpmPdfjsEnabled = false
|
|
32102
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
32103
|
+
if (isUseNpmPdfjsEnabled) {
|
|
32104
|
+
this.loadAssets(EXIF_READER, []);
|
|
32105
|
+
// Kick off the dynamic imports so the pdfjs chunks land in cache
|
|
32106
|
+
// before per-file load() awaits them. Errors are swallowed; load()
|
|
32107
|
+
// will surface them later.
|
|
32108
|
+
this.loadPdfjsFromNpm().catch(() => {});
|
|
32109
|
+
return;
|
|
32110
|
+
}
|
|
32070
32111
|
const ASSETS = [...JS_NO_EXIF, ...EXIF_READER];
|
|
32071
32112
|
this.loadAssets(ASSETS, docAssets_CSS);
|
|
32072
32113
|
this.loadAssets(PRELOAD_JS, []);
|
|
@@ -32940,6 +32981,7 @@ class DocBaseViewer extends viewers_BaseViewer {
|
|
|
32940
32981
|
loadUI() {
|
|
32941
32982
|
this.controls = new ControlsRoot({
|
|
32942
32983
|
containerEl: this.containerEl,
|
|
32984
|
+
fileExtension: this.options.file.extension,
|
|
32943
32985
|
fileId: this.options.file.id
|
|
32944
32986
|
});
|
|
32945
32987
|
this.annotationControlsFSM.subscribe(() => this.renderUI());
|
|
@@ -33364,8 +33406,23 @@ class DocBaseViewer extends viewers_BaseViewer {
|
|
|
33364
33406
|
}
|
|
33365
33407
|
trackpadPinchToZoomHandler(event) {
|
|
33366
33408
|
if (!event.ctrlKey) {
|
|
33409
|
+
this.isTrackpadPinching = false;
|
|
33367
33410
|
return;
|
|
33368
33411
|
}
|
|
33412
|
+
if (!this.isTrackpadPinching) {
|
|
33413
|
+
this.isTrackpadPinching = true;
|
|
33414
|
+
this.options.resin?.recordAction({
|
|
33415
|
+
action: 'programmatic',
|
|
33416
|
+
component: 'toolbar',
|
|
33417
|
+
target: event.deltaY > 0 ? 'zoomOut' : 'zoomIn',
|
|
33418
|
+
fileId: this.options.file.id,
|
|
33419
|
+
fileExtension: this.options.file.extension
|
|
33420
|
+
});
|
|
33421
|
+
}
|
|
33422
|
+
clearTimeout(this.trackpadPinchIdleTimer);
|
|
33423
|
+
this.trackpadPinchIdleTimer = setTimeout(() => {
|
|
33424
|
+
this.isTrackpadPinching = false;
|
|
33425
|
+
}, 200);
|
|
33369
33426
|
event.preventDefault();
|
|
33370
33427
|
const {
|
|
33371
33428
|
currentScale
|
|
@@ -40193,16 +40250,18 @@ class Preview extends (events_default()) {
|
|
|
40193
40250
|
*
|
|
40194
40251
|
* @public
|
|
40195
40252
|
* @param {string[]} [viewerNames] - Names of viewers to load assets for, defaults to none
|
|
40253
|
+
* @param {Object} [options] - Options forwarded to the viewer's loadViewerAssets
|
|
40196
40254
|
* @return {void}
|
|
40197
40255
|
*/
|
|
40198
40256
|
loadViewers() {
|
|
40199
40257
|
let viewerNames = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
40258
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
40200
40259
|
this.getViewers().filter(viewer => viewerNames.includes(viewer.NAME)).forEach(viewer => {
|
|
40201
40260
|
const viewerInstance = new viewer.CONSTRUCTOR(this.createViewerOptions({
|
|
40202
40261
|
viewer
|
|
40203
40262
|
}));
|
|
40204
40263
|
if (typeof viewerInstance.loadViewerAssets === 'function') {
|
|
40205
|
-
viewerInstance.loadViewerAssets();
|
|
40264
|
+
viewerInstance.loadViewerAssets(options);
|
|
40206
40265
|
}
|
|
40207
40266
|
});
|
|
40208
40267
|
}
|
|
@@ -40501,6 +40560,9 @@ class Preview extends (events_default()) {
|
|
|
40501
40560
|
this.options.preloadStatus = options.preloadStatus;
|
|
40502
40561
|
this.options.clientName = options.clientName;
|
|
40503
40562
|
|
|
40563
|
+
// Optional resin analytics instance for tracking user interactions
|
|
40564
|
+
this.options.resin = options.resin;
|
|
40565
|
+
|
|
40504
40566
|
// Options that are applicable to certain file ids
|
|
40505
40567
|
this.options.fileOptions = options.fileOptions || {};
|
|
40506
40568
|
|