1448, add clipboard controller

This commit is contained in:
Ahmed Ejaz 2023-11-12 16:03:59 +05:00 committed by Andreas Nedbal
parent ac3dc12ee3
commit 03d41ec8b1
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,14 @@
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static values = {
copy: String
}
declare readonly copyValue: string;
async copy(){
await navigator.clipboard.writeText(this.copyValue)
}
}

View File

@ -14,6 +14,7 @@ import ToastController from "retrospring/controllers/toast_controller";
import PwaBadgeController from "retrospring/controllers/pwa_badge_controller";
import NavigationController from "retrospring/controllers/navigation_controller";
import ShareController from "retrospring/controllers/share_controller";
import ClipboardController from "retrospring/controllers/clipboard_controller";
/**
* This module sets up Stimulus and our controllers
@ -39,4 +40,5 @@ export default function (): void {
window['Stimulus'].register('theme', ThemeController);
window['Stimulus'].register('toast', ToastController);
window['Stimulus'].register('share', ShareController);
window['Stimulus'].register('clipboard', ClipboardController)
}