dtable-ui-component 6.0.107-opl.3 → 6.0.107-opl.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.
@@ -27,38 +27,44 @@ function ImagePreviewerLightbox(props) {
27
27
  onRotateImage
28
28
  } = props;
29
29
  const imageSrcList = imageItems.map(src => {
30
+ let name = '';
31
+ try {
32
+ name = src ? decodeURIComponent(src.slice(src.lastIndexOf('/') + 1)) : '';
33
+ } catch (error) {
34
+ // eslint-disable-next-line no-console
35
+ console.log(error);
36
+ }
30
37
  if (server && dtableUuid && (0, _url.isCustomAssetUrl)(src)) {
31
38
  const assetUuid = src.slice(src.lastIndexOf('/') + 1, src.lastIndexOf('.'));
32
- return server + '/dtable/' + dtableUuid + '/custom-asset/' + assetUuid;
39
+ return {
40
+ name,
41
+ thumbnail: server + '/dtable/' + dtableUuid + '/custom-asset/' + assetUuid
42
+ };
33
43
  }
34
44
  if (server && dtableUuid && workspaceID && (0, _url.isDigitalSignsUrl)(src)) {
35
- return (0, _url.generateCurrentBaseImageUrl)({
36
- server,
37
- workspaceID,
38
- dtableUuid,
39
- partUrl: src
40
- });
45
+ return {
46
+ name,
47
+ thumbnail: (0, _url.generateCurrentBaseImageUrl)({
48
+ server,
49
+ workspaceID,
50
+ dtableUuid,
51
+ partUrl: src
52
+ })
53
+ };
41
54
  }
42
55
  return {
43
- name: URL ? decodeURI(URL.slice(URL.lastIndexOf('/') + 1)) : '',
56
+ name: name || '',
44
57
  thumbnail: src
45
58
  };
46
59
  });
47
60
  const imagesLength = imageSrcList.length;
48
61
  const [currentImageIndex, setCurrentImageIndex] = _react.default.useState(imageIndex || 0);
49
- const URL = imageSrcList[currentImageIndex];
62
+ const imageItem = imageSrcList[currentImageIndex];
63
+ const URL = imageItem ? imageItem.thumbnail : '';
64
+ const imageName = imageItem ? imageItem.name : '';
50
65
  _react.default.useEffect(() => {
51
66
  setCurrentImageIndex(imageIndex);
52
67
  }, [imageIndex]);
53
-
54
- // Handle URL has special symbol %$
55
- let imageName = '';
56
- try {
57
- imageName = URL ? decodeURI(URL.slice(URL.lastIndexOf('/') + 1)) : '';
58
- } catch (error) {
59
- // eslint-disable-next-line no-console
60
- console.log(error);
61
- }
62
68
  const canRotateImage = onRotateImage && !readOnly && !['gif', 'heic', 'heif'].includes((0, _url.getFileSuffix)(URL)) && (0, _url.isInternalImg)(URL, server);
63
69
  let mainSrc = URL;
64
70
  if ((0, _url.needUseThumbnailImage)(URL)) {
@@ -73,7 +79,7 @@ function ImagePreviewerLightbox(props) {
73
79
  className: "d-flex",
74
80
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
75
81
  className: "text-truncate",
76
- children: imageName
82
+ children: imageName || ''
77
83
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
78
84
  className: "flex-shrink-0 pl-1",
79
85
  children: ["(", currentImageIndex + 1, "/", imagesLength, ")"]
@@ -87,8 +93,8 @@ function ImagePreviewerLightbox(props) {
87
93
  wrapperClassName: (0, _classnames.default)('dtable-ui-component', className),
88
94
  imageTitle: imageTitleDOM,
89
95
  mainSrc: mainSrc,
90
- nextSrc: imageSrcList[(currentImageIndex + 1) % imagesLength],
91
- prevSrc: imageSrcList[(currentImageIndex + imagesLength - 1) % imagesLength],
96
+ nextSrc: imageSrcList[(currentImageIndex + 1) % imagesLength] ? imageSrcList[(currentImageIndex + 1) % imagesLength].thumbnail : '',
97
+ prevSrc: imageSrcList[(currentImageIndex + imagesLength - 1) % imagesLength] ? imageSrcList[(currentImageIndex + imagesLength - 1) % imagesLength].thumbnail : '',
92
98
  imagePadding: 70,
93
99
  viewOriginalImageLabel: (0, _lang.getLocale)('View_original_image'),
94
100
  enableRotate: canRotateImage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.107opl.3",
3
+ "version": "6.0.107opl.4",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "^5.0.4",