Skip to content

Commit f6bfbd4

Browse files
authored
fix: add text to copy, sms, and email (#64)
1 parent 7d61bcf commit f6bfbd4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/share.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ navigator.share = navigator.share || (function () {
533533
const payload = text + ': ' + url;
534534
switch (tool.dataset.tool) {
535535
case 'copy': {
536-
navigator.clipboard.writeText(url);
536+
navigator.clipboard.writeText(`${title}\n${data.text || ''}\n${url}`);
537537
break;
538538
}
539539
case 'print': {
@@ -544,12 +544,15 @@ navigator.share = navigator.share || (function () {
544544
break;
545545
}
546546
case 'email': {
547-
window.open("mailto:" + '' + '?subject=' + title + '&body=' + url);
547+
// %0D%0A is newline
548+
const emailText = `${text}%0D%0A`
549+
const mailto = `mailto:?subject=${title}&body=${emailText}${url}`
550+
window.open(mailto);
548551
break;
549552
}
550553
case 'sms': {
551554
// window.open(toolsUrls.sms(title + ': \n' + url));
552-
location.href = `sms:${language.selectSms}?&body=${title}: ${url}`;
555+
location.href = `sms:${language.selectSms}?&body=${title}: ${data.text || ''} ${url}`;
553556
// window.open("sms:"+''+'?subject='+title+'&body='+url);
554557
break;
555558
}

0 commit comments

Comments
 (0)