copy to clipboard instead of downloading an image
This commit is contained in:
@@ -161,7 +161,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
Screenshot the house:
|
Screenshot the house:
|
||||||
<button class="button" id="screenshot-house">Screenshot</button>
|
<button class="button" id="screenshot-house">copy to clipboard</button>
|
||||||
</p>
|
</p>
|
||||||
</details>
|
</details>
|
||||||
<svg class="round-svg" xmlns="http://www.w3.org/2000/svg">
|
<svg class="round-svg" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
|||||||
18
main.ts
18
main.ts
@@ -83,12 +83,20 @@ const screenshotHouseButton = document.querySelector('#screenshot-house')
|
|||||||
if (screenshotHouseButton) {
|
if (screenshotHouseButton) {
|
||||||
screenshotHouseButton.addEventListener('click', async () => {
|
screenshotHouseButton.addEventListener('click', async () => {
|
||||||
const house = document.querySelector('#thinking-people-system')
|
const house = document.querySelector('#thinking-people-system')
|
||||||
if (house) {
|
if (!house) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const png = await domToPng(house)
|
const png = await domToPng(house)
|
||||||
const a = document.createElement('a')
|
|
||||||
a.href = png
|
try {
|
||||||
a.download = 'thinking-people-system.png'
|
const response = await fetch(png)
|
||||||
a.click()
|
const blob = await response.blob()
|
||||||
|
await navigator.clipboard.write([
|
||||||
|
new ClipboardItem({ [blob.type]: blob })
|
||||||
|
])
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
Screenshot the house:
|
Screenshot the house:
|
||||||
<button class="button" id="screenshot-house">Screenshot</button>
|
<button class="button" id="screenshot-house">copy to clipboard</button>
|
||||||
</p>
|
</p>
|
||||||
</details>
|
</details>
|
||||||
<svg class="round-svg" xmlns="http://www.w3.org/2000/svg">
|
<svg class="round-svg" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
|||||||
Reference in New Issue
Block a user