dtable-ui-component 4.3.6 → 4.3.8
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/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.css +22 -59
- package/lib/DTableCustomizeSelect/index.js +99 -95
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.css +103 -0
- package/lib/SelectOptionGroup/index.js +157 -135
- package/lib/SelectOptionGroup/option.js +31 -38
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +28 -0
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +4 -4
|
@@ -1,125 +1,117 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import Loading from '../Loading';
|
|
7
3
|
import { getImageThumbnailUrl } from './utils';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_classCallCheck(this, ImagesLazyLoad);
|
|
14
|
-
_this = _super.call(this, _props);
|
|
15
|
-
_this.componentDidMount = function () {
|
|
16
|
-
_this.lazyLoadImages(_this.props);
|
|
4
|
+
class ImagesLazyLoad extends React.Component {
|
|
5
|
+
constructor(_props) {
|
|
6
|
+
super(_props);
|
|
7
|
+
this.componentDidMount = () => {
|
|
8
|
+
this.lazyLoadImages(this.props);
|
|
17
9
|
};
|
|
18
|
-
|
|
19
|
-
if (nextProps.images.toString() !==
|
|
20
|
-
|
|
10
|
+
this.UNSAFE_componentWillReceiveProps = nextProps => {
|
|
11
|
+
if (nextProps.images.toString() !== this.props.images.toString()) {
|
|
12
|
+
this.lazyLoadImages(nextProps);
|
|
21
13
|
}
|
|
22
14
|
};
|
|
23
|
-
|
|
15
|
+
this.componentWillUnmount = () => {
|
|
24
16
|
// prevent async operation
|
|
25
|
-
|
|
17
|
+
this.setState = (state, callback) => {
|
|
26
18
|
return;
|
|
27
19
|
};
|
|
28
20
|
};
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
this.lazyLoadImages = props => {
|
|
22
|
+
const {
|
|
23
|
+
images
|
|
24
|
+
} = props;
|
|
31
25
|
if (!Array.isArray(images) || images.length === 0) {
|
|
32
26
|
return;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
images
|
|
28
|
+
this.setState({
|
|
29
|
+
images,
|
|
36
30
|
loadedImages: [],
|
|
37
31
|
loadedCount: 0
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
}, () => {
|
|
33
|
+
let {
|
|
34
|
+
server
|
|
35
|
+
} = this.props;
|
|
36
|
+
images.forEach((item, index) => {
|
|
37
|
+
let url = getImageThumbnailUrl(item, server);
|
|
38
|
+
this.lazyLoadImage(url, image => {
|
|
39
|
+
let {
|
|
40
|
+
loadedCount,
|
|
41
|
+
loadedImages
|
|
42
|
+
} = this.state;
|
|
43
|
+
let newImageList = loadedImages.slice(0);
|
|
47
44
|
newImageList[index] = image;
|
|
48
|
-
|
|
45
|
+
this.setState({
|
|
49
46
|
loadedCount: loadedCount + 1,
|
|
50
47
|
loadedImages: newImageList
|
|
51
48
|
});
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
}, () => {
|
|
50
|
+
let {
|
|
51
|
+
loadedCount
|
|
52
|
+
} = this.state;
|
|
53
|
+
this.setState({
|
|
55
54
|
loadedCount: loadedCount + 1
|
|
56
55
|
});
|
|
57
56
|
});
|
|
58
57
|
});
|
|
59
58
|
});
|
|
60
59
|
};
|
|
61
|
-
|
|
60
|
+
this.lazyLoadImage = (url, resolve, reject) => {
|
|
62
61
|
if (!url) {
|
|
63
62
|
reject('img path is require');
|
|
64
63
|
return;
|
|
65
64
|
}
|
|
66
|
-
|
|
67
|
-
image.onload =
|
|
65
|
+
const image = new Image();
|
|
66
|
+
image.onload = () => {
|
|
68
67
|
resolve(image);
|
|
69
68
|
};
|
|
70
|
-
image.onerror =
|
|
69
|
+
image.onerror = e => {
|
|
71
70
|
reject(e);
|
|
72
71
|
};
|
|
73
72
|
image.src = url;
|
|
74
73
|
};
|
|
75
|
-
|
|
74
|
+
this.onMouseDown = event => {
|
|
76
75
|
event.stopPropagation();
|
|
77
76
|
};
|
|
78
|
-
|
|
77
|
+
this.onImageClick = (event, index) => {
|
|
79
78
|
event.stopPropagation();
|
|
80
|
-
|
|
79
|
+
this.props.onImageClick(index);
|
|
81
80
|
};
|
|
82
|
-
|
|
81
|
+
this.state = {
|
|
83
82
|
images: _props.images,
|
|
84
83
|
loadedImages: [],
|
|
85
84
|
loadedCount: 0
|
|
86
85
|
};
|
|
87
|
-
return _this;
|
|
88
86
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (!Array.isArray(images) || images.length === 0) {
|
|
98
|
-
return '';
|
|
99
|
-
}
|
|
100
|
-
if (images.length > loadedCount) {
|
|
101
|
-
var style = {
|
|
102
|
-
marginLeft: '4px'
|
|
103
|
-
};
|
|
104
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
105
|
-
style: style,
|
|
106
|
-
className: "d-flex align-items-center"
|
|
107
|
-
}, /*#__PURE__*/React.createElement(Loading, null));
|
|
108
|
-
}
|
|
109
|
-
return loadedImages.map(function (image, index) {
|
|
110
|
-
return /*#__PURE__*/React.createElement("img", {
|
|
111
|
-
key: index,
|
|
112
|
-
className: "image-item",
|
|
113
|
-
src: image.src,
|
|
114
|
-
onMouseDown: _this2.onMouseDown,
|
|
115
|
-
onClick: function onClick(event) {
|
|
116
|
-
return _this2.onImageClick(event, index);
|
|
117
|
-
},
|
|
118
|
-
alt: ""
|
|
119
|
-
});
|
|
120
|
-
});
|
|
87
|
+
render() {
|
|
88
|
+
const {
|
|
89
|
+
images,
|
|
90
|
+
loadedImages,
|
|
91
|
+
loadedCount
|
|
92
|
+
} = this.state;
|
|
93
|
+
if (!Array.isArray(images) || images.length === 0) {
|
|
94
|
+
return '';
|
|
121
95
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
96
|
+
if (images.length > loadedCount) {
|
|
97
|
+
let style = {
|
|
98
|
+
marginLeft: '4px'
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
style: style,
|
|
102
|
+
className: "d-flex align-items-center"
|
|
103
|
+
}, /*#__PURE__*/React.createElement(Loading, null));
|
|
104
|
+
}
|
|
105
|
+
return loadedImages.map((image, index) => {
|
|
106
|
+
return /*#__PURE__*/React.createElement("img", {
|
|
107
|
+
key: index,
|
|
108
|
+
className: "image-item",
|
|
109
|
+
src: image.src,
|
|
110
|
+
onMouseDown: this.onMouseDown,
|
|
111
|
+
onClick: event => this.onImageClick(event, index),
|
|
112
|
+
alt: ""
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
125
117
|
export default ImagesLazyLoad;
|
|
@@ -1,128 +1,117 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React, { Fragment } from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import ImagesLazyLoad from './images-lazy-load';
|
|
8
4
|
import { getImageThumbnailUrl } from './utils';
|
|
9
5
|
import ImagePreviewerLightbox from '../ImagePreviewerLightbox';
|
|
10
6
|
import './index.css';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_this = _super.call(this, props);
|
|
18
|
-
_this.onImageClick = function (index) {
|
|
19
|
-
if (!_this.props.isSupportPreview) return;
|
|
20
|
-
_this.setState({
|
|
7
|
+
class ImageFormatter extends React.Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.onImageClick = index => {
|
|
11
|
+
if (!this.props.isSupportPreview) return;
|
|
12
|
+
this.setState({
|
|
21
13
|
isPreviewImage: true,
|
|
22
14
|
previewImageIndex: index
|
|
23
15
|
});
|
|
24
16
|
};
|
|
25
|
-
|
|
26
|
-
if (!
|
|
27
|
-
if (
|
|
28
|
-
|
|
17
|
+
this.closeImagePopup = () => {
|
|
18
|
+
if (!this.props.isSupportPreview) return;
|
|
19
|
+
if (this.props.onCloseCallback) {
|
|
20
|
+
this.props.onCloseCallback();
|
|
29
21
|
}
|
|
30
|
-
|
|
22
|
+
this.setState({
|
|
31
23
|
isPreviewImage: false,
|
|
32
24
|
previewImageIndex: -1
|
|
33
25
|
});
|
|
34
26
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
});
|
|
27
|
+
this.movePrev = () => {
|
|
28
|
+
let images = this.props.value;
|
|
29
|
+
this.setState(prevState => ({
|
|
30
|
+
previewImageIndex: (prevState.previewImageIndex + images.length - 1) % images.length
|
|
31
|
+
}));
|
|
42
32
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
});
|
|
33
|
+
this.moveNext = () => {
|
|
34
|
+
let images = this.props.value;
|
|
35
|
+
this.setState(prevState => ({
|
|
36
|
+
previewImageIndex: (prevState.previewImageIndex + 1) % images.length
|
|
37
|
+
}));
|
|
50
38
|
};
|
|
51
|
-
|
|
52
|
-
if (!
|
|
53
|
-
|
|
39
|
+
this.downloadImage = imageItemUrl => {
|
|
40
|
+
if (!this.props.downloadImage) return;
|
|
41
|
+
this.props.downloadImage(imageItemUrl);
|
|
54
42
|
};
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
this.deleteImage = index => {
|
|
44
|
+
const {
|
|
45
|
+
readOnly
|
|
46
|
+
} = this.props;
|
|
57
47
|
if (readOnly) return;
|
|
58
|
-
if (!
|
|
59
|
-
|
|
48
|
+
if (!this.props.deleteImage) return;
|
|
49
|
+
this.props.deleteImage(index);
|
|
60
50
|
};
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
this.onRotateImage = (index, degree) => {
|
|
52
|
+
const {
|
|
53
|
+
readOnly
|
|
54
|
+
} = this.props;
|
|
63
55
|
if (readOnly) return;
|
|
64
|
-
if (!
|
|
65
|
-
|
|
56
|
+
if (!this.props.rotateImage) return;
|
|
57
|
+
this.props.rotateImage(index, degree);
|
|
66
58
|
};
|
|
67
|
-
|
|
59
|
+
this.state = {
|
|
68
60
|
isPreviewImage: false,
|
|
69
61
|
previewImageIndex: -1
|
|
70
62
|
};
|
|
71
|
-
return _this;
|
|
72
63
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
className: className
|
|
94
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
95
|
-
className: "image-item",
|
|
96
|
-
src: url,
|
|
97
|
-
alt: ""
|
|
98
|
-
}), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
|
|
99
|
-
className: "image-item-count"
|
|
100
|
-
}, "+".concat(value.length)));
|
|
101
|
-
}
|
|
102
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
render() {
|
|
65
|
+
const {
|
|
66
|
+
isSample,
|
|
67
|
+
value,
|
|
68
|
+
server,
|
|
69
|
+
containerClassName,
|
|
70
|
+
readOnly
|
|
71
|
+
} = this.props;
|
|
72
|
+
const className = classnames('dtable-ui cell-formatter-container image-formatter', containerClassName);
|
|
73
|
+
const {
|
|
74
|
+
isPreviewImage,
|
|
75
|
+
previewImageIndex
|
|
76
|
+
} = this.state;
|
|
77
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (isSample) {
|
|
81
|
+
let item = value[0];
|
|
82
|
+
let url = getImageThumbnailUrl(item, server);
|
|
83
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
103
84
|
className: className
|
|
104
|
-
}, /*#__PURE__*/React.createElement(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
closeImagePopup: this.closeImagePopup,
|
|
112
|
-
moveToPrevImage: this.movePrev,
|
|
113
|
-
moveToNextImage: this.moveNext,
|
|
114
|
-
deleteImage: readOnly ? null : this.deleteImage,
|
|
115
|
-
downloadImage: this.downloadImage,
|
|
116
|
-
onRotateImage: readOnly ? null : this.onRotateImage,
|
|
117
|
-
readOnly: readOnly,
|
|
118
|
-
server: server,
|
|
119
|
-
moveToPrevRowImage: this.props.moveToPrevRowImage,
|
|
120
|
-
moveToNextRowImage: this.props.moveToNextRowImage
|
|
121
|
-
}));
|
|
85
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
86
|
+
className: "image-item",
|
|
87
|
+
src: url,
|
|
88
|
+
alt: ""
|
|
89
|
+
}), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
|
|
90
|
+
className: "image-item-count"
|
|
91
|
+
}, "+".concat(value.length)));
|
|
122
92
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
93
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: className
|
|
95
|
+
}, /*#__PURE__*/React.createElement(ImagesLazyLoad, {
|
|
96
|
+
images: value,
|
|
97
|
+
server: server,
|
|
98
|
+
onImageClick: this.onImageClick
|
|
99
|
+
})), isPreviewImage && /*#__PURE__*/React.createElement(ImagePreviewerLightbox, {
|
|
100
|
+
imageItems: value,
|
|
101
|
+
imageIndex: previewImageIndex,
|
|
102
|
+
closeImagePopup: this.closeImagePopup,
|
|
103
|
+
moveToPrevImage: this.movePrev,
|
|
104
|
+
moveToNextImage: this.moveNext,
|
|
105
|
+
deleteImage: readOnly ? null : this.deleteImage,
|
|
106
|
+
downloadImage: this.downloadImage,
|
|
107
|
+
onRotateImage: readOnly ? null : this.onRotateImage,
|
|
108
|
+
readOnly: readOnly,
|
|
109
|
+
server: server,
|
|
110
|
+
moveToPrevRowImage: this.props.moveToPrevRowImage,
|
|
111
|
+
moveToNextRowImage: this.props.moveToNextRowImage
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
126
115
|
ImageFormatter.defaultProps = {
|
|
127
116
|
isSample: false,
|
|
128
117
|
isSupportPreview: false,
|
|
@@ -4,22 +4,24 @@ import Lightbox from '@seafile/react-image-lightbox';
|
|
|
4
4
|
import { checkSVGImage, isInternalImg } from './utils';
|
|
5
5
|
import '@seafile/react-image-lightbox/style.css';
|
|
6
6
|
function ImagePreviewerLightbox(props) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const {
|
|
8
|
+
imageItems,
|
|
9
|
+
imageIndex,
|
|
10
|
+
deleteImage,
|
|
11
|
+
downloadImage,
|
|
12
|
+
onRotateImage,
|
|
13
|
+
readOnly,
|
|
14
|
+
server,
|
|
15
|
+
moveToPrevRowImage,
|
|
16
|
+
moveToNextRowImage,
|
|
17
|
+
className
|
|
18
|
+
} = props;
|
|
19
|
+
const imageItemsLength = imageItems.length;
|
|
20
|
+
const URL = imageItems[imageIndex];
|
|
21
|
+
const imageTitle = URL ? decodeURI(URL.slice(URL.lastIndexOf('/') + 1)) : '';
|
|
20
22
|
// svg image is vectorgraph and can't rotate, external image can't rotate
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const canRotateImage = onRotateImage && !readOnly && !checkSVGImage(URL) && isInternalImg(URL, server);
|
|
24
|
+
const imageTitleEl = /*#__PURE__*/React.createElement("span", {
|
|
23
25
|
className: "d-flex"
|
|
24
26
|
}, /*#__PURE__*/React.createElement("span", {
|
|
25
27
|
className: "text-truncate"
|
|
@@ -37,13 +39,13 @@ function ImagePreviewerLightbox(props) {
|
|
|
37
39
|
onMoveNextRequest: props.moveToNextImage,
|
|
38
40
|
onClickMoveUp: moveToPrevRowImage,
|
|
39
41
|
onClickMoveDown: moveToNextRowImage,
|
|
40
|
-
onRotateImage: canRotateImage ?
|
|
42
|
+
onRotateImage: canRotateImage ? deg => {
|
|
41
43
|
onRotateImage(imageIndex, deg);
|
|
42
44
|
} : null,
|
|
43
|
-
onClickDelete: !readOnly && deleteImage ?
|
|
45
|
+
onClickDelete: !readOnly && deleteImage ? () => {
|
|
44
46
|
deleteImage(imageIndex, 'previewer');
|
|
45
47
|
} : null,
|
|
46
|
-
onClickDownload: downloadImage ?
|
|
48
|
+
onClickDownload: downloadImage ? () => {
|
|
47
49
|
downloadImage(URL);
|
|
48
50
|
} : null
|
|
49
51
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const isInternalImg = (url, server) => {
|
|
2
2
|
if (!url) return;
|
|
3
|
-
|
|
3
|
+
const currentServer = server || window.dtable && window.dtable.server;
|
|
4
4
|
return url.indexOf(currentServer) > -1;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export const checkSVGImage = url => {
|
|
7
7
|
if (!url) return false;
|
|
8
8
|
return url.substr(-4).toLowerCase() === '.svg';
|
|
9
9
|
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import CollaboratorItem from '../CollaboratorItem';
|
|
@@ -12,27 +8,19 @@ import './index.css';
|
|
|
12
8
|
// 2 value is exist, but can't find in collaborators
|
|
13
9
|
// 3 value is exist, typeof value is a string
|
|
14
10
|
// 4 value is exist, typeof value is array
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
|
-
_this.getCollaborators = function () {
|
|
26
|
-
var _this$props = _this.props,
|
|
27
|
-
value = _this$props.value,
|
|
28
|
-
collaborators = _this$props.collaborators;
|
|
11
|
+
class LastModifierFormatter extends React.PureComponent {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.getCollaborators = () => {
|
|
15
|
+
let {
|
|
16
|
+
value,
|
|
17
|
+
collaborators
|
|
18
|
+
} = this.props;
|
|
29
19
|
if (!Array.isArray(value)) {
|
|
30
20
|
value = [value];
|
|
31
21
|
}
|
|
32
|
-
return value.map(
|
|
33
|
-
|
|
34
|
-
return collaborator.email === item;
|
|
35
|
-
});
|
|
22
|
+
return value.map((item, index) => {
|
|
23
|
+
let collaborator = collaborators.find(collaborator => collaborator.email === item);
|
|
36
24
|
// the collaborator can be not exist, because the row modified by third app
|
|
37
25
|
if (!collaborator) {
|
|
38
26
|
collaborator = {
|
|
@@ -46,28 +34,24 @@ var LastModifierFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
46
34
|
});
|
|
47
35
|
});
|
|
48
36
|
};
|
|
49
|
-
return _this;
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (!value || Array.isArray(value) && value.length === 0) {
|
|
59
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
-
className: classname
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
var collaborators = this.getCollaborators();
|
|
38
|
+
render() {
|
|
39
|
+
const {
|
|
40
|
+
containerClassName,
|
|
41
|
+
value
|
|
42
|
+
} = this.props;
|
|
43
|
+
const classname = classnames('dtable-ui cell-formatter-container last-modified-formatter', containerClassName);
|
|
44
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
64
45
|
return /*#__PURE__*/React.createElement("div", {
|
|
65
46
|
className: classname
|
|
66
|
-
}
|
|
47
|
+
});
|
|
67
48
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
const collaborators = this.getCollaborators();
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: classname
|
|
52
|
+
}, collaborators);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
71
55
|
LastModifierFormatter.defaultProps = {
|
|
72
56
|
value: ''
|
|
73
57
|
};
|