I currently have code to strip any formatting on paste so the user is just pasting plain text, however it is not stripping line breaks. I have tried adding the line text = text.replace(/(\r\n\t|\n|\r\t)/gm, ""); to remove the line breaks, but this is not working. I need this to function within IE 11, how can I accomplish this?
$('[contenteditable]').on('paste', function (e) {
e.preventDefault();
var text = '';
if (e.clipboardData || e.originalEvent.clipboardData) {
text = (e.originalEvent || e).clipboardData.getData('text/plain');
} else if (window.clipboardData) {
text = window.clipboardData.getData('Text');
}
if (document.queryCommandSupported('insertText')) {
document.execCommand('insertText', false, text);
} else {
document.execCommand('paste', false, text);
}
});