paste image

i

by leftstick

HTML

<div contenteditable class="editor">

</div>

CSS

.editor {
  width: 200px;
  height: 200px;
  background-color: #fff;
}

JavaScript

document.querySelector('.editor').addEventListener("paste", function(e){
  const blob = e.clipboardData.items[0].getAsFile()
  
  const img = document.createElement('img')
  const URLObj = window.URL || window.webkitURL;
  img.src = URLObj.createObjectURL(blob);

	this.appendChild(img)
}, false);