@esvndev/es-react-template-chat 0.0.96 → 0.0.98
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/index.js +159 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -167
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -91728,7 +91728,6 @@ const IconFileTypeColor = (props) => {
|
|
|
91728
91728
|
return jsx("img", { ...props, src: icon, style: { width: width ? width : 24, height: height ? height : 'auto', ...props.style } });
|
|
91729
91729
|
};
|
|
91730
91730
|
|
|
91731
|
-
const MySwal$1 = withReactContent(Swal);
|
|
91732
91731
|
const DateHeader = memo(({ label }) => (jsx("div", { className: "d-flex justify-content-center", children: jsx("div", { style: {
|
|
91733
91732
|
backgroundColor: "rgba(0,0,0,0.2)",
|
|
91734
91733
|
padding: "2px 15px",
|
|
@@ -91749,8 +91748,8 @@ const ADMINISTRATIVE_ITEMS = [
|
|
|
91749
91748
|
const ChatLog = (props) => {
|
|
91750
91749
|
// ** Props & Store
|
|
91751
91750
|
//const clipboard = useClipboard()
|
|
91752
|
-
|
|
91753
|
-
|
|
91751
|
+
useLexicalComposerContext();
|
|
91752
|
+
useTranslation();
|
|
91754
91753
|
useUploadFile();
|
|
91755
91754
|
const { typeChat, contactId, chatRoomId, active, messageByGroup, pinnedMessages, setScroll, checkScroll, pinMessageChatRoom, deleteMessageApi, recallMessageApi, get_message_by_group_cursor_api, getPinMessageChatRoomApi, deletePinMessage,
|
|
91756
91755
|
//updateGroupTagApi,
|
|
@@ -91826,8 +91825,8 @@ const ChatLog = (props) => {
|
|
|
91826
91825
|
useState(true);
|
|
91827
91826
|
const [expandedMessages, setExpandedMessages] = useState(new Set());
|
|
91828
91827
|
const [clickedImageFile, setClickedImageFile] = useState(null);
|
|
91829
|
-
|
|
91830
|
-
|
|
91828
|
+
useState(false);
|
|
91829
|
+
useState(new Set());
|
|
91831
91830
|
const BASE_CONTEXT_ITEMS = [
|
|
91832
91831
|
"reply", "share", "pin", "bookmark",
|
|
91833
91832
|
"selectMultiMessage", "detail", "other", "recall", "delete"
|
|
@@ -92462,7 +92461,7 @@ const ChatLog = (props) => {
|
|
|
92462
92461
|
backgroundImage: `url(${`${CDN_URL_VIEW}/${replyData?.path[0].path.trim()}`})`
|
|
92463
92462
|
} })), replyData?.type === "file" && (jsx("div", { style: { marginRight: 8 }, children: jsx(IconFileTypeColor, { fileType: replyData?.path?.[0]?.type, width: 35 }) })), jsxs("div", { className: "reply-content d-flex flex-column", children: [jsx("div", { className: "fw-bold", children: replyData?.createdByName }), jsx("div", { children: renderMessageReply(replyData?.type, replyData?.msg) })] })] }) }));
|
|
92464
92463
|
}, [renderMessageReply]);
|
|
92465
|
-
|
|
92464
|
+
useCallback(async (path) => {
|
|
92466
92465
|
const url = `${CDN_URL_VIEW}/${path}`;
|
|
92467
92466
|
try {
|
|
92468
92467
|
const response = await axios$1.get(url, { responseType: "blob" });
|
|
@@ -92479,167 +92478,160 @@ const ChatLog = (props) => {
|
|
|
92479
92478
|
console.error(error);
|
|
92480
92479
|
}
|
|
92481
92480
|
}, []);
|
|
92482
|
-
const handleDownloadClick = useCallback((param) => {
|
|
92483
|
-
|
|
92484
|
-
|
|
92485
|
-
|
|
92486
|
-
|
|
92487
|
-
|
|
92488
|
-
|
|
92489
|
-
|
|
92490
|
-
|
|
92491
|
-
|
|
92492
|
-
|
|
92493
|
-
|
|
92494
|
-
|
|
92495
|
-
|
|
92496
|
-
|
|
92497
|
-
|
|
92498
|
-
|
|
92499
|
-
|
|
92500
|
-
|
|
92501
|
-
|
|
92502
|
-
|
|
92503
|
-
|
|
92504
|
-
|
|
92505
|
-
|
|
92506
|
-
|
|
92507
|
-
|
|
92508
|
-
|
|
92509
|
-
|
|
92510
|
-
|
|
92511
|
-
|
|
92512
|
-
|
|
92513
|
-
|
|
92514
|
-
|
|
92515
|
-
|
|
92516
|
-
|
|
92517
|
-
|
|
92518
|
-
|
|
92519
|
-
|
|
92520
|
-
|
|
92521
|
-
|
|
92522
|
-
|
|
92523
|
-
|
|
92524
|
-
|
|
92525
|
-
|
|
92526
|
-
|
|
92527
|
-
|
|
92528
|
-
|
|
92529
|
-
|
|
92530
|
-
|
|
92531
|
-
|
|
92532
|
-
|
|
92533
|
-
|
|
92534
|
-
|
|
92535
|
-
|
|
92536
|
-
|
|
92537
|
-
|
|
92538
|
-
|
|
92539
|
-
|
|
92540
|
-
|
|
92541
|
-
|
|
92542
|
-
|
|
92543
|
-
|
|
92544
|
-
|
|
92545
|
-
|
|
92546
|
-
|
|
92547
|
-
|
|
92548
|
-
|
|
92549
|
-
|
|
92550
|
-
|
|
92551
|
-
|
|
92552
|
-
|
|
92553
|
-
|
|
92554
|
-
|
|
92555
|
-
|
|
92556
|
-
|
|
92557
|
-
|
|
92558
|
-
|
|
92559
|
-
|
|
92560
|
-
|
|
92561
|
-
|
|
92562
|
-
|
|
92563
|
-
|
|
92564
|
-
|
|
92565
|
-
|
|
92566
|
-
|
|
92567
|
-
|
|
92568
|
-
|
|
92569
|
-
|
|
92570
|
-
|
|
92571
|
-
|
|
92572
|
-
|
|
92573
|
-
|
|
92574
|
-
|
|
92575
|
-
|
|
92576
|
-
|
|
92577
|
-
|
|
92578
|
-
|
|
92579
|
-
|
|
92580
|
-
|
|
92581
|
-
|
|
92582
|
-
|
|
92583
|
-
|
|
92584
|
-
|
|
92585
|
-
|
|
92586
|
-
|
|
92587
|
-
|
|
92588
|
-
|
|
92589
|
-
}, [
|
|
92590
|
-
useCallback((
|
|
92591
|
-
|
|
92592
|
-
|
|
92593
|
-
}, [
|
|
92594
|
-
useCallback((
|
|
92595
|
-
|
|
92596
|
-
|
|
92597
|
-
}, [])
|
|
92598
|
-
const
|
|
92599
|
-
|
|
92600
|
-
|
|
92601
|
-
|
|
92602
|
-
|
|
92603
|
-
|
|
92604
|
-
|
|
92605
|
-
|
|
92606
|
-
|
|
92607
|
-
|
|
92608
|
-
|
|
92609
|
-
|
|
92610
|
-
|
|
92611
|
-
|
|
92612
|
-
|
|
92613
|
-
}
|
|
92614
|
-
|
|
92615
|
-
|
|
92616
|
-
|
|
92617
|
-
|
|
92618
|
-
|
|
92619
|
-
|
|
92620
|
-
|
|
92621
|
-
|
|
92622
|
-
|
|
92623
|
-
|
|
92624
|
-
|
|
92625
|
-
|
|
92626
|
-
|
|
92627
|
-
|
|
92628
|
-
|
|
92629
|
-
|
|
92630
|
-
|
|
92631
|
-
|
|
92632
|
-
|
|
92633
|
-
|
|
92634
|
-
|
|
92635
|
-
|
|
92636
|
-
}
|
|
92637
|
-
catch (error) {
|
|
92638
|
-
console.error('Error deleting messages:', error);
|
|
92639
|
-
}
|
|
92640
|
-
}
|
|
92641
|
-
});
|
|
92642
|
-
}, [selectedMessages, deleteMessageApi, groupChatUsers?.id, handleExitMultiSelectMode, t]);
|
|
92481
|
+
// const handleDownloadClick = useCallback((param: any) => {
|
|
92482
|
+
// // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
|
|
92483
|
+
// const targetFile = clickedImageFile || param?.path?.[0]
|
|
92484
|
+
// if (targetFile?.path) {
|
|
92485
|
+
// downloadFile(targetFile.path)
|
|
92486
|
+
// } else {
|
|
92487
|
+
// console.error("No valid path found in param")
|
|
92488
|
+
// }
|
|
92489
|
+
// }, [clickedImageFile, downloadFile])
|
|
92490
|
+
// const handleDelete = useCallback(async (param: any) => {
|
|
92491
|
+
// try {
|
|
92492
|
+
// const result = await MySwal.fire({
|
|
92493
|
+
// title: "Xác nhận",
|
|
92494
|
+
// html: "Tin nhắn sẽ bị xóa vĩnh viễn. <br> Bạn có chắc muốn xóa?",
|
|
92495
|
+
// allowOutsideClick: false,
|
|
92496
|
+
// showCancelButton: true,
|
|
92497
|
+
// confirmButtonText: "Xoá",
|
|
92498
|
+
// cancelButtonText: "Hủy",
|
|
92499
|
+
// customClass: {
|
|
92500
|
+
// confirmButton: "btn btn-primary",
|
|
92501
|
+
// cancelButton: "btn btn-danger ms-1"
|
|
92502
|
+
// },
|
|
92503
|
+
// buttonsStyling: false
|
|
92504
|
+
// })
|
|
92505
|
+
// if (result.value) {
|
|
92506
|
+
// const data = { id: param.id, chatRoomId: groupChatUsers.id }
|
|
92507
|
+
// await deleteMessageApi(data)
|
|
92508
|
+
// } else if (result.dismiss === MySwal.DismissReason.cancel) {
|
|
92509
|
+
// console.log("Hủy xóa tin nhắn")
|
|
92510
|
+
// }
|
|
92511
|
+
// } catch (error) {
|
|
92512
|
+
// console.error("Error deleting message:", error)
|
|
92513
|
+
// }
|
|
92514
|
+
// }, [deleteMessageApi, groupChatUsers?.id])
|
|
92515
|
+
// const handleRecall = useCallback(async (param: any) => {
|
|
92516
|
+
// try {
|
|
92517
|
+
// const result = await MySwal.fire({
|
|
92518
|
+
// title: "Xác nhận",
|
|
92519
|
+
// html: "Bạn có chắc muốn thu hồi tin nhắn này?<br>Tin nhắn sẽ bị ẩn với tất cả mọi người.",
|
|
92520
|
+
// allowOutsideClick: false,
|
|
92521
|
+
// showCancelButton: true,
|
|
92522
|
+
// confirmButtonText: "Thu hồi",
|
|
92523
|
+
// cancelButtonText: "Hủy",
|
|
92524
|
+
// customClass: {
|
|
92525
|
+
// confirmButton: "btn btn-primary",
|
|
92526
|
+
// cancelButton: "btn btn-danger ms-1"
|
|
92527
|
+
// },
|
|
92528
|
+
// buttonsStyling: false
|
|
92529
|
+
// })
|
|
92530
|
+
// if (result.value) {
|
|
92531
|
+
// const data = { id: param.id, chatRoomId: groupChatUsers.id }
|
|
92532
|
+
// await recallMessageApi(data)
|
|
92533
|
+
// } else if (result.dismiss === MySwal.DismissReason.cancel) {
|
|
92534
|
+
// console.log("Hủy thu hồi tin nhắn")
|
|
92535
|
+
// }
|
|
92536
|
+
// } catch (error) {
|
|
92537
|
+
// console.error("Error recalling message:", error)
|
|
92538
|
+
// }
|
|
92539
|
+
// }, [recallMessageApi, groupChatUsers?.id])
|
|
92540
|
+
// const contextMenuClick = useCallback(async (val: any) => {
|
|
92541
|
+
// switch (val.id) {
|
|
92542
|
+
// case "copyImage":
|
|
92543
|
+
// try {
|
|
92544
|
+
// // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
|
|
92545
|
+
// const targetFile = clickedImageFile || val?.currentMessage?.path?.[0]
|
|
92546
|
+
// const imagePath = targetFile?.path
|
|
92547
|
+
// if (!imagePath) {
|
|
92548
|
+
// console.error('Không tìm thấy đường dẫn ảnh')
|
|
92549
|
+
// return
|
|
92550
|
+
// }
|
|
92551
|
+
// const imgUrl = `${CDN_URL_VIEW}/${imagePath}`
|
|
92552
|
+
// const response = await fetch(imgUrl)
|
|
92553
|
+
// const blob = await response.blob()
|
|
92554
|
+
// await navigator.clipboard.write([
|
|
92555
|
+
// new ClipboardItem({
|
|
92556
|
+
// [blob.type]: blob
|
|
92557
|
+
// })
|
|
92558
|
+
// ])
|
|
92559
|
+
// } catch (error) {
|
|
92560
|
+
// console.error('Lỗi khi copy ảnh:', error)
|
|
92561
|
+
// }
|
|
92562
|
+
// break
|
|
92563
|
+
// case "copyText":
|
|
92564
|
+
// navigator.clipboard.writeText(val?.currentMessage.msg)
|
|
92565
|
+
// break
|
|
92566
|
+
// case "reply":
|
|
92567
|
+
// setReplyMessage(val)
|
|
92568
|
+
// break
|
|
92569
|
+
// case "save":
|
|
92570
|
+
// handleDownloadClick(val.currentMessage)
|
|
92571
|
+
// break
|
|
92572
|
+
// case "delete":
|
|
92573
|
+
// handleDelete(val.currentMessage)
|
|
92574
|
+
// break
|
|
92575
|
+
// case "recall":
|
|
92576
|
+
// handleRecall(val.currentMessage)
|
|
92577
|
+
// break
|
|
92578
|
+
// default:
|
|
92579
|
+
// break
|
|
92580
|
+
// }
|
|
92581
|
+
// }, [clickedImageFile, handleDelete, handleDownloadClick, handleRecall])
|
|
92582
|
+
// const handleFocus = useCallback(() => {
|
|
92583
|
+
// editor.focus()
|
|
92584
|
+
// }, [editor])
|
|
92585
|
+
// const handleReply = useCallback((data: any) => {
|
|
92586
|
+
// handleFocus()
|
|
92587
|
+
// setReplyMessage({ id: "reply", currentMessage: data })
|
|
92588
|
+
// }, [handleFocus])
|
|
92589
|
+
// const handleEnterMultiSelectMode = useCallback((message: any) => {
|
|
92590
|
+
// setIsMultiSelectMode(true)
|
|
92591
|
+
// setSelectedMessages(new Set([message.id]))
|
|
92592
|
+
// }, [])
|
|
92593
|
+
// const handleExitMultiSelectMode = useCallback(() => {
|
|
92594
|
+
// setIsMultiSelectMode(false)
|
|
92595
|
+
// setSelectedMessages(new Set())
|
|
92596
|
+
// }, [])
|
|
92597
|
+
// const handleToggleMessageSelection = useCallback((messageId: string) => {
|
|
92598
|
+
// setSelectedMessages(prev => {
|
|
92599
|
+
// const newSet = new Set(prev)
|
|
92600
|
+
// if (newSet.has(messageId)) {
|
|
92601
|
+
// newSet.delete(messageId)
|
|
92602
|
+
// } else {
|
|
92603
|
+
// newSet.add(messageId)
|
|
92604
|
+
// }
|
|
92605
|
+
// return newSet
|
|
92606
|
+
// })
|
|
92607
|
+
// }, [])
|
|
92608
|
+
// const handleBatchDelete = useCallback(async () => {
|
|
92609
|
+
// if (selectedMessages.size === 0) { return }
|
|
92610
|
+
// MySwal.fire({
|
|
92611
|
+
// title: t("Confirm"),
|
|
92612
|
+
// html: `Bạn có chắc muốn xóa ${selectedMessages.size} tin nhắn đã chọn?`,
|
|
92613
|
+
// allowOutsideClick: false,
|
|
92614
|
+
// showCancelButton: true,
|
|
92615
|
+
// confirmButtonText: t("Delete"),
|
|
92616
|
+
// cancelButtonText: t("Cancel"),
|
|
92617
|
+
// customClass: {
|
|
92618
|
+
// confirmButton: "btn btn-primary",
|
|
92619
|
+
// cancelButton: "btn btn-danger ms-1"
|
|
92620
|
+
// },
|
|
92621
|
+
// buttonsStyling: false
|
|
92622
|
+
// }).then(async (result) => {
|
|
92623
|
+
// if (result.value) {
|
|
92624
|
+
// try {
|
|
92625
|
+
// const deletePromises = Array.from(selectedMessages).map(id => deleteMessageApi({ id, chatRoomId: groupChatUsers?.id })
|
|
92626
|
+
// )
|
|
92627
|
+
// await Promise.all(deletePromises)
|
|
92628
|
+
// handleExitMultiSelectMode()
|
|
92629
|
+
// } catch (error) {
|
|
92630
|
+
// console.error('Error deleting messages:', error)
|
|
92631
|
+
// }
|
|
92632
|
+
// }
|
|
92633
|
+
// })
|
|
92634
|
+
// }, [selectedMessages, deleteMessageApi, groupChatUsers?.id, handleExitMultiSelectMode, t])
|
|
92643
92635
|
// const handleBatchRecall = useCallback(async () => {
|
|
92644
92636
|
// if (selectedMessages.size === 0) { return }
|
|
92645
92637
|
// MySwal.fire({
|