Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
In the TinyMCE HTML Editor an extra paragraph tag is inserted after clicking Enter - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • In the TinyMCE HTML Editor an extra paragraph tag is inserted after clicking Enter
KB0524073

In the TinyMCE HTML Editor an extra paragraph tag is inserted after clicking Enter


5073 Views Last updated : Jun 25, 2024 public Copy Permalink
KB Summary by Now Assist

Description

Updating the source code using the HTML Source Editor on the TinyMCE Editor adds an extra tag (<p>&nbsp;</p>) after clicking Enter.

 

Steps to Reproduce

  1. Create a knowledge base article.
  2. Click the HTML icon to launch the HTML Source Editor. 
  3. Edit the source code to add the tag, <hr>.
  4. Click Update to save the article. 
  5. After the horizontal line in the article, click Enter.
    The pointer moves up to the first line in the article and an extra tag, <p>&nbsp;</p>, is inserted into the html source code right after the <body> tag.

Workaround

Adding an extra paragraph tag when pressing the enter key is expected behaviour for third party products like TinyMCE, or even Microsoft Word, where if you want text directly on the next line you need to hold shift+enter.
ServiceNow will continue to implement TinyMCE's improvements as they become available. A workaround is described in the article below:

https://community.servicenow.com/community/blogs/blog/2014/12/12/extra-line-spacing-with-p-tags-in-email-client

Alternatively you can use this onChange client script that will remove the trailing content: <p>&nbsp;</p>

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}

	var fieldName = 'text';
	
	// use decodeURIComponent because   becomes " " when client script is written to the desktop form.
	var patterns = [decodeURIComponent('<p>%26nbsp;</p>'), '<p></p>'];
	var hasTrailingTag = false;
	for(var i=0; i < patterns.length; i++) {
		if (newValue.substr(-(patterns[i].length)) === patterns[i]) {
			hasTrailingTag = true;
			break;
		}
	}

	if (!hasTrailingTag)
		return;

	// Remove patterns from the end of the field value
	var lines = newValue.split('\n');
	for (i = lines.length-1; i >= 0; i--) {
		if (patterns.indexOf(lines[i]) > -1)
			lines.pop();
		else
			break;
	}
	newValue = lines.join('\n');

	// Set the clean value on the field
	g_form.setValue(fieldName, newValue);
}

 


Related Problem: PRB585174

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.