mirror of https://github.com/moparisthebest/mail
rendering mail content in 2nd sandboxed iframe works
This commit is contained in:
parent
55a237e6be
commit
32cc6b10e8
|
@ -52,3 +52,25 @@ div#sandboxDiv iframe {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div#readViewContent ul {
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
li#bodyItem {
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mailContentFrame {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 2000px;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 8pt;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
|
@ -48,19 +48,20 @@
|
||||||
|
|
||||||
} else if (tryHtml && emailBody.indexOf('</') !== -1) {
|
} else if (tryHtml && emailBody.indexOf('</') !== -1) {
|
||||||
// render html email inside a sandboxed iframe
|
// render html email inside a sandboxed iframe
|
||||||
var iframe = page.find('#idMailContent'),
|
var iframe = page.find('#mailContentFrame');
|
||||||
iframeDoc = iframe[0].contentDocument || iframe[0].contentWindow.document;
|
|
||||||
|
|
||||||
iframe.load(function() {
|
iframe.load(function() {
|
||||||
// resize
|
// set listener for the answering call, which return the document height
|
||||||
var newheight = iframeDoc.body.scrollHeight;
|
window.onmessage = function(e) {
|
||||||
var newwidth = iframeDoc.body.scrollWidth;
|
// resize
|
||||||
iframe[0].height = (newheight) + 'px';
|
var newheight = e.data;
|
||||||
iframe[0].width = (newwidth) + 'px';
|
//var newwidth = iframeDoc.body.scrollWidth;
|
||||||
});
|
iframe[0].height = (newheight) + 'px';
|
||||||
|
//iframe[0].width = (newwidth) + 'px';
|
||||||
|
};
|
||||||
|
|
||||||
iframeDoc.write(emailBody);
|
// send email body to content frame
|
||||||
iframeDoc.close();
|
document.getElementById('mailContentFrame').contentWindow.postMessage(emailBody, '*');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sandbox": {
|
"sandbox": {
|
||||||
"pages": ["sandbox.html"],
|
"pages": ["sandbox.html", "mail-content.html"],
|
||||||
"content_security_policy": "sandbox allow-scripts; default-src 'self'; object-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'"
|
"content_security_policy": "sandbox allow-scripts; default-src 'self'; object-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src *"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
<a href="#accounts/<%- account %>/folders/<%- folder %>/reply/<%- id %>" data-role="button" data-icon="back" data-iconpos="right" class="ui-btn-right">Reply</a>
|
<a href="#accounts/<%- account %>/folders/<%- folder %>/reply/<%- id %>" data-role="button" data-icon="back" data-iconpos="right" class="ui-btn-right">Reply</a>
|
||||||
</div><!-- /header -->
|
</div><!-- /header -->
|
||||||
|
|
||||||
<div data-role="content">
|
<div data-role="content" id="readViewContent">
|
||||||
<ul data-role="listview" data-theme="d" data-divider-theme="d" id="idEmailList" data-mini="true">
|
<ul data-role="listview" data-theme="d" data-divider-theme="d" id="idEmailList" data-mini="true">
|
||||||
|
|
||||||
<li style="border: 0px">
|
<li style="border: 0px">
|
||||||
|
@ -21,9 +21,9 @@
|
||||||
<p id="idMailDate"><%- sentDate %></p>
|
<p id="idMailDate"><%- sentDate %></p>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li id="bodyItem" style="background-color: #FFFFFF">
|
<li id="bodyItem">
|
||||||
<div style="font-size: 8pt; font-weight: normal">
|
<div id="mailContentDiv">
|
||||||
<iframe id="idMailContent" sandbox="allow-same-origin" width="100%" height="100%" frameborder="0" scrolling="no"></iframe>
|
<iframe src="mail-content.html" sandbox="allow-scripts" id="mailContentFrame" frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue