调整ckeditor的响应式设计

use*_*471 4 javascript ckeditor

我正在尝试在响应式设计上使用CKEditor,但我无法达到工作的高度.以下带有高度定义的代码可以将文本区域的大小调整为100%,从而溢出包含的div.

        CKEDITOR.replace( 'article', {
            toolbar: [
                { name: 'basicstyles', items: [ 'Bold', 'Italic' ] },
                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Blockquote' ] },
                { name: 'links', items : [ 'Link','Unlink' ] },
                { name: 'insert', items : [ 'Image' ] }
            ],
            uiColor: '#f9fafb',
            height: '100%'
        });
Run Code Online (Sandbox Code Playgroud)

我找到了下面的代码,但我无法弄清楚粘贴的位置.我也尝试过编辑config.js,并遵循CKEDitor网站上的所有文档.他们告诉你该做什么,但不知道该做什么.

editor.resize( '100%', '350', true );
Run Code Online (Sandbox Code Playgroud)

理论上,"真实"将使高度包括整个编辑器,而不仅仅是文本区域,但我不知道它属于哪里.

包含编辑器的div使用此CSS:

height: -moz-calc(100% - 400px);
height: -webkit-calc(100% - 400px);
height: calc(100% - 400px);
Run Code Online (Sandbox Code Playgroud)

Moh*_*med 14

在 Django 中,我必须autosettings.py文件中设置宽度:

CKEDITOR_CONFIGS = {
'default': {
    'toolbar': None, #You can change this based on your requirements.
    'width': 'auto',

          },
    }
Run Code Online (Sandbox Code Playgroud)

  • 是的,非常感谢。这按预期工作!:)) (2认同)

小智 7

如果你想做响应需要改变设置 config.js

CKEDITOR.editorConfig = function (config) {

    config.width = "auto";
    config.height = "auto";
Run Code Online (Sandbox Code Playgroud)