From 501f594a0af59a0cf56a62f731bc627a078045f0 Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Sat, 23 Nov 2024 14:39:54 +0100 Subject: [PATCH] Split paste into addr field by commas --- webmail/webmail.js | 17 +++++++++++++++++ webmail/webmail.ts | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/webmail/webmail.js b/webmail/webmail.js index c859276..a65e440 100644 --- a/webmail/webmail.js +++ b/webmail/webmail.js @@ -2862,6 +2862,23 @@ const compose = (opts, listMailboxes) => { }, function change() { autosizeElem.dataset.value = inputElem.value; fetchRecipientSecurity(); + }, function paste(e) { + const data = e.clipboardData?.getData('text/plain'); + if (typeof data !== 'string' || data === '') { + return; + } + const split = data.split(','); + if (split.length <= 1) { + return; + } + autosizeElem.dataset.value = inputElem.value = split[0]; + let last; + for (const rest of split.splice(1)) { + last = newAddrView(rest.trim(), isRecipient, views, btn, cell, row, single); + } + last.input.focus(); + e.preventDefault(); + e.stopPropagation(); }), securityBar = dom.span(css('securitybar', { margin: '0 1px', borderBottom: '1.5px solid', diff --git a/webmail/webmail.ts b/webmail/webmail.ts index d90f1cc..af25bbc 100644 --- a/webmail/webmail.ts +++ b/webmail/webmail.ts @@ -1785,6 +1785,24 @@ const compose = (opts: ComposeOptions, listMailboxes: listMailboxes) => { autosizeElem.dataset.value = inputElem.value fetchRecipientSecurity() }, + function paste(e: ClipboardEvent) { + const data = e.clipboardData?.getData('text/plain') + if (typeof data !== 'string' || data === '') { + return + } + const split = data.split(',') + if (split.length <= 1) { + return + } + autosizeElem.dataset.value = inputElem.value = split[0] + let last + for (const rest of split.splice(1)) { + last = newAddrView(rest.trim(), isRecipient, views, btn, cell, row, single) + } + last!!.input.focus() + e.preventDefault() + e.stopPropagation() + }, ), securityBar=dom.span( css('securitybar', {