mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Fix mailto: that i broke in #484
This commit is contained in:
parent
ec24392664
commit
54107ca937
4 changed files with 36 additions and 24 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { encodeHtml } from 'Common/Html';
|
||||
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
|
|
@ -332,13 +333,31 @@ export class EmailModel extends AbstractModel {
|
|||
|
||||
/**
|
||||
* @param {boolean} friendlyView = false
|
||||
* @param {boolean} wrapWithLink = false
|
||||
* @returns {string}
|
||||
*/
|
||||
toLine(friendlyView) {
|
||||
let result = this.email;
|
||||
return (result && this.name)
|
||||
? (friendlyView ? this.name : '"' + this.name + '" <' + result + '>')
|
||||
: result;
|
||||
toLine(friendlyView, wrapWithLink) {
|
||||
let result = this.email,
|
||||
name = this.name,
|
||||
toLink = text =>
|
||||
'<a href="mailto:'
|
||||
+ encodeHtml(result) + (name ? '?to=' + encodeURIComponent('"' + name + '" <' + result + '>') : '')
|
||||
+ '" target="_blank" tabindex="-1">'
|
||||
+ encodeHtml(text || result)
|
||||
+ '</a>';
|
||||
if (result) {
|
||||
if (name) {
|
||||
result = friendlyView
|
||||
? (wrapWithLink ? toLink(name) : name)
|
||||
: (wrapWithLink
|
||||
? encodeHtml('"' + name + '" <') + toLink() + encodeHtml('>')
|
||||
: '"' + name + '" <' + result + '>'
|
||||
);
|
||||
} else if (wrapWithLink) {
|
||||
result = toLink();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static splitEmailLine(line) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue