@bigbinary/neeto-editor 1.28.17 → 1.28.18
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/index.cjs.js +105 -67
- package/index.cjs.js.map +1 -1
- package/index.js +106 -68
- package/index.js.map +1 -1
- package/package.json +1 -2
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNotEmpty, findBy, noop as noop$2, removeBy, findIndexBy, removeById, slugify } from '@bigbinary/neeto-commons-frontend/pure';
|
|
2
|
-
import { pluck, isEmpty as isEmpty$1, isNil, mergeDeepLeft,
|
|
2
|
+
import { pluck, isEmpty as isEmpty$1, isNil, mergeDeepLeft, mergeRight, assoc, concat as concat$3, is, not, prop, fromPairs, last, min as min$1 } from 'ramda';
|
|
3
3
|
import * as React$6 from 'react';
|
|
4
4
|
import React__default, { useContext, useState, useRef as useRef$1, useEffect as useEffect$1, useImperativeHandle, createContext, forwardRef as forwardRef$1, cloneElement, useLayoutEffect, useMemo, useCallback } from 'react';
|
|
5
5
|
import { renderToString } from 'react-dom/server';
|
|
@@ -58253,16 +58253,6 @@ var useUppyUploader = function useUppyUploader(_ref) {
|
|
|
58253
58253
|
};
|
|
58254
58254
|
};
|
|
58255
58255
|
|
|
58256
|
-
var FileSaver_min = {exports: {}};
|
|
58257
|
-
|
|
58258
|
-
(function (module, exports) {
|
|
58259
|
-
(function(a,b){b();})(commonjsGlobal,function(){function b(a,b){return "undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c);},d.onerror=function(){console.error("could not download file");},d.send();}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send();}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"));}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b);}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof commonjsGlobal&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,a=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href);},4E4),setTimeout(function(){e(j);},0));}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else {var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i);});}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null;},k.readAsDataURL(b);}else {var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m);},4E4);}});f.saveAs=g.saveAs=g,(module.exports=g);});
|
|
58260
|
-
|
|
58261
|
-
|
|
58262
|
-
} (FileSaver_min));
|
|
58263
|
-
|
|
58264
|
-
var saveAs = FileSaver_min.exports;
|
|
58265
|
-
|
|
58266
58256
|
var MAX_FILE_SIZE = 100 * 1024 * 1024; // 100 MB
|
|
58267
58257
|
|
|
58268
58258
|
var DEFAULT_UPPY_CONFIG = {
|
|
@@ -59106,6 +59096,101 @@ var File$1 = function File(_ref) {
|
|
|
59106
59096
|
}, defaultStyles[extension])));
|
|
59107
59097
|
};
|
|
59108
59098
|
|
|
59099
|
+
var newAxiosInstance = axios.create();
|
|
59100
|
+
var getFile = function getFile(url) {
|
|
59101
|
+
return newAxiosInstance.get(url, {
|
|
59102
|
+
responseType: "blob"
|
|
59103
|
+
});
|
|
59104
|
+
};
|
|
59105
|
+
var fileDownloadApi = {
|
|
59106
|
+
getFile: getFile
|
|
59107
|
+
};
|
|
59108
|
+
|
|
59109
|
+
var t$3 = instance.t;
|
|
59110
|
+
var buildUppyConfig = function buildUppyConfig(restrictions) {
|
|
59111
|
+
return mergeRight(DEFAULT_UPPY_CONFIG, {
|
|
59112
|
+
restrictions: restrictions
|
|
59113
|
+
});
|
|
59114
|
+
};
|
|
59115
|
+
var selectFiles = function selectFiles(_ref) {
|
|
59116
|
+
var previousAttachmentsCount = _ref.previousAttachmentsCount,
|
|
59117
|
+
config = _ref.config,
|
|
59118
|
+
files = _ref.files;
|
|
59119
|
+
var maxNumberOfFiles = config.maxNumberOfFiles;
|
|
59120
|
+
if (maxNumberOfFiles) {
|
|
59121
|
+
var remainingAttachments = maxNumberOfFiles - previousAttachmentsCount;
|
|
59122
|
+
if (remainingAttachments <= 0) {
|
|
59123
|
+
Toastr.warning(t$3("attachments.maxNumberOfFiles", {
|
|
59124
|
+
entity: maxNumberOfFiles
|
|
59125
|
+
}));
|
|
59126
|
+
return [];
|
|
59127
|
+
}
|
|
59128
|
+
var selectedFiles = Array.from(files).slice(0, remainingAttachments);
|
|
59129
|
+
if (selectedFiles.length < files.length) {
|
|
59130
|
+
Toastr.warning(t$3("attachments.maxNumberOfFiles", {
|
|
59131
|
+
entity: maxNumberOfFiles
|
|
59132
|
+
}));
|
|
59133
|
+
}
|
|
59134
|
+
return selectedFiles;
|
|
59135
|
+
}
|
|
59136
|
+
return Array.from(files);
|
|
59137
|
+
};
|
|
59138
|
+
var handleDrop = function handleDrop(_ref2) {
|
|
59139
|
+
var uppy = _ref2.uppy,
|
|
59140
|
+
config = _ref2.config,
|
|
59141
|
+
previousAttachmentsCount = _ref2.previousAttachmentsCount;
|
|
59142
|
+
var maxNumberOfFiles = config.maxNumberOfFiles;
|
|
59143
|
+
if (maxNumberOfFiles) {
|
|
59144
|
+
var files = uppy.getFiles();
|
|
59145
|
+
var totalAttachments = files.length + previousAttachmentsCount;
|
|
59146
|
+
if (totalAttachments > maxNumberOfFiles) {
|
|
59147
|
+
Toastr.warning(t$3("attachments.maxNumberOfFiles", {
|
|
59148
|
+
entity: maxNumberOfFiles
|
|
59149
|
+
}));
|
|
59150
|
+
uppy.reset();
|
|
59151
|
+
return false;
|
|
59152
|
+
}
|
|
59153
|
+
}
|
|
59154
|
+
return true;
|
|
59155
|
+
};
|
|
59156
|
+
var downloadFile = /*#__PURE__*/function () {
|
|
59157
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(fileUrl, filename) {
|
|
59158
|
+
var response, blob, url, a;
|
|
59159
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
59160
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59161
|
+
case 0:
|
|
59162
|
+
_context.prev = 0;
|
|
59163
|
+
_context.next = 3;
|
|
59164
|
+
return fileDownloadApi.getFile(fileUrl);
|
|
59165
|
+
case 3:
|
|
59166
|
+
response = _context.sent;
|
|
59167
|
+
blob = new Blob([response.data]);
|
|
59168
|
+
url = URL.createObjectURL(blob);
|
|
59169
|
+
a = document.createElement("a");
|
|
59170
|
+
a.href = url;
|
|
59171
|
+
a.setAttribute("download", filename);
|
|
59172
|
+
a.style.display = "none";
|
|
59173
|
+
document.body.appendChild(a);
|
|
59174
|
+
a.click();
|
|
59175
|
+
URL.revokeObjectURL(url);
|
|
59176
|
+
document.body.removeChild(a);
|
|
59177
|
+
_context.next = 19;
|
|
59178
|
+
break;
|
|
59179
|
+
case 16:
|
|
59180
|
+
_context.prev = 16;
|
|
59181
|
+
_context.t0 = _context["catch"](0);
|
|
59182
|
+
Toastr.error(_context.t0);
|
|
59183
|
+
case 19:
|
|
59184
|
+
case "end":
|
|
59185
|
+
return _context.stop();
|
|
59186
|
+
}
|
|
59187
|
+
}, _callee, null, [[0, 16]]);
|
|
59188
|
+
}));
|
|
59189
|
+
return function downloadFile(_x, _x2) {
|
|
59190
|
+
return _ref3.apply(this, arguments);
|
|
59191
|
+
};
|
|
59192
|
+
}();
|
|
59193
|
+
|
|
59109
59194
|
var Menu$8 = Dropdown$1.Menu,
|
|
59110
59195
|
MenuItem$3 = Dropdown$1.MenuItem;
|
|
59111
59196
|
var Attachment = function Attachment(_ref) {
|
|
@@ -59135,7 +59220,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
59135
59220
|
newFilename = _useState8[0],
|
|
59136
59221
|
setNewFilename = _useState8[1];
|
|
59137
59222
|
var handleDownload = function handleDownload() {
|
|
59138
|
-
|
|
59223
|
+
return downloadFile(attachment.url, attachment.filename);
|
|
59139
59224
|
};
|
|
59140
59225
|
var handleRename = /*#__PURE__*/function () {
|
|
59141
59226
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
@@ -59383,8 +59468,15 @@ var Preview = function Preview(_ref) {
|
|
|
59383
59468
|
setSelectedAttachment(attachments[newIndex]);
|
|
59384
59469
|
(_downloadRef$current2 = downloadRef.current) === null || _downloadRef$current2 === void 0 ? void 0 : _downloadRef$current2.focus();
|
|
59385
59470
|
};
|
|
59471
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
59472
|
+
if (event.key === "ArrowRight") {
|
|
59473
|
+
handleRightArrowClick();
|
|
59474
|
+
} else if (event.key === "ArrowLeft") {
|
|
59475
|
+
handleLeftArrowClick();
|
|
59476
|
+
}
|
|
59477
|
+
};
|
|
59386
59478
|
var handleDownload = function handleDownload() {
|
|
59387
|
-
|
|
59479
|
+
return downloadFile(url, filename);
|
|
59388
59480
|
};
|
|
59389
59481
|
var setPreview = function setPreview() {
|
|
59390
59482
|
switch (contentType.split("/")[0]) {
|
|
@@ -59418,13 +59510,7 @@ var Preview = function Preview(_ref) {
|
|
|
59418
59510
|
isOpen: !isEmpty$1(selectedAttachment),
|
|
59419
59511
|
size: "large",
|
|
59420
59512
|
onClose: onClose,
|
|
59421
|
-
onKeyDown:
|
|
59422
|
-
if (event.key === "ArrowRight") {
|
|
59423
|
-
handleRightArrowClick();
|
|
59424
|
-
} else if (event.key === "ArrowLeft") {
|
|
59425
|
-
handleLeftArrowClick();
|
|
59426
|
-
}
|
|
59427
|
-
}
|
|
59513
|
+
onKeyDown: handleKeyDown
|
|
59428
59514
|
}, /*#__PURE__*/React__default.createElement(Modal.Header, {
|
|
59429
59515
|
className: "ne-attachments-preview__header"
|
|
59430
59516
|
}, /*#__PURE__*/React__default.createElement(Typography, {
|
|
@@ -59448,54 +59534,6 @@ var Preview = function Preview(_ref) {
|
|
|
59448
59534
|
})));
|
|
59449
59535
|
};
|
|
59450
59536
|
|
|
59451
|
-
var t$3 = instance.t;
|
|
59452
|
-
var buildUppyConfig = function buildUppyConfig(restrictions) {
|
|
59453
|
-
return mergeRight(DEFAULT_UPPY_CONFIG, {
|
|
59454
|
-
restrictions: restrictions
|
|
59455
|
-
});
|
|
59456
|
-
};
|
|
59457
|
-
var selectFiles = function selectFiles(_ref) {
|
|
59458
|
-
var previousAttachmentsCount = _ref.previousAttachmentsCount,
|
|
59459
|
-
config = _ref.config,
|
|
59460
|
-
files = _ref.files;
|
|
59461
|
-
var maxNumberOfFiles = config.maxNumberOfFiles;
|
|
59462
|
-
if (maxNumberOfFiles) {
|
|
59463
|
-
var remainingAttachments = maxNumberOfFiles - previousAttachmentsCount;
|
|
59464
|
-
if (remainingAttachments <= 0) {
|
|
59465
|
-
Toastr.warning(t$3("attachments.maxNumberOfFiles", {
|
|
59466
|
-
entity: maxNumberOfFiles
|
|
59467
|
-
}));
|
|
59468
|
-
return [];
|
|
59469
|
-
}
|
|
59470
|
-
var selectedFiles = Array.from(files).slice(0, remainingAttachments);
|
|
59471
|
-
if (selectedFiles.length < files.length) {
|
|
59472
|
-
Toastr.warning(t$3("attachments.maxNumberOfFiles", {
|
|
59473
|
-
entity: maxNumberOfFiles
|
|
59474
|
-
}));
|
|
59475
|
-
}
|
|
59476
|
-
return selectedFiles;
|
|
59477
|
-
}
|
|
59478
|
-
return Array.from(files);
|
|
59479
|
-
};
|
|
59480
|
-
var handleDrop = function handleDrop(_ref2) {
|
|
59481
|
-
var uppy = _ref2.uppy,
|
|
59482
|
-
config = _ref2.config,
|
|
59483
|
-
previousAttachmentsCount = _ref2.previousAttachmentsCount;
|
|
59484
|
-
var maxNumberOfFiles = config.maxNumberOfFiles;
|
|
59485
|
-
if (maxNumberOfFiles) {
|
|
59486
|
-
var files = uppy.getFiles();
|
|
59487
|
-
var totalAttachments = files.length + previousAttachmentsCount;
|
|
59488
|
-
if (totalAttachments > maxNumberOfFiles) {
|
|
59489
|
-
Toastr.warning(t$3("attachments.maxNumberOfFiles", {
|
|
59490
|
-
entity: maxNumberOfFiles
|
|
59491
|
-
}));
|
|
59492
|
-
uppy.reset();
|
|
59493
|
-
return false;
|
|
59494
|
-
}
|
|
59495
|
-
}
|
|
59496
|
-
return true;
|
|
59497
|
-
};
|
|
59498
|
-
|
|
59499
59537
|
function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
59500
59538
|
function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$c(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
59501
59539
|
var Attachments = function Attachments(_ref, ref) {
|