Easiest way to Copy to Clipboard in React

preview_player
Показать описание
Learn how to copy text and image data to a visitor's clipboard with the Clipboard API.

We'll walk through how to write both text and image data to a clipboard using the writeText and write methods and even learn how to read data using readText and read methods. Then we'll see how we can provide backwards compatibility with execCommand and library copy-to-clipboard.

🧰 Resources

#colbyfayock #react #ux #webdevelopment
Рекомендации по теме
Комментарии
Автор

Love this tutorial. Direct, instructive, and straight to the point. Good stuff, Colby!

MikeBifulco
Автор

So nice! I definitely didn't know about copying images!

JamesQQuick
Автор

Subscribed in 5 sec of scrolling your channel!
Very helpful for a beginner to get to know whats possible in react.

denisblack
Автор

Hi Colby, I have an issue while pasting the clipboard Item. The clipboardItem is
const clipboardItem = new window.ClipboardItem({
"text/plain": blobPlainText,
"text/html": blobHTML,
});


This is to support rich text and plain text.
However when I paste the content in One Note. There are two Froms which come in One note as source. This only happens in one note application.
Ex. (after pasting in one note)

blobHtmlText display here
From <website name>

From<website name>

How do we restrict it to one.

debarshipal
Автор

so why you prefer using the browser clipboard directly instead of using a package

albin
Автор

the Clipboard did not work on the Smartphone, it returns the error "undefined". On the computer it works normally. Project Next.js v12.1.5

lucasdeandradeoficial
Автор

Your tutorials are so useful and necessary 🫡

nemeziz_prime