@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.js
CHANGED
|
@@ -91777,7 +91777,6 @@ const IconFileTypeColor = (props) => {
|
|
|
91777
91777
|
return jsxRuntime.jsx("img", { ...props, src: icon, style: { width: width ? width : 24, height: height ? height : 'auto', ...props.style } });
|
|
91778
91778
|
};
|
|
91779
91779
|
|
|
91780
|
-
const MySwal$1 = withReactContent(Swal);
|
|
91781
91780
|
const DateHeader = React.memo(({ label }) => (jsxRuntime.jsx("div", { className: "d-flex justify-content-center", children: jsxRuntime.jsx("div", { style: {
|
|
91782
91781
|
backgroundColor: "rgba(0,0,0,0.2)",
|
|
91783
91782
|
padding: "2px 15px",
|
|
@@ -91798,8 +91797,8 @@ const ADMINISTRATIVE_ITEMS = [
|
|
|
91798
91797
|
const ChatLog = (props) => {
|
|
91799
91798
|
// ** Props & Store
|
|
91800
91799
|
//const clipboard = useClipboard()
|
|
91801
|
-
|
|
91802
|
-
|
|
91800
|
+
useLexicalComposerContext();
|
|
91801
|
+
reactI18next.useTranslation();
|
|
91803
91802
|
useUploadFile();
|
|
91804
91803
|
const { typeChat, contactId, chatRoomId, active, messageByGroup, pinnedMessages, setScroll, checkScroll, pinMessageChatRoom, deleteMessageApi, recallMessageApi, get_message_by_group_cursor_api, getPinMessageChatRoomApi, deletePinMessage,
|
|
91805
91804
|
//updateGroupTagApi,
|
|
@@ -91875,8 +91874,8 @@ const ChatLog = (props) => {
|
|
|
91875
91874
|
React.useState(true);
|
|
91876
91875
|
const [expandedMessages, setExpandedMessages] = React.useState(new Set());
|
|
91877
91876
|
const [clickedImageFile, setClickedImageFile] = React.useState(null);
|
|
91878
|
-
|
|
91879
|
-
|
|
91877
|
+
React.useState(false);
|
|
91878
|
+
React.useState(new Set());
|
|
91880
91879
|
const BASE_CONTEXT_ITEMS = [
|
|
91881
91880
|
"reply", "share", "pin", "bookmark",
|
|
91882
91881
|
"selectMultiMessage", "detail", "other", "recall", "delete"
|
|
@@ -92511,7 +92510,7 @@ const ChatLog = (props) => {
|
|
|
92511
92510
|
backgroundImage: `url(${`${CDN_URL_VIEW}/${replyData?.path[0].path.trim()}`})`
|
|
92512
92511
|
} })), replyData?.type === "file" && (jsxRuntime.jsx("div", { style: { marginRight: 8 }, children: jsxRuntime.jsx(IconFileTypeColor, { fileType: replyData?.path?.[0]?.type, width: 35 }) })), jsxRuntime.jsxs("div", { className: "reply-content d-flex flex-column", children: [jsxRuntime.jsx("div", { className: "fw-bold", children: replyData?.createdByName }), jsxRuntime.jsx("div", { children: renderMessageReply(replyData?.type, replyData?.msg) })] })] }) }));
|
|
92513
92512
|
}, [renderMessageReply]);
|
|
92514
|
-
|
|
92513
|
+
React.useCallback(async (path) => {
|
|
92515
92514
|
const url = `${CDN_URL_VIEW}/${path}`;
|
|
92516
92515
|
try {
|
|
92517
92516
|
const response = await axios$1.get(url, { responseType: "blob" });
|
|
@@ -92528,167 +92527,160 @@ const ChatLog = (props) => {
|
|
|
92528
92527
|
console.error(error);
|
|
92529
92528
|
}
|
|
92530
92529
|
}, []);
|
|
92531
|
-
const handleDownloadClick =
|
|
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
|
-
|
|
92591
|
-
|
|
92592
|
-
|
|
92593
|
-
|
|
92594
|
-
|
|
92595
|
-
|
|
92596
|
-
|
|
92597
|
-
|
|
92598
|
-
|
|
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
|
-
|
|
92638
|
-
}, [
|
|
92639
|
-
|
|
92640
|
-
|
|
92641
|
-
|
|
92642
|
-
}, [
|
|
92643
|
-
|
|
92644
|
-
|
|
92645
|
-
|
|
92646
|
-
}, [])
|
|
92647
|
-
const
|
|
92648
|
-
|
|
92649
|
-
|
|
92650
|
-
|
|
92651
|
-
|
|
92652
|
-
|
|
92653
|
-
|
|
92654
|
-
|
|
92655
|
-
|
|
92656
|
-
|
|
92657
|
-
|
|
92658
|
-
|
|
92659
|
-
|
|
92660
|
-
|
|
92661
|
-
|
|
92662
|
-
}
|
|
92663
|
-
|
|
92664
|
-
|
|
92665
|
-
|
|
92666
|
-
|
|
92667
|
-
|
|
92668
|
-
|
|
92669
|
-
|
|
92670
|
-
|
|
92671
|
-
|
|
92672
|
-
|
|
92673
|
-
|
|
92674
|
-
|
|
92675
|
-
|
|
92676
|
-
|
|
92677
|
-
|
|
92678
|
-
|
|
92679
|
-
|
|
92680
|
-
|
|
92681
|
-
|
|
92682
|
-
|
|
92683
|
-
|
|
92684
|
-
|
|
92685
|
-
}
|
|
92686
|
-
catch (error) {
|
|
92687
|
-
console.error('Error deleting messages:', error);
|
|
92688
|
-
}
|
|
92689
|
-
}
|
|
92690
|
-
});
|
|
92691
|
-
}, [selectedMessages, deleteMessageApi, groupChatUsers?.id, handleExitMultiSelectMode, t]);
|
|
92530
|
+
// const handleDownloadClick = useCallback((param: any) => {
|
|
92531
|
+
// // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
|
|
92532
|
+
// const targetFile = clickedImageFile || param?.path?.[0]
|
|
92533
|
+
// if (targetFile?.path) {
|
|
92534
|
+
// downloadFile(targetFile.path)
|
|
92535
|
+
// } else {
|
|
92536
|
+
// console.error("No valid path found in param")
|
|
92537
|
+
// }
|
|
92538
|
+
// }, [clickedImageFile, downloadFile])
|
|
92539
|
+
// const handleDelete = useCallback(async (param: any) => {
|
|
92540
|
+
// try {
|
|
92541
|
+
// const result = await MySwal.fire({
|
|
92542
|
+
// title: "Xác nhận",
|
|
92543
|
+
// html: "Tin nhắn sẽ bị xóa vĩnh viễn. <br> Bạn có chắc muốn xóa?",
|
|
92544
|
+
// allowOutsideClick: false,
|
|
92545
|
+
// showCancelButton: true,
|
|
92546
|
+
// confirmButtonText: "Xoá",
|
|
92547
|
+
// cancelButtonText: "Hủy",
|
|
92548
|
+
// customClass: {
|
|
92549
|
+
// confirmButton: "btn btn-primary",
|
|
92550
|
+
// cancelButton: "btn btn-danger ms-1"
|
|
92551
|
+
// },
|
|
92552
|
+
// buttonsStyling: false
|
|
92553
|
+
// })
|
|
92554
|
+
// if (result.value) {
|
|
92555
|
+
// const data = { id: param.id, chatRoomId: groupChatUsers.id }
|
|
92556
|
+
// await deleteMessageApi(data)
|
|
92557
|
+
// } else if (result.dismiss === MySwal.DismissReason.cancel) {
|
|
92558
|
+
// console.log("Hủy xóa tin nhắn")
|
|
92559
|
+
// }
|
|
92560
|
+
// } catch (error) {
|
|
92561
|
+
// console.error("Error deleting message:", error)
|
|
92562
|
+
// }
|
|
92563
|
+
// }, [deleteMessageApi, groupChatUsers?.id])
|
|
92564
|
+
// const handleRecall = useCallback(async (param: any) => {
|
|
92565
|
+
// try {
|
|
92566
|
+
// const result = await MySwal.fire({
|
|
92567
|
+
// title: "Xác nhận",
|
|
92568
|
+
// 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.",
|
|
92569
|
+
// allowOutsideClick: false,
|
|
92570
|
+
// showCancelButton: true,
|
|
92571
|
+
// confirmButtonText: "Thu hồi",
|
|
92572
|
+
// cancelButtonText: "Hủy",
|
|
92573
|
+
// customClass: {
|
|
92574
|
+
// confirmButton: "btn btn-primary",
|
|
92575
|
+
// cancelButton: "btn btn-danger ms-1"
|
|
92576
|
+
// },
|
|
92577
|
+
// buttonsStyling: false
|
|
92578
|
+
// })
|
|
92579
|
+
// if (result.value) {
|
|
92580
|
+
// const data = { id: param.id, chatRoomId: groupChatUsers.id }
|
|
92581
|
+
// await recallMessageApi(data)
|
|
92582
|
+
// } else if (result.dismiss === MySwal.DismissReason.cancel) {
|
|
92583
|
+
// console.log("Hủy thu hồi tin nhắn")
|
|
92584
|
+
// }
|
|
92585
|
+
// } catch (error) {
|
|
92586
|
+
// console.error("Error recalling message:", error)
|
|
92587
|
+
// }
|
|
92588
|
+
// }, [recallMessageApi, groupChatUsers?.id])
|
|
92589
|
+
// const contextMenuClick = useCallback(async (val: any) => {
|
|
92590
|
+
// switch (val.id) {
|
|
92591
|
+
// case "copyImage":
|
|
92592
|
+
// try {
|
|
92593
|
+
// // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
|
|
92594
|
+
// const targetFile = clickedImageFile || val?.currentMessage?.path?.[0]
|
|
92595
|
+
// const imagePath = targetFile?.path
|
|
92596
|
+
// if (!imagePath) {
|
|
92597
|
+
// console.error('Không tìm thấy đường dẫn ảnh')
|
|
92598
|
+
// return
|
|
92599
|
+
// }
|
|
92600
|
+
// const imgUrl = `${CDN_URL_VIEW}/${imagePath}`
|
|
92601
|
+
// const response = await fetch(imgUrl)
|
|
92602
|
+
// const blob = await response.blob()
|
|
92603
|
+
// await navigator.clipboard.write([
|
|
92604
|
+
// new ClipboardItem({
|
|
92605
|
+
// [blob.type]: blob
|
|
92606
|
+
// })
|
|
92607
|
+
// ])
|
|
92608
|
+
// } catch (error) {
|
|
92609
|
+
// console.error('Lỗi khi copy ảnh:', error)
|
|
92610
|
+
// }
|
|
92611
|
+
// break
|
|
92612
|
+
// case "copyText":
|
|
92613
|
+
// navigator.clipboard.writeText(val?.currentMessage.msg)
|
|
92614
|
+
// break
|
|
92615
|
+
// case "reply":
|
|
92616
|
+
// setReplyMessage(val)
|
|
92617
|
+
// break
|
|
92618
|
+
// case "save":
|
|
92619
|
+
// handleDownloadClick(val.currentMessage)
|
|
92620
|
+
// break
|
|
92621
|
+
// case "delete":
|
|
92622
|
+
// handleDelete(val.currentMessage)
|
|
92623
|
+
// break
|
|
92624
|
+
// case "recall":
|
|
92625
|
+
// handleRecall(val.currentMessage)
|
|
92626
|
+
// break
|
|
92627
|
+
// default:
|
|
92628
|
+
// break
|
|
92629
|
+
// }
|
|
92630
|
+
// }, [clickedImageFile, handleDelete, handleDownloadClick, handleRecall])
|
|
92631
|
+
// const handleFocus = useCallback(() => {
|
|
92632
|
+
// editor.focus()
|
|
92633
|
+
// }, [editor])
|
|
92634
|
+
// const handleReply = useCallback((data: any) => {
|
|
92635
|
+
// handleFocus()
|
|
92636
|
+
// setReplyMessage({ id: "reply", currentMessage: data })
|
|
92637
|
+
// }, [handleFocus])
|
|
92638
|
+
// const handleEnterMultiSelectMode = useCallback((message: any) => {
|
|
92639
|
+
// setIsMultiSelectMode(true)
|
|
92640
|
+
// setSelectedMessages(new Set([message.id]))
|
|
92641
|
+
// }, [])
|
|
92642
|
+
// const handleExitMultiSelectMode = useCallback(() => {
|
|
92643
|
+
// setIsMultiSelectMode(false)
|
|
92644
|
+
// setSelectedMessages(new Set())
|
|
92645
|
+
// }, [])
|
|
92646
|
+
// const handleToggleMessageSelection = useCallback((messageId: string) => {
|
|
92647
|
+
// setSelectedMessages(prev => {
|
|
92648
|
+
// const newSet = new Set(prev)
|
|
92649
|
+
// if (newSet.has(messageId)) {
|
|
92650
|
+
// newSet.delete(messageId)
|
|
92651
|
+
// } else {
|
|
92652
|
+
// newSet.add(messageId)
|
|
92653
|
+
// }
|
|
92654
|
+
// return newSet
|
|
92655
|
+
// })
|
|
92656
|
+
// }, [])
|
|
92657
|
+
// const handleBatchDelete = useCallback(async () => {
|
|
92658
|
+
// if (selectedMessages.size === 0) { return }
|
|
92659
|
+
// MySwal.fire({
|
|
92660
|
+
// title: t("Confirm"),
|
|
92661
|
+
// html: `Bạn có chắc muốn xóa ${selectedMessages.size} tin nhắn đã chọn?`,
|
|
92662
|
+
// allowOutsideClick: false,
|
|
92663
|
+
// showCancelButton: true,
|
|
92664
|
+
// confirmButtonText: t("Delete"),
|
|
92665
|
+
// cancelButtonText: t("Cancel"),
|
|
92666
|
+
// customClass: {
|
|
92667
|
+
// confirmButton: "btn btn-primary",
|
|
92668
|
+
// cancelButton: "btn btn-danger ms-1"
|
|
92669
|
+
// },
|
|
92670
|
+
// buttonsStyling: false
|
|
92671
|
+
// }).then(async (result) => {
|
|
92672
|
+
// if (result.value) {
|
|
92673
|
+
// try {
|
|
92674
|
+
// const deletePromises = Array.from(selectedMessages).map(id => deleteMessageApi({ id, chatRoomId: groupChatUsers?.id })
|
|
92675
|
+
// )
|
|
92676
|
+
// await Promise.all(deletePromises)
|
|
92677
|
+
// handleExitMultiSelectMode()
|
|
92678
|
+
// } catch (error) {
|
|
92679
|
+
// console.error('Error deleting messages:', error)
|
|
92680
|
+
// }
|
|
92681
|
+
// }
|
|
92682
|
+
// })
|
|
92683
|
+
// }, [selectedMessages, deleteMessageApi, groupChatUsers?.id, handleExitMultiSelectMode, t])
|
|
92692
92684
|
// const handleBatchRecall = useCallback(async () => {
|
|
92693
92685
|
// if (selectedMessages.size === 0) { return }
|
|
92694
92686
|
// MySwal.fire({
|