legacy-knowledge-base
公開されました Jun. 30, 2025

Character replacement in web content with CKEditor

written-by

Jose Bodega

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

Issue

  • When modifying the text entered in a text area of a web content in edit mode and publishing it, line breaks are automatically added in the generated HTML. After publishing, the <br> tags are automatically replaced with <p> tags.

Environment

  • Liferay 7.2

Resolution

  • This would be the normal behavior of the CKEditor WYSIWYG editor, on which AlloyEditor is based.
  • Both editors can be configured to change their behavior according to your preferences. You can choose which one to use by default by adding this property in the `portal-ext.properties` file and restarting the portal:
    • 'editor.wysiwyg.default=ckeditor' // to use CKEditor by default
      or
    • 'editor.wysiwyg.default=alloyeditor' // to use AlloyEditor by default
  • However, to change this behavior, the following parameter should be configured in CKEditor: 'config.enterMode' to the appropriate value.The default value creates a paragraph element each time the "Enter" key is pressed (this is the recommended and correct behavior according to the documentation):
config.enterMode = CKEDITOR.ENTER_P; // inserts <p></p>

You can choose to create a "div" element instead of a paragraph:

config.enterMode = CKEDITOR.ENTER_DIV; // inserts <div></div>

If you prefer not to wrap the text in anything, you can opt to insert a line break tag:
config.enterMode = CKEDITOR.ENTER_BR; // inserts <br />

The application developer indicates that the `ENTER_BR` configuration is not recommended.

  • As an alternative, the following structure could be used in the HTML field, consisting of having a paragraph with <br /> tags inside it, as shown in the following example:
    <p>1. Sample Test<br /> 2. Sample Test<br /> 3. Sample Test</p>

 

Additional Information

did-this-article-resolve-your-issue

legacy-knowledge-base