@scaleflex/widget-pdftron 0.0.1
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 +7395 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/lib/Pdftron.js +66 -0
- package/lib/index.js +80 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 scaleflex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `@scaleflex/widget-pdftron`
|
|
2
|
+
|
|
3
|
+
[![Plugins][plugins-image]](#plugins)
|
|
4
|
+
[![Website][filerobot-image]][sfx-url]
|
|
5
|
+
[![Version][filerobot-version]][version-url]
|
|
6
|
+
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
|
+
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<div align='center'>
|
|
12
|
+
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://cdn.scaleflex.com/plugins/filerobot-widget/assets/filerobot_widget_logo_with_fire.png?vh=b2ff09" width="140"/>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
pdftron integration with [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core).
|
|
16
|
+
|
|
17
|
+
<!-- TODD(docs): add usage and properties section -->
|
|
18
|
+
|
|
19
|
+
<!-- Variables -->
|
|
20
|
+
|
|
21
|
+
[npm-url]: https://www.npmjs.com/package/@filerobobt/pdftron
|
|
22
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
23
|
+
[sfx-url]: https://www.scaleflex.com/
|
|
24
|
+
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-pdftron
|
|
25
|
+
[codeSandbox-url]: https://codesandbox.io/s/filerobot-widget-v3-c5l9th
|
|
26
|
+
|
|
27
|
+
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
28
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
29
|
+
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
30
|
+
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
31
|
+
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
32
|
+
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-pdftron?label=Version&style=for-the-badge&logo=npm
|
|
33
|
+
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
package/lib/Pdftron.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import { useDispatch } from 'react-redux';
|
|
8
|
+
import { useState, useRef, useEffect } from 'react';
|
|
9
|
+
import WebViewer from '@pdftron/webviewer';
|
|
10
|
+
import { BackButton, PC, Spinner } from '@scaleflex/widget-common';
|
|
11
|
+
import { useExplorer } from '@scaleflex/widget-explorer/lib/hooks';
|
|
12
|
+
import handleError from '@scaleflex/widget-utils/lib/handleError';
|
|
13
|
+
import { useTheme } from '@scaleflex/ui/theme/hooks';
|
|
14
|
+
import { pdfFilePreviewOpened } from '@scaleflex/widget-explorer/lib/slices/panels.slice';
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
+
var Pdftron = function Pdftron(_ref) {
|
|
17
|
+
var pdfFilePreview = _ref.pdfFilePreview,
|
|
18
|
+
pdftronStaticPath = _ref.pdftronStaticPath;
|
|
19
|
+
var dispatch = useDispatch();
|
|
20
|
+
var _useExplorer = useExplorer(),
|
|
21
|
+
info = _useExplorer.info;
|
|
22
|
+
var theme = useTheme();
|
|
23
|
+
var _useState = useState(false),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
isLoadingUI = _useState2[0],
|
|
26
|
+
setIsLoadingUI = _useState2[1];
|
|
27
|
+
var viewer = useRef(null);
|
|
28
|
+
var iconPrimaryColor = theme.palette[PC.IconsPrimary];
|
|
29
|
+
var closePreview = function closePreview() {
|
|
30
|
+
return dispatch(pdfFilePreviewOpened(null));
|
|
31
|
+
};
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
var _pdfFilePreview$url;
|
|
34
|
+
setIsLoadingUI(true);
|
|
35
|
+
WebViewer({
|
|
36
|
+
path: pdftronStaticPath,
|
|
37
|
+
initialDoc: pdfFilePreview === null || pdfFilePreview === void 0 ? void 0 : (_pdfFilePreview$url = pdfFilePreview.url) === null || _pdfFilePreview$url === void 0 ? void 0 : _pdfFilePreview$url.cdn
|
|
38
|
+
}, viewer.current).then(function () {
|
|
39
|
+
setIsLoadingUI(false);
|
|
40
|
+
})["catch"](function (error) {
|
|
41
|
+
return handleError(error, info);
|
|
42
|
+
});
|
|
43
|
+
}, []);
|
|
44
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
45
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
46
|
+
className: "filerobot-Explorer-FilePreview-bar",
|
|
47
|
+
children: [/*#__PURE__*/_jsx(BackButton, {
|
|
48
|
+
onClick: closePreview,
|
|
49
|
+
iconPrimaryColor: iconPrimaryColor,
|
|
50
|
+
hideDivider: true
|
|
51
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
52
|
+
className: "filerobot-Explorer-FilePreview-bar-imageName",
|
|
53
|
+
children: pdfFilePreview.name
|
|
54
|
+
})]
|
|
55
|
+
}), isLoadingUI && /*#__PURE__*/_jsx(Spinner, {
|
|
56
|
+
fillContainer: true
|
|
57
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
58
|
+
className: "webviewer",
|
|
59
|
+
ref: viewer,
|
|
60
|
+
style: {
|
|
61
|
+
height: '93%'
|
|
62
|
+
}
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
export default Pdftron;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
6
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
7
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
12
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
13
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
15
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
16
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
17
|
+
import { Plugin } from '@scaleflex/widget-core';
|
|
18
|
+
import Explorer from '@scaleflex/widget-explorer';
|
|
19
|
+
import Translator from '@scaleflex/widget-utils/lib/Translator';
|
|
20
|
+
import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
|
|
21
|
+
import PdftronUI from './Pdftron';
|
|
22
|
+
// TODO: find a way to show version of the current plugin
|
|
23
|
+
// why solution below isn't good?
|
|
24
|
+
// first import doesn't work with webpack 5 as it was deprecated
|
|
25
|
+
// second import fixes webpack 5 issue as it was mentioned in their docs
|
|
26
|
+
// but it exposes our package.json to the client and it is mentioned as security rist in mutiple places
|
|
27
|
+
// https://github.com/axelpale/genversion
|
|
28
|
+
// https://stackoverflow.com/questions/64993118/error-should-not-import-the-named-export-version-imported-as-version
|
|
29
|
+
// https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code/10855054#10855054
|
|
30
|
+
// import { version } from '../package.json'
|
|
31
|
+
// import packageInfo from '../package.json'
|
|
32
|
+
var Pdftron = /*#__PURE__*/function (_Plugin) {
|
|
33
|
+
// static VERSION = packageInfo.version
|
|
34
|
+
|
|
35
|
+
function Pdftron(filerobot) {
|
|
36
|
+
var _this;
|
|
37
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
38
|
+
_classCallCheck(this, Pdftron);
|
|
39
|
+
_this = _callSuper(this, Pdftron, [filerobot, opts]);
|
|
40
|
+
_this.id = PLUGINS_IDS.PDFTRON;
|
|
41
|
+
_this.title = 'Pdftron';
|
|
42
|
+
_this.type = 'editor';
|
|
43
|
+
_this.opts = _objectSpread({
|
|
44
|
+
pdftronStaticPath: ''
|
|
45
|
+
}, opts);
|
|
46
|
+
_this.i18nInit();
|
|
47
|
+
return _this;
|
|
48
|
+
}
|
|
49
|
+
_inherits(Pdftron, _Plugin);
|
|
50
|
+
return _createClass(Pdftron, [{
|
|
51
|
+
key: "i18nInit",
|
|
52
|
+
value: function i18nInit() {
|
|
53
|
+
this.translator = new Translator([this.defaultLocale, this.filerobot.locale, this.opts.locale]);
|
|
54
|
+
this.i18n = this.translator.translate.bind(this.translator);
|
|
55
|
+
this.i18nArray = this.translator.translateArray.bind(this.translator);
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "install",
|
|
59
|
+
value: function install() {
|
|
60
|
+
if (Explorer) {
|
|
61
|
+
this.mount(Explorer, this);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "uninstall",
|
|
66
|
+
value: function uninstall() {
|
|
67
|
+
this.unmount();
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "render",
|
|
71
|
+
value: function render(_ref) {
|
|
72
|
+
var pdfFilePreview = _ref.pdfFilePreview;
|
|
73
|
+
return PdftronUI({
|
|
74
|
+
pdfFilePreview: pdfFilePreview,
|
|
75
|
+
pdftronStaticPath: this.opts.pdftronStaticPath
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}]);
|
|
79
|
+
}(Plugin);
|
|
80
|
+
export default Pdftron;
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scaleflex/widget-pdftron",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "PDFTRON integration with Scaleflex",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist",
|
|
9
|
+
"/lib",
|
|
10
|
+
"/types"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pdftron/webviewer": "^10.1.1",
|
|
17
|
+
"@scaleflex/icons": "^3.0.0-beta.11",
|
|
18
|
+
"@scaleflex/ui": "^3.0.0-beta.11",
|
|
19
|
+
"@scaleflex/widget-common": "^0.0.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"react": "^19.0.0",
|
|
23
|
+
"react-dom": "^19.0.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@scaleflex/widget-core": "^0.0.0",
|
|
27
|
+
"@scaleflex/widget-explorer": "^0.0.0",
|
|
28
|
+
"react": ">=19.0.0",
|
|
29
|
+
"react-dom": ">=19.0.0"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "64ea82e745b7deda36d6794863350e6671e9010d"
|
|
32
|
+
}
|