From e7f2582f59b62ce8902350773d57cc0e756696f6 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Sun, 12 Nov 2023 02:46:41 +0500 Subject: [PATCH] #1448, add copyToClipboard controller action --- .../retrospring/controllers/share_controller.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/javascript/retrospring/controllers/share_controller.ts b/app/javascript/retrospring/controllers/share_controller.ts index c1b5d350..e48daceb 100644 --- a/app/javascript/retrospring/controllers/share_controller.ts +++ b/app/javascript/retrospring/controllers/share_controller.ts @@ -5,12 +5,14 @@ export default class extends Controller { static values = { url: String, text: String, - title: String + title: String, + copyContent: String }; declare readonly urlValue: string; declare readonly textValue: string; declare readonly titleValue: string; + declare readonly copyContentValue: string; share() { let shareConfiguration = {}; @@ -42,4 +44,8 @@ export default class extends Controller { }) .catch(noop); } + + async copyToClipboard(){ + await navigator.clipboard.writeText(this.copyContentValue) + } }