mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 04:06:17 +02:00
feat: add email share
This commit is contained in:
@@ -104,6 +104,8 @@
|
||||
"watch.title": "Be notified of new replies in this topic",
|
||||
"unwatch.title": "Stop watching this topic",
|
||||
"share-this-post": "Share this Post",
|
||||
"share-mail-subject": "Check out this post on \"%1\"",
|
||||
"share-mail-body": "I thought you might be interested in this post: %1",
|
||||
"watching": "Watching",
|
||||
"not-watching": "Not Watching",
|
||||
"ignoring": "Ignoring",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('share', ['hooks'], function (hooks) {
|
||||
define('share', ['hooks', 'translator'], function (hooks, translator) {
|
||||
const share = {};
|
||||
const baseUrl = window.location.protocol + '//' + window.location.host;
|
||||
|
||||
@@ -69,6 +69,16 @@ define('share', ['hooks'], function (hooks) {
|
||||
return openShare(mastodon_url, postUrl, 626, 760);
|
||||
});
|
||||
|
||||
addHandler('[component="share/email"]', async function () {
|
||||
const postUrl = getPostUrl($(this));
|
||||
const [subject, body] = await translator.translateKeys([
|
||||
translator.compile('topic:share-mail-subject', config.siteTitle),
|
||||
translator.compile('topic:share-mail-body', postUrl),
|
||||
]);
|
||||
const mailtoUrl = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
|
||||
window.location.href = mailtoUrl;
|
||||
});
|
||||
|
||||
hooks.fire('action:share.addHandlers', { openShare: openShare });
|
||||
};
|
||||
|
||||
|
||||
@@ -45,6 +45,11 @@ social.getPostSharing = async function () {
|
||||
name: 'Mastodon',
|
||||
class: 'fa-brands fa-mastodon',
|
||||
},
|
||||
{
|
||||
id: 'email',
|
||||
name: 'Email',
|
||||
class: 'fa-regular fa-envelope',
|
||||
},
|
||||
];
|
||||
networks = await plugins.hooks.fire('filter:social.posts', networks);
|
||||
networks.forEach((network) => {
|
||||
|
||||
Reference in New Issue
Block a user