Skip to content

Commit

Permalink
feat: ✨ Share button = copy to clipboard if no sharenav
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatOneCalculator committed Apr 4, 2022
1 parent fff67c1 commit 648b6aa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,19 @@ function viewPaste(content: string, views: string, singleView: boolean) {
addMessage("This is a single-view paste!")
}

if (navigator.canShare) {
show(shareButton)

shareButton.addEventListener("click", function () {
show(shareButton)
shareButton.addEventListener("click", function () {
const url = window.location.toString()
if (navigator.canShare) {
navigator.share({
title: "zer0bin paste",
url: window.location.toString(),
url: url,
})
})
}
} else {
navigator.clipboard.writeText(url)
addMessage("Copied URL to clipboard!")
}
})

disable(saveButton)
disable(markdownButton)
Expand Down

0 comments on commit 648b6aa

Please sign in to comment.