MCPcopy Create free account
hub / github.com/datapane/datapane / copyOnce

Method copyOnce

web-components/shared/DPClipboard.ts:60–73  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

58 }
59
60 public static async copyOnce(text: string): Promise<void> {
61 /**
62 * Copy on the fly using the native `navigator` API -- useful in cases where it's inefficient to use Clipboard.js
63 * as it requires maintaining the text in memory before copying is triggered via a listener.
64 *
65 * Note that in Firefox and Safari this method will only work if part of a user action callback (e.g. button.onClick)
66 */
67 try {
68 await navigator.clipboard.writeText(text);
69 DPClipboard.onSuccess();
70 } catch (e) {
71 console.error("Error copying to clipboard: ", e);
72 }
73 }
74}

Callers

nothing calls this directly

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected