Skip to content

Commit 93c23b8

Browse files
committed
docs(clipboard): add programmatic copy example via $tsui.copy
1 parent 64398ae commit 93c23b8

5 files changed

Lines changed: 503 additions & 415 deletions

File tree

app/Enums/Examples/V3/Ui/Clipboard.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ class Clipboard
4848
:icons="['copy' => 'pencil', 'copied' => 'check']"/>
4949
HTML;
5050

51+
public const string PROGRAMMATIC = <<<'HTML'
52+
<x-button x-on:click="$tsui.copy('TallStackUI')">
53+
Copy
54+
</x-button>
55+
HTML;
56+
57+
public const string PROGRAMMATIC_EVENT = <<<'JS'
58+
// $tsui.copy resolves to a boolean reporting whether the copy succeeded.
59+
const copied = await window.$tsui.copy('TallStackUI');
60+
61+
// It also dispatches the `ts-ui:copy` event on window with the copied text.
62+
window.addEventListener('ts-ui:copy', (event) => {
63+
alert(`Copied: ${event.detail.text}`); // 'Copied: TallStackUI'
64+
});
65+
JS;
66+
5167
public const string CUSTOMIZATION = <<<'HTML'
5268
TallStackUi::customize()
5369
->clipboard()

0 commit comments

Comments
 (0)