Created
November 3, 2023 12:50
-
-
Save IharKrasnik/43c005c30ba72f57f38062defab40fc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- This code reads images and gifs on clipboard paste | |
| Use it for your rich text editors so your users can edit content fast --> | |
| <script> | |
| import { uploadFile } from 'yourApiLib'; | |
| const pasteImage = (evt) => { | |
| Array.from(evt.clipboardData.files).forEach(async (file) => { | |
| if (file.type.startsWith('image/') || file.type.startsWith('video/')) { | |
| uploadFile(file); | |
| } | |
| }); | |
| }; | |
| </script> | |
| <!-- Here's how you use it in your Html Markup (Svelte Here) --> | |
| <div contenteditable on:paste={pasteImage} /> | |
| <input on:paste={pasteImage} /> | |
| <textarea on:paste={pasteImage} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment