estevanmaito / sharect

🔗 A lightweight JavaScript library to let users share their text selections to social networks.

Home Page:https://estevanmaito.github.io/sharect/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Email sharing please

dlewand691 opened this issue · comments

Describe the solution you'd like
Would like to be able to share via email with the subject line auto-populated with link to page and message auto-populated with selected text.

This can already be done using the method appendCustomShareButtons

Here's an example using a random icon, and a link that creates an email with a placeholder email address, a subject (in this case, the page title, window.document.title) and the body text containing the selected text and link.

Sharect.appendCustomShareButtons([{
  icon: '<?xml version="1.0" encoding="iso-8859-1"?><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24" height="24" viewBox="0 0 489.776 489.776" style="enable-background:new 0 0 489.776 489.776;" xml:space="preserve"><g><path d="M469.075,64.488h-448.2c-10.3,0-18.8,7.5-20.5,17.3c-0.6,2.4-0.3,322.7-0.3,322.7c0,11.4,9.4,20.8,20.8,20.8h447.1 c11.4,0,20.8-8.3,21.8-19.8v-320.2C489.875,73.788,480.475,64.488,469.075,64.488z M404.275,106.088l-159.8,114.4l-159.8-114.4 H404.275z M40.675,384.788v-259.9l192.4,137.2c7.8,6.3,17.2,4.4,22.9,0l192.4-137.8v260.5L40.675,384.788L40.675,384.788z"/></g></svg>',
  url: `mailto:email?subject=${window.document.title}&body=TEXT_SELECTION%20PAGE_URL`
}]).init()

Let me know if it solves your problem.