diff --git a/app/helpers/social_helper.rb b/app/helpers/social_helper.rb index c4d8b329..6925c259 100644 --- a/app/helpers/social_helper.rb +++ b/app/helpers/social_helper.rb @@ -13,4 +13,9 @@ module SocialHelper protocol: (APP_CONFIG["https"] ? :https : :http), ) end + + def answer_copy_content(answer) + # copy content template: "question - answer [link]" + "#{answer.question.content} - #{answer.content} [#{answer_share_url(answer)}]" + end end diff --git a/app/views/actions/_share.html.haml b/app/views/actions/_share.html.haml index 5fc3c26b..4e57c056 100644 --- a/app/views/actions/_share.html.haml +++ b/app/views/actions/_share.html.haml @@ -8,5 +8,8 @@ %a.dropdown-item{ href: telegram_share_url(answer), target: "_blank" } %i.fa.fa-fw.fa-telegram = t(".telegram") + %a.dropdown-item{ href: "#", data: { controller: :share, action: "share#copyToClipboard", share_copy_content_value: answer_copy_content(answer) } } + %i.fa.fa-fw.fa-solid.fa-copy + = t(".copy") %a.dropdown-item{ href: "#", data: { controller: :share, action: "share#share", share_url_value: answer_share_url(answer) } } = t(".other") diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 9c94c671..0b495cfc 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -79,6 +79,7 @@ en: pin: "Pin to Profile" unpin: "Unpin from Profile" share: + copy: "Copy to Clipboard" twitter: "Share on Twitter" tumblr: "Share on Tumblr" telegram: "Share on Telegram"