Skip to content

Instantly share code, notes, and snippets.

@kamwing
Forked from cesarfigueroa/paste.js
Created October 8, 2020 02:42
Show Gist options
  • Save kamwing/03502c5ed96cd2945e82455864b68839 to your computer and use it in GitHub Desktop.
Save kamwing/03502c5ed96cd2945e82455864b68839 to your computer and use it in GitHub Desktop.
Paste onto a [contenteditable] element as plain text
document.querySelector('[contenteditable]').addEventListener('paste', function (event) {
event.preventDefault();
document.execCommand('inserttext', false, event.clipboardData.getData('text/plain'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment