CKEditor不需要& nbsp;字符 [英] CKEditor unwanted   characters

查看:1319
本文介绍了CKEditor不需要& nbsp;字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我不想要它时,如何禁用CKEditor每次& nbsp; 我使用CKEditor与jQuery适配器。

How can I disable CKEditor to get me every time  , when i don't want them? I'm using CKEditor with jQuery adapter.

我不想拥有任何& nbsp; 标签。

推荐答案

经过一番研究,我可能会对这个问题有所了解 - 不幸的是没有现成的解决方案。

After some research I might shed some light on this issue - unfortunately there is no out-of-the-box solution.

在CKEditor中,有四种方式可以产生不间断空格(任何人都知道更多?):

In the CKEditor there are four ways a no-break space can occur (anybody knows more?):


  1. 自动填充空块。这可以在配置中禁用:

  1. Automatic filling of empty blocks. This can be disabled in the config:

config.fillEmptyBlocks = false;


  • 按TAB键时自动插入。这可以在配置中禁用:

  • Automatic insertion when pressing TAB-key. This can be diabled in the config:

    config.tabSpaces = 0;
    


  • 将双空格转换为SPACE + NBSP。 这是浏览器行为,因此不会由CKEditor团队修复。它可以是固定的服务器端或通过客户端javascript onunload。也许这个php是一个开始:

  • Converting double spaces to SPACE+NBSP. This is a browser behavior and will thus not be fixed by the CKEditor team. It could be fixed serverside or by a clientside javascript onunload. Maybe this php is a start:

    preg_replace('/\s \s/i', ' ', $text);
    


  • 通过复制和粘贴。如果您粘贴 UTF-8无中断空格或双空格CKEditor将转换它自动。我看到的唯一的解决方案是做一个正则表达式如上。 config.forcePasteAsPlainText = true; 不起作用。

  • By copy&paste. If you paste a UTF-8 no-break space or double-spaces CKEditor will convert it automatically. The only solution I see here is doing a regex as above. config.forcePasteAsPlainText = true; doesn't help.

    总结:为了摆脱所有的不间断空格,你需要编写一个额外的功能来清除用户输入。

    Summary: To get rid of all no-break spaces you need to write an additional function that cleans user input.

    非常感谢评论和进一步的建议! (我使用ckeditor 3.6.4)

    这篇关于CKEditor不需要& nbsp;字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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