From 7ec40fb66966135a9c4c6646e6ea83eccaefeccc Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 2 Dec 2024 11:40:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=89=8D=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Online/Input/EmailEditorPopup.jsx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/views/Conversations/Online/Input/EmailEditorPopup.jsx b/src/views/Conversations/Online/Input/EmailEditorPopup.jsx index ae0963c..7250abb 100644 --- a/src/views/Conversations/Online/Input/EmailEditorPopup.jsx +++ b/src/views/Conversations/Online/Input/EmailEditorPopup.jsx @@ -296,6 +296,42 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, fromOrder, toEma newFileList.splice(index, 1); setFileList(newFileList); }, + onPreview: (file) => { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onloadend = (e) => { + var dataURL = e.target.result; + var win = window.open("", "_blank"); + if (file.type.startsWith('image/')) { + win.document.write(""); + } else if (file.type.startsWith('text/') || file.type === 'application/html' || file.type === 'application/xhtml+xml') { + var iframe = win.document.createElement('iframe'); + iframe.srcdoc = e.target.result; + iframe.style.width = '100%'; + iframe.style.height = '100%'; + iframe.style.border = 'none'; + win.document.body.appendChild(iframe); + } else if (file.type === 'application/pdf') { + win.document.write(""); + } else if (file.type.startsWith('audio/')) { + win.document.write(""); + } else if (file.type.startsWith('video/')) { + win.document.write(""); + } else { + win.document.write("

Preview not available for this file type

"); + } + // win.document.write(""); + resolve(reader.result) + }; + if (file.type.startsWith('text/') || file.type === 'application/html' || file.type === 'application/xhtml+xml') { + reader.readAsText(file); + } else { + reader.readAsDataURL(file); + } + // reader.readAsDataURL(file); + reader.onerror = (error) => reject(error); + }) + }, }; /**