Issue
- We are using CKEditor instead of the regular editor. When putting some content into the HTML field while creating blogs
<p>and</p>tags are appended by default. - We would like to remove these tags or change them to another one.
Environment
- DXP 7.2
Resolution
- This is the normal behavior of the editor WYSIWYG CKEditor, which AlloyEditor is based on.
Both editors can be configured to change their behaviors as desired. - Attached a sample portlet that removes the tags.
- Also, the user can choose the default tag by adding this property in the portal-ext.properties and restarting the portal:
editor.wysiwyg.default=ckeditor // to use by default CKEditor
oreditor.wysiwyg.default=alloyeditor // to use by default AlloyEditor
In order to change this behavior, you need to set the CKEditor configuration setting config.enterMode to the proper value.
-
The default creates a paragraph element each time the "enter" key is pressed (this one is recommended and the correct one to use as per 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>
- To completely remove the tags, if you prefer to not wrap the text in anything, you can choose to insert a line break tag:
config.enterMode = CKEDITOR.ENTER_BR; // inserts <br />
The application developer indicates that using the ENTER_BR setting is not recommended.
See the documentation for more information here.
There are three more settings that are somewhat related to this subject:config.fillEmptyBlocks config.forceEnterMode config.ignoreEmptyParagraph