Turn off enclosing

tags in CKEditor 3.0

前端 未结 11 985
天涯浪人
天涯浪人 2020-12-04 07:49

Is there a possibility to turn off the automatic enclosing of all written content within

in CKEditor 3.x?

I tried

  CKEDITOR.con         


        
相关标签:
11条回答
  • 2020-12-04 08:16

    Set such config:

        CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR
        CKEDITOR.config.forcePasteAsPlainText = true
    
    0 讨论(0)
  • 2020-12-04 08:18

    MAKE THIS YOUR config.js file code

    CKEDITOR.editorConfig = function( config ) {
    
       //   config.enterMode = 2; //disabled <p> completely
            config.enterMode = CKEDITOR.ENTER_BR // pressing the ENTER KEY input <br/>
            config.shiftEnterMode = CKEDITOR.ENTER_P; //pressing the SHIFT + ENTER KEYS input <p>
            config.autoParagraph = false; // stops automatic insertion of <p> on focus
        };
    
    0 讨论(0)
  • 2020-12-04 08:19

    CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR; - this works perfectly for me. Have you tried clearing your browser cache - this is an issue sometimes.
    You can also check it out with the jQuery adapter:

    <script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="/js/ckeditor/adapters/jquery.js"></script>
    <script type="text/javascript">
    $(function() {
        $('#your_textarea').ckeditor({
            toolbar: 'Full',
            enterMode : CKEDITOR.ENTER_BR,
            shiftEnterMode: CKEDITOR.ENTER_P
        });
    });
    </script>
    


    UPDATE according to @Tomkay's comment:

    Since version 3.6 of CKEditor you can configure if you want inline content to be automatically wrapped with tags like <p></p>. This is the correct setting:

    CKEDITOR.config.autoParagraph = false;
    

    Source: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.autoParagraph

    0 讨论(0)
  • 2020-12-04 08:20

    I'm doing something I'm not proud of as workaround. In my Python servlet that actually saves to the database, I do:

    if description.startswith('<p>') and description.endswith('</p>'):
        description = description[3:-4]
    
    0 讨论(0)
  • 2020-12-04 08:21

    In VS2015, this worked to turn the Enter key into <br>

    myCKEControl.EnterMode = CKEditor.NET.EnterMode.BR
    

    Personally, I don't care if my resulting text only has <br> and not <p>. It renders perfectly fine and it looks the way I want it to. In the end, it works.

    0 讨论(0)
提交回复
热议问题