How to make tinymce paste in plain text by default

后端 未结 11 1034
忘掉有多难
忘掉有多难 2020-12-02 04:24

Googled it thousands of times, No one gives a complete solution of how to make Tinymce paste in plain text by default and strip out any formatting without clicking the \"pas

11条回答
  •  一生所求
    2020-12-02 05:11

    FYI, TinyMCE has improved this by implementing it as a default option in the paste plugin. More info: http://www.tinymce.com/wiki.php/Plugin:paste

    However, it's still not perfect. So here is a script that also trips off all HTML:

    // Paste
            paste_auto_cleanup_on_paste : true,
            paste_remove_spans: true,
            paste_remove_styles: true,
            paste_retain_style_properties: false,
    
            paste_preprocess : function(pl, o) 
            {    // Replace 
    with

    o.content = o.content.replace(/

    /gi, "

    "); o.content = o.content.replace(/<\/div>/gi, "

    "); o.content = o.content.replace(/<\r\n/gi, "\n"); o.content = o.content.replace(/<\n\n/gi, "\n"); o.content = o.content.replace(/<\n\n/gi, "\n"); // Replace empty styles o.content = o.content.replace(/