Editing a Single-Line Text or Multi-Line Text field in the Experience Editor might get the text wrapped in HTML <p> elements on the first saving:
<p>Text</p>
Re-editing this field does not result in adding the tag.
To resolve the issue, consider the following options:
Alternatively, you can consider the following options:
Sitecore.PageModes.InlineEditingUtil.clearNonPrintableTags(target); var newLineNode = Sitecore.WebEditSettings.newLineBreak; if (newLineNode.toLowerCase() == "p" || newLineNode.toLowerCase() == "div") { var selection = document.getSelection(); var range = selection.getRangeAt(0); if (!Sitecore.PageModes.InlineEditingUtil.checkContentEditable(selection.focusNode)) { return true; } var node = document.createElement(newLineNode); range.insertNode(node); range.collapse(true); node.innerHTML = "<br />"; range.selectNodeContents(node); selection.removeAllRanges(); selection.addRange(range); return true; }
if (selection.baseNode.getAttribute("scfieldtype") !== "single-line text" && selection.baseNode.getAttribute("scfieldtype") !== "multi-line text" )
{
//piece of code from the second step
}