Change config in ckeditor for line break

1.9k Views Asked by At

I wanted to have

config.enterMode = CKEDITOR.ENTER_BR;

I am referencing editor directly form CDN

I tried it this way

@Html.TextAreaFor(model => model.About, new { @class = "form-control", @id = "About" })
                <script>
                    CKEDITOR.replace('About');
                    CKEDITOR.editorConfig = function (config) {
                        config.enterMode = CKEDITOR.ENTER_BR;
                    };
                </script>

Thanks

1

There are 1 best solutions below

7
On BEST ANSWER

Loading CKEditor from CDN does not prevent you from providing a custom configuration.

See the following resources:

  • The CKEditor CDN site itself!
  • The Setting CKEditor Configuration article which descibes how and where you can provide the editor configuration.
  • Any of the samples from CKEditor SDK - scroll down to the "Get Sample Source Code" to see the entire code needed to generate this exact configuration, with CKEditor loaded from CDN.

Example for an in-page configuration (so for the CKEditor instance with id of About):

<script>
    CKEDITOR.replace( 'About', {
        enterMode: CKEDITOR.ENTER_BR
    } );
</script>

By the way, using CKEDITOR.ENTER_BR is actually unrecommended, especially if you want to use it just to change paragraph spacing.