dtable-ui-component 6.0.2 → 6.0.4
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/lib/ButtonFormatter/index.js +8 -2
- package/lib/CheckboxEditor/index.css +8 -20
- package/lib/CheckboxEditor/index.js +98 -35
- package/lib/CheckboxFormatter/index.css +5 -0
- package/lib/CheckboxFormatter/index.js +9 -15
- package/lib/CollaboratorEditor/index.css +12 -35
- package/lib/CollaboratorEditor/index.js +18 -212
- package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +27 -30
- package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
- package/lib/CollaboratorItem/index.css +7 -1
- package/lib/CollaboratorItem/index.js +6 -2
- package/lib/Comment/body/comment.js +190 -0
- package/lib/Comment/body/index.css +95 -0
- package/lib/Comment/body/index.js +32 -0
- package/lib/Comment/footer/btns/index.css +40 -0
- package/lib/Comment/footer/btns/index.js +113 -0
- package/lib/Comment/footer/index.css +157 -0
- package/lib/Comment/footer/index.js +169 -0
- package/lib/Comment/footer/input/index.css +52 -0
- package/lib/Comment/footer/input/index.js +448 -0
- package/lib/Comment/footer/input/participant/index.css +0 -0
- package/lib/Comment/footer/input/participant/index.js +53 -0
- package/lib/Comment/footer/participants/index.css +22 -0
- package/lib/Comment/footer/participants/index.js +68 -0
- package/lib/Comment/footer/participants/participant/index.css +5 -0
- package/lib/Comment/footer/participants/participant/index.js +32 -0
- package/lib/Comment/footer/participants/participant-select/index.css +104 -0
- package/lib/Comment/footer/participants/participant-select/index.js +182 -0
- package/lib/Comment/index.css +19 -0
- package/lib/Comment/index.js +304 -0
- package/lib/Comment/model.js +25 -0
- package/lib/Comment/utils/common.js +62 -0
- package/lib/Comment/utils/index.js +27 -0
- package/lib/Comment/utils/utilities.js +176 -0
- package/lib/DTableColorPicker/index.css +1 -1
- package/lib/DTableCustomizeSelect/index.js +2 -2
- package/lib/DTableFiltersPopover/utils/index.js +1 -7
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
- package/lib/DTableGroupSelect/index.js +3 -3
- package/lib/DTableSelect/index.js +3 -1
- package/lib/DateEditor/index.js +14 -51
- package/lib/DateEditor/pc-date-editor-popover.js +149 -12
- package/lib/{common/delete-tip.js → DeleteTip/index.js} +12 -16
- package/lib/Department-editor/department-single-select.js +1 -1
- package/lib/Department-editor/index.js +3 -4
- package/lib/DepartmentSingleSelectFormatter/index.js +3 -2
- package/lib/DigitalSignEditor/constants.js +7 -0
- package/lib/DigitalSignEditor/index.css +69 -0
- package/lib/DigitalSignEditor/index.js +182 -0
- package/lib/DigitalSignEditor/service.js +39 -0
- package/lib/DigitalSignEditor/signature-board/index.css +35 -0
- package/lib/DigitalSignEditor/signature-board/index.js +135 -0
- package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
- package/lib/DigitalSignEditor/utils.js +29 -0
- package/lib/DurationEditor/index.js +110 -0
- package/lib/EmailEditor/index.js +58 -0
- package/lib/FileEditor/addition-previewer/index.css +1 -0
- package/lib/FileEditor/addition-previewer/index.js +52 -0
- package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
- package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
- package/lib/FileEditor/constants.js +7 -0
- package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
- package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
- package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
- package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
- package/lib/FileEditor/files-previewer/index.css +56 -0
- package/lib/FileEditor/files-previewer/index.js +277 -0
- package/lib/FileEditor/index.css +6 -0
- package/lib/FileEditor/index.js +258 -11
- package/lib/FileEditor/utils.js +22 -0
- package/lib/FileItemFormatter/index.js +19 -20
- package/lib/FileUploader/index.css +9 -0
- package/lib/FileUploader/index.js +268 -14
- package/lib/FormulaFormatter/cell-value-validator.js +17 -17
- package/lib/FormulaFormatter/index.js +2 -1
- package/lib/FormulaFormatter/utils.js +0 -31
- package/lib/GeolocationEditor/country-editor.js +319 -0
- package/lib/GeolocationEditor/index.css +641 -0
- package/lib/GeolocationEditor/index.js +240 -0
- package/lib/GeolocationEditor/location-editor.js +368 -0
- package/lib/GeolocationEditor/map-editor/index.js +456 -0
- package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
- package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
- package/lib/GeolocationEditor/map-editor-utils.js +153 -0
- package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
- package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
- package/lib/GeolocationEditor/parse-geolocation.js +282 -0
- package/lib/GeolocationEditor/province-city-editor.js +292 -0
- package/lib/GeolocationEditor/province-editor.js +226 -0
- package/lib/GeolocationEditor/selector-header-item.js +28 -0
- package/lib/GeolocationEditor/selector-list.js +33 -0
- package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
- package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
- package/lib/ImageEditor/addition-previewer/index.css +106 -0
- package/lib/ImageEditor/addition-previewer/index.js +63 -0
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
- package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
- package/lib/ImageEditor/constants.js +7 -0
- package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
- package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
- package/lib/ImageEditor/images-previewer/index.css +18 -0
- package/lib/ImageEditor/images-previewer/index.js +140 -0
- package/lib/ImageEditor/index.css +24 -0
- package/lib/ImageEditor/index.js +194 -0
- package/lib/ImageFormatter/images-lazy-load.js +4 -2
- package/lib/ImageFormatter/index.js +8 -3
- package/lib/ImageThumbnail/index.css +20 -0
- package/lib/ImageThumbnail/index.js +137 -0
- package/lib/LinkEditor/index.js +2 -3
- package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
- package/lib/MultipleSelectEditor/index.js +16 -177
- package/lib/NumberEditor/index.js +63 -77
- package/lib/RoleStatusEditor/index.css +0 -2
- package/lib/RowExpandDialog/body/index.css +21 -0
- package/lib/RowExpandDialog/body/index.js +262 -0
- package/lib/RowExpandDialog/column-content/index.css +48 -0
- package/lib/RowExpandDialog/column-content/index.js +50 -0
- package/lib/RowExpandDialog/header/index.css +31 -0
- package/lib/RowExpandDialog/header/index.js +55 -0
- package/lib/RowExpandDialog/index.css +28 -0
- package/lib/RowExpandDialog/index.js +237 -0
- package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
- package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
- package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
- package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
- package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +104 -0
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
- package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
- package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
- package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
- package/lib/RowExpandEditor/RowExpandFileEditor/index.js +148 -0
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
- package/lib/RowExpandEditor/RowExpandImageEditor/index.css +11 -0
- package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
- package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +123 -0
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +247 -0
- package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
- package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
- package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +206 -0
- package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
- package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
- package/lib/RowExpandEditor/constants.js +44 -0
- package/lib/RowExpandEditor/index.css +0 -0
- package/lib/RowExpandEditor/index.js +32 -0
- package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
- package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
- package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
- package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +12 -13
- package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
- package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +5 -5
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +2 -2
- package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +20 -20
- package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
- package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
- package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
- package/lib/RowExpandFormatter/constants.js +61 -0
- package/lib/RowExpandFormatter/index.css +28 -3
- package/lib/RowExpandFormatter/index.js +113 -131
- package/lib/SimpleLongTextFormatter/widgets/longTextEditor.css +2 -2
- package/lib/SingleSelectEditor/index.js +16 -156
- package/lib/SvgIcon/index.css +11 -0
- package/lib/SvgIcon/index.js +29 -0
- package/lib/TextEditor/index.js +112 -42
- package/lib/UploadProgress/index.js +38 -0
- package/lib/UrlEditor/index.js +61 -0
- package/lib/common/editor-base.js +52 -0
- package/lib/constants/file.js +96 -0
- package/lib/constants/index.js +27 -15
- package/lib/constants/key-codes.js +109 -0
- package/lib/css/cell-editor.css +18 -2
- package/lib/formatterConfig/base-formatter-config.js +23 -23
- package/lib/formatterConfig/index.js +3 -3
- package/lib/hooks/index.js +16 -0
- package/lib/index.js +81 -46
- package/lib/lang/index.js +19 -16
- package/lib/locales/de.json +167 -0
- package/lib/locales/en.json +167 -0
- package/lib/locales/es.json +167 -0
- package/lib/locales/fr.json +167 -0
- package/lib/locales/pt.json +167 -0
- package/lib/locales/ru.json +167 -0
- package/lib/locales/zh-CN.json +167 -0
- package/lib/select-editor/index.js +6 -6
- package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
- package/lib/select-editor/pc-select-editor/index.css +85 -0
- package/lib/select-editor/pc-select-editor/index.js +295 -0
- package/lib/toaster/toast.js +19 -15
- package/lib/utils/cell-comparer.js +35 -0
- package/lib/utils/cell.js +55 -0
- package/lib/utils/column-utils.js +25 -0
- package/lib/utils/editor-utils.js +1 -6
- package/lib/utils/get-event-transfer.js +75 -0
- package/lib/utils/hotkey.js +37 -0
- package/lib/utils/object-utils.js +61 -0
- package/lib/utils/url.js +127 -8
- package/lib/utils/utils.js +119 -2
- package/package.json +4 -3
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
- package/lib/FileEditor/pc-files-addition/index.js +0 -1
- package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
- package/lib/FileEditor/pc-files-preview/index.js +0 -1
- package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
- package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
- package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
- package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
- package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
- package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
- package/lib/FileItemFormatter/utils.js +0 -99
- package/lib/MultipleSelectEditor/index.css +0 -9
- package/lib/RowExpandLinkFormatter/utils.js +0 -71
- package/lib/RowExpandUrlFormatter/index.css +0 -1
- package/lib/SingleSelectEditor/index.css +0 -14
- package/lib/common/modal-portal.js +0 -26
- package/lib/locals/de.js +0 -103
- package/lib/locals/en.js +0 -104
- package/lib/locals/es.js +0 -103
- package/lib/locals/fr.js +0 -103
- package/lib/locals/pt.js +0 -103
- package/lib/locals/ru.js +0 -103
- package/lib/locals/zh-CN.js +0 -104
- package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
- package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
- /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
- /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
- /package/lib/{common/delete-tip.css → DeleteTip/index.css} +0 -0
- /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
- /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
- /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
package/lib/utils/url.js
CHANGED
|
@@ -3,15 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.needUseThumbnailImage = exports.isTargetUrl = exports.isInternalImg = exports.isDigitalSignsUrl = exports.isCustomAssetUrl = exports.getImageThumbnailUrl = exports.generateCurrentBaseImageUrl = exports.generateCurrentBaseImageThumbnailUrl = exports.checkSVGImage = void 0;
|
|
6
|
+
exports.needUseThumbnailImage = exports.isTargetUrl = exports.isInternalURL = exports.isInternalImg = exports.isDigitalSignsUrl = exports.isCustomAssetUrl = exports.isBase64 = exports.isAIUrl = exports.imageCheck = exports.getValidFileImageUrls = exports.getImageThumbnailUrl = exports.getFileThumbnailInfo = exports.getFileName = exports.getFileIconUrl = exports.generateCurrentBaseImageUrl = exports.generateCurrentBaseImageThumbnailUrl = exports.checkSVGImage = exports.checkImgExists = void 0;
|
|
7
|
+
var _file = require("../constants/file");
|
|
7
8
|
const isTargetUrl = (target, url) => {
|
|
8
9
|
if (!url || typeof url !== 'string') return false;
|
|
9
10
|
return target && url ? url.indexOf(target) > -1 : false;
|
|
10
11
|
};
|
|
11
12
|
exports.isTargetUrl = isTargetUrl;
|
|
13
|
+
const isBase64 = url => {
|
|
14
|
+
if (!url || typeof url !== 'string') return false;
|
|
15
|
+
const target = 'data:image/png;base64';
|
|
16
|
+
return url ? url.startsWith(target) : false;
|
|
17
|
+
};
|
|
18
|
+
exports.isBase64 = isBase64;
|
|
12
19
|
const isInternalImg = (url, server) => {
|
|
20
|
+
var _window;
|
|
13
21
|
if (!url || typeof url !== 'string') return false;
|
|
14
|
-
const currentServer = server || window.dtable && window.dtable.server;
|
|
22
|
+
const currentServer = server || ((_window = window) === null || _window === void 0 ? void 0 : _window.dtable) && window.dtable.server;
|
|
15
23
|
return url.indexOf(currentServer) > -1;
|
|
16
24
|
};
|
|
17
25
|
exports.isInternalImg = isInternalImg;
|
|
@@ -19,14 +27,33 @@ const isCustomAssetUrl = url => {
|
|
|
19
27
|
return isTargetUrl('custom-asset://', url);
|
|
20
28
|
};
|
|
21
29
|
exports.isCustomAssetUrl = isCustomAssetUrl;
|
|
30
|
+
const checkImgExists = url => {
|
|
31
|
+
return new Promise(function (resolve, reject) {
|
|
32
|
+
let image = new Image();
|
|
33
|
+
image.src = url;
|
|
34
|
+
image.onload = function (res) {
|
|
35
|
+
resolve(res);
|
|
36
|
+
};
|
|
37
|
+
image.onerror = function (err) {
|
|
38
|
+
reject(err);
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.checkImgExists = checkImgExists;
|
|
22
43
|
const checkSVGImage = url => {
|
|
23
44
|
if (!url || typeof url !== 'string') return false;
|
|
24
45
|
const isSVGImage = url.substring(url.lastIndexOf('.')).toLowerCase() === '.svg';
|
|
25
46
|
return isSVGImage;
|
|
26
47
|
};
|
|
27
48
|
exports.checkSVGImage = checkSVGImage;
|
|
49
|
+
const isAIUrl = url => {
|
|
50
|
+
if (!url || typeof url !== 'string') return false;
|
|
51
|
+
return isTargetUrl('/ai/asset/', url) && url.includes('http');
|
|
52
|
+
};
|
|
53
|
+
exports.isAIUrl = isAIUrl;
|
|
28
54
|
const isDigitalSignsUrl = url => {
|
|
29
55
|
if (!url || typeof url !== 'string') return false;
|
|
56
|
+
if (isAIUrl(url)) return true;
|
|
30
57
|
return isTargetUrl('/digital-signs/', url) && !url.includes('http');
|
|
31
58
|
};
|
|
32
59
|
exports.isDigitalSignsUrl = isDigitalSignsUrl;
|
|
@@ -40,6 +67,7 @@ const needUseThumbnailImage = url => {
|
|
|
40
67
|
};
|
|
41
68
|
exports.needUseThumbnailImage = needUseThumbnailImage;
|
|
42
69
|
const generateCurrentBaseImageThumbnailUrl = _ref => {
|
|
70
|
+
var _window2;
|
|
43
71
|
let {
|
|
44
72
|
server,
|
|
45
73
|
workspaceID,
|
|
@@ -47,11 +75,15 @@ const generateCurrentBaseImageThumbnailUrl = _ref => {
|
|
|
47
75
|
partUrl,
|
|
48
76
|
size
|
|
49
77
|
} = _ref;
|
|
78
|
+
const validServer = server || ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.dtable) && window.dtable.server || '';
|
|
50
79
|
if (!partUrl || typeof partUrl !== 'string') return '';
|
|
51
|
-
|
|
80
|
+
let url = "".concat(validServer, "/thumbnail/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl);
|
|
81
|
+
if (url.indexOf('?') > -1) return "".concat(url, "&size=").concat(size);
|
|
82
|
+
return "".concat(url, "?size=").concat(size);
|
|
52
83
|
};
|
|
53
84
|
exports.generateCurrentBaseImageThumbnailUrl = generateCurrentBaseImageThumbnailUrl;
|
|
54
85
|
const generateCurrentBaseImageUrl = _ref2 => {
|
|
86
|
+
var _window3;
|
|
55
87
|
let {
|
|
56
88
|
server,
|
|
57
89
|
workspaceID,
|
|
@@ -59,7 +91,9 @@ const generateCurrentBaseImageUrl = _ref2 => {
|
|
|
59
91
|
partUrl
|
|
60
92
|
} = _ref2;
|
|
61
93
|
if (!partUrl || typeof partUrl !== 'string') return '';
|
|
62
|
-
|
|
94
|
+
if (partUrl.startsWith('http')) return partUrl;
|
|
95
|
+
const validServer = server || ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.dtable) && window.dtable.server || '';
|
|
96
|
+
return "".concat(validServer, "/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(partUrl);
|
|
63
97
|
};
|
|
64
98
|
exports.generateCurrentBaseImageUrl = generateCurrentBaseImageUrl;
|
|
65
99
|
const getImageThumbnailUrl = function (url) {
|
|
@@ -70,6 +104,7 @@ const getImageThumbnailUrl = function (url) {
|
|
|
70
104
|
size = 256
|
|
71
105
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
72
106
|
if (!url || typeof url !== 'string') return '';
|
|
107
|
+
if (isAIUrl(url) || checkSVGImage(url) || !isInternalImg(url) || isBase64(url)) return url;
|
|
73
108
|
if (server && dtableUuid && isCustomAssetUrl(url)) {
|
|
74
109
|
const assetUuid = url.slice(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
|
|
75
110
|
return server + '/dtable/' + dtableUuid + '/custom-asset-thumbnail/' + assetUuid + '?size=' + size;
|
|
@@ -83,9 +118,93 @@ const getImageThumbnailUrl = function (url) {
|
|
|
83
118
|
partUrl: url
|
|
84
119
|
});
|
|
85
120
|
}
|
|
86
|
-
if (
|
|
87
|
-
return url;
|
|
88
|
-
}
|
|
121
|
+
if (url.includes('/thumbnail/workspace')) return url;
|
|
89
122
|
return url.replace('/workspace', '/thumbnail/workspace') + '?size=' + size;
|
|
90
123
|
};
|
|
91
|
-
exports.getImageThumbnailUrl = getImageThumbnailUrl;
|
|
124
|
+
exports.getImageThumbnailUrl = getImageThumbnailUrl;
|
|
125
|
+
const getFileName = url => {
|
|
126
|
+
if (!url) return null;
|
|
127
|
+
let validUrl = url;
|
|
128
|
+
let qIndex = url.indexOf('/?');
|
|
129
|
+
if (qIndex !== -1) {
|
|
130
|
+
validUrl = validUrl.slice(0, qIndex);
|
|
131
|
+
}
|
|
132
|
+
const lastIndex = validUrl.lastIndexOf('/');
|
|
133
|
+
const name = url.slice(lastIndex + 1, qIndex);
|
|
134
|
+
return decodeURI(name);
|
|
135
|
+
};
|
|
136
|
+
exports.getFileName = getFileName;
|
|
137
|
+
const imageCheck = filename => {
|
|
138
|
+
// no file ext
|
|
139
|
+
if (!filename || typeof filename !== 'string') return false;
|
|
140
|
+
if (filename.lastIndexOf('.') === -1) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
const file_ext = filename.substr(filename.lastIndexOf('.') + 1).toLowerCase();
|
|
144
|
+
const image_exts = ['gif', 'jpeg', 'jpg', 'png', 'ico', 'bmp', 'tif', 'tiff', 'webp'];
|
|
145
|
+
return image_exts.includes(file_ext);
|
|
146
|
+
};
|
|
147
|
+
exports.imageCheck = imageCheck;
|
|
148
|
+
const isInternalURL = function (url) {
|
|
149
|
+
let {
|
|
150
|
+
server = ''
|
|
151
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
152
|
+
if (!url || typeof url !== 'string') return false;
|
|
153
|
+
return server && url.indexOf(server) > -1;
|
|
154
|
+
};
|
|
155
|
+
exports.isInternalURL = isInternalURL;
|
|
156
|
+
const getValidFileImageUrls = files => {
|
|
157
|
+
if (!Array.isArray(files)) return [];
|
|
158
|
+
return files.map(file => {
|
|
159
|
+
if (typeof file !== 'object') return null;
|
|
160
|
+
const {
|
|
161
|
+
url,
|
|
162
|
+
name
|
|
163
|
+
} = file;
|
|
164
|
+
if (!url || url.indexOf('/asset') < 0) return null;
|
|
165
|
+
return imageCheck(name) ? url : null;
|
|
166
|
+
}).filter(Boolean);
|
|
167
|
+
};
|
|
168
|
+
exports.getValidFileImageUrls = getValidFileImageUrls;
|
|
169
|
+
const getFileIconUrl = (filename, direntType) => {
|
|
170
|
+
const defaultIcon = _file.FILEEXT_ICON_MAP['default'];
|
|
171
|
+
const defaultIconUrl = _file.FILEEXT_ICON_URL_MAP[defaultIcon];
|
|
172
|
+
if (typeof direntType === 'string' && direntType === 'dir') {
|
|
173
|
+
const folder = _file.FILEEXT_ICON_MAP['folder'];
|
|
174
|
+
return _file.FILEEXT_ICON_URL_MAP[folder]['192'];
|
|
175
|
+
}
|
|
176
|
+
const identifierIndex = typeof filename === 'string' && filename.lastIndexOf('.');
|
|
177
|
+
if (identifierIndex === -1) return defaultIconUrl['192'];
|
|
178
|
+
const fileExt = typeof filename === 'string' && filename.slice(identifierIndex + 1).toLowerCase() || 'default';
|
|
179
|
+
const fileIcon = _file.FILEEXT_ICON_MAP[fileExt];
|
|
180
|
+
if (fileIcon) {
|
|
181
|
+
const iconUrl = _file.FILEEXT_ICON_URL_MAP[fileIcon];
|
|
182
|
+
return iconUrl['192'];
|
|
183
|
+
}
|
|
184
|
+
return defaultIconUrl['192'];
|
|
185
|
+
};
|
|
186
|
+
exports.getFileIconUrl = getFileIconUrl;
|
|
187
|
+
const getFileThumbnailInfo = function (file) {
|
|
188
|
+
let {
|
|
189
|
+
server
|
|
190
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
191
|
+
const defaultIcon = _file.FILEEXT_ICON_MAP['default'];
|
|
192
|
+
const defaultIconUrl = _file.FILEEXT_ICON_URL_MAP[defaultIcon];
|
|
193
|
+
if (!file || !file.name) return {
|
|
194
|
+
isImage: false,
|
|
195
|
+
fileIconUrl: defaultIconUrl['192']
|
|
196
|
+
};
|
|
197
|
+
const isImage = imageCheck(file.name);
|
|
198
|
+
if (isImage && server) return {
|
|
199
|
+
isImage,
|
|
200
|
+
fileIconUrl: getImageThumbnailUrl(file.url, {
|
|
201
|
+
server
|
|
202
|
+
})
|
|
203
|
+
};
|
|
204
|
+
const iconUrl = getFileIconUrl(file.name, file.type);
|
|
205
|
+
return {
|
|
206
|
+
fileIconUrl: iconUrl,
|
|
207
|
+
isImage: false
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
exports.getFileThumbnailInfo = getFileThumbnailInfo;
|
package/lib/utils/utils.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getTrimmedString = exports.getFormulaArrayValue = exports.getEventClassName = exports.getErrorMsg = exports.downloadFiles = exports.downloadFile = exports.debounce = void 0;
|
|
7
|
+
exports.isArrayFormatColumn = isArrayFormatColumn;
|
|
8
|
+
exports.throttle = exports.openUrlLink = exports.isValidUrl = exports.isValidCellValue = exports.isMobile = exports.isMac = exports.isFunction = void 0;
|
|
9
|
+
var _constants = require("../constants");
|
|
10
|
+
var _url = require("./url");
|
|
7
11
|
const debounce = (fn, wait) => {
|
|
8
12
|
let timeout = null;
|
|
9
13
|
return function () {
|
|
@@ -30,6 +34,7 @@ const throttle = (func, delay) => {
|
|
|
30
34
|
};
|
|
31
35
|
};
|
|
32
36
|
exports.throttle = throttle;
|
|
37
|
+
const isMobile = exports.isMobile = typeof window !== 'undefined' && (window.innerWidth < 768 || navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null);
|
|
33
38
|
const isMac = () => {
|
|
34
39
|
const platform = navigator.platform;
|
|
35
40
|
// eslint-disable-next-line eqeqeq
|
|
@@ -48,9 +53,121 @@ const downloadFile = downloadUrl => {
|
|
|
48
53
|
document.body.appendChild(iframe);
|
|
49
54
|
};
|
|
50
55
|
exports.downloadFile = downloadFile;
|
|
56
|
+
const downloadFiles = (downloadUrlList, config) => {
|
|
57
|
+
const downloadFrame = document.getElementById('dtableUiComponentDownloadFrame');
|
|
58
|
+
if (downloadFrame != null) {
|
|
59
|
+
document.body.removeChild(downloadFrame);
|
|
60
|
+
}
|
|
61
|
+
downloadUrlList.forEach((url, index) => {
|
|
62
|
+
if (!(0, _url.isInternalURL)(url, config) && (0, _url.imageCheck)(url.replace('?dl=1', ''))) {
|
|
63
|
+
window.open(url);
|
|
64
|
+
} else {
|
|
65
|
+
const path = url;
|
|
66
|
+
let timer1 = setTimeout(function (path) {
|
|
67
|
+
return function () {
|
|
68
|
+
let iframe = document.createElement('iframe');
|
|
69
|
+
iframe.setAttribute('id', 'dtableUiComponentDownloadFrame');
|
|
70
|
+
iframe.style.display = 'none';
|
|
71
|
+
iframe.src = path;
|
|
72
|
+
document.body.appendChild(iframe);
|
|
73
|
+
let timer2 = setTimeout(function () {
|
|
74
|
+
iframe.remove();
|
|
75
|
+
clearTimeout(timer2);
|
|
76
|
+
}, 5000);
|
|
77
|
+
clearTimeout(timer1);
|
|
78
|
+
};
|
|
79
|
+
}(path), 1000 * index);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
exports.downloadFiles = downloadFiles;
|
|
51
84
|
const getEventClassName = e => {
|
|
52
85
|
// svg mouseEvent event.target.className is an object
|
|
53
86
|
if (!e || !e.target) return '';
|
|
54
87
|
return e.target.getAttribute('class') || '';
|
|
55
88
|
};
|
|
56
|
-
exports.getEventClassName = getEventClassName;
|
|
89
|
+
exports.getEventClassName = getEventClassName;
|
|
90
|
+
const getTrimmedString = value => {
|
|
91
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
92
|
+
};
|
|
93
|
+
exports.getTrimmedString = getTrimmedString;
|
|
94
|
+
const isFunction = functionToCheck => {
|
|
95
|
+
const getType = {};
|
|
96
|
+
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
97
|
+
};
|
|
98
|
+
exports.isFunction = isFunction;
|
|
99
|
+
const isValidCellValue = value => {
|
|
100
|
+
if (value === undefined) return false;
|
|
101
|
+
if (value === null) return false;
|
|
102
|
+
if (value === '') return false;
|
|
103
|
+
if (JSON.stringify(value) === '{}') return false;
|
|
104
|
+
if (JSON.stringify(value) === '[]') return false;
|
|
105
|
+
return true;
|
|
106
|
+
};
|
|
107
|
+
exports.isValidCellValue = isValidCellValue;
|
|
108
|
+
const isValidUrl = url => {
|
|
109
|
+
const reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
|
|
110
|
+
return reg.test(url);
|
|
111
|
+
};
|
|
112
|
+
exports.isValidUrl = isValidUrl;
|
|
113
|
+
const openUrlLink = url => {
|
|
114
|
+
let a = document.createElement('a');
|
|
115
|
+
document.body.appendChild(a);
|
|
116
|
+
a.href = url;
|
|
117
|
+
a.target = '_blank';
|
|
118
|
+
a.rel = 'noopener noreferrer';
|
|
119
|
+
a.click();
|
|
120
|
+
document.body.removeChild(a);
|
|
121
|
+
};
|
|
122
|
+
exports.openUrlLink = openUrlLink;
|
|
123
|
+
const getErrorMsg = error => {
|
|
124
|
+
let errorMsg = '';
|
|
125
|
+
if (error.response) {
|
|
126
|
+
if (error.response.status === 403) {
|
|
127
|
+
errorMsg = 'Permission_denied';
|
|
128
|
+
} else if (error.response.data && error.response.data['error_msg']) {
|
|
129
|
+
errorMsg = error.response.data['error_msg'];
|
|
130
|
+
} else if (error.response.data && error.response.data['error_message']) {
|
|
131
|
+
errorMsg = error.response.data['error_message'];
|
|
132
|
+
} else {
|
|
133
|
+
errorMsg = 'Error';
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
if (typeof error === 'object' && error.name) {
|
|
137
|
+
errorMsg = error.name;
|
|
138
|
+
} else {
|
|
139
|
+
errorMsg = 'Please_check_the_network';
|
|
140
|
+
}
|
|
141
|
+
// eslint-disable-next-line
|
|
142
|
+
console.log(error);
|
|
143
|
+
}
|
|
144
|
+
return errorMsg;
|
|
145
|
+
};
|
|
146
|
+
exports.getErrorMsg = getErrorMsg;
|
|
147
|
+
function isArrayFormatColumn(columnType) {
|
|
148
|
+
return _constants.ARRAY_FORMAT_COLUMNS.includes(columnType);
|
|
149
|
+
}
|
|
150
|
+
const getFormulaArrayValue = value => {
|
|
151
|
+
if (!Array.isArray(value)) return [];
|
|
152
|
+
return value.map(item => {
|
|
153
|
+
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
154
|
+
return item;
|
|
155
|
+
}
|
|
156
|
+
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
|
|
157
|
+
const {
|
|
158
|
+
display_value
|
|
159
|
+
} = item;
|
|
160
|
+
if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
|
|
161
|
+
return display_value.map(i => {
|
|
162
|
+
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
163
|
+
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
|
|
164
|
+
const {
|
|
165
|
+
display_value
|
|
166
|
+
} = i;
|
|
167
|
+
return display_value;
|
|
168
|
+
}
|
|
169
|
+
return i;
|
|
170
|
+
});
|
|
171
|
+
}).filter(item => isValidCellValue(item));
|
|
172
|
+
};
|
|
173
|
+
exports.getFormulaArrayValue = getFormulaArrayValue;
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@seafile/react-image-lightbox": "4.0.0",
|
|
7
7
|
"@seafile/seafile-calendar": "0.0.24",
|
|
8
|
-
"@seafile/seafile-editor": "2.0.
|
|
8
|
+
"@seafile/seafile-editor": "2.0.1",
|
|
9
9
|
"antd-mobile": "2.3.1",
|
|
10
10
|
"classnames": "2.3.2",
|
|
11
11
|
"dayjs": "1.10.7",
|
|
12
|
-
"dtable-utils": "5.0.
|
|
12
|
+
"dtable-utils": "5.0.16",
|
|
13
13
|
"is-hotkey": "0.2.0",
|
|
14
14
|
"react-color": "2.19.3",
|
|
15
15
|
"react-responsive": "10.0.0",
|
|
16
16
|
"react-select": "5.10.0",
|
|
17
|
+
"react-sweet-progress": "^1.1.2",
|
|
17
18
|
"react-transition-group": "4.4.5",
|
|
18
19
|
"reactstrap": "9.2.3"
|
|
19
20
|
},
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _lang = require("../../lang");
|
|
10
|
-
var _CollaboratorItem = _interopRequireDefault(require("../../CollaboratorItem"));
|
|
11
|
-
require("./index.css");
|
|
12
|
-
class PCCollaboratorEditorPopover extends _react.default.Component {
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(props);
|
|
15
|
-
this.onValueChanged = event => {
|
|
16
|
-
let value = event.target.value;
|
|
17
|
-
this.setState({
|
|
18
|
-
searchValue: value
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
this.onInputClick = event => {
|
|
22
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
23
|
-
event.stopPropagation();
|
|
24
|
-
};
|
|
25
|
-
this.onCollaboratorItemToggle = item => {
|
|
26
|
-
this.props.onCollaboratorItemToggle(item);
|
|
27
|
-
};
|
|
28
|
-
this.getFilterCollaborator = () => {
|
|
29
|
-
let {
|
|
30
|
-
collaborators
|
|
31
|
-
} = this.props;
|
|
32
|
-
let filter = this.state.searchValue.toLowerCase();
|
|
33
|
-
if (!filter) {
|
|
34
|
-
return collaborators;
|
|
35
|
-
}
|
|
36
|
-
return collaborators.filter(collaborator => {
|
|
37
|
-
return collaborator.name.toString().toLowerCase().indexOf(filter) > -1;
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
this.state = {
|
|
41
|
-
searchValue: ''
|
|
42
|
-
};
|
|
43
|
-
this.editorInputRef = /*#__PURE__*/_react.default.createRef();
|
|
44
|
-
}
|
|
45
|
-
componentDidMount() {
|
|
46
|
-
this.editorInputRef.current.focus();
|
|
47
|
-
}
|
|
48
|
-
render() {
|
|
49
|
-
let {
|
|
50
|
-
searchValue
|
|
51
|
-
} = this.state;
|
|
52
|
-
let {
|
|
53
|
-
selectedCollaborators,
|
|
54
|
-
popoverPosition
|
|
55
|
-
} = this.props;
|
|
56
|
-
let collaborators = this.getFilterCollaborator();
|
|
57
|
-
let popoverStyle = Object.assign({}, {
|
|
58
|
-
...popoverPosition
|
|
59
|
-
}, {
|
|
60
|
-
position: 'absolute'
|
|
61
|
-
});
|
|
62
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
63
|
-
className: "dtable-ui-editor-popover dtable-ui-collaborator-editor-popover",
|
|
64
|
-
style: popoverStyle,
|
|
65
|
-
ref: this.props.setPopoverRef
|
|
66
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
67
|
-
className: "collaborator-search-container"
|
|
68
|
-
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
69
|
-
className: "form-control",
|
|
70
|
-
value: searchValue,
|
|
71
|
-
onChange: this.onValueChanged,
|
|
72
|
-
onClick: this.onInputClick,
|
|
73
|
-
placeholder: (0, _lang.getLocale)('Search_collaborator'),
|
|
74
|
-
ref: this.editorInputRef
|
|
75
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
76
|
-
className: "collaborator-list-container"
|
|
77
|
-
}, collaborators.length > 0 && collaborators.map((collaborator, index) => {
|
|
78
|
-
const isSelect = selectedCollaborators.some(selectedCollaborator => {
|
|
79
|
-
return selectedCollaborator.email === collaborator.email;
|
|
80
|
-
});
|
|
81
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
82
|
-
key: index,
|
|
83
|
-
className: "collaborator-item-container",
|
|
84
|
-
onClick: this.onCollaboratorItemToggle.bind(this, collaborator)
|
|
85
|
-
}, /*#__PURE__*/_react.default.createElement(_CollaboratorItem.default, {
|
|
86
|
-
collaborator: collaborator
|
|
87
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
88
|
-
className: "collaborator-checked"
|
|
89
|
-
}, isSelect && /*#__PURE__*/_react.default.createElement("i", {
|
|
90
|
-
className: "dtable-font dtable-icon-check-mark"
|
|
91
|
-
})));
|
|
92
|
-
}), collaborators.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
-
className: "no-search-result"
|
|
94
|
-
}, (0, _lang.getLocale)('No_collaborators_available'))));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
var _default = exports.default = PCCollaboratorEditorPopover;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.imageCheck = exports.getFileThumbnailInfo = exports.getFileIconUrl = void 0;
|
|
7
|
-
var _url = require("../utils/url");
|
|
8
|
-
const FILEEXT_ICON_MAP = {
|
|
9
|
-
// text file
|
|
10
|
-
md: 'txt.png',
|
|
11
|
-
txt: 'txt.png',
|
|
12
|
-
// pdf file
|
|
13
|
-
pdf: 'pdf.png',
|
|
14
|
-
// document file
|
|
15
|
-
doc: 'word.png',
|
|
16
|
-
docx: 'word.png',
|
|
17
|
-
odt: 'word.png',
|
|
18
|
-
fodt: 'word.png',
|
|
19
|
-
ppt: 'ppt.png',
|
|
20
|
-
pptx: 'ppt.png',
|
|
21
|
-
odp: 'ppt.png',
|
|
22
|
-
fodp: 'ppt.png',
|
|
23
|
-
xls: 'excel.png',
|
|
24
|
-
xlsx: 'excel.png',
|
|
25
|
-
ods: 'excel.png',
|
|
26
|
-
fods: 'excel.png',
|
|
27
|
-
// video
|
|
28
|
-
mp4: 'video.png',
|
|
29
|
-
ogv: 'video.png',
|
|
30
|
-
webm: 'video.png',
|
|
31
|
-
mov: 'video.png',
|
|
32
|
-
flv: 'video.png',
|
|
33
|
-
wmv: 'video.png',
|
|
34
|
-
rmvb: 'video.png',
|
|
35
|
-
// music file
|
|
36
|
-
mp3: 'music.png',
|
|
37
|
-
oga: 'music.png',
|
|
38
|
-
ogg: 'music.png',
|
|
39
|
-
flac: 'music.png',
|
|
40
|
-
aac: 'music.png',
|
|
41
|
-
ac3: 'music.png',
|
|
42
|
-
wma: 'music.png',
|
|
43
|
-
// image file
|
|
44
|
-
jpg: 'pic.png',
|
|
45
|
-
jpeg: 'pic.png',
|
|
46
|
-
png: 'pic.png',
|
|
47
|
-
svg: 'pic.png',
|
|
48
|
-
gif: 'pic.png',
|
|
49
|
-
bmp: 'pic.png',
|
|
50
|
-
ico: 'pic.png',
|
|
51
|
-
// folder dir
|
|
52
|
-
folder: 'folder-192.png',
|
|
53
|
-
// default
|
|
54
|
-
default: 'file.png'
|
|
55
|
-
};
|
|
56
|
-
const getFileThumbnailInfo = fileItem => {
|
|
57
|
-
let fileIconUrl;
|
|
58
|
-
let isImage;
|
|
59
|
-
if (!fileItem.name) {
|
|
60
|
-
fileIconUrl = FILEEXT_ICON_MAP['default'];
|
|
61
|
-
isImage = false;
|
|
62
|
-
} else {
|
|
63
|
-
isImage = imageCheck(fileItem.name);
|
|
64
|
-
if (isImage) {
|
|
65
|
-
fileIconUrl = (0, _url.getImageThumbnailUrl)(fileItem.url);
|
|
66
|
-
} else {
|
|
67
|
-
fileIconUrl = require('./' + getFileIconUrl(fileItem.name, fileItem.type));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
fileIconUrl,
|
|
72
|
-
isImage
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
exports.getFileThumbnailInfo = getFileThumbnailInfo;
|
|
76
|
-
const getFileIconUrl = (filename, direntType) => {
|
|
77
|
-
if (typeof direntType === 'string' && direntType === 'dir') {
|
|
78
|
-
return 'assets/folder/' + FILEEXT_ICON_MAP['folder'];
|
|
79
|
-
}
|
|
80
|
-
const identifierIndex = typeof filename === 'string' && filename.lastIndexOf('.');
|
|
81
|
-
if (identifierIndex === -1) {
|
|
82
|
-
return 'assets/file/192/' + FILEEXT_ICON_MAP['default'];
|
|
83
|
-
}
|
|
84
|
-
const file_ext = typeof filename === 'string' && filename.slice(identifierIndex + 1).toLowerCase() || 'default';
|
|
85
|
-
const iconUrl = FILEEXT_ICON_MAP[file_ext] ? 'assets/file/192/' + FILEEXT_ICON_MAP[file_ext] : 'assets/file/192/' + FILEEXT_ICON_MAP['default'];
|
|
86
|
-
return iconUrl;
|
|
87
|
-
};
|
|
88
|
-
exports.getFileIconUrl = getFileIconUrl;
|
|
89
|
-
const imageCheck = filename => {
|
|
90
|
-
// no file ext
|
|
91
|
-
if (!filename || typeof filename !== 'string') return false;
|
|
92
|
-
if (filename.lastIndexOf('.') === -1) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
const file_ext = filename.substr(filename.lastIndexOf('.') + 1).toLowerCase();
|
|
96
|
-
const image_exts = ['gif', 'jpeg', 'jpg', 'png', 'ico', 'bmp', 'tif', 'tiff', 'webp'];
|
|
97
|
-
return image_exts.includes(file_ext);
|
|
98
|
-
};
|
|
99
|
-
exports.imageCheck = imageCheck;
|