我已经成功地设置了一个粘贴事件来在粘贴时捕获粘贴到文本区域中的 HTML。
我需要在将该 HTML 粘贴到文本区域之前或之时自动将 removeFormat 命令应用于该 HTML,以便我可以去除它的类、各种标签和其他属性。有人可以指出正确的方向以正确应用 removeFormat 命令吗?
到目前为止,这是我的代码:
$(function(){
$('textarea').ckeditor(
function( textarea ){
var editor = this;
editor.on('paste', function( e ) {
//alert(e.data.html); // This shows the HTML
editor.execCommand( 'removeFormat', e.data.html ); // Doesn't seem to do anything, HTML is pasted with the attributes intact
});
}
)
});
谢谢!
附言强制纯文本选项不可行,因为我希望保留一些 HTML 元素(p、表格等)。
最佳答案
你可以使用
config.forcePasteAsPlainText = true;
比照http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
关于javascript - CKEditor:在粘贴上应用 removeFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7246046/