Skip to content

Commit 648b6aa

Browse files
feat: ✨ Share button = copy to clipboard if no sharenav
1 parent fff67c1 commit 648b6aa

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

frontend/src/index.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,19 @@ function viewPaste(content: string, views: string, singleView: boolean) {
167167
addMessage("This is a single-view paste!")
168168
}
169169

170-
if (navigator.canShare) {
171-
show(shareButton)
172-
173-
shareButton.addEventListener("click", function () {
170+
show(shareButton)
171+
shareButton.addEventListener("click", function () {
172+
const url = window.location.toString()
173+
if (navigator.canShare) {
174174
navigator.share({
175175
title: "zer0bin paste",
176-
url: window.location.toString(),
176+
url: url,
177177
})
178-
})
179-
}
178+
} else {
179+
navigator.clipboard.writeText(url)
180+
addMessage("Copied URL to clipboard!")
181+
}
182+
})
180183

181184
disable(saveButton)
182185
disable(markdownButton)

0 commit comments

Comments
 (0)