@scaleflex/widget-image-editor 4.8.6 → 4.8.11
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/dist/style.css +27 -0
- package/dist/style.min.css +1 -0
- package/lib/ImageEditor.js +452 -0
- package/lib/ImageEditor.thunks.js +63 -0
- package/lib/b64ToBlob.js +19 -0
- package/lib/defaultLocale.js +14 -0
- package/lib/index.js +126 -0
- package/lib/style.scss +30 -0
- package/package.json +5 -5
- package/CHANGELOG.md +0 -7834
package/lib/index.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
5
|
+
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); } }
|
|
6
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
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); }
|
|
9
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
12
|
+
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); }
|
|
13
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
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); }
|
|
17
|
+
import { Plugin } from '@scaleflex/widget-core';
|
|
18
|
+
import Explorer from '@scaleflex/widget-explorer';
|
|
19
|
+
import isImage from '@scaleflex/widget-utils/lib/isImage';
|
|
20
|
+
import Translator from '@scaleflex/widget-utils/lib/Translator';
|
|
21
|
+
import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
|
|
22
|
+
import { selectUploadsCount } from '@scaleflex/widget-core/lib/slices/uploads.slice';
|
|
23
|
+
import { imageEditorOpened, selectImageEditorFile } from '@scaleflex/widget-explorer/lib/slices/panels.slice';
|
|
24
|
+
import ImageEditorUI from './ImageEditor';
|
|
25
|
+
import defaultLocale from './defaultLocale';
|
|
26
|
+
// TODO: find a way to show version of the current plugin
|
|
27
|
+
// why solution below isn't good?
|
|
28
|
+
// first import doesn't work with webpack 5 as it was deprecated
|
|
29
|
+
// second import fixes webpack 5 issue as it was mentioned in their docs
|
|
30
|
+
// but it exposes our package.json to the client and it is mentioned as security rist in mutiple places
|
|
31
|
+
// https://github.com/axelpale/genversion
|
|
32
|
+
// https://stackoverflow.com/questions/64993118/error-should-not-import-the-named-export-version-imported-as-version
|
|
33
|
+
// https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code/10855054#10855054
|
|
34
|
+
// import { version } from '../package.json'
|
|
35
|
+
// import packageInfo from '../package.json'
|
|
36
|
+
var ImageEditor = /*#__PURE__*/function (_Plugin) {
|
|
37
|
+
// static VERSION = packageInfo.version
|
|
38
|
+
|
|
39
|
+
function ImageEditor(filerobot) {
|
|
40
|
+
var _this;
|
|
41
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
42
|
+
_classCallCheck(this, ImageEditor);
|
|
43
|
+
_this = _callSuper(this, ImageEditor, [filerobot, opts]);
|
|
44
|
+
_defineProperty(_this, "forceOpenImgEditor", function (file) {
|
|
45
|
+
if (isImage(file) && selectUploadsCount(_this.getGlobalState()) === 1) {
|
|
46
|
+
_this.dispatch(imageEditorOpened({
|
|
47
|
+
file: file,
|
|
48
|
+
showBackButton: 'auto'
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(_this, "closeImgEditor", function (closeReason) {
|
|
53
|
+
// If the force open for image editor enabled, and user closed the image editor then remove the image as it is not saved from image editor.
|
|
54
|
+
if (closeReason && _this.opts.forceOpenOnImgAddedToUpload && selectUploadsCount(_this.getGlobalState()) > 0) {
|
|
55
|
+
_this.filerobot.removeUploads(selectImageEditorFile(_this.getGlobalState()));
|
|
56
|
+
}
|
|
57
|
+
_this.dispatch(imageEditorOpened({
|
|
58
|
+
file: null,
|
|
59
|
+
showBackButton: 'auto'
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
62
|
+
_defineProperty(_this, "render", function (props) {
|
|
63
|
+
return ImageEditorUI(_objectSpread(_objectSpread({}, props), {}, {
|
|
64
|
+
closeEditor: _this.closeImgEditor,
|
|
65
|
+
opts: _this.opts,
|
|
66
|
+
i18n: _this.i18n
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
_this.id = PLUGINS_IDS.IMAGE_EDITOR;
|
|
70
|
+
_this.title = 'Image Editor';
|
|
71
|
+
_this.type = 'editor';
|
|
72
|
+
_this.defaultLocale = {
|
|
73
|
+
strings: defaultLocale
|
|
74
|
+
};
|
|
75
|
+
_this.i18nInit();
|
|
76
|
+
_this.opts = _objectSpread(_objectSpread({
|
|
77
|
+
forceOpenOnImgAddedToUpload: false
|
|
78
|
+
}, opts), {}, {
|
|
79
|
+
cloudimage: _objectSpread(_objectSpread({
|
|
80
|
+
token: filerobot.opts.container
|
|
81
|
+
}, opts.cloudimage), {}, {
|
|
82
|
+
dontPrefixUrl: true
|
|
83
|
+
}),
|
|
84
|
+
showBackButton: true
|
|
85
|
+
});
|
|
86
|
+
return _this;
|
|
87
|
+
}
|
|
88
|
+
_inherits(ImageEditor, _Plugin);
|
|
89
|
+
return _createClass(ImageEditor, [{
|
|
90
|
+
key: "i18nInit",
|
|
91
|
+
value: function i18nInit() {
|
|
92
|
+
this.translator = new Translator([this.defaultLocale, this.filerobot.locale, this.opts.locale]);
|
|
93
|
+
this.i18n = this.translator.translate.bind(this.translator);
|
|
94
|
+
this.i18nArray = this.translator.translateArray.bind(this.translator);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "install",
|
|
98
|
+
value: function install() {
|
|
99
|
+
var _this2 = this;
|
|
100
|
+
if (Explorer) {
|
|
101
|
+
this.mount(Explorer, this);
|
|
102
|
+
if (this.opts.forceOpenOnImgAddedToUpload) {
|
|
103
|
+
this.filerobot.on('file-added', this.forceOpenImgEditor);
|
|
104
|
+
}
|
|
105
|
+
if (this.opts.forceOpenAfterUpload) {
|
|
106
|
+
this.filerobot.on('complete', function (_ref) {
|
|
107
|
+
var successful = _ref.successful;
|
|
108
|
+
return _this2.forceOpenImgEditor(successful === null || successful === void 0 ? void 0 : successful[0]);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "uninstall",
|
|
115
|
+
value: function uninstall() {
|
|
116
|
+
this.unmount();
|
|
117
|
+
if (this.opts.forceOpenOnImgAddedToUpload) {
|
|
118
|
+
this.filerobot.off('file-added', this.forceOpenImgEditor);
|
|
119
|
+
}
|
|
120
|
+
if (this.opts.forceOpenAfterUpload) {
|
|
121
|
+
this.filerobot.off('complete', this.forceOpenImgEditor);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}]);
|
|
125
|
+
}(Plugin);
|
|
126
|
+
export default ImageEditor;
|
package/lib/style.scss
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// packages/@scaleflex/widget-image-editor/src/components/SaveAsModalContent.jsx
|
|
2
|
+
@import '@scaleflex/widget-core/lib/_variables.scss';
|
|
3
|
+
|
|
4
|
+
.filerobot-ImageEditor-SaveAsModal-fieldGroup {
|
|
5
|
+
text-align: left;
|
|
6
|
+
margin-bottom: 12px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.filerobot-ImageEditor-SaveAsModal-fieldInput {
|
|
10
|
+
margin-top: 4px;
|
|
11
|
+
height: 32px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.filerobot-ImageEditor-SaveAsModal-folderFieldGroup {
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: flex-start;
|
|
17
|
+
align-items: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.filerobot-ImageEditor-SaveAsModal-folderPathInput {
|
|
21
|
+
flex-grow: 1;
|
|
22
|
+
border-radius: 2px 0 0 2px;
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.filerobot-ImageEditor-SaveAsModal-browseButton {
|
|
27
|
+
background: $active-secondary;
|
|
28
|
+
border-radius: 0 2px 2px 0;
|
|
29
|
+
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/widget-image-editor",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.11",
|
|
4
4
|
"description": "FilerobotImageEditor integration with Scaleflex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@scaleflex/icons": "^3.0.0-beta.11",
|
|
17
17
|
"@scaleflex/ui": "^3.0.0-beta.11",
|
|
18
|
-
"@scaleflex/widget-common": "^4.8.
|
|
19
|
-
"@scaleflex/widget-icons": "^4.8.
|
|
20
|
-
"@scaleflex/widget-utils": "^4.8.
|
|
18
|
+
"@scaleflex/widget-common": "^4.8.11",
|
|
19
|
+
"@scaleflex/widget-icons": "^4.8.11",
|
|
20
|
+
"@scaleflex/widget-utils": "^4.8.11",
|
|
21
21
|
"react-filerobot-image-editor": "5.0.0-beta.93",
|
|
22
22
|
"react-filerobot-video-editor": "1.1.3"
|
|
23
23
|
},
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"react-konva": ">=19.0.3",
|
|
36
36
|
"react-redux": "^8.1.1"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "4e66456d033b9d9829c3c76a8c29b020dcacae2e"
|
|
39
39
|
}
|