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); + }) + }, }; /**