javascript - Remove styles when pasting from Word or other source - Stack Overflow

I'm trying to set it up so that when I paste text, specifically from Word or another source, all t

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 mand+V.

Any help?

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 mand+V.

Any help?

Share Improve this question asked Jun 29, 2009 at 0:40 dougoftheabacidougoftheabaci
Add a ment  | 

2 Answers 2

Reset to default 6

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;

Try not loading the paste extension.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745127411a4612774.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信