mirror of
https://github.com/moparisthebest/mail
synced 2024-12-23 15:58:49 -05:00
[WO-64] fix newline in reader and text parser in writer
This commit is contained in:
parent
5c7eb7052d
commit
4e6f9b9bbf
@ -15,7 +15,7 @@ define(function(require) {
|
||||
firstSelect = true;
|
||||
|
||||
emailDao = appController._emailDao;
|
||||
|
||||
if (emailDao) {
|
||||
emailDao.onIncomingMessage = function(email) {
|
||||
if (email.subject.indexOf(str.subjectPrefix) === -1) {
|
||||
return;
|
||||
@ -27,6 +27,8 @@ define(function(require) {
|
||||
notificationForEmail(email);
|
||||
});
|
||||
};
|
||||
chrome.notifications.onClicked.addListener(notificationClicked);
|
||||
}
|
||||
|
||||
function notificationClicked(uidString) {
|
||||
var email, uid = parseInt(uidString, 10);
|
||||
@ -43,7 +45,6 @@ define(function(require) {
|
||||
$scope.select(email);
|
||||
}
|
||||
}
|
||||
chrome.notifications.onClicked.addListener(notificationClicked);
|
||||
|
||||
//
|
||||
// scope functions
|
||||
@ -55,7 +56,13 @@ define(function(require) {
|
||||
}
|
||||
// split text only emails into parts for easier rendering
|
||||
if (!email.html && typeof email.body === 'string') {
|
||||
email.bodyDisplayParts = email.body.split('\n');
|
||||
email.bodyDisplayParts = [];
|
||||
var parts = email.body.split('\n');
|
||||
parts.forEach(function(part) {
|
||||
if (part.trim().length > 0) {
|
||||
email.bodyDisplayParts.push(part);
|
||||
}
|
||||
});
|
||||
}
|
||||
$scope.selected = email;
|
||||
// set selected in parent scope ro it can be displayed in the read view
|
||||
|
@ -6,6 +6,7 @@ define(function(require) {
|
||||
aes = require('cryptoLib/aes-cbc'),
|
||||
util = require('cryptoLib/util'),
|
||||
str = require('js/app-config').string,
|
||||
$ = require('jquery'),
|
||||
emailDao;
|
||||
|
||||
//
|
||||
@ -129,9 +130,8 @@ define(function(require) {
|
||||
return;
|
||||
}
|
||||
|
||||
body = $scope.body;
|
||||
// remove generated html from body
|
||||
body = parseBody(body);
|
||||
body = parseBody($scope.body);
|
||||
|
||||
email = {
|
||||
to: [], // list of receivers
|
||||
@ -165,23 +165,12 @@ define(function(require) {
|
||||
};
|
||||
|
||||
function parseBody(body) {
|
||||
function has(substr) {
|
||||
return (body.indexOf(substr) !== -1);
|
||||
}
|
||||
while (has('<div><br>')) {
|
||||
body = body.replace('<div><br>', '\n');
|
||||
}
|
||||
while (has('<div>')) {
|
||||
body = body.replace('<div>', '\n');
|
||||
}
|
||||
while (has('<br>')) {
|
||||
body = body.replace('<br>', '\n');
|
||||
}
|
||||
while (has('</div>')) {
|
||||
body = body.replace('</div>', '');
|
||||
}
|
||||
var regex = /(\r\n|\n|\r)/gm;
|
||||
|
||||
return body;
|
||||
var text = body.replace(regex, '').split('<div><br>').join('\n').split('<div>').join('\n').split('<br>').join('\n');
|
||||
var html = '<p>' + text + '</p>';
|
||||
|
||||
return $(html).text();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -24,10 +24,6 @@
|
||||
<iframe ng-switch-when="true" sandbox="allow-same-origin" srcdoc="{{selected.body}}" seamless frame-load></iframe>
|
||||
|
||||
<!-- Render parts of a text only email in paragraphs for easier styling -->
|
||||
<p ng-repeat="part in selected.bodyDisplayParts track by $index">
|
||||
<span ng-switch="part.length !== 0">
|
||||
<span ng-switch-when="true">{{part}}</span>
|
||||
</span>
|
||||
</p>
|
||||
<p ng-repeat="part in selected.bodyDisplayParts track by $index">{{part}}</p>
|
||||
</div><!--/.body-->
|
||||
</div><!--/.view-read-->
|
Loading…
Reference in New Issue
Block a user