From f3009ee781bc5495c083c5ad57bbe6a499339b45 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Wed, 10 Aug 2022 11:47:15 +0200 Subject: [PATCH] Resolve #484 --- dev/Component/EmailAddresses.js | 2 +- dev/Model/Email.js | 43 ++++----------------------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/dev/Component/EmailAddresses.js b/dev/Component/EmailAddresses.js index 316d06936..afc294ad2 100644 --- a/dev/Component/EmailAddresses.js +++ b/dev/Component/EmailAddresses.js @@ -262,7 +262,7 @@ export class EmailAddressesComponent { if (v.obj) { let li = createElement('li',{title:v.obj.toLine(),draggable:'true'}), el = createElement('span'); - el.append(v.obj.toLine(true, false, true)); + el.append(v.obj.toLine(true)); li.append(el); el = createElement('a',{href:'#', class:'ficon'}); diff --git a/dev/Model/Email.js b/dev/Model/Email.js index 6502e105e..9edd51477 100644 --- a/dev/Model/Email.js +++ b/dev/Model/Email.js @@ -1,4 +1,3 @@ -import { encodeHtml } from 'Common/Html'; import { AbstractModel } from 'Knoin/AbstractModel'; @@ -333,45 +332,13 @@ export class EmailModel extends AbstractModel { /** * @param {boolean} friendlyView = false - * @param {boolean=} wrapWithLink = false - * @param {boolean=} useEncodeHtml = false * @returns {string} */ - toLine(friendlyView, wrapWithLink, useEncodeHtml) { - let result = '', - toLink = (to, txt) => '' + encodeHtml(txt) + ''; - if (this.email) { - if (friendlyView && this.name) { - result = wrapWithLink - ? toLink( - encodeHtml(this.email) + '?to=' + encodeURIComponent('"' + this.name + '" <' + this.email + '>'), - this.name - ) - : (useEncodeHtml ? encodeHtml(this.name) : this.name); - } else { - result = this.email; - if (this.name) { - if (wrapWithLink) { - result = - encodeHtml('"' + this.name + '" <') - + toLink( - encodeHtml(this.email) + '?to=' + encodeURIComponent('"' + this.name + '" <' + this.email + '>'), - result - ) - + encodeHtml('>'); - } else { - result = '"' + this.name + '" <' + result + '>'; - if (useEncodeHtml) { - result = encodeHtml(result); - } - } - } else if (wrapWithLink) { - result = toLink(encodeHtml(this.email), this.email); - } - } - } - - return result; + toLine(friendlyView) { + let result = this.email; + return (result && this.name) + ? (friendlyView ? this.name : '"' + this.name + '" <' + result + '>') + : result; } static splitEmailLine(line) {