-2

I want to add images and screenshots from my clipboard to my text-angular editor. Like this

  • 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 Answers1

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;
        }
    }
  }
}    

like this

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