Skip to content

Commit b36b887

Browse files
committed
Merge branch 'patch-5' of https://github.com/valentinoli/share-api-polyfill into valentinoli-patch-5
2 parents 5ad885e + f6bfbd4 commit b36b887

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
@@ -534,7 +534,7 @@ navigator.share = navigator.share || (function () {
534534
const payload = encodeURIComponent(text + ': ' + url);
535535
switch (tool.dataset.tool) {
536536
case 'copy': {
537-
navigator.clipboard.writeText(url);
537+
navigator.clipboard.writeText(`${title}\n${data.text || ''}\n${url}`);
538538
break;
539539
}
540540
case 'print': {
@@ -545,12 +545,15 @@ navigator.share = navigator.share || (function () {
545545
break;
546546
}
547547
case 'email': {
548-
window.open("mailto:" + '' + '?subject=' + title + '&body=' + url);
548+
// %0D%0A is newline
549+
const emailText = `${text}%0D%0A`
550+
const mailto = `mailto:?subject=${title}&body=${emailText}${url}`
551+
window.open(mailto);
549552
break;
550553
}
551554
case 'sms': {
552555
// window.open(toolsUrls.sms(title + ': \n' + url));
553-
location.href = `sms:${language.selectSms}?&body=${title}: ${url}`;
556+
location.href = `sms:${language.selectSms}?&body=${title}: ${data.text || ''} ${url}`;
554557
// window.open("sms:"+''+'?subject='+title+'&body='+url);
555558
break;
556559
}

0 commit comments

Comments
 (0)