[英]Why does CKeditor add line breaks and paragraph before initial text?
I have a web page with a CKEditor on it and my issue is that when I view source or post to the server, I am getting extra spaces and line breaks before the initial text that I type in the textarea. 我有一个带有CKEditor的网页,我的问题是当我查看源或发布到服务器时,我在textarea中输入的初始文本之前得到了额外的空格和换行符。
Here is what I type 这是我输入的内容
and when I click on source, here is what I see: 当我点击源代码时,这就是我所看到的:
When I post this to the server, before the initial text I see: 当我将其发布到服务器时,在初始文本之前我看到:
<p>\r\n\tWe do deli . . .
Does anyone know how I can change the settings so it doesn't add all of this extra paragraph and line breaks when I don't want them. 有谁知道如何更改设置,以便在我不需要时不会添加所有这些额外的段落和换行符。 Is this a setting on CKEditor or is this something that I need to deal with on the client?
这是CKEditor上的设置还是我需要在客户端处理的东西? I notice that there is also a
</p>
at the end of the data. 我注意到数据末尾还有一个
</p>
。
I Fixed my problem by adding this code n my config.js (just replace br
for p
) 我通过在config.js中添加此代码来解决我的问题(只需将
br
替换为p
)
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.dataProcessor.writer.setRules('br',
{
indent: false,
breakBeforeOpen: false,
breakAfterOpen: false,
breakBeforeClose: false,
breakAfterClose: false
});
});
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_BR;
It applies to all ckeditors avoiding the need of code being replicated ( ctrl + c + ctrl + v ) 它适用于所有ckeditors,无需复制代码( ctrl + c + ctrl + v )
It's a setting, you can disable it. 这是一个设置,你可以禁用它。 See the docs on Output Formatting
请参阅有关输出格式的文档
Its a setting in the enter key plugin code. 它是输入密钥插件代码中的一个设置。 You can disable it from there and then compile the ckeditor code again...
您可以从那里禁用它,然后再次编译ckeditor代码......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.