Ckeditor应用样式时添加空白段落 [英] Ckeditor adds empty paragraphs when applying a style

查看:101
本文介绍了Ckeditor应用样式时添加空白段落的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将样式应用于所选段落时,我的CKEditor添加了很多不必要的标签

My CKEditor is adding a lot of unnecessary tags when applying a style to a selected paragraph

我使用以下html来启动CKeditor:

I initiate CKeditor with the following html:

<p>
    Hi, this a text!</p>

当我选择段落并使用工具栏应用样式时,CKEditor将html的格式设置为以下内容:

When I select the paragraph and apply a style using the toolbar, CKEditor formats my html to the following:

<p>
    <span style="display: none;">&nbsp;</span></p>
<p>
    <span id="cke_bm_173S" style="display: none;">&nbsp;</span>Hi, this a text!<span id="cke_bm_173E" style="display: none;">&nbsp;</span></p>
<p>
    <span style="display: none;">&nbsp;</span></p>

有什么方法可以防止CKEditor在不加空格的情况下添加段落吗?

Is there any way preventing CKEditor from adding the paragraphs with the non breaking space?

我已经尝试过的事情是添加 config.fillEmptyBlocks = false; config.IgnoreEmptyParagraphValue = true; 到我的配置文件

Things I've already tried are adding config.fillEmptyBlocks = false; and config.IgnoreEmptyParagraphValue = true; to my config file

更新
原来,此问题是由样式本身引起的自定义定义的样式。这是一段代码的问题: {name:'Heading1',element:'p class = subheadingsecondlevel} ,一旦我将其更改为: {name:'Heading1',元素:'p',属性:{class:'subheadingsecondlevel'}}

Update Turns out this problem was caused by the style itself which was a custom defined style. This piece of code was the problem: {name : 'Heading1', element : 'p class= "subheadingsecondlevel"}, once I changed it to: {name : 'Heading1', element : 'p', attributes : {class : 'subheadingsecondlevel'} }

推荐答案

您可能需要考虑以下因素:

You might want to consider these:

config.enterMode = CKEDITOR.ENTER_BR;
config.autoParagraph = false;

您可以在此处查看我的信息以获取更多信息:

如何将ckeditor配置为不包装内容在< p>中

You can check out my post here for more info:
How to configure ckeditor to not wrap content in <p> block?

以下配置设置将阻止编辑器在空段中插入不间断空格:

The following config setting will stop the editor from inserting a non-breaking space in empty paragraphs:

  config.fillEmptyBlocks = false;



是否仅在应用一种样式后插入了所有其他代码?

您应用了哪种样式,无论使用哪种样式,都插入了所有额外的代码吗?

如果选择文本并单击加粗按钮会发生什么? />
是从编辑器的源视图还是从用于显示内容的最终页面复制正在显示的代码?


Was all of the additional code inserted after applying just one style?
What style did you apply, is all the extra code inserted regardless of the style you use?
What happens if you select the text and click the bold button?
Is the code you are showing being copied from the source view of the editor or from the final page that you use to display your content?

Be好吧,

Be Well,
Joe

这篇关于Ckeditor应用样式时添加空白段落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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