I want to add images and screenshots from my clipboard to my text-angular editor. Like this
Asked
Active
Viewed 373 times
-2
-
Does this answer your question? [How does the paste image from clipboard functionality work in Gmail and Google Chrome 12+?](https://stackoverflow.com/questions/6333814/how-does-the-paste-image-from-clipboard-functionality-work-in-gmail-and-google-c) – Gopal Mishra Sep 20 '21 at 11:15
1 Answers
0
This can be done in textAngular.js library. Add below code to paste screenshots and data from clipboard to text-editor.
if (/Files/i.test(_types)) {
for (var i = 0; i < clipboardData.items.length; i++) {
if (clipboardData.items[i].type.indexOf("image") === 0) {
var blob = clipboardData.items[i].getAsFile();
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = function () {
var base64String = reader.result;
var id='img'+Date.now();
pastedContent = '<img id="'+id+'" src="'+base64String+'" />';
processpaste(pastedContent);
e.stopPropagation();
e.preventDefault();
return false;
}
}
}
}

Peter Csala
- 17,736
- 16
- 35
- 75

Mudasser khattak
- 1
- 1