我如何禁用CKEditor,使其不会每次在我不需要它们时插入
?我正在使用带有jQuery适配器的CKEditor。
我不想要任何
标签。
我如何禁用CKEditor,使其不会每次在我不需要它们时插入
?我正在使用带有jQuery适配器的CKEditor。
我不想要任何
标签。
Automatic filling of empty blocks. This can be disabled in the config:
config.fillEmptyBlocks = false;
Automatic insertion when pressing TAB-key. This can be disabled in the config:
config.tabSpaces = 0;
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/ig', ' ', $text);
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.
config.fillEmptyBlocks = false;
对我来说并没有解决问题。 - dsdsdsdsd/\s* \s*/ig
,以便在字符串中替换多个实例,并考虑到更多将空格与
混合的情况。因此,像西瓜 味道 饮料
(这种情况经常发生)将被替换,而使用你的正则表达式则不会。此外,在每个\s
前面应该使用*,因为HTML只渲染一个空格。 - dhaupin尝试:
config.basicEntities = false;
对我来说解决了问题。
还有一种情况会出现不间断空格字符,就是在句子末尾输入一个空格。
CKEditor会转义基本的HTML实体以及拉丁文和希腊文的实体。
添加以下配置选项可防止此问题(您也可以将它们添加到配置文件中):
CKEDITOR.on( 'instanceCreated', function( event ) {
editor.on( 'configLoaded', function() {
editor.config.basicEntities = false;
editor.config.entities_greek = false;
editor.config.entities_latin = false;
editor.config.entities_additional = '';
});
});
这些选项将防止CKEditor转义nbsp gt lt amp ' "
以及其他拉丁和希腊字符。
来源: http://docs.ckeditor.com/#!/api/CKEDITOR.config http://docs.ckeditor.com/source/plugin48.html#CKEDITOR-config-cfg-basicEntities
CKEDITOR.editorConfig = function( config ) {
config.enterMode = CKEDITOR.ENTER_BR; // <p></p> to <br />
config.entities = false;
config.basicEntities = false;
};
对于我来说很管用,之后你可以使用php打印文本:html_entity_decode( $someText )
;
而不是普通的空格。我正在调用normalize()
http://www.w3schools.com/jsref/met_node_normalize.asp来改变修改后的元素:CKEDITOR.on('instanceReady', function (ck) {
ck.editor.on("change", function (e) {
var sel = ck.editor.getSelection();
if (sel) {
var selected = sel.getStartElement();
if (selected && selected.$)
sel.getStartElement().$.normalize();
}
});
});
这是一个糟糕的解决方案。
config.basicEntities = false;
<script type="text/javascript" src="/scripts/redactor/ckeditor/ckeditor.js"></script>
<p> </p>
这样的空块不能在文本中指定缩进,因为字符
将被删除(config.fillEmptyBlocks = true;)这是正确的解决方案
$text = preg_replace("#([^>]) #ui", "$1 ", $text);
替换为一个空格,除了那些在标签内部的字符,如<p> </p>
我已经不得不在 config.js 文件中进行调整,为了解决 Safari 中出现“?”的问题,最终我在 config.js 文件中添加了3行代码。
config.fillEmptyBlocks = function (element) {
return true; // DON'T DO ANYTHING!!!!!};
config.entities = false;
config.basicEntities = false;
align="left"
创建表格,则会添加<p> </p>
,但是如果将CSS规则更改为align="center"
,则可以将段落编辑掉,并且它们不会再次添加。preg_replace("/[\<]p[\>][\s]+ [\<][\/]p[\>]/" , " " , $pre_comment);
"<p> </p>"
享受吧 :)
Maxwell
1.
此问题已经得到正确回答!(当你没有更好的答案时,请不要回答,并尤其注意老问题)2.
这个模式包含不必要的[]
括号(所有的),不必要的转义序列\>
,很可能还有\<
和在\s
后面不必要的+
(模式~<p>\s </p>~
看起来更短)。3.
如果您想确保P
标签内只有一个普通空格,则将大小写不敏感的模式~<p>\s* \s*</p>~i
替换为SPACE是一个更好的建议(而且更短)。 - Wh1T3h4Ck5config.js
文件中:config.enterMode = CKEDITOR.ENTER_BR,