@droppii-org/chat-sdk 0.1.70 → 0.1.71
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/components/media-collection/FileCollection.d.ts.map +1 -1
- package/dist/components/media-collection/FileCollection.js +1 -2
- package/dist/components/message/footer/FilePreview.d.ts +0 -6
- package/dist/components/message/footer/FilePreview.d.ts.map +1 -1
- package/dist/components/message/footer/FilePreview.js +1 -17
- package/dist/components/message/item/FileMessage.d.ts.map +1 -1
- package/dist/components/message/item/FileMessage.js +1 -2
- package/dist/utils/common.d.ts +6 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/common.js +18 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileCollection.d.ts","sourceRoot":"","sources":["../../../src/components/media-collection/FileCollection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileCollection.d.ts","sourceRoot":"","sources":["../../../src/components/media-collection/FileCollection.tsx"],"names":[],"mappings":"AAYA,QAAA,MAAM,cAAc,+CAqGnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -8,8 +8,7 @@ import dayjs from "dayjs";
|
|
|
8
8
|
import useConversationStore from "../../store/conversation";
|
|
9
9
|
import { useTranslation } from "react-i18next";
|
|
10
10
|
import { documentIcon } from "../../assets/svg";
|
|
11
|
-
import { shortenFileName } from "../../
|
|
12
|
-
import { renderFileSize } from "../../utils/common";
|
|
11
|
+
import { renderFileSize, shortenFileName } from "../../utils/common";
|
|
13
12
|
const FileCollection = () => {
|
|
14
13
|
const { t } = useTranslation();
|
|
15
14
|
const selectedSourceId = useConversationStore((state) => state.selectedSourceId);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { UploadFile } from "antd";
|
|
2
|
-
interface ShortenOptions {
|
|
3
|
-
maxLength?: number;
|
|
4
|
-
keepStart?: number;
|
|
5
|
-
keepEnd?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const shortenFileName: (name?: string, options?: ShortenOptions) => string;
|
|
8
2
|
export declare function FilePreviewList({ files, onRemove, onVideoReady, }: {
|
|
9
3
|
files: UploadFile[];
|
|
10
4
|
onRemove: (file: UploadFile) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/FilePreview.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/FilePreview.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AA6IlC,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,YAAY,GACb,EAAE;IACD,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,kDAsBA;AAED,QAAA,MAAM,WAAW,+CAQhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,23 +5,7 @@ import { useMessageFooterContext } from ".";
|
|
|
5
5
|
import { Icon } from "../../../components/icon";
|
|
6
6
|
import { documentIcon } from "../../../assets/svg";
|
|
7
7
|
import { DOCUMENT_MIME_TYPES } from "../../../utils/fileValidation";
|
|
8
|
-
import { formatDuration } from "../../../utils/common";
|
|
9
|
-
export const shortenFileName = (name, options = {}) => {
|
|
10
|
-
if (!name)
|
|
11
|
-
return "";
|
|
12
|
-
const { maxLength = 20, keepStart = 8, keepEnd = 3 } = options;
|
|
13
|
-
if (name.length <= maxLength)
|
|
14
|
-
return name;
|
|
15
|
-
const dotIndex = name.lastIndexOf(".");
|
|
16
|
-
const ext = dotIndex !== -1 ? name.slice(dotIndex) : "";
|
|
17
|
-
const base = dotIndex !== -1 ? name.slice(0, dotIndex) : name;
|
|
18
|
-
const available = maxLength - ext.length - 3;
|
|
19
|
-
const startLen = keepStart !== null && keepStart !== void 0 ? keepStart : Math.floor(available / 2);
|
|
20
|
-
const endLen = keepEnd !== null && keepEnd !== void 0 ? keepEnd : Math.floor(available / 2);
|
|
21
|
-
const start = base.slice(0, startLen);
|
|
22
|
-
const end = base.slice(-endLen);
|
|
23
|
-
return `${start}...${end}${ext}`;
|
|
24
|
-
};
|
|
8
|
+
import { formatDuration, shortenFileName } from "../../../utils/common";
|
|
25
9
|
const formatFileSize = (bytes) => {
|
|
26
10
|
if (bytes === 0)
|
|
27
11
|
return "0 B";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/FileMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/FileMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,yBAAyB,CAAC;AAMrE,UAAU,oBAAoB;IAC5B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,oBAAoB,4CAiEnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -3,8 +3,7 @@ import { MessageStatus } from "@openim/wasm-client-sdk";
|
|
|
3
3
|
import { Spin } from "antd";
|
|
4
4
|
import { Icon } from "../../../components/icon";
|
|
5
5
|
import { documentIcon } from "../../../assets/svg";
|
|
6
|
-
import { shortenFileName } from "../../../
|
|
7
|
-
import { renderFileSize } from "../../../utils/common";
|
|
6
|
+
import { renderFileSize, shortenFileName } from "../../../utils/common";
|
|
8
7
|
const FileMessageItem = (props) => {
|
|
9
8
|
var _a;
|
|
10
9
|
const { message } = props;
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ import { PeerType } from "../types/conversation";
|
|
|
5
5
|
export declare const parseUrlMetadata: (ex?: string) => UrlMetadataInfo | undefined;
|
|
6
6
|
export declare function formatDuration(seconds: number): string;
|
|
7
7
|
export declare function renderFileSize(bytes: number): string;
|
|
8
|
+
interface ShortenFileNameOptions {
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
keepStart?: number;
|
|
11
|
+
keepEnd?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const shortenFileName: (name?: string, options?: ShortenFileNameOptions) => string;
|
|
8
14
|
export declare const generateContentBasedOnMessageType: (contentType: MessageType, plainText?: string, t?: TFunction, mediaMeta?: {
|
|
9
15
|
duration?: number;
|
|
10
16
|
fileName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAqB,eAAe,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,eAAe,GAAG,SAQhE,CAAC;AAwBF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAapD;AAED,eAAO,MAAM,iCAAiC,GAC5C,aAAa,WAAW,EACxB,YAAY,MAAM,EAClB,IAAI,SAAS,EACb,YAAY;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO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AO,CAAC,EAAE,aAAa,GACtB,MAAM,CAqBR;AAED,eAAO,MAAM,QAAQ,QAAkD,CAAC;AAExE,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAqC3D;AAED,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAOrD,CAAC;AAKF,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,OACf,CAAC;AAEnC,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAO9B,CAAC;AAEZ;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgEjD"}
|
package/dist/utils/common.js
CHANGED
|
@@ -46,6 +46,22 @@ export function renderFileSize(bytes) {
|
|
|
46
46
|
}
|
|
47
47
|
return `${size.toFixed(1)} ${units[index]}`;
|
|
48
48
|
}
|
|
49
|
+
export const shortenFileName = (name, options = {}) => {
|
|
50
|
+
if (!name)
|
|
51
|
+
return "";
|
|
52
|
+
const { maxLength = 20, keepStart = 8, keepEnd = 3 } = options;
|
|
53
|
+
if (name.length <= maxLength)
|
|
54
|
+
return name;
|
|
55
|
+
const dotIndex = name.lastIndexOf(".");
|
|
56
|
+
const ext = dotIndex !== -1 ? name.slice(dotIndex) : "";
|
|
57
|
+
const base = dotIndex !== -1 ? name.slice(0, dotIndex) : name;
|
|
58
|
+
const available = maxLength - ext.length - 3;
|
|
59
|
+
const startLen = keepStart !== null && keepStart !== void 0 ? keepStart : Math.floor(available / 2);
|
|
60
|
+
const endLen = keepEnd !== null && keepEnd !== void 0 ? keepEnd : Math.floor(available / 2);
|
|
61
|
+
const start = base.slice(0, startLen);
|
|
62
|
+
const end = base.slice(-endLen);
|
|
63
|
+
return `${start}...${end}${ext}`;
|
|
64
|
+
};
|
|
49
65
|
export const generateContentBasedOnMessageType = (contentType, plainText, t, mediaMeta) => {
|
|
50
66
|
switch (contentType) {
|
|
51
67
|
case MessageType.TextMessage:
|
|
@@ -67,7 +83,8 @@ export const generateContentBasedOnMessageType = (contentType, plainText, t, med
|
|
|
67
83
|
}
|
|
68
84
|
case MessageType.FileMessage: {
|
|
69
85
|
const base = t ? t("msg_type_file") : "[File]";
|
|
70
|
-
|
|
86
|
+
const fileName = shortenFileName(mediaMeta === null || mediaMeta === void 0 ? void 0 : mediaMeta.fileName);
|
|
87
|
+
return fileName ? `${base} ${fileName}` : base;
|
|
71
88
|
}
|
|
72
89
|
case MessageType.RevokeMessage:
|
|
73
90
|
return t ? t("revoked") : "Đã thu hồi tin nhắn";
|