Skip to content
Snippets Groups Projects
Commit ddb3e017 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Add filter #202

parent 1276a290
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,20 @@ $(function () {
if (e.keyCode === 8) {
$.summernote.rails.cleanEmptyAttachments($editable);
}
},
// Remove text styles on paste
onPaste: function (event) {
var paragraph;
event.preventDefault();
// Get and trim clipboard content as paragraph
paragraph = document.createElement('p');
paragraph.textContent = ((event.originalEvent || event).clipboardData || window.clipboardData).getData('Text').trim();
// Delete selection if anything is selected (expected behaviour on paste)
if ((window.getSelection !== undefined ? window.getSelection() : document.selection.createRange()).toString().length > 0) {
document.execCommand('delete', false);
}
// Insert trimmed clipboard content as paragraph
document.execCommand('insertHTML', false, paragraph.outerHTML);
}
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment