1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-23 15:58:49 -05:00

[WO-323] Render HTML content in sandboxed iframe

This commit is contained in:
Tankred Hase 2014-05-08 16:32:46 +02:00
parent 4fc4b02c26
commit c272b4f937
3 changed files with 49 additions and 29 deletions

View File

@ -330,11 +330,15 @@ define(function(require) {
}; };
}); });
ngModule.directive('frameLoad', function() { ngModule.directive('frameLoad', function($parse, $sce, $timeout) {
return function(scope, elm) { return function(scope, elm, attrs) {
elm.bind('load', function() { scope.$watch(attrs.frameLoad, function(value) {
var frame = elm[0]; scope.html = undefined;
frame.height = frame.contentWindow.document.body.scrollHeight + 'px'; if (value) {
$timeout(function() {
scope.html = $sce.trustAsHtml(value);
});
}
}); });
}; };
}); });

View File

@ -87,13 +87,9 @@
} }
} }
.body { .working-wrapper {
flex-grow: 1; flex-grow: 1;
position: relative; position: relative;
margin-top: 1.75em;
line-height: 1.5em;
overflow-y: scroll;
user-select: text;
.working { .working {
@include scut-vcenter-tt; @include scut-vcenter-tt;
@ -106,6 +102,22 @@
vertical-align: middle; vertical-align: middle;
} }
} }
}
iframe {
flex-grow: 1;
margin-top: 1.75em;
width: 100%;
height: 100%;
border: none;
}
.body {
flex-grow: 1;
margin-top: 1.75em;
line-height: 1.5em;
overflow-y: scroll;
user-select: text;
.line { .line {
cursor: text; cursor: text;
@ -147,11 +159,6 @@
} }
} }
iframe {
flex-grow: 1;
width: 100%;
}
.reply-selection { .reply-selection {
.popover-content { .popover-content {
padding: 0; padding: 0;

View File

@ -1,4 +1,5 @@
<div class="view-read" ng-controller="ReadCtrl"> <div class="view-read" ng-controller="ReadCtrl">
<div class="headers"> <div class="headers">
<div class="controls"> <div class="controls">
<button ng-click="state.mailList.remove(state.mailList.selected)" class="btn-icon" title="Delete mail">&#xe005;</button> <button ng-click="state.mailList.remove(state.mailList.selected)" class="btn-icon" title="Delete mail">&#xe005;</button>
@ -43,21 +44,28 @@
<div ng-switch-default class="seperator-line"></div> <div ng-switch-default class="seperator-line"></div>
</div><!--/.attachments-wrapper--> </div><!--/.attachments-wrapper-->
<div class="body" ng-switch="state.mailList.selected === undefined || (state.mailList.selected.encrypted === false && state.mailList.selected.body !== undefined) || (state.mailList.selected.encrypted === true && state.mailList.selected.decrypted === true)"> <!-- Show working spinner -->
<div ng-switch-when="true"> <div class="working-wrapper"
ng-if="!html && state.mailList.selected !== undefined && (state.mailList.selected.body === undefined || (state.mailList.selected.encrypted && !state.mailList.selected.decrypted))">
<div class="working">
<span class="spinner"></span>
<strong ng-bind="(state.mailList.selected.decryptingBody) ? 'Decrypting...' : 'Loading...' "></strong>
</div><!--/.working-->
</div><!--/.working-wrapper-->
<!-- Render conversation as recursive text nodes --> <!-- Render html body in sandboxed iframe -->
<iframe ng-show="html" sandbox srcdoc="{{html}}"
frame-load="state.mailList.selected.html">
</iframe>
<!-- Render text body as colored conversation in recursive text nodes -->
<div class="body"
ng-if="!html && (state.mailList.selected === undefined || (state.mailList.selected.encrypted === false && state.mailList.selected.body !== undefined) || (state.mailList.selected.encrypted === true && state.mailList.selected.decrypted === true))">
<div ng-include="'tpl/text-node.html'" <div ng-include="'tpl/text-node.html'"
ng-if="node !== undefined" ng-if="node !== undefined"
ng-repeat="child in node.children track by $index" ng-repeat="child in node.children track by $index"
onload="node = child"> onload="node = child">
</div> </div>
</div><!--/ng-switch-when-->
<div class="working" ng-switch-default>
<span class="spinner"></span>
<strong ng-bind="(state.mailList.selected.loadingBody === true || state.mailList.selected.body === undefined || state.mailList.selected.body === null) ? 'Loading...' : 'Decrypting...'"></strong>
</div><!--/.working-->
</div><!--/.body--> </div><!--/.body-->
<!-- popovers --> <!-- popovers -->
@ -74,4 +82,5 @@
<li><button data-icon="&#xe015;" ng-click="state.writer.write(state.mailList.selected, null, true)">Forward</button></li> <li><button data-icon="&#xe015;" ng-click="state.writer.write(state.mailList.selected, null, true)">Forward</button></li>
</ul> </ul>
</div><!--/.reply-selection--> </div><!--/.reply-selection-->
</div><!--/.view-read--> </div><!--/.view-read-->