@bigbinary/neeto-editor-frontend 0.0.0-stage → 2.0.2
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/LICENSE.md +21 -0
- package/README.md +145 -2
- package/app/javascript/src/translations/ar.json +209 -0
- package/app/javascript/src/translations/bg.json +209 -0
- package/app/javascript/src/translations/ca.json +209 -0
- package/app/javascript/src/translations/cs.json +209 -0
- package/app/javascript/src/translations/da.json +209 -0
- package/app/javascript/src/translations/de.json +209 -0
- package/app/javascript/src/translations/en.json +208 -0
- package/app/javascript/src/translations/es-MX.json +209 -0
- package/app/javascript/src/translations/es.json +209 -0
- package/app/javascript/src/translations/et.json +209 -0
- package/app/javascript/src/translations/fi.json +209 -0
- package/app/javascript/src/translations/fil.json +209 -0
- package/app/javascript/src/translations/fr.json +209 -0
- package/app/javascript/src/translations/he.json +209 -0
- package/app/javascript/src/translations/hi.json +209 -0
- package/app/javascript/src/translations/hr.json +209 -0
- package/app/javascript/src/translations/hu.json +209 -0
- package/app/javascript/src/translations/id.json +209 -0
- package/app/javascript/src/translations/index.js +1 -0
- package/app/javascript/src/translations/it.json +209 -0
- package/app/javascript/src/translations/ja.json +209 -0
- package/app/javascript/src/translations/ko.json +209 -0
- package/app/javascript/src/translations/lv.json +208 -0
- package/app/javascript/src/translations/nl.json +209 -0
- package/app/javascript/src/translations/pl.json +209 -0
- package/app/javascript/src/translations/pt-BR.json +209 -0
- package/app/javascript/src/translations/pt.json +209 -0
- package/app/javascript/src/translations/ro.json +209 -0
- package/app/javascript/src/translations/ru.json +209 -0
- package/app/javascript/src/translations/sk.json +209 -0
- package/app/javascript/src/translations/sl.json +209 -0
- package/app/javascript/src/translations/sv.json +209 -0
- package/app/javascript/src/translations/th.json +209 -0
- package/app/javascript/src/translations/tr.json +209 -0
- package/app/javascript/src/translations/uk.json +209 -0
- package/app/javascript/src/translations/vi.json +209 -0
- package/app/javascript/src/translations/zh-CN.json +209 -0
- package/app/javascript/src/translations/zh-TW.json +209 -0
- package/dist/.ready +1 -0
- package/dist/Attachments.js +53 -0
- package/dist/Attachments.js.map +1 -0
- package/dist/Editor.js +5532 -0
- package/dist/Editor.js.map +1 -0
- package/dist/EditorContent.js +252 -0
- package/dist/EditorContent.js.map +1 -0
- package/dist/FormikEditor.js +202 -0
- package/dist/FormikEditor.js.map +1 -0
- package/dist/Menu.js +107 -0
- package/dist/Menu.js.map +1 -0
- package/dist/chunk-1NlIGj6C.js +378 -0
- package/dist/chunk-1NlIGj6C.js.map +1 -0
- package/dist/chunk-BFKmIsWV.js +8660 -0
- package/dist/chunk-BFKmIsWV.js.map +1 -0
- package/dist/chunk-BFTU3MAI.js +8 -0
- package/dist/chunk-BFTU3MAI.js.map +1 -0
- package/dist/chunk-Ba4Q3HC8.js +15258 -0
- package/dist/chunk-Ba4Q3HC8.js.map +1 -0
- package/dist/chunk-Bra5VPWO.js +555 -0
- package/dist/chunk-Bra5VPWO.js.map +1 -0
- package/dist/chunk-C2dztUxs.js +4 -0
- package/dist/chunk-C2dztUxs.js.map +1 -0
- package/dist/chunk-CK_Ss-J5.js +425 -0
- package/dist/chunk-CK_Ss-J5.js.map +1 -0
- package/dist/chunk-CO-Yfs5R.js +206 -0
- package/dist/chunk-CO-Yfs5R.js.map +1 -0
- package/dist/chunk-CX-0IHKE.js +381 -0
- package/dist/chunk-CX-0IHKE.js.map +1 -0
- package/dist/chunk-CeoqieEt.js +25570 -0
- package/dist/chunk-CeoqieEt.js.map +1 -0
- package/dist/chunk-D52F37yF.js +19 -0
- package/dist/chunk-D52F37yF.js.map +1 -0
- package/dist/chunk-DcFvJOrc.js +3368 -0
- package/dist/chunk-DcFvJOrc.js.map +1 -0
- package/dist/chunk-DgZGzqPs.js +6804 -0
- package/dist/chunk-DgZGzqPs.js.map +1 -0
- package/dist/chunk-Di3ipdfT.js +20227 -0
- package/dist/chunk-Di3ipdfT.js.map +1 -0
- package/dist/chunk-DrHVV_g1.js +89 -0
- package/dist/chunk-DrHVV_g1.js.map +1 -0
- package/dist/chunk-DsAUS6bL.js +3464 -0
- package/dist/chunk-DsAUS6bL.js.map +1 -0
- package/dist/chunk-PSGRE5nX.js +97 -0
- package/dist/chunk-PSGRE5nX.js.map +1 -0
- package/dist/chunk-Qg4uQqj3.js +16238 -0
- package/dist/chunk-Qg4uQqj3.js.map +1 -0
- package/dist/chunk-aCTMceVU.js +135 -0
- package/dist/chunk-aCTMceVU.js.map +1 -0
- package/dist/chunk-fDmcpgqx.js +12510 -0
- package/dist/chunk-fDmcpgqx.js.map +1 -0
- package/dist/chunk-mFZL53CS.js +204 -0
- package/dist/chunk-mFZL53CS.js.map +1 -0
- package/dist/chunk-y5pmJStT.js +573 -0
- package/dist/chunk-y5pmJStT.js.map +1 -0
- package/dist/cjs/Attachments.cjs.js +59 -0
- package/dist/cjs/Attachments.cjs.js.map +1 -0
- package/dist/cjs/Editor.cjs.js +5611 -0
- package/dist/cjs/Editor.cjs.js.map +1 -0
- package/dist/cjs/EditorContent.cjs.js +266 -0
- package/dist/cjs/EditorContent.cjs.js.map +1 -0
- package/dist/cjs/FormikEditor.cjs.js +209 -0
- package/dist/cjs/FormikEditor.cjs.js.map +1 -0
- package/dist/cjs/Menu.cjs.js +113 -0
- package/dist/cjs/Menu.cjs.js.map +1 -0
- package/dist/cjs/chunk-B2NfgecV.cjs.js +599 -0
- package/dist/cjs/chunk-B2NfgecV.cjs.js.map +1 -0
- package/dist/cjs/chunk-B6qYtOJe.cjs.js +6 -0
- package/dist/cjs/chunk-B6qYtOJe.cjs.js.map +1 -0
- package/dist/cjs/chunk-BJu3ubxk.cjs.js +11 -0
- package/dist/cjs/chunk-BJu3ubxk.cjs.js.map +1 -0
- package/dist/cjs/chunk-BKvkHB8E.cjs.js +16259 -0
- package/dist/cjs/chunk-BKvkHB8E.cjs.js.map +1 -0
- package/dist/cjs/chunk-BlWQNLLE.cjs.js +3450 -0
- package/dist/cjs/chunk-BlWQNLLE.cjs.js.map +1 -0
- package/dist/cjs/chunk-Bmjmsp-E.cjs.js +97 -0
- package/dist/cjs/chunk-Bmjmsp-E.cjs.js.map +1 -0
- package/dist/cjs/chunk-C-VxABfm.cjs.js +25578 -0
- package/dist/cjs/chunk-C-VxABfm.cjs.js.map +1 -0
- package/dist/cjs/chunk-C8X4oFtP.cjs.js +216 -0
- package/dist/cjs/chunk-C8X4oFtP.cjs.js.map +1 -0
- package/dist/cjs/chunk-CCCSexAh.cjs.js +206 -0
- package/dist/cjs/chunk-CCCSexAh.cjs.js.map +1 -0
- package/dist/cjs/chunk-CNIzgxEP.cjs.js +49 -0
- package/dist/cjs/chunk-CNIzgxEP.cjs.js.map +1 -0
- package/dist/cjs/chunk-CesnwG-V.cjs.js +140 -0
- package/dist/cjs/chunk-CesnwG-V.cjs.js.map +1 -0
- package/dist/cjs/chunk-CohcWDmm.cjs.js +20318 -0
- package/dist/cjs/chunk-CohcWDmm.cjs.js.map +1 -0
- package/dist/cjs/chunk-Crp27WMe.cjs.js +6833 -0
- package/dist/cjs/chunk-Crp27WMe.cjs.js.map +1 -0
- package/dist/cjs/chunk-D3Unocnm.cjs.js +8681 -0
- package/dist/cjs/chunk-D3Unocnm.cjs.js.map +1 -0
- package/dist/cjs/chunk-D6ygkQBu.cjs.js +421 -0
- package/dist/cjs/chunk-D6ygkQBu.cjs.js.map +1 -0
- package/dist/cjs/chunk-D7p10rIr.cjs.js +112 -0
- package/dist/cjs/chunk-D7p10rIr.cjs.js.map +1 -0
- package/dist/cjs/chunk-DM1lUvXy.cjs.js +3525 -0
- package/dist/cjs/chunk-DM1lUvXy.cjs.js.map +1 -0
- package/dist/cjs/chunk-DWyvxp1a.cjs.js +394 -0
- package/dist/cjs/chunk-DWyvxp1a.cjs.js.map +1 -0
- package/dist/cjs/chunk-DXsX8co9.cjs.js +12512 -0
- package/dist/cjs/chunk-DXsX8co9.cjs.js.map +1 -0
- package/dist/cjs/chunk-DxXc6tiG.cjs.js +15326 -0
- package/dist/cjs/chunk-DxXc6tiG.cjs.js.map +1 -0
- package/dist/cjs/chunk-MxWVMW6e.cjs.js +569 -0
- package/dist/cjs/chunk-MxWVMW6e.cjs.js.map +1 -0
- package/dist/cjs/chunk-cwORbcv3.cjs.js +479 -0
- package/dist/cjs/chunk-cwORbcv3.cjs.js.map +1 -0
- package/dist/cjs/constants.cjs.js +13 -0
- package/dist/cjs/constants.cjs.js.map +1 -0
- package/dist/cjs/index.cjs.js +163 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/utils.cjs.js +29 -0
- package/dist/cjs/utils.cjs.js.map +1 -0
- package/dist/cjs/v2/Attachments.cjs.js +49 -0
- package/dist/cjs/v2/Attachments.cjs.js.map +1 -0
- package/dist/cjs/v2/Editor.cjs.js +5741 -0
- package/dist/cjs/v2/Editor.cjs.js.map +1 -0
- package/dist/cjs/v2/EditorContent.cjs.js +33 -0
- package/dist/cjs/v2/EditorContent.cjs.js.map +1 -0
- package/dist/cjs/v2/FormikEditor.cjs.js +164 -0
- package/dist/cjs/v2/FormikEditor.cjs.js.map +1 -0
- package/dist/cjs/v2/Menu.cjs.js +62 -0
- package/dist/cjs/v2/Menu.cjs.js.map +1 -0
- package/dist/cjs/v2/constants.cjs.js +13 -0
- package/dist/cjs/v2/constants.cjs.js.map +1 -0
- package/dist/cjs/v2/index.cjs.js +120 -0
- package/dist/cjs/v2/index.cjs.js.map +1 -0
- package/dist/cjs/v2/utils.cjs.js +29 -0
- package/dist/cjs/v2/utils.cjs.js.map +1 -0
- package/dist/codeblockHighlight.js +15155 -0
- package/dist/codeblockHighlight.js.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/editor-content.min.css +1 -0
- package/dist/editor-output-pdf-email.css +1 -0
- package/dist/editor-output-pdf-email.js +4 -0
- package/dist/editor-output-pdf-email.js.map +1 -0
- package/dist/editor-output.js +4 -0
- package/dist/editor-output.js.map +1 -0
- package/dist/editor-stats.html +4842 -0
- package/dist/editorUtils.js +170 -0
- package/dist/headerLinks.js +59 -0
- package/dist/headerLinks.js.map +1 -0
- package/dist/index.js +146 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.js +17 -0
- package/dist/utils.js.map +1 -0
- package/dist/v2/Attachments.js +43 -0
- package/dist/v2/Attachments.js.map +1 -0
- package/dist/v2/Editor.js +5692 -0
- package/dist/v2/Editor.js.map +1 -0
- package/dist/v2/EditorContent.js +27 -0
- package/dist/v2/EditorContent.js.map +1 -0
- package/dist/v2/FormikEditor.js +157 -0
- package/dist/v2/FormikEditor.js.map +1 -0
- package/dist/v2/Menu.js +56 -0
- package/dist/v2/Menu.js.map +1 -0
- package/dist/v2/constants.js +6 -0
- package/dist/v2/constants.js.map +1 -0
- package/dist/v2/editor-content-styles.js +4 -0
- package/dist/v2/editor-content-styles.js.map +1 -0
- package/dist/v2/editor-content.min.css +1 -0
- package/dist/v2/index.js +101 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/styles.css +1 -0
- package/dist/v2/styles.js +4 -0
- package/dist/v2/styles.js.map +1 -0
- package/dist/v2/utils.js +17 -0
- package/dist/v2/utils.js.map +1 -0
- package/formik.d.ts +9 -0
- package/package.json +322 -4
- package/types.d.ts +199 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { Dialog, Typography, Button } from '@bigbinary/neeto-atoms';
|
|
3
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
4
|
+
import { findIndexBy } from '@bigbinary/neeto-cist';
|
|
5
|
+
import { isEmpty } from 'ramda';
|
|
6
|
+
import { D as DocViewer, a as DocViewerRenderers } from './chunk-CeoqieEt.js';
|
|
7
|
+
import { useTranslation, Trans } from 'react-i18next';
|
|
8
|
+
import { c as convertToFileSize, A as ATTACHMENTS_PREVIEW_DATA_CY } from './chunk-1NlIGj6C.js';
|
|
9
|
+
import { d as downloadFile, c as checkPreviewAvailability } from './chunk-Bra5VPWO.js';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
+
import './chunk-BFTU3MAI.js';
|
|
12
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
13
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
14
|
+
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
15
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
|
16
|
+
import '@babel/runtime/regenerator';
|
|
17
|
+
import 'zustand/shallow';
|
|
18
|
+
import 'axios';
|
|
19
|
+
import './chunk-BFKmIsWV.js';
|
|
20
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
21
|
+
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
22
|
+
import 'zustand';
|
|
23
|
+
import '@babel/runtime/helpers/createClass';
|
|
24
|
+
import '@babel/runtime/helpers/classCallCheck';
|
|
25
|
+
import 'i18next';
|
|
26
|
+
import '@bigbinary/neeto-commons-frontend/v2/initializers';
|
|
27
|
+
import './chunk-DrHVV_g1.js';
|
|
28
|
+
import '@bigbinary/neeto-icons/LeftAlign';
|
|
29
|
+
import '@bigbinary/neeto-icons/CenterAlign';
|
|
30
|
+
import '@bigbinary/neeto-icons/RightAlign';
|
|
31
|
+
import '@bigbinary/neeto-icons/Delete';
|
|
32
|
+
import '@bigbinary/neeto-icons/CustomSize';
|
|
33
|
+
import '@bigbinary/neeto-icons/BorderDisable';
|
|
34
|
+
import '@bigbinary/neeto-icons/BorderEnable';
|
|
35
|
+
import '@bigbinary/neeto-icons/AspectRatio11';
|
|
36
|
+
import '@bigbinary/neeto-icons/AspectRatio169';
|
|
37
|
+
import '@bigbinary/neeto-icons/AspectRatio916';
|
|
38
|
+
import '@bigbinary/neeto-icons/AspectRatio43';
|
|
39
|
+
import '@bigbinary/neeto-icons/AspectRatio32';
|
|
40
|
+
import 'yup';
|
|
41
|
+
import 'classnames';
|
|
42
|
+
import '@bigbinary/neeto-commons-frontend/v2/react-utils/useOnClickOutside';
|
|
43
|
+
import '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
44
|
+
|
|
45
|
+
var Preview = function Preview(_ref) {
|
|
46
|
+
var onClose = _ref.onClose,
|
|
47
|
+
attachments = _ref.attachments,
|
|
48
|
+
selectedAttachment = _ref.selectedAttachment,
|
|
49
|
+
setSelectedAttachment = _ref.setSelectedAttachment,
|
|
50
|
+
setDidFetchPreviewBundle = _ref.setDidFetchPreviewBundle;
|
|
51
|
+
var _useTranslation = useTranslation(),
|
|
52
|
+
t = _useTranslation.t;
|
|
53
|
+
var downloadRef = useRef(null);
|
|
54
|
+
var _selectedAttachment$f = selectedAttachment.filename,
|
|
55
|
+
filename = _selectedAttachment$f === void 0 ? "" : _selectedAttachment$f,
|
|
56
|
+
_selectedAttachment$c = selectedAttachment.contentType,
|
|
57
|
+
contentType = _selectedAttachment$c === void 0 ? null : _selectedAttachment$c,
|
|
58
|
+
_selectedAttachment$u = selectedAttachment.url,
|
|
59
|
+
url = _selectedAttachment$u === void 0 ? "" : _selectedAttachment$u,
|
|
60
|
+
_selectedAttachment$s = selectedAttachment.signedId,
|
|
61
|
+
signedId = _selectedAttachment$s === void 0 ? "" : _selectedAttachment$s,
|
|
62
|
+
_selectedAttachment$s2 = selectedAttachment.size,
|
|
63
|
+
size = _selectedAttachment$s2 === void 0 ? undefined : _selectedAttachment$s2,
|
|
64
|
+
_selectedAttachment$p = selectedAttachment.previewUrl,
|
|
65
|
+
previewUrl = _selectedAttachment$p === void 0 ? null : _selectedAttachment$p;
|
|
66
|
+
var attachmentIndex = findIndexBy({
|
|
67
|
+
signedId: signedId
|
|
68
|
+
}, attachments);
|
|
69
|
+
var handleRightArrowClick = function handleRightArrowClick() {
|
|
70
|
+
var _downloadRef$current;
|
|
71
|
+
var newIndex = (attachmentIndex + 1) % attachments.length;
|
|
72
|
+
setSelectedAttachment(attachments[newIndex]);
|
|
73
|
+
(_downloadRef$current = downloadRef.current) === null || _downloadRef$current === void 0 || _downloadRef$current.focus();
|
|
74
|
+
};
|
|
75
|
+
var handleLeftArrowClick = function handleLeftArrowClick() {
|
|
76
|
+
var _downloadRef$current2;
|
|
77
|
+
var newIndex = (attachmentIndex - 1 + attachments.length) % attachments.length;
|
|
78
|
+
setSelectedAttachment(attachments[newIndex]);
|
|
79
|
+
(_downloadRef$current2 = downloadRef.current) === null || _downloadRef$current2 === void 0 || _downloadRef$current2.focus();
|
|
80
|
+
};
|
|
81
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
82
|
+
if (event.key === "ArrowRight") {
|
|
83
|
+
handleRightArrowClick();
|
|
84
|
+
} else if (event.key === "ArrowLeft") {
|
|
85
|
+
handleLeftArrowClick();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
useEffect(function () {
|
|
89
|
+
setDidFetchPreviewBundle(true);
|
|
90
|
+
}, []);
|
|
91
|
+
var handleDownload = function handleDownload() {
|
|
92
|
+
return downloadFile(url, filename);
|
|
93
|
+
};
|
|
94
|
+
var setPreview = function setPreview() {
|
|
95
|
+
var isPreviewAvailable = checkPreviewAvailability(contentType, previewUrl);
|
|
96
|
+
if (isPreviewAvailable) {
|
|
97
|
+
switch (contentType.split("/")[0]) {
|
|
98
|
+
case "image":
|
|
99
|
+
return /*#__PURE__*/jsx("img", {
|
|
100
|
+
"data-testid": ATTACHMENTS_PREVIEW_DATA_CY,
|
|
101
|
+
src: previewUrl || url
|
|
102
|
+
});
|
|
103
|
+
case "video":
|
|
104
|
+
return /*#__PURE__*/jsx("video", {
|
|
105
|
+
controls: true,
|
|
106
|
+
"data-testid": ATTACHMENTS_PREVIEW_DATA_CY,
|
|
107
|
+
src: url
|
|
108
|
+
});
|
|
109
|
+
case "application":
|
|
110
|
+
case "text":
|
|
111
|
+
if (contentType === "application/pdf") {
|
|
112
|
+
return /*#__PURE__*/jsx("iframe", {
|
|
113
|
+
"data-testid": ATTACHMENTS_PREVIEW_DATA_CY,
|
|
114
|
+
src: url,
|
|
115
|
+
width: "100%"
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return /*#__PURE__*/jsx(DocViewer, {
|
|
119
|
+
className: "ne-attachments-preview__body-docviewer",
|
|
120
|
+
"data-testid": ATTACHMENTS_PREVIEW_DATA_CY,
|
|
121
|
+
documents: [{
|
|
122
|
+
uri: url,
|
|
123
|
+
fileType: contentType
|
|
124
|
+
}],
|
|
125
|
+
pluginRenderers: DocViewerRenderers,
|
|
126
|
+
config: {
|
|
127
|
+
header: {
|
|
128
|
+
disableHeader: true,
|
|
129
|
+
disableFileName: true
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
default:
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return /*#__PURE__*/jsx(Typography, {
|
|
138
|
+
children: /*#__PURE__*/jsx(Trans, {
|
|
139
|
+
i18nKey: "neetoEditor.attachments.noPreview",
|
|
140
|
+
components: {
|
|
141
|
+
span: /*#__PURE__*/jsx("span", {
|
|
142
|
+
className: "ne-attachments-preview__body-download",
|
|
143
|
+
onClick: handleDownload
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
return /*#__PURE__*/jsxs(Dialog, {
|
|
150
|
+
onClose: onClose,
|
|
151
|
+
className: "ne-attachments-preview p-0",
|
|
152
|
+
isOpen: !isEmpty(selectedAttachment),
|
|
153
|
+
size: "fullScreen",
|
|
154
|
+
onKeyDown: handleKeyDown,
|
|
155
|
+
children: [/*#__PURE__*/jsxs(Dialog.Header, {
|
|
156
|
+
className: "ne-attachments-preview__header items-center",
|
|
157
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
158
|
+
className: "ne-attachments-preview__header__fileinfo min-w-0 overflow-hidden",
|
|
159
|
+
children: [/*#__PURE__*/jsx(Dialog.Title, {
|
|
160
|
+
className: "min-w-0 overflow-hidden",
|
|
161
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
162
|
+
className: "truncate",
|
|
163
|
+
variant: "h5",
|
|
164
|
+
children: filename
|
|
165
|
+
})
|
|
166
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
167
|
+
className: "shrink-0 whitespace-nowrap",
|
|
168
|
+
color: "muted",
|
|
169
|
+
variant: "body2",
|
|
170
|
+
children: convertToFileSize(size)
|
|
171
|
+
})]
|
|
172
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
173
|
+
className: "shrink-0",
|
|
174
|
+
"data-testid": "download-preview-button",
|
|
175
|
+
label: t("neetoEditor.common.download"),
|
|
176
|
+
ref: downloadRef,
|
|
177
|
+
variant: "link",
|
|
178
|
+
onClick: handleDownload
|
|
179
|
+
})]
|
|
180
|
+
}), /*#__PURE__*/jsxs(Dialog.Body, {
|
|
181
|
+
className: "ne-attachments-preview__body w-full",
|
|
182
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
183
|
+
className: "ne-attachments-preview__body-left",
|
|
184
|
+
icon: /*#__PURE__*/jsx(ChevronLeft, {
|
|
185
|
+
className: "size-8"
|
|
186
|
+
}),
|
|
187
|
+
size: "lg",
|
|
188
|
+
variant: "ghost",
|
|
189
|
+
onClick: handleLeftArrowClick
|
|
190
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
191
|
+
className: "ne-attachments-preview__body-right",
|
|
192
|
+
icon: /*#__PURE__*/jsx(ChevronRight, {
|
|
193
|
+
className: "size-8"
|
|
194
|
+
}),
|
|
195
|
+
size: "lg",
|
|
196
|
+
variant: "ghost",
|
|
197
|
+
onClick: handleRightArrowClick
|
|
198
|
+
}), setPreview()]
|
|
199
|
+
})]
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export { Preview as default };
|
|
204
|
+
//# sourceMappingURL=chunk-mFZL53CS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-mFZL53CS.js","sources":["../app/javascript/src/v2/components/Attachments/Preview.jsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport { Button, Dialog, Typography } from \"@bigbinary/neeto-atoms\";\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { findIndexBy } from \"neetocist\";\nimport { isEmpty } from \"ramda\";\nimport DocViewer, { DocViewerRenderers } from \"react-doc-viewer\";\nimport { Trans, useTranslation } from \"react-i18next\";\n\nimport { convertToFileSize } from \"src/v2/components/Editor/MediaUploader/utils\";\n\nimport { ATTACHMENTS_PREVIEW_DATA_CY } from \"./constants\";\nimport { checkPreviewAvailability, downloadFile } from \"./utils\";\n\nconst Preview = ({\n onClose,\n attachments,\n selectedAttachment,\n setSelectedAttachment,\n setDidFetchPreviewBundle,\n}) => {\n const { t } = useTranslation();\n const downloadRef = useRef(null);\n\n const {\n filename = \"\",\n contentType = null,\n url = \"\",\n signedId = \"\",\n size = undefined,\n previewUrl = null,\n } = selectedAttachment;\n\n const attachmentIndex = findIndexBy({ signedId }, attachments);\n\n const handleRightArrowClick = () => {\n const newIndex = (attachmentIndex + 1) % attachments.length;\n setSelectedAttachment(attachments[newIndex]);\n downloadRef.current?.focus();\n };\n\n const handleLeftArrowClick = () => {\n const newIndex =\n (attachmentIndex - 1 + attachments.length) % attachments.length;\n setSelectedAttachment(attachments[newIndex]);\n downloadRef.current?.focus();\n };\n\n const handleKeyDown = event => {\n if (event.key === \"ArrowRight\") {\n handleRightArrowClick();\n } else if (event.key === \"ArrowLeft\") {\n handleLeftArrowClick();\n }\n };\n\n useEffect(() => {\n setDidFetchPreviewBundle(true);\n }, []);\n\n const handleDownload = () => downloadFile(url, filename);\n\n const setPreview = () => {\n const isPreviewAvailable = checkPreviewAvailability(\n contentType,\n previewUrl\n );\n\n if (isPreviewAvailable) {\n switch (contentType.split(\"/\")[0]) {\n case \"image\":\n return (\n <img\n data-testid={ATTACHMENTS_PREVIEW_DATA_CY}\n src={previewUrl || url}\n />\n );\n case \"video\":\n return (\n <video\n controls\n data-testid={ATTACHMENTS_PREVIEW_DATA_CY}\n src={url}\n />\n );\n case \"application\":\n case \"text\":\n if (contentType === \"application/pdf\") {\n return (\n <iframe\n data-testid={ATTACHMENTS_PREVIEW_DATA_CY}\n src={url}\n width=\"100%\"\n />\n );\n }\n\n return (\n <DocViewer\n className=\"ne-attachments-preview__body-docviewer\"\n data-testid={ATTACHMENTS_PREVIEW_DATA_CY}\n documents={[{ uri: url, fileType: contentType }]}\n pluginRenderers={DocViewerRenderers}\n config={{\n header: { disableHeader: true, disableFileName: true },\n }}\n />\n );\n default:\n return null;\n }\n }\n\n return (\n <Typography>\n <Trans\n i18nKey=\"neetoEditor.attachments.noPreview\"\n components={{\n span: (\n <span\n className=\"ne-attachments-preview__body-download\"\n onClick={handleDownload}\n />\n ),\n }}\n />\n </Typography>\n );\n };\n\n return (\n <Dialog\n {...{ onClose }}\n className=\"ne-attachments-preview p-0\"\n isOpen={!isEmpty(selectedAttachment)}\n size=\"fullScreen\"\n onKeyDown={handleKeyDown}\n >\n <Dialog.Header className=\"ne-attachments-preview__header items-center\">\n <div className=\"ne-attachments-preview__header__fileinfo min-w-0 overflow-hidden\">\n <Dialog.Title className=\"min-w-0 overflow-hidden\">\n <Typography className=\"truncate\" variant=\"h5\">\n {filename}\n </Typography>\n </Dialog.Title>\n <Typography\n className=\"shrink-0 whitespace-nowrap\"\n color=\"muted\"\n variant=\"body2\"\n >\n {convertToFileSize(size)}\n </Typography>\n </div>\n <Button\n className=\"shrink-0\"\n data-testid=\"download-preview-button\"\n label={t(\"neetoEditor.common.download\")}\n ref={downloadRef}\n variant=\"link\"\n onClick={handleDownload}\n />\n </Dialog.Header>\n <Dialog.Body className=\"ne-attachments-preview__body w-full\">\n <Button\n className=\"ne-attachments-preview__body-left\"\n icon={<ChevronLeft className=\"size-8\" />}\n size=\"lg\"\n variant=\"ghost\"\n onClick={handleLeftArrowClick}\n />\n <Button\n className=\"ne-attachments-preview__body-right\"\n icon={<ChevronRight className=\"size-8\" />}\n size=\"lg\"\n variant=\"ghost\"\n onClick={handleRightArrowClick}\n />\n {setPreview()}\n </Dialog.Body>\n </Dialog>\n );\n};\n\nexport default Preview;\n"],"names":["Preview","_ref","onClose","attachments","selectedAttachment","setSelectedAttachment","setDidFetchPreviewBundle","_useTranslation","useTranslation","t","downloadRef","useRef","_selectedAttachment$f","filename","_selectedAttachment$c","contentType","_selectedAttachment$u","url","_selectedAttachment$s","signedId","_selectedAttachment$s2","size","undefined","_selectedAttachment$p","previewUrl","attachmentIndex","findIndexBy","handleRightArrowClick","_downloadRef$current","newIndex","length","current","focus","handleLeftArrowClick","_downloadRef$current2","handleKeyDown","event","key","useEffect","handleDownload","downloadFile","setPreview","isPreviewAvailable","checkPreviewAvailability","split","_jsx","ATTACHMENTS_PREVIEW_DATA_CY","src","controls","width","DocViewer","className","documents","uri","fileType","pluginRenderers","DocViewerRenderers","config","header","disableHeader","disableFileName","Typography","children","Trans","i18nKey","components","span","onClick","_jsxs","Dialog","isOpen","isEmpty","onKeyDown","Header","Title","variant","color","convertToFileSize","Button","label","ref","Body","icon","ChevronLeft","ChevronRight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAMP;AAAA,EAAA,IALJC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,kBAAkB,GAAAH,IAAA,CAAlBG,kBAAkB;IAClBC,qBAAqB,GAAAJ,IAAA,CAArBI,qBAAqB;IACrBC,wBAAwB,GAAAL,IAAA,CAAxBK,wBAAwB;AAExB,EAAA,IAAAC,eAAA,GAAcC,cAAc,EAAE;IAAtBC,CAAC,GAAAF,eAAA,CAADE,CAAC;AACT,EAAA,IAAMC,WAAW,GAAGC,MAAM,CAAC,IAAI,CAAC;AAEhC,EAAA,IAAAC,qBAAA,GAOIR,kBAAkB,CANpBS,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,qBAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,qBAAA;IAAAE,qBAAA,GA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