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

Method constructor

web-components/shared/DPClipboard.ts:16–33  ·  view source on GitHub ↗
(btn: CopyBtn, options: ClipboardOptions)

Source from the content-addressed store, hash-verified

14 private clip: ClipboardJS;
15
16 public constructor(btn: CopyBtn, options: ClipboardOptions) {
17 /**
18 * btn: The button to bind the copy action to
19 * options: Either the raw text to write to clipboard, or the input field whose value should be used
20 */
21 this.clip = new ClipboardJS(btn, {
22 text() {
23 const textToCopy = options.text
24 ? options.text
25 : DPClipboard.getFieldValue(options.fieldId);
26 return textToCopy;
27 },
28 });
29 this.clip.on("error", () =>
30 console.error("An error occurred while copying to clipboard"),
31 );
32 this.clip.on("success", DPClipboard.onSuccess);
33 }
34
35 public destroy() {
36 this.clip.destroy();

Callers

nothing calls this directly

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected