Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

CKEditor: Why am I getting two <br> with one ENTER press with enterMode: 2 and two <p> with enterMode: 1?

This is my config in settings.py:

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Custom',
        'colorButton_colors': '000000,0000FF,FFFF00,FF0000,FF00FF,00FFFF,008000,FFFFFF', 
        'colorButton_enableAutomatic': False,
        'colorButton_enableMore': False, 
        'extraPlugins': 'sharedspace',
        'toolbar_Custom': [
            ['Italic', 'Underline'],
            {'name': 'colors', 'items': ['TextColor', 'BGColor']},
        ],
        'sharedSpaces': {
            'top': 'top',
            'bottom': 'bottom',
        },
        'removePlugins': ['elementspath', 'resize', 'magicline'],
        'enterMode': 2,
        'height': 150,
        'width': 300,
    },
}

If I have an editor with the following contents: This is a sample text., and I press ENTER right before the 's' in 'sample', it becomes this: This is a <br><br><div>sample text</div>, when—I think—it should be this: This is a <br>sample text.. Not only I'm getting an extra <br>, but also that weird <div>.

Seen in the inspector:

enter image description here

The documentation says nothing about this double <br> or the weird <div>, or at least I can't find anything.

I tried changing enterMode to 1, but this is what happens:

enter image description here

I almost always pre-populate the editor with text from the database, but I don't think it has anything to do with this.

If I select 'Break the line with a <br>' in the sample in the documentation and inspect the element, I see this problem doesn't occur; however, I can't find what's causing it in my case.

I'm really stuck here.

question from:https://stackoverflow.com/questions/65921449/ckeditor-why-am-i-getting-two-br-with-one-enter-press-with-entermode-2-and-t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...