|
|
|
@ -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("<img src='" + e.target.result + "' />");
|
|
|
|
|
} 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("<iframe src='" + e.target.result + "' width='100%' height='100%' style=\"border:none\"></iframe>");
|
|
|
|
|
} else if (file.type.startsWith('audio/')) {
|
|
|
|
|
win.document.write("<audio controls src='" + e.target.result + "'></audio>");
|
|
|
|
|
} else if (file.type.startsWith('video/')) {
|
|
|
|
|
win.document.write("<video controls src='" + e.target.result + "'></video>");
|
|
|
|
|
} else {
|
|
|
|
|
win.document.write("<p>Preview not available for this file type</p>");
|
|
|
|
|
}
|
|
|
|
|
// win.document.write("<iframe src='" + dataURL + "' width='100%' height='100%' style=\"border:none\"></iframe>");
|
|
|
|
|
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);
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|