@atlaskit/media-viewer 52.2.4 → 52.3.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/CHANGELOG.md +19 -0
- package/dist/cjs/analytics/index.js +1 -1
- package/dist/cjs/analytics/ufoExperiences.js +1 -1
- package/dist/cjs/item-viewer.js +19 -0
- package/dist/cjs/viewers/doc-next/index.compiled.css +4 -0
- package/dist/cjs/viewers/doc-next/index.js +163 -0
- package/dist/es2019/analytics/index.js +1 -1
- package/dist/es2019/analytics/ufoExperiences.js +1 -1
- package/dist/es2019/item-viewer.js +11 -0
- package/dist/es2019/viewers/doc-next/index.compiled.css +4 -0
- package/dist/es2019/viewers/doc-next/index.js +82 -0
- package/dist/esm/analytics/index.js +1 -1
- package/dist/esm/analytics/ufoExperiences.js +1 -1
- package/dist/esm/item-viewer.js +17 -0
- package/dist/esm/viewers/doc-next/index.compiled.css +4 -0
- package/dist/esm/viewers/doc-next/index.js +154 -0
- package/dist/types/viewers/doc-next/index.d.ts +34 -0
- package/dist/types-ts4.5/viewers/doc-next/index.d.ts +34 -0
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/media-viewer
|
|
2
2
|
|
|
3
|
+
## 52.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#172332](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/172332)
|
|
8
|
+
[`4c6d176844a01`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4c6d176844a01) -
|
|
9
|
+
Integrated media document viewer and to enable the new document viewing experience behind
|
|
10
|
+
media_document_viewer feature gate
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 52.2.5
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 52.2.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -10,7 +10,7 @@ exports.packageVersion = exports.packageName = void 0;
|
|
|
10
10
|
var _analytics = require("@atlaskit/media-common/analytics");
|
|
11
11
|
var componentName = exports.component = exports.componentName = 'mediaViewer';
|
|
12
12
|
var packageName = exports.packageName = "@atlaskit/media-viewer";
|
|
13
|
-
var packageVersion = exports.packageVersion = "52.
|
|
13
|
+
var packageVersion = exports.packageVersion = "52.3.0";
|
|
14
14
|
function getFileAttributes(fileState) {
|
|
15
15
|
if (!fileState) {
|
|
16
16
|
return {
|
|
@@ -12,7 +12,7 @@ var _mediaCommon = require("@atlaskit/media-common");
|
|
|
12
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
14
|
var packageName = "@atlaskit/media-viewer";
|
|
15
|
-
var packageVersion = "52.
|
|
15
|
+
var packageVersion = "52.3.0";
|
|
16
16
|
var ufoExperience;
|
|
17
17
|
var getExperience = function getExperience() {
|
|
18
18
|
if (!ufoExperience) {
|
package/dist/cjs/item-viewer.js
CHANGED
|
@@ -29,6 +29,7 @@ var _interactiveImg = require("./viewers/image/interactive-img");
|
|
|
29
29
|
var _archiveViewerLoader = _interopRequireDefault(require("./viewers/archiveSidebar/archiveViewerLoader"));
|
|
30
30
|
var _ufoExperiences = require("./analytics/ufoExperiences");
|
|
31
31
|
var _customViewer = require("./viewers/customViewer/customViewer");
|
|
32
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
32
33
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
33
34
|
var ImageViewer = (0, _reactLoadable.default)({
|
|
34
35
|
loader: function loader() {
|
|
@@ -78,6 +79,18 @@ var DocViewer = (0, _reactLoadable.default)({
|
|
|
78
79
|
return /*#__PURE__*/_react.default.createElement(_loading.Spinner, null);
|
|
79
80
|
}
|
|
80
81
|
});
|
|
82
|
+
var DocNextViewer = (0, _reactLoadable.default)({
|
|
83
|
+
loader: function loader() {
|
|
84
|
+
return Promise.resolve().then(function () {
|
|
85
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_docNextViewer" */'./viewers/doc-next'));
|
|
86
|
+
}).then(function (mod) {
|
|
87
|
+
return mod.DocViewer;
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
loading: function loading() {
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement(_loading.Spinner, null);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
81
94
|
var CodeViewer = (0, _reactLoadable.default)({
|
|
82
95
|
loader: function loader() {
|
|
83
96
|
return Promise.resolve().then(function () {
|
|
@@ -271,6 +284,12 @@ var ItemViewerBase = exports.ItemViewerBase = function ItemViewerBase(_ref) {
|
|
|
271
284
|
onError: onLoadFail
|
|
272
285
|
}, viewerProps));
|
|
273
286
|
case 'doc':
|
|
287
|
+
if ((0, _platformFeatureFlags.fg)('media_document_viewer')) {
|
|
288
|
+
return /*#__PURE__*/_react.default.createElement(DocNextViewer, (0, _extends2.default)({
|
|
289
|
+
onSuccess: onSuccess,
|
|
290
|
+
onError: onLoadFail
|
|
291
|
+
}, viewerProps));
|
|
292
|
+
}
|
|
274
293
|
return /*#__PURE__*/_react.default.createElement(DocViewer, (0, _extends2.default)({
|
|
275
294
|
onSuccess: onSuccess,
|
|
276
295
|
onError: onLoadFail
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.DocViewer = void 0;
|
|
10
|
+
require("./index.compiled.css");
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
var _mediaDocumentViewer = require("@atlaskit/media-document-viewer");
|
|
22
|
+
var _domain = require("../../domain");
|
|
23
|
+
var _baseViewer = require("../base-viewer");
|
|
24
|
+
var _zoomControls = require("../../zoomControls");
|
|
25
|
+
var _zoomLevel = require("../../domain/zoomLevel");
|
|
26
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
27
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
28
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
29
|
+
var documentViewerStyles = null;
|
|
30
|
+
var DocViewer = exports.DocViewer = /*#__PURE__*/function (_BaseViewer) {
|
|
31
|
+
function DocViewer() {
|
|
32
|
+
var _this;
|
|
33
|
+
(0, _classCallCheck2.default)(this, DocViewer);
|
|
34
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35
|
+
args[_key] = arguments[_key];
|
|
36
|
+
}
|
|
37
|
+
_this = _callSuper(this, DocViewer, [].concat(args));
|
|
38
|
+
(0, _defineProperty2.default)(_this, "isObjectUrl", false);
|
|
39
|
+
(0, _defineProperty2.default)(_this, "getContent", /*#__PURE__*/function () {
|
|
40
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(pageStart, pageEnd) {
|
|
41
|
+
var src;
|
|
42
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
_context.next = 2;
|
|
46
|
+
return _this.props.mediaClient.mediaStore.getDocumentContent(_this.props.item.id, {
|
|
47
|
+
pageStart: pageStart,
|
|
48
|
+
pageEnd: pageEnd,
|
|
49
|
+
collectionName: _this.props.collectionName
|
|
50
|
+
});
|
|
51
|
+
case 2:
|
|
52
|
+
src = _context.sent;
|
|
53
|
+
return _context.abrupt("return", src);
|
|
54
|
+
case 4:
|
|
55
|
+
case "end":
|
|
56
|
+
return _context.stop();
|
|
57
|
+
}
|
|
58
|
+
}, _callee);
|
|
59
|
+
}));
|
|
60
|
+
return function (_x, _x2) {
|
|
61
|
+
return _ref.apply(this, arguments);
|
|
62
|
+
};
|
|
63
|
+
}());
|
|
64
|
+
(0, _defineProperty2.default)(_this, "getPageImageUrl", /*#__PURE__*/function () {
|
|
65
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(pageNumber, zoom) {
|
|
66
|
+
var src;
|
|
67
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
68
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
_context2.next = 2;
|
|
71
|
+
return _this.props.mediaClient.mediaStore.getDocumentPageImage(_this.props.item.id, {
|
|
72
|
+
page: pageNumber,
|
|
73
|
+
zoom: zoom,
|
|
74
|
+
collectionName: _this.props.collectionName
|
|
75
|
+
});
|
|
76
|
+
case 2:
|
|
77
|
+
src = _context2.sent;
|
|
78
|
+
return _context2.abrupt("return", URL.createObjectURL(src));
|
|
79
|
+
case 4:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context2.stop();
|
|
82
|
+
}
|
|
83
|
+
}, _callee2);
|
|
84
|
+
}));
|
|
85
|
+
return function (_x3, _x4) {
|
|
86
|
+
return _ref2.apply(this, arguments);
|
|
87
|
+
};
|
|
88
|
+
}());
|
|
89
|
+
(0, _defineProperty2.default)(_this, "onZoomChange", function (newZoomLevel) {
|
|
90
|
+
_this.setState({
|
|
91
|
+
zoomLevel: newZoomLevel
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
return _this;
|
|
95
|
+
}
|
|
96
|
+
(0, _inherits2.default)(DocViewer, _BaseViewer);
|
|
97
|
+
return (0, _createClass2.default)(DocViewer, [{
|
|
98
|
+
key: "initialState",
|
|
99
|
+
get: function get() {
|
|
100
|
+
return {
|
|
101
|
+
content: _domain.Outcome.pending(),
|
|
102
|
+
zoomLevel: new _zoomLevel.ZoomLevel(1.75)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "needsReset",
|
|
107
|
+
value: function needsReset(propsA, propsB) {
|
|
108
|
+
if (this.state.content.status === 'SUCCESSFUL') {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return propsA.item.status !== propsB.item.status;
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "init",
|
|
115
|
+
value: function () {
|
|
116
|
+
var _init = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
117
|
+
var item;
|
|
118
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
119
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
item = this.props.item;
|
|
122
|
+
this.setState({
|
|
123
|
+
content: _domain.Outcome.successful(item.id)
|
|
124
|
+
});
|
|
125
|
+
case 2:
|
|
126
|
+
case "end":
|
|
127
|
+
return _context3.stop();
|
|
128
|
+
}
|
|
129
|
+
}, _callee3, this);
|
|
130
|
+
}));
|
|
131
|
+
function init() {
|
|
132
|
+
return _init.apply(this, arguments);
|
|
133
|
+
}
|
|
134
|
+
return init;
|
|
135
|
+
}()
|
|
136
|
+
}, {
|
|
137
|
+
key: "release",
|
|
138
|
+
value: function release() {
|
|
139
|
+
if (!this.isObjectUrl) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
var content = this.state.content;
|
|
143
|
+
if (content.data) {
|
|
144
|
+
URL.revokeObjectURL(content.data);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "renderSuccessful",
|
|
149
|
+
value: function renderSuccessful() {
|
|
150
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
151
|
+
id: _mediaDocumentViewer.DOCUMENT_SCROLL_ROOT_ID,
|
|
152
|
+
className: (0, _runtime.ax)(["_1reo1wug _18m91wug _4t3i1kxc _1bsbauwl"])
|
|
153
|
+
}, /*#__PURE__*/React.createElement(_mediaDocumentViewer.DocumentViewer, {
|
|
154
|
+
getContent: this.getContent,
|
|
155
|
+
getPageImageUrl: this.getPageImageUrl,
|
|
156
|
+
zoom: this.state.zoomLevel.value
|
|
157
|
+
}), /*#__PURE__*/React.createElement(_zoomControls.ZoomControls, {
|
|
158
|
+
onChange: this.onZoomChange,
|
|
159
|
+
zoomLevel: this.state.zoomLevel
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
}]);
|
|
163
|
+
}(_baseViewer.BaseViewer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ANALYTICS_MEDIA_CHANNEL, sanitiseAnalyticsPayload } from '@atlaskit/media-common/analytics';
|
|
2
2
|
const componentName = 'mediaViewer';
|
|
3
3
|
const packageName = "@atlaskit/media-viewer";
|
|
4
|
-
const packageVersion = "52.
|
|
4
|
+
const packageVersion = "52.3.0";
|
|
5
5
|
export { packageName, packageVersion, componentName, componentName as component };
|
|
6
6
|
export function getFileAttributes(fileState) {
|
|
7
7
|
if (!fileState) {
|
|
@@ -2,7 +2,7 @@ import { UFOExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atl
|
|
|
2
2
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
3
3
|
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
|
|
4
4
|
const packageName = "@atlaskit/media-viewer";
|
|
5
|
-
const packageVersion = "52.
|
|
5
|
+
const packageVersion = "52.3.0";
|
|
6
6
|
let ufoExperience;
|
|
7
7
|
const getExperience = () => {
|
|
8
8
|
if (!ufoExperience) {
|
|
@@ -20,6 +20,7 @@ import { InteractiveImg } from './viewers/image/interactive-img';
|
|
|
20
20
|
import ArchiveViewerLoader from './viewers/archiveSidebar/archiveViewerLoader';
|
|
21
21
|
import { startMediaFileUfoExperience, succeedMediaFileUfoExperience } from './analytics/ufoExperiences';
|
|
22
22
|
import { CustomViewer } from './viewers/customViewer/customViewer';
|
|
23
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
23
24
|
const ImageViewer = Loadable({
|
|
24
25
|
loader: () => import( /* webpackChunkName: "@atlaskit-internal_imageViewer" */'./viewers/image').then(mod => mod.ImageViewer),
|
|
25
26
|
loading: () => /*#__PURE__*/React.createElement(Spinner, null)
|
|
@@ -36,6 +37,10 @@ const DocViewer = Loadable({
|
|
|
36
37
|
loader: () => import( /* webpackChunkName: "@atlaskit-internal_docViewer" */'./viewers/doc').then(mod => mod.DocViewer),
|
|
37
38
|
loading: () => /*#__PURE__*/React.createElement(Spinner, null)
|
|
38
39
|
});
|
|
40
|
+
const DocNextViewer = Loadable({
|
|
41
|
+
loader: () => import( /* webpackChunkName: "@atlaskit-internal_docNextViewer" */'./viewers/doc-next').then(mod => mod.DocViewer),
|
|
42
|
+
loading: () => /*#__PURE__*/React.createElement(Spinner, null)
|
|
43
|
+
});
|
|
39
44
|
const CodeViewer = Loadable({
|
|
40
45
|
loader: () => import( /* webpackChunkName: "@atlaskit-internal_codeViewer" */'./viewers/codeViewer').then(mod => mod.CodeViewer),
|
|
41
46
|
loading: () => /*#__PURE__*/React.createElement(Spinner, null)
|
|
@@ -209,6 +214,12 @@ export const ItemViewerBase = ({
|
|
|
209
214
|
onError: onLoadFail
|
|
210
215
|
}, viewerProps));
|
|
211
216
|
case 'doc':
|
|
217
|
+
if (fg('media_document_viewer')) {
|
|
218
|
+
return /*#__PURE__*/React.createElement(DocNextViewer, _extends({
|
|
219
|
+
onSuccess: onSuccess,
|
|
220
|
+
onError: onLoadFail
|
|
221
|
+
}, viewerProps));
|
|
222
|
+
}
|
|
212
223
|
return /*#__PURE__*/React.createElement(DocViewer, _extends({
|
|
213
224
|
onSuccess: onSuccess,
|
|
214
225
|
onError: onLoadFail
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import "./index.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
import { DOCUMENT_SCROLL_ROOT_ID, DocumentViewer } from '@atlaskit/media-document-viewer';
|
|
7
|
+
import { Outcome } from '../../domain';
|
|
8
|
+
import { BaseViewer } from '../base-viewer';
|
|
9
|
+
import { ZoomControls } from '../../zoomControls';
|
|
10
|
+
import { ZoomLevel } from '../../domain/zoomLevel';
|
|
11
|
+
const documentViewerStyles = null;
|
|
12
|
+
export class DocViewer extends BaseViewer {
|
|
13
|
+
constructor(...args) {
|
|
14
|
+
super(...args);
|
|
15
|
+
_defineProperty(this, "isObjectUrl", false);
|
|
16
|
+
_defineProperty(this, "getContent", async (pageStart, pageEnd) => {
|
|
17
|
+
const src = await this.props.mediaClient.mediaStore.getDocumentContent(this.props.item.id, {
|
|
18
|
+
pageStart,
|
|
19
|
+
pageEnd,
|
|
20
|
+
collectionName: this.props.collectionName
|
|
21
|
+
});
|
|
22
|
+
return src;
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(this, "getPageImageUrl", async (pageNumber, zoom) => {
|
|
25
|
+
const src = await this.props.mediaClient.mediaStore.getDocumentPageImage(this.props.item.id, {
|
|
26
|
+
page: pageNumber,
|
|
27
|
+
zoom,
|
|
28
|
+
collectionName: this.props.collectionName
|
|
29
|
+
});
|
|
30
|
+
return URL.createObjectURL(src);
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(this, "onZoomChange", newZoomLevel => {
|
|
33
|
+
this.setState({
|
|
34
|
+
zoomLevel: newZoomLevel
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
get initialState() {
|
|
39
|
+
return {
|
|
40
|
+
content: Outcome.pending(),
|
|
41
|
+
zoomLevel: new ZoomLevel(1.75)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
needsReset(propsA, propsB) {
|
|
45
|
+
if (this.state.content.status === 'SUCCESSFUL') {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return propsA.item.status !== propsB.item.status;
|
|
49
|
+
}
|
|
50
|
+
async init() {
|
|
51
|
+
const {
|
|
52
|
+
item
|
|
53
|
+
} = this.props;
|
|
54
|
+
this.setState({
|
|
55
|
+
content: Outcome.successful(item.id)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
release() {
|
|
59
|
+
if (!this.isObjectUrl) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const {
|
|
63
|
+
content
|
|
64
|
+
} = this.state;
|
|
65
|
+
if (content.data) {
|
|
66
|
+
URL.revokeObjectURL(content.data);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
renderSuccessful() {
|
|
70
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
id: DOCUMENT_SCROLL_ROOT_ID,
|
|
72
|
+
className: ax(["_1reo1wug _18m91wug _4t3i1kxc _1bsbauwl"])
|
|
73
|
+
}, /*#__PURE__*/React.createElement(DocumentViewer, {
|
|
74
|
+
getContent: this.getContent,
|
|
75
|
+
getPageImageUrl: this.getPageImageUrl,
|
|
76
|
+
zoom: this.state.zoomLevel.value
|
|
77
|
+
}), /*#__PURE__*/React.createElement(ZoomControls, {
|
|
78
|
+
onChange: this.onZoomChange,
|
|
79
|
+
zoomLevel: this.state.zoomLevel
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ANALYTICS_MEDIA_CHANNEL, sanitiseAnalyticsPayload } from '@atlaskit/media-common/analytics';
|
|
2
2
|
var componentName = 'mediaViewer';
|
|
3
3
|
var packageName = "@atlaskit/media-viewer";
|
|
4
|
-
var packageVersion = "52.
|
|
4
|
+
var packageVersion = "52.3.0";
|
|
5
5
|
export { packageName, packageVersion, componentName, componentName as component };
|
|
6
6
|
export function getFileAttributes(fileState) {
|
|
7
7
|
if (!fileState) {
|
|
@@ -5,7 +5,7 @@ import { UFOExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atl
|
|
|
5
5
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
6
6
|
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
|
|
7
7
|
var packageName = "@atlaskit/media-viewer";
|
|
8
|
-
var packageVersion = "52.
|
|
8
|
+
var packageVersion = "52.3.0";
|
|
9
9
|
var ufoExperience;
|
|
10
10
|
var getExperience = function getExperience() {
|
|
11
11
|
if (!ufoExperience) {
|
package/dist/esm/item-viewer.js
CHANGED
|
@@ -21,6 +21,7 @@ import { InteractiveImg } from './viewers/image/interactive-img';
|
|
|
21
21
|
import ArchiveViewerLoader from './viewers/archiveSidebar/archiveViewerLoader';
|
|
22
22
|
import { startMediaFileUfoExperience, succeedMediaFileUfoExperience } from './analytics/ufoExperiences';
|
|
23
23
|
import { CustomViewer } from './viewers/customViewer/customViewer';
|
|
24
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
24
25
|
var ImageViewer = Loadable({
|
|
25
26
|
loader: function loader() {
|
|
26
27
|
return import( /* webpackChunkName: "@atlaskit-internal_imageViewer" */'./viewers/image').then(function (mod) {
|
|
@@ -61,6 +62,16 @@ var DocViewer = Loadable({
|
|
|
61
62
|
return /*#__PURE__*/React.createElement(Spinner, null);
|
|
62
63
|
}
|
|
63
64
|
});
|
|
65
|
+
var DocNextViewer = Loadable({
|
|
66
|
+
loader: function loader() {
|
|
67
|
+
return import( /* webpackChunkName: "@atlaskit-internal_docNextViewer" */'./viewers/doc-next').then(function (mod) {
|
|
68
|
+
return mod.DocViewer;
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
loading: function loading() {
|
|
72
|
+
return /*#__PURE__*/React.createElement(Spinner, null);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
64
75
|
var CodeViewer = Loadable({
|
|
65
76
|
loader: function loader() {
|
|
66
77
|
return import( /* webpackChunkName: "@atlaskit-internal_codeViewer" */'./viewers/codeViewer').then(function (mod) {
|
|
@@ -250,6 +261,12 @@ export var ItemViewerBase = function ItemViewerBase(_ref) {
|
|
|
250
261
|
onError: onLoadFail
|
|
251
262
|
}, viewerProps));
|
|
252
263
|
case 'doc':
|
|
264
|
+
if (fg('media_document_viewer')) {
|
|
265
|
+
return /*#__PURE__*/React.createElement(DocNextViewer, _extends({
|
|
266
|
+
onSuccess: onSuccess,
|
|
267
|
+
onError: onLoadFail
|
|
268
|
+
}, viewerProps));
|
|
269
|
+
}
|
|
253
270
|
return /*#__PURE__*/React.createElement(DocViewer, _extends({
|
|
254
271
|
onSuccess: onSuccess,
|
|
255
272
|
onError: onLoadFail
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
import "./index.compiled.css";
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
12
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
13
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
14
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
15
|
+
import { DOCUMENT_SCROLL_ROOT_ID, DocumentViewer } from '@atlaskit/media-document-viewer';
|
|
16
|
+
import { Outcome } from '../../domain';
|
|
17
|
+
import { BaseViewer } from '../base-viewer';
|
|
18
|
+
import { ZoomControls } from '../../zoomControls';
|
|
19
|
+
import { ZoomLevel } from '../../domain/zoomLevel';
|
|
20
|
+
var documentViewerStyles = null;
|
|
21
|
+
export var DocViewer = /*#__PURE__*/function (_BaseViewer) {
|
|
22
|
+
function DocViewer() {
|
|
23
|
+
var _this;
|
|
24
|
+
_classCallCheck(this, DocViewer);
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
_this = _callSuper(this, DocViewer, [].concat(args));
|
|
29
|
+
_defineProperty(_this, "isObjectUrl", false);
|
|
30
|
+
_defineProperty(_this, "getContent", /*#__PURE__*/function () {
|
|
31
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(pageStart, pageEnd) {
|
|
32
|
+
var src;
|
|
33
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
34
|
+
while (1) switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
_context.next = 2;
|
|
37
|
+
return _this.props.mediaClient.mediaStore.getDocumentContent(_this.props.item.id, {
|
|
38
|
+
pageStart: pageStart,
|
|
39
|
+
pageEnd: pageEnd,
|
|
40
|
+
collectionName: _this.props.collectionName
|
|
41
|
+
});
|
|
42
|
+
case 2:
|
|
43
|
+
src = _context.sent;
|
|
44
|
+
return _context.abrupt("return", src);
|
|
45
|
+
case 4:
|
|
46
|
+
case "end":
|
|
47
|
+
return _context.stop();
|
|
48
|
+
}
|
|
49
|
+
}, _callee);
|
|
50
|
+
}));
|
|
51
|
+
return function (_x, _x2) {
|
|
52
|
+
return _ref.apply(this, arguments);
|
|
53
|
+
};
|
|
54
|
+
}());
|
|
55
|
+
_defineProperty(_this, "getPageImageUrl", /*#__PURE__*/function () {
|
|
56
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pageNumber, zoom) {
|
|
57
|
+
var src;
|
|
58
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
59
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
_context2.next = 2;
|
|
62
|
+
return _this.props.mediaClient.mediaStore.getDocumentPageImage(_this.props.item.id, {
|
|
63
|
+
page: pageNumber,
|
|
64
|
+
zoom: zoom,
|
|
65
|
+
collectionName: _this.props.collectionName
|
|
66
|
+
});
|
|
67
|
+
case 2:
|
|
68
|
+
src = _context2.sent;
|
|
69
|
+
return _context2.abrupt("return", URL.createObjectURL(src));
|
|
70
|
+
case 4:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context2.stop();
|
|
73
|
+
}
|
|
74
|
+
}, _callee2);
|
|
75
|
+
}));
|
|
76
|
+
return function (_x3, _x4) {
|
|
77
|
+
return _ref2.apply(this, arguments);
|
|
78
|
+
};
|
|
79
|
+
}());
|
|
80
|
+
_defineProperty(_this, "onZoomChange", function (newZoomLevel) {
|
|
81
|
+
_this.setState({
|
|
82
|
+
zoomLevel: newZoomLevel
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return _this;
|
|
86
|
+
}
|
|
87
|
+
_inherits(DocViewer, _BaseViewer);
|
|
88
|
+
return _createClass(DocViewer, [{
|
|
89
|
+
key: "initialState",
|
|
90
|
+
get: function get() {
|
|
91
|
+
return {
|
|
92
|
+
content: Outcome.pending(),
|
|
93
|
+
zoomLevel: new ZoomLevel(1.75)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "needsReset",
|
|
98
|
+
value: function needsReset(propsA, propsB) {
|
|
99
|
+
if (this.state.content.status === 'SUCCESSFUL') {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return propsA.item.status !== propsB.item.status;
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "init",
|
|
106
|
+
value: function () {
|
|
107
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
108
|
+
var item;
|
|
109
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
110
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
111
|
+
case 0:
|
|
112
|
+
item = this.props.item;
|
|
113
|
+
this.setState({
|
|
114
|
+
content: Outcome.successful(item.id)
|
|
115
|
+
});
|
|
116
|
+
case 2:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context3.stop();
|
|
119
|
+
}
|
|
120
|
+
}, _callee3, this);
|
|
121
|
+
}));
|
|
122
|
+
function init() {
|
|
123
|
+
return _init.apply(this, arguments);
|
|
124
|
+
}
|
|
125
|
+
return init;
|
|
126
|
+
}()
|
|
127
|
+
}, {
|
|
128
|
+
key: "release",
|
|
129
|
+
value: function release() {
|
|
130
|
+
if (!this.isObjectUrl) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
var content = this.state.content;
|
|
134
|
+
if (content.data) {
|
|
135
|
+
URL.revokeObjectURL(content.data);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "renderSuccessful",
|
|
140
|
+
value: function renderSuccessful() {
|
|
141
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
142
|
+
id: DOCUMENT_SCROLL_ROOT_ID,
|
|
143
|
+
className: ax(["_1reo1wug _18m91wug _4t3i1kxc _1bsbauwl"])
|
|
144
|
+
}, /*#__PURE__*/React.createElement(DocumentViewer, {
|
|
145
|
+
getContent: this.getContent,
|
|
146
|
+
getPageImageUrl: this.getPageImageUrl,
|
|
147
|
+
zoom: this.state.zoomLevel.value
|
|
148
|
+
}), /*#__PURE__*/React.createElement(ZoomControls, {
|
|
149
|
+
onChange: this.onZoomChange,
|
|
150
|
+
zoomLevel: this.state.zoomLevel
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
}]);
|
|
154
|
+
}(BaseViewer);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MediaClient, type FileState } from '@atlaskit/media-client';
|
|
3
|
+
import { Outcome } from '../../domain';
|
|
4
|
+
import { MediaViewerError } from '../../errors';
|
|
5
|
+
import { BaseViewer } from '../base-viewer';
|
|
6
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
7
|
+
import { ZoomLevel } from '../../domain/zoomLevel';
|
|
8
|
+
export type Props = {
|
|
9
|
+
mediaClient: MediaClient;
|
|
10
|
+
item: FileState;
|
|
11
|
+
collectionName?: string;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
onError: (error: MediaViewerError) => void;
|
|
14
|
+
onSuccess: () => void;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
16
|
+
};
|
|
17
|
+
export type State = {
|
|
18
|
+
content: Outcome<string, MediaViewerError>;
|
|
19
|
+
zoomLevel: ZoomLevel;
|
|
20
|
+
};
|
|
21
|
+
export declare class DocViewer extends BaseViewer<string, Props, State> {
|
|
22
|
+
private isObjectUrl;
|
|
23
|
+
protected get initialState(): {
|
|
24
|
+
content: Outcome<string, MediaViewerError>;
|
|
25
|
+
zoomLevel: ZoomLevel;
|
|
26
|
+
};
|
|
27
|
+
protected needsReset(propsA: Props, propsB: Props): boolean;
|
|
28
|
+
protected init(): Promise<void>;
|
|
29
|
+
protected release(): void;
|
|
30
|
+
private getContent;
|
|
31
|
+
private getPageImageUrl;
|
|
32
|
+
private onZoomChange;
|
|
33
|
+
protected renderSuccessful(): JSX.Element;
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MediaClient, type FileState } from '@atlaskit/media-client';
|
|
3
|
+
import { Outcome } from '../../domain';
|
|
4
|
+
import { MediaViewerError } from '../../errors';
|
|
5
|
+
import { BaseViewer } from '../base-viewer';
|
|
6
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
7
|
+
import { ZoomLevel } from '../../domain/zoomLevel';
|
|
8
|
+
export type Props = {
|
|
9
|
+
mediaClient: MediaClient;
|
|
10
|
+
item: FileState;
|
|
11
|
+
collectionName?: string;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
onError: (error: MediaViewerError) => void;
|
|
14
|
+
onSuccess: () => void;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
16
|
+
};
|
|
17
|
+
export type State = {
|
|
18
|
+
content: Outcome<string, MediaViewerError>;
|
|
19
|
+
zoomLevel: ZoomLevel;
|
|
20
|
+
};
|
|
21
|
+
export declare class DocViewer extends BaseViewer<string, Props, State> {
|
|
22
|
+
private isObjectUrl;
|
|
23
|
+
protected get initialState(): {
|
|
24
|
+
content: Outcome<string, MediaViewerError>;
|
|
25
|
+
zoomLevel: ZoomLevel;
|
|
26
|
+
};
|
|
27
|
+
protected needsReset(propsA: Props, propsB: Props): boolean;
|
|
28
|
+
protected init(): Promise<void>;
|
|
29
|
+
protected release(): void;
|
|
30
|
+
private getContent;
|
|
31
|
+
private getPageImageUrl;
|
|
32
|
+
private onZoomChange;
|
|
33
|
+
protected renderSuccessful(): JSX.Element;
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-viewer",
|
|
3
|
-
"version": "52.
|
|
3
|
+
"version": "52.3.0",
|
|
4
4
|
"description": "MediaViewer is Atlassian's powerful solution for viewing files on the web. It's both powerful and extendable yet easy-to-integrate",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -42,12 +42,13 @@
|
|
|
42
42
|
"@atlaskit/css": "^0.10.0",
|
|
43
43
|
"@atlaskit/form": "^12.0.0",
|
|
44
44
|
"@atlaskit/heading": "^5.2.0",
|
|
45
|
-
"@atlaskit/icon": "^
|
|
45
|
+
"@atlaskit/icon": "^27.0.0",
|
|
46
46
|
"@atlaskit/icon-file-type": "^7.0.0",
|
|
47
|
-
"@atlaskit/icon-lab": "^
|
|
48
|
-
"@atlaskit/media-client": "^33.
|
|
47
|
+
"@atlaskit/icon-lab": "^5.0.0",
|
|
48
|
+
"@atlaskit/media-client": "^33.5.0",
|
|
49
49
|
"@atlaskit/media-client-react": "^4.1.0",
|
|
50
50
|
"@atlaskit/media-common": "^12.2.0",
|
|
51
|
+
"@atlaskit/media-document-viewer": "^0.2.0",
|
|
51
52
|
"@atlaskit/media-svg": "^2.1.0",
|
|
52
53
|
"@atlaskit/media-ui": "^28.3.0",
|
|
53
54
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
@@ -129,6 +130,9 @@
|
|
|
129
130
|
},
|
|
130
131
|
"media_advanced_text_viewer": {
|
|
131
132
|
"type": "boolean"
|
|
133
|
+
},
|
|
134
|
+
"media_document_viewer": {
|
|
135
|
+
"type": "boolean"
|
|
132
136
|
}
|
|
133
137
|
},
|
|
134
138
|
"techstack": {
|