TinyMCE 在使用单词 paste 时添加 &nbsp 而不是空格 [英] TinyMCE is adding &nbsp instead of the space when using the word paste

查看:33
本文介绍了TinyMCE 在使用单词 paste 时添加 &nbsp 而不是空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TinyMCE 编辑器和 word 函数中的粘贴.

I am using the TinyMCE editor and the paste from word function.

我的问题是,当我有空格时,tinyMCE 会将它们转换为 &nbsp,我想保留正常的空格.

My problem is that when I have spaces, tinyMCE transform them in &nbsp and I would like to keep the normal space.

是否有过滤功能或类似的东西可以在 tinyMCe.init 中使用来做到这一点?

Is there a filtering function or something similar which can be used in tinyMCe.init which will do that?

谢谢.

推荐答案

我找到了一个解决方案,我不确定它是否合适,但它有效.在 tinyMCE.init 中,我添加了:

I have found a soultion, I am not sure that's the proper one, but it works. In the tinyMCE.init, I added:

paste_auto_cleanup_on_paste : true,
    paste_postprocess : function(pl, o) {
        // remove extra line breaks
        o.node.innerHTML = o.node.innerHTML.replace(/ /ig, " ");
    }

这是整个 tinyMCE init:

Here is the entire tinyMCE init:

function addTinyMCE_Authors_AffiliationsWord() {
    jQuery('#dialog-authors_affiliations_parsing').tinymce({
        script_url: '/js/tiny_mce_3.2.7_jquery/jscripts/tiny_mce/tiny_mce.js',
        width: "800px",
        height: "250px",
        mode: "textarea",
        theme : "advanced",
        plugins : "paste",
        // Theme options
        theme_advanced_buttons1 : "pasteword",
        theme_advanced_buttons2 :"",
        theme_advanced_buttons3 :"",
        theme_advanced_buttons4 :"",
        theme_advanced_toolbar_location : "bottom",
        valid_elements : "p",
        paste_auto_cleanup_on_paste : true,
        paste_postprocess : function(pl, o) {
            // remove &nbsp
            o.node.innerHTML = o.node.innerHTML.replace(/ /ig, " ");
         }
     });
}

享受...

这篇关于TinyMCE 在使用单词 paste 时添加 &nbsp 而不是空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆