2

When you click [Ctrl+Enter] in Rich Text Editor it inserts a paragraph (<p>) at the cursor, and also encapsulates the content before the cursor in another paragraph.

I've already created a custom Rich Text Editor profile in core://sitecore/system/Settings/Html Editor Profiles/Rich Text Custom

which includes a custom Configuration Type which inherits from the default settings, but have set linebreaks to use <br>:

public class CustomEditor : Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration
{
    protected override void SetupEditor()
    {
        base.SetupEditor();

        Editor.NewLineMode = EditorNewLineModes.Br;
    }
}

Even with this setting, pressing [Ctrl+Enter] in the editor inserts a new paragraph.

I though maybe the Editor.EnableFilter(EditorFilters.FixEnclosingP); filter might have something to do with it, but enabling/disabling this has no effect.

So, how can I prevent Rich Text Editor from inserting paragraphs when pressing [Ctrl+Enter] on the keyboard?

Sitecore 8.2 Update 5, Issue is tested in IE11 + Chrome68

4

There is a setting in config which allows you to set which tag to use for line breaks. By default it is set to use the p tag but you can change it to something else, using a patch config file:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
  <sitecore>

    <settings>
      <!--
        HTML EDITOR LINE BREAK
        Specifies the tag that the HTML editor inserts on Enter. Values can be
        "br", "div" and "p".        
      -->
      <setting name="HtmlEditor.LineBreak" set:value="br" />
    </settings>     

  </sitecore>
</configuration>

This should achieve what you are trying to do in the code.

You mention you are using [Ctrl+Enter] but in all instances I have tried this does nothing. Using as default install, [Enter] inserts a <p> tag, and [Shift+Enter] inserts a <br /> tag. It is the same behaviour in Chrome, Firefox and IE11 but hopefully the above helps.

  • That setting is the same as I've already done in code. The difference is that this config file setting is global, and using code, like I've done, is applicable to only one RTEditor profile. – GTHvidsten Aug 15 '18 at 16:26
  • Sure, makes sense. But pressing [Ctrl+Enter] does nothing for me in any case. [Shift+Enter] works, but inserts a br with any setting, so not sure why it's inserting paragraphs for you – jammykam Aug 16 '18 at 2:44
  • We updated that setting and we're getting 'br's in our RTE, but still all wrappen in a 'p'. – MStodd Sep 11 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.