Published
Edited
Sep 18, 2021
Importers
24 stars
Insert cell
Insert cell
Insert cell
Copier("Click me!", {value: "Hello, world!"})
Insert cell
Copier([
["1", "I have eaten the plums that were in the icebox"],
["2", "and which you were probably saving for breakfast"],
["3", "Forgive me they were delicious so sweet and so cold"]
], {label: "Snippets"})
Insert cell
Insert cell
{
let count = 0;
return Object.assign(
html`<button>Click me to copy text!`,
{onclick: () => pbcopy(`Hello, world! ${++count}`)}
);
}
Insert cell
pbcopy = text => navigator.clipboard.writeText(text)
Insert cell
function Copier(content = "Copy code", options) {
if (Array.isArray(content)) content = Array.from(content, ([key, value]) => [key, () => (pbcopy(value), value)]);
return Inputs.button(content, {...options, reduce: (value) => (pbcopy(value), value)});
}
Insert cell
copy = pbcopy // Deprecated alias
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more