Ckeditor adds empty paragraphs when applying a style

后端 未结 2 1700
名媛妹妹
名媛妹妹 2021-01-02 09:14

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

I initiate CKeditor with the following html:

相关标签:
2条回答
  • 2021-01-02 09:36

    You might want to consider these:

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

    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 Well,
    Joe

    0 讨论(0)
  • 2021-01-02 10:03

    Or, if all fails, you can use the CSS selector pseudo-class ':empty' and give it a 'display:none'. In practice, you add this line to your CSS:

    p:empty {
      display:none
    }
    

    I understand it's a dirty solution but it works perfectly in most cases and has minimal inpact on design and functionality.

    0 讨论(0)
提交回复
热议问题