2017-08-03 41 views
1

我正在使用javascript ckEditor,我有一个调整大小的问题,这个问题一直是过去几天讨论的问题。 我有一个名为ckEditorConfig的角度对象,我在那里存储我的ckEditor的配置。目前我可以看到一些属性被设置(所以我知道它在某种程度上有效)。但是,当我尝试调整编辑器的大小时,它不会调整到我想要的级别。JavaScript调整CK编辑器不能正常工作

这里有一个片段的的HTML和JS代码到更多的光线添加到我谈论什么:

  • 这是包含在我的控制器

    $scope.ckEditorConfig = { 
        uiColor : '#FFFFFF', 
        toolbarGroups: [ 
         { name: 'undo' } 
        ], 
    
        removeButtons: '', 
        extraPlugins: 'font,sourcedialog,sourcearea,stylescombo,colorbutton, colordialog', 
        contentsCss: '/path/to/css', 
        customConfig: '/path/to/js', 
        width: 561, 
        height: 150 
    }; 
    
    
    websiteApp.directive('ckEditor', ['$timeout', function ($timeout) { 
    return { 
        require: '?ngModel', 
        link: function ($scope, elm, attr, ngModel) { 
         var ck = CKEDITOR.replace(elm[0]); 
         if($scope.ckEditorConfig){ 
          $.each($scope.ckEditorConfig, function(key, value){ 
           ck.config[key] = value; 
          }); 
         } 
    
         var height = ck.config.height; var width = ck.config.width; 
         if(height && width){ 
          ck.on('instanceReady', function(event){ 
           var editor = event.editor; 
           console.log('ck height: '+ height+', ck width: '+width); 
           console.log('editor config height: '+ editor.config.height+', editor config width: '+editor.config.width); 
           editor.resize(editor.config.width, editor.config.height, false, false); 
          }); 
          // ck.resize(height, width, true, false); 
         } 
        } 
    }; 
    

    }]) ;

,我有这个在我的HTML

> <textarea id="fflFieldLabel" class="txtArea" rows="1" 
> ng-model="{{ngmodel}}" ck-editor></textarea> 

回答

0

试试这个:

<textarea id="fflFieldLabel" ></textarea> 
    CKEDITOR.replace('#myfield',{customConfig :'',width:'700px',height:'700px'}); 

或改变textarea标签的宽度和高度。希望它能起作用。

+0

没有,没有任何区别 – dlimestar

0

如果您使用的是config.widthconfig.height,则不需要调用editor.resize,应根据初始化时编辑器自动根据配置自动设置大小。

它与

<textarea name="editor1" id="editor1" rows="1" cols="80"> 
    <p>Foo Bar Baz</p> 
</textarea> 

CKEDITOR.replace('editor1', { width: 450, height: 150 }); 

因此,也许有一些整合问题,或尺寸被覆盖/更新别的地方?