从Word或其他来源粘贴时删除样式 [英] Remove styles when pasting from Word or other source
问题描述
我试图设置它,以便当我粘贴文本,特别是从Word或其他来源,所有的样式将被剥离。
我如何做到这一点?
我很高兴让大胆和斜体的风格保持和列表等等,我知道有一个插件,如果我通过点击按钮粘贴,但我正在寻找是否有人按CTRL + V或命令+ V。 p>
任何帮助?
我使用TinyMCE与粘贴插件以下设置:
paste_create_paragraphs:false,
paste_create_linebreaks:false,
paste_use_dialog:true,
paste_auto_cleanup_on_paste:true,
paste_convert_middot_lists:false,
paste_unindented_list_class:unindentedList,
paste_convert_headers_to_strong:true,
paste_insert_word_content_callback:convertWord,
这也是:当你点击Ctrl-V,弹出一个对话框,让你粘贴到你的内容,
您可能还需要此无操作回调:
function convertWord(type,content){
switch(type){
//在内置逻辑执行之前执行它的清理
casebefore:
// content = content.toLowerCase(); //一些虚拟逻辑
break;
//内置的逻辑执行后清除
caseafter:
// content = content.toLowerCase(); //一些虚拟逻辑
break;
}
返回内容;
I'm trying to set it up so that when I paste text, specifically from Word or another source, all the styling will be stripped. I'm happy to let bold and italic styles stay as well as lists and so forth, but the rest should go.
How can I do this?
I know there is a plugin that will allow me to do this if I paste via clicking a button but I'm looking for if someone presses CTRL+V or command+V.
Any help?
I am using TinyMCE with the paste plugin an the following setup:
paste_create_paragraphs : false,
paste_create_linebreaks : false,
paste_use_dialog : true,
paste_auto_cleanup_on_paste : true,
paste_convert_middot_lists : false,
paste_unindented_list_class : "unindentedList",
paste_convert_headers_to_strong : true,
paste_insert_word_content_callback : "convertWord",
And it does just that: When you hit "Ctrl-V", a dialog pops up letting you paste in your contents, which gets autocleaned from any Word related stuff.
You may also need this no-op callback:
function convertWord(type, content) {
switch (type) {
// Gets executed before the built in logic performes it's cleanups
case "before":
//content = content.toLowerCase(); // Some dummy logic
break;
// Gets executed after the built in logic performes it's cleanups
case "after":
//content = content.toLowerCase(); // Some dummy logic
break;
}
return content;
这篇关于从Word或其他来源粘贴时删除样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!