在做一个题库项目,经常需要从 word 中复制考题到 summernote 文本框中,但是想只粘贴并保留纯文本内容,需要将内容的样式自动去除。例如,字体颜色等。
$editor.summernote({
callbacks: {
onPaste: function (e) {
var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');
e.preventDefault();
document.execCommand('insertText', false, bufferText);
}
}
});