@nocobase/plugin-file-manager 2.1.0-alpha.40 → 2.1.0-alpha.46
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/client/867ada653cd02a3e.mjs +6 -0
- package/dist/client/876.ca16d7a6e6387862.js +11 -0
- package/dist/client/index.js +1 -1
- package/dist/client/locale/index.d.ts +1 -1
- package/dist/client/previewer/filePreviewTypes.d.ts +1 -1
- package/dist/client/templates/file.d.ts +1 -1
- package/dist/client-v2/125.0b8eef1f19b87042.js +10 -0
- package/dist/client-v2/867ada653cd02a3e.mjs +6 -0
- package/dist/client-v2/876.22cd8e41ac8631ed.js +11 -0
- package/dist/client-v2/{942.9dc2d49980a4dd9e.js → 942.f36d807d763a1b53.js} +1 -1
- package/dist/client-v2/index.d.ts +2 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/{shared → client-v2}/previewer/filePreviewTypes.d.ts +4 -0
- package/dist/externalVersion.js +9 -9
- package/dist/locale/de-DE.json +3 -0
- package/dist/locale/en-US.json +3 -0
- package/dist/locale/es-ES.json +3 -0
- package/dist/locale/fr-FR.json +3 -0
- package/dist/locale/hu-HU.json +4 -1
- package/dist/locale/id-ID.json +4 -1
- package/dist/locale/it-IT.json +3 -0
- package/dist/locale/ja-JP.json +3 -0
- package/dist/locale/ko-KR.json +3 -0
- package/dist/locale/nl-NL.json +3 -0
- package/dist/locale/pt-BR.json +3 -0
- package/dist/locale/ru-RU.json +3 -0
- package/dist/locale/tr-TR.json +3 -0
- package/dist/locale/uk-UA.json +3 -0
- package/dist/locale/vi-VN.json +4 -1
- package/dist/locale/zh-CN.json +3 -0
- package/dist/locale/zh-TW.json +3 -0
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
- package/dist/node_modules/ali-oss/package.json +1 -1
- package/dist/node_modules/cos-nodejs-sdk-v5/package.json +1 -1
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/url-join/package.json +1 -1
- package/dist/server/actions/attachments.js +2 -2
- package/dist/server/actions/index.js +8 -1
- package/dist/{shared/locale.d.ts → server/actions/storage-validation.d.ts} +2 -1
- package/dist/server/actions/storage-validation.js +73 -0
- package/dist/server/commands/repair-filenames.d.ts +55 -0
- package/dist/server/commands/repair-filenames.js +283 -0
- package/dist/server/server.d.ts +1 -0
- package/dist/server/server.js +7 -0
- package/dist/server/storages/ali-oss.d.ts +3 -1
- package/dist/server/storages/ali-oss.js +23 -2
- package/dist/server/storages/index.d.ts +3 -0
- package/dist/server/storages/index.js +6 -0
- package/dist/server/storages/local.d.ts +6 -0
- package/dist/server/storages/local.js +74 -13
- package/dist/server/storages/s3.d.ts +2 -0
- package/dist/server/storages/s3.js +26 -0
- package/dist/server/storages/tx-cos.d.ts +2 -0
- package/dist/server/storages/tx-cos.js +27 -0
- package/dist/server/utils.js +12 -2
- package/package.json +4 -2
- package/dist/client-v2/125.01d5562df948d974.js +0 -10
- package/dist/shared/locale.js +0 -36
- package/dist/shared/previewer/filePreviewTypes.js +0 -459
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var filePreviewTypes_exports = {};
|
|
38
|
-
__export(filePreviewTypes_exports, {
|
|
39
|
-
FilePreviewRenderer: () => FilePreviewRenderer,
|
|
40
|
-
FilePreviewTypes: () => FilePreviewTypes,
|
|
41
|
-
filePreviewTypes: () => filePreviewTypes,
|
|
42
|
-
getDownloadFileName: () => getDownloadFileName,
|
|
43
|
-
getFallbackIcon: () => getFallbackIcon,
|
|
44
|
-
getFileExt: () => getFileExt,
|
|
45
|
-
getFileName: () => getFileName,
|
|
46
|
-
getFileUrl: () => getFileUrl,
|
|
47
|
-
getPreviewFileUrl: () => getPreviewFileUrl,
|
|
48
|
-
getPreviewThumbnailUrl: () => getPreviewThumbnailUrl,
|
|
49
|
-
isActiveContentFile: () => isActiveContentFile,
|
|
50
|
-
matchMimetype: () => matchMimetype,
|
|
51
|
-
normalizePreviewFile: () => normalizePreviewFile,
|
|
52
|
-
wrapWithModalPreviewer: () => wrapWithModalPreviewer
|
|
53
|
-
});
|
|
54
|
-
module.exports = __toCommonJS(filePreviewTypes_exports);
|
|
55
|
-
var import_react = __toESM(require("react"));
|
|
56
|
-
var import_icons = require("@ant-design/icons");
|
|
57
|
-
var import_antd = require("antd");
|
|
58
|
-
var import_mime_match = __toESM(require("mime-match"));
|
|
59
|
-
var import_react_i18next = require("react-i18next");
|
|
60
|
-
var import_locale = require("../locale");
|
|
61
|
-
class FilePreviewTypes {
|
|
62
|
-
types = [];
|
|
63
|
-
add(type) {
|
|
64
|
-
this.types.unshift(type);
|
|
65
|
-
}
|
|
66
|
-
getTypeByFile(file) {
|
|
67
|
-
const normalized = normalizePreviewFile(file);
|
|
68
|
-
return this.types.find((type) => type.match(normalized));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const filePreviewTypes = new FilePreviewTypes();
|
|
72
|
-
function normalizePreviewFile(file) {
|
|
73
|
-
if (!file) {
|
|
74
|
-
return file;
|
|
75
|
-
}
|
|
76
|
-
if (typeof file === "string") {
|
|
77
|
-
return { url: file };
|
|
78
|
-
}
|
|
79
|
-
return file;
|
|
80
|
-
}
|
|
81
|
-
function getPreviewFileUrl(file) {
|
|
82
|
-
if (!file) {
|
|
83
|
-
return "";
|
|
84
|
-
}
|
|
85
|
-
if (typeof file === "string") {
|
|
86
|
-
return file;
|
|
87
|
-
}
|
|
88
|
-
return file.preview || file.url || "";
|
|
89
|
-
}
|
|
90
|
-
function getFileUrl(file) {
|
|
91
|
-
if (!file) {
|
|
92
|
-
return "";
|
|
93
|
-
}
|
|
94
|
-
if (typeof file === "string") {
|
|
95
|
-
return file;
|
|
96
|
-
}
|
|
97
|
-
return file.url || file.preview || "";
|
|
98
|
-
}
|
|
99
|
-
const FALLBACK_ICON_MAP = {
|
|
100
|
-
pdf: "/file-placeholder/pdf-200-200.png",
|
|
101
|
-
mp4: "/file-placeholder/video-200-200.png",
|
|
102
|
-
mov: "/file-placeholder/video-200-200.png",
|
|
103
|
-
avi: "/file-placeholder/video-200-200.png",
|
|
104
|
-
wmv: "/file-placeholder/video-200-200.png",
|
|
105
|
-
flv: "/file-placeholder/video-200-200.png",
|
|
106
|
-
mkv: "/file-placeholder/video-200-200.png",
|
|
107
|
-
mp3: "/file-placeholder/audio-200-200.png",
|
|
108
|
-
wav: "/file-placeholder/audio-200-200.png",
|
|
109
|
-
aac: "/file-placeholder/audio-200-200.png",
|
|
110
|
-
ogg: "/file-placeholder/audio-200-200.png",
|
|
111
|
-
doc: "/file-placeholder/docx-200-200.png",
|
|
112
|
-
docx: "/file-placeholder/docx-200-200.png",
|
|
113
|
-
odt: "/file-placeholder/docx-200-200.png",
|
|
114
|
-
xls: "/file-placeholder/xlsx-200-200.png",
|
|
115
|
-
xlsx: "/file-placeholder/xlsx-200-200.png",
|
|
116
|
-
csv: "/file-placeholder/xlsx-200-200.png",
|
|
117
|
-
ppt: "/file-placeholder/pptx-200-200.png",
|
|
118
|
-
pptx: "/file-placeholder/pptx-200-200.png",
|
|
119
|
-
jpg: "/file-placeholder/jpeg-200-200.png",
|
|
120
|
-
jpeg: "/file-placeholder/jpeg-200-200.png",
|
|
121
|
-
png: "/file-placeholder/png-200-200.png",
|
|
122
|
-
gif: "/file-placeholder/gif-200-200.png",
|
|
123
|
-
webp: "/file-placeholder/png-200-200.png",
|
|
124
|
-
bmp: "/file-placeholder/png-200-200.png",
|
|
125
|
-
svg: "/file-placeholder/svg-200-200.png",
|
|
126
|
-
default: "/file-placeholder/unknown-200-200.png"
|
|
127
|
-
};
|
|
128
|
-
const ACTIVE_CONTENT_MIMETYPES = /* @__PURE__ */ new Set(["application/xhtml+xml", "image/svg+xml", "text/html"]);
|
|
129
|
-
const ACTIVE_CONTENT_EXTENSIONS = /* @__PURE__ */ new Set(["htm", "html", "svg", "svgz", "xhtml"]);
|
|
130
|
-
const stripQueryAndHash = (url) => url.split("?")[0].split("#")[0];
|
|
131
|
-
const getExtFromName = (value) => {
|
|
132
|
-
if (!value) {
|
|
133
|
-
return "";
|
|
134
|
-
}
|
|
135
|
-
const clean = stripQueryAndHash(value);
|
|
136
|
-
const index = clean.lastIndexOf(".");
|
|
137
|
-
return index !== -1 ? clean.slice(index + 1).toLowerCase() : "";
|
|
138
|
-
};
|
|
139
|
-
const EXT_MIMETYPE_MAP = {
|
|
140
|
-
aac: "audio/aac",
|
|
141
|
-
avi: "video/x-msvideo",
|
|
142
|
-
bmp: "image/bmp",
|
|
143
|
-
csv: "text/csv",
|
|
144
|
-
doc: "application/msword",
|
|
145
|
-
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
146
|
-
flv: "video/x-flv",
|
|
147
|
-
gif: "image/gif",
|
|
148
|
-
jpeg: "image/jpeg",
|
|
149
|
-
jpg: "image/jpeg",
|
|
150
|
-
json: "application/json",
|
|
151
|
-
mkv: "video/x-matroska",
|
|
152
|
-
mov: "video/quicktime",
|
|
153
|
-
mp3: "audio/mpeg",
|
|
154
|
-
mp4: "video/mp4",
|
|
155
|
-
odt: "application/vnd.oasis.opendocument.text",
|
|
156
|
-
ogg: "audio/ogg",
|
|
157
|
-
pdf: "application/pdf",
|
|
158
|
-
png: "image/png",
|
|
159
|
-
ppt: "application/vnd.ms-powerpoint",
|
|
160
|
-
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
161
|
-
svg: "image/svg+xml",
|
|
162
|
-
txt: "text/plain",
|
|
163
|
-
wav: "audio/wav",
|
|
164
|
-
webp: "image/webp",
|
|
165
|
-
wmv: "video/x-ms-wmv",
|
|
166
|
-
xls: "application/vnd.ms-excel",
|
|
167
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
168
|
-
};
|
|
169
|
-
function matchMimetype(file, type) {
|
|
170
|
-
if (!file) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
if (file.originFileObj) {
|
|
174
|
-
return (0, import_mime_match.default)(file.type, type);
|
|
175
|
-
}
|
|
176
|
-
if (file.mimetype) {
|
|
177
|
-
return (0, import_mime_match.default)(file.mimetype, type);
|
|
178
|
-
}
|
|
179
|
-
if (file.url) {
|
|
180
|
-
return (0, import_mime_match.default)(EXT_MIMETYPE_MAP[getExtFromName(file.url)] || "", type);
|
|
181
|
-
}
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
const getNameFromUrl = (url) => {
|
|
185
|
-
if (!url) {
|
|
186
|
-
return "";
|
|
187
|
-
}
|
|
188
|
-
const clean = stripQueryAndHash(url);
|
|
189
|
-
const index = clean.lastIndexOf("/");
|
|
190
|
-
return index !== -1 ? clean.slice(index + 1) : clean;
|
|
191
|
-
};
|
|
192
|
-
const getFileExt = (file, url) => {
|
|
193
|
-
if (file && typeof file === "object") {
|
|
194
|
-
if (file.extname) {
|
|
195
|
-
return String(file.extname).replace(/^\./, "").toLowerCase();
|
|
196
|
-
}
|
|
197
|
-
const nameExt = getExtFromName(file.name || file.filename || file.title);
|
|
198
|
-
if (nameExt) {
|
|
199
|
-
return nameExt;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return getExtFromName(url);
|
|
203
|
-
};
|
|
204
|
-
const isActiveContentFile = (file, url) => {
|
|
205
|
-
const mimetype = (file == null ? void 0 : file.mimetype) || (file == null ? void 0 : file.type);
|
|
206
|
-
if (typeof mimetype === "string" && ACTIVE_CONTENT_MIMETYPES.has(mimetype.toLowerCase())) {
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
const ext = getFileExt(file, url);
|
|
210
|
-
return ACTIVE_CONTENT_EXTENSIONS.has(ext);
|
|
211
|
-
};
|
|
212
|
-
const getFileName = (file, url) => {
|
|
213
|
-
const nameFromUrl = getNameFromUrl(url);
|
|
214
|
-
if (!file || typeof file === "string") {
|
|
215
|
-
return nameFromUrl;
|
|
216
|
-
}
|
|
217
|
-
return file.name || file.filename || file.title || nameFromUrl;
|
|
218
|
-
};
|
|
219
|
-
const getDownloadFileName = (file, url) => {
|
|
220
|
-
const resolvedUrl = url || getFileUrl(file);
|
|
221
|
-
let filename = getFileName(file, resolvedUrl);
|
|
222
|
-
const ext = getFileExt(file, resolvedUrl);
|
|
223
|
-
if (filename && ext && !filename.toLowerCase().endsWith(`.${ext}`)) {
|
|
224
|
-
filename = `${filename}.${ext}`;
|
|
225
|
-
}
|
|
226
|
-
return `${Date.now()}_${filename || "file"}`;
|
|
227
|
-
};
|
|
228
|
-
const getFallbackIcon = (file, url) => {
|
|
229
|
-
const ext = getFileExt(file, url);
|
|
230
|
-
return FALLBACK_ICON_MAP[ext] || FALLBACK_ICON_MAP.default;
|
|
231
|
-
};
|
|
232
|
-
const getPreviewThumbnailUrl = (file) => {
|
|
233
|
-
const previewFile = normalizePreviewFile(file);
|
|
234
|
-
const src = getPreviewFileUrl(previewFile);
|
|
235
|
-
if (isActiveContentFile(previewFile, src)) {
|
|
236
|
-
return getFallbackIcon(previewFile, src);
|
|
237
|
-
}
|
|
238
|
-
const { getThumbnailURL } = filePreviewTypes.getTypeByFile(previewFile) ?? {};
|
|
239
|
-
const thumbnail = getThumbnailURL == null ? void 0 : getThumbnailURL(previewFile);
|
|
240
|
-
if (thumbnail) {
|
|
241
|
-
return thumbnail;
|
|
242
|
-
}
|
|
243
|
-
if (matchMimetype(previewFile, "image/*")) {
|
|
244
|
-
return "";
|
|
245
|
-
}
|
|
246
|
-
return getFallbackIcon(previewFile, src);
|
|
247
|
-
};
|
|
248
|
-
const renderModalFooter = (props) => {
|
|
249
|
-
const { index, list, onSwitchIndex, onDownload, file } = props;
|
|
250
|
-
const canPrev = typeof index === "number" && !!onSwitchIndex && index > 0;
|
|
251
|
-
const canNext = typeof index === "number" && !!onSwitchIndex && index < list.length - 1;
|
|
252
|
-
return /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { size: 14, style: { fontSize: "20px" } }, /* @__PURE__ */ import_react.default.createElement(
|
|
253
|
-
import_icons.LeftOutlined,
|
|
254
|
-
{
|
|
255
|
-
style: { cursor: canPrev ? "pointer" : "not-allowed" },
|
|
256
|
-
disabled: !canPrev,
|
|
257
|
-
onClick: () => canPrev && (onSwitchIndex == null ? void 0 : onSwitchIndex(index - 1))
|
|
258
|
-
}
|
|
259
|
-
), /* @__PURE__ */ import_react.default.createElement(
|
|
260
|
-
import_icons.RightOutlined,
|
|
261
|
-
{
|
|
262
|
-
style: { cursor: canNext ? "pointer" : "not-allowed" },
|
|
263
|
-
disabled: !canNext,
|
|
264
|
-
onClick: () => canNext && (onSwitchIndex == null ? void 0 : onSwitchIndex(index + 1))
|
|
265
|
-
}
|
|
266
|
-
), /* @__PURE__ */ import_react.default.createElement(import_icons.DownloadOutlined, { onClick: () => onDownload(file) }));
|
|
267
|
-
};
|
|
268
|
-
const wrapWithModalPreviewer = (Previewer) => {
|
|
269
|
-
return function WrappedPreviewer(props) {
|
|
270
|
-
const { open, onOpenChange, onClose, file } = props;
|
|
271
|
-
if (typeof open !== "boolean") {
|
|
272
|
-
return /* @__PURE__ */ import_react.default.createElement(Previewer, { ...props });
|
|
273
|
-
}
|
|
274
|
-
const title = getFileName(file, getFileUrl(file));
|
|
275
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
276
|
-
import_antd.Modal,
|
|
277
|
-
{
|
|
278
|
-
open,
|
|
279
|
-
title,
|
|
280
|
-
onCancel: () => {
|
|
281
|
-
onOpenChange == null ? void 0 : onOpenChange(false);
|
|
282
|
-
onClose == null ? void 0 : onClose();
|
|
283
|
-
},
|
|
284
|
-
footer: renderModalFooter(props),
|
|
285
|
-
width: "90vw",
|
|
286
|
-
centered: true
|
|
287
|
-
},
|
|
288
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
289
|
-
"div",
|
|
290
|
-
{
|
|
291
|
-
style: {
|
|
292
|
-
maxWidth: "100%",
|
|
293
|
-
maxHeight: "calc(100vh - 256px)",
|
|
294
|
-
height: "80vh",
|
|
295
|
-
width: "100%",
|
|
296
|
-
background: "white",
|
|
297
|
-
display: "flex",
|
|
298
|
-
flexDirection: "column",
|
|
299
|
-
justifyContent: "center",
|
|
300
|
-
alignItems: "center",
|
|
301
|
-
overflowY: "auto"
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
/* @__PURE__ */ import_react.default.createElement(Previewer, { ...props })
|
|
305
|
-
)
|
|
306
|
-
);
|
|
307
|
-
};
|
|
308
|
-
};
|
|
309
|
-
const ImagePreviewer = (props) => {
|
|
310
|
-
const { file, list, index, open, onOpenChange, onSwitchIndex, onClose, onDownload } = props;
|
|
311
|
-
if (typeof open !== "boolean") {
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
const src = getFileUrl(file);
|
|
315
|
-
if (!src) {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
const canPrev = typeof index === "number" && index > 0;
|
|
319
|
-
const canNext = typeof index === "number" && index < list.length - 1;
|
|
320
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
321
|
-
import_antd.Image,
|
|
322
|
-
{
|
|
323
|
-
wrapperStyle: { display: "none" },
|
|
324
|
-
preview: {
|
|
325
|
-
visible: open,
|
|
326
|
-
onVisibleChange: (visible) => onOpenChange == null ? void 0 : onOpenChange(visible),
|
|
327
|
-
afterOpenChange: (visible) => {
|
|
328
|
-
if (!visible) {
|
|
329
|
-
onClose == null ? void 0 : onClose();
|
|
330
|
-
}
|
|
331
|
-
},
|
|
332
|
-
toolbarRender: (_, {
|
|
333
|
-
transform: { scale },
|
|
334
|
-
actions: { onFlipY, onFlipX, onRotateLeft, onRotateRight, onZoomOut, onZoomIn, onReset }
|
|
335
|
-
}) => /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { size: 14, className: "toolbar-wrapper", style: { fontSize: "20px" } }, /* @__PURE__ */ import_react.default.createElement(
|
|
336
|
-
import_icons.LeftOutlined,
|
|
337
|
-
{
|
|
338
|
-
style: { cursor: canPrev ? "pointer" : "not-allowed" },
|
|
339
|
-
disabled: !canPrev,
|
|
340
|
-
onClick: () => canPrev && (onSwitchIndex == null ? void 0 : onSwitchIndex(index - 1))
|
|
341
|
-
}
|
|
342
|
-
), /* @__PURE__ */ import_react.default.createElement(
|
|
343
|
-
import_icons.RightOutlined,
|
|
344
|
-
{
|
|
345
|
-
style: { cursor: canNext ? "pointer" : "not-allowed" },
|
|
346
|
-
disabled: !canNext,
|
|
347
|
-
onClick: () => canNext && (onSwitchIndex == null ? void 0 : onSwitchIndex(index + 1))
|
|
348
|
-
}
|
|
349
|
-
), onDownload ? /* @__PURE__ */ import_react.default.createElement(import_icons.DownloadOutlined, { onClick: () => onDownload(file) }) : null, /* @__PURE__ */ import_react.default.createElement(import_icons.SwapOutlined, { rotate: 90, onClick: onFlipY }), /* @__PURE__ */ import_react.default.createElement(import_icons.SwapOutlined, { onClick: onFlipX }), /* @__PURE__ */ import_react.default.createElement(import_icons.RotateLeftOutlined, { onClick: onRotateLeft }), /* @__PURE__ */ import_react.default.createElement(import_icons.RotateRightOutlined, { onClick: onRotateRight }), /* @__PURE__ */ import_react.default.createElement(import_icons.ZoomOutOutlined, { disabled: scale === 1, onClick: onZoomOut }), /* @__PURE__ */ import_react.default.createElement(import_icons.ZoomInOutlined, { disabled: scale === 50, onClick: onZoomIn }), /* @__PURE__ */ import_react.default.createElement(import_icons.UndoOutlined, { onClick: onReset }))
|
|
350
|
-
},
|
|
351
|
-
src
|
|
352
|
-
}
|
|
353
|
-
);
|
|
354
|
-
};
|
|
355
|
-
const IframePreviewer = ({ file }) => {
|
|
356
|
-
const src = getFileUrl(file);
|
|
357
|
-
if (!src) {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
return /* @__PURE__ */ import_react.default.createElement("iframe", { src, width: "100%", height: "100%", style: { border: "none" } });
|
|
361
|
-
};
|
|
362
|
-
const AudioPreviewer = ({ file }) => {
|
|
363
|
-
const { t } = (0, import_react_i18next.useTranslation)();
|
|
364
|
-
const src = getFileUrl(file);
|
|
365
|
-
if (!src) {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
return /* @__PURE__ */ import_react.default.createElement("audio", { controls: true }, /* @__PURE__ */ import_react.default.createElement("source", { src, type: (file == null ? void 0 : file.type) || (file == null ? void 0 : file.mimetype) }), t("Your browser does not support the audio tag."));
|
|
369
|
-
};
|
|
370
|
-
const VideoPreviewer = ({ file }) => {
|
|
371
|
-
const { t } = (0, import_react_i18next.useTranslation)();
|
|
372
|
-
const src = getFileUrl(file);
|
|
373
|
-
if (!src) {
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
return /* @__PURE__ */ import_react.default.createElement("video", { controls: true, width: "100%", height: "100%" }, /* @__PURE__ */ import_react.default.createElement("source", { src, type: (file == null ? void 0 : file.type) || (file == null ? void 0 : file.mimetype) }), t("Your browser does not support the video tag."));
|
|
377
|
-
};
|
|
378
|
-
const UnsupportedPreviewer = (props) => {
|
|
379
|
-
const { t } = (0, import_react_i18next.useTranslation)();
|
|
380
|
-
const { file } = props;
|
|
381
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
382
|
-
import_antd.Alert,
|
|
383
|
-
{
|
|
384
|
-
type: "warning",
|
|
385
|
-
description: /* @__PURE__ */ import_react.default.createElement(import_react_i18next.Trans, { ns: import_locale.NAMESPACE }, "File type is not supported for previewing, please ", props.onDownload ? /* @__PURE__ */ import_react.default.createElement("a", { onClick: () => {
|
|
386
|
-
var _a;
|
|
387
|
-
return (_a = props.onDownload) == null ? void 0 : _a.call(props, file);
|
|
388
|
-
}, style: { textDecoration: "underline", cursor: "pointer" } }, "download it to preview") : /* @__PURE__ */ import_react.default.createElement("span", null, "download it to preview")),
|
|
389
|
-
showIcon: true
|
|
390
|
-
}
|
|
391
|
-
);
|
|
392
|
-
};
|
|
393
|
-
filePreviewTypes.add({
|
|
394
|
-
match() {
|
|
395
|
-
return true;
|
|
396
|
-
},
|
|
397
|
-
Previewer: wrapWithModalPreviewer(UnsupportedPreviewer)
|
|
398
|
-
});
|
|
399
|
-
filePreviewTypes.add({
|
|
400
|
-
match(file) {
|
|
401
|
-
return matchMimetype(file, "image/*");
|
|
402
|
-
},
|
|
403
|
-
getThumbnailURL(file) {
|
|
404
|
-
return getPreviewFileUrl(file);
|
|
405
|
-
},
|
|
406
|
-
Previewer: ImagePreviewer
|
|
407
|
-
});
|
|
408
|
-
filePreviewTypes.add({
|
|
409
|
-
match(file) {
|
|
410
|
-
return ["text/plain", "application/pdf", "application/json"].some((type) => matchMimetype(file, type));
|
|
411
|
-
},
|
|
412
|
-
Previewer: wrapWithModalPreviewer(IframePreviewer)
|
|
413
|
-
});
|
|
414
|
-
filePreviewTypes.add({
|
|
415
|
-
match(file) {
|
|
416
|
-
return matchMimetype(file, "audio/*");
|
|
417
|
-
},
|
|
418
|
-
Previewer: wrapWithModalPreviewer(AudioPreviewer)
|
|
419
|
-
});
|
|
420
|
-
filePreviewTypes.add({
|
|
421
|
-
match(file) {
|
|
422
|
-
return matchMimetype(file, "video/*");
|
|
423
|
-
},
|
|
424
|
-
Previewer: wrapWithModalPreviewer(VideoPreviewer)
|
|
425
|
-
});
|
|
426
|
-
filePreviewTypes.add({
|
|
427
|
-
match(file) {
|
|
428
|
-
return isActiveContentFile(file, getFileUrl(file));
|
|
429
|
-
},
|
|
430
|
-
Previewer: wrapWithModalPreviewer(UnsupportedPreviewer)
|
|
431
|
-
});
|
|
432
|
-
const FilePreviewRenderer = (props) => {
|
|
433
|
-
const normalized = normalizePreviewFile(props.file);
|
|
434
|
-
if (!normalized) {
|
|
435
|
-
return null;
|
|
436
|
-
}
|
|
437
|
-
const { Previewer } = filePreviewTypes.getTypeByFile(normalized) ?? {};
|
|
438
|
-
if (!Previewer) {
|
|
439
|
-
return null;
|
|
440
|
-
}
|
|
441
|
-
return /* @__PURE__ */ import_react.default.createElement(Previewer, { ...props, file: normalized });
|
|
442
|
-
};
|
|
443
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
444
|
-
0 && (module.exports = {
|
|
445
|
-
FilePreviewRenderer,
|
|
446
|
-
FilePreviewTypes,
|
|
447
|
-
filePreviewTypes,
|
|
448
|
-
getDownloadFileName,
|
|
449
|
-
getFallbackIcon,
|
|
450
|
-
getFileExt,
|
|
451
|
-
getFileName,
|
|
452
|
-
getFileUrl,
|
|
453
|
-
getPreviewFileUrl,
|
|
454
|
-
getPreviewThumbnailUrl,
|
|
455
|
-
isActiveContentFile,
|
|
456
|
-
matchMimetype,
|
|
457
|
-
normalizePreviewFile,
|
|
458
|
-
wrapWithModalPreviewer
|
|
459
|
-
});
|