2017-08-03 89 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 }); 

因此,也許有一些整合問題,或尺寸被覆蓋/更新別的地方?