2015-01-15 2 views
0

코드 0 :ckeditor 4 jQuery Adapter, 사용자 정의 단추를 추가하는 방법?

$editor.ckeditor(function() { 
    var editor = this; 
    editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, { 
     label: 'My Button', 
     command: 'test' 
    }); 
}, {toolbar: [['MyButton']]}); 

코드 1 :

var editor = CKEDITOR.replace('editor', {toolbar: [['MyButton']]}); 
editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, { 
    label: 'My Button', 
    command: 'test' 
}); 

[코드 1] 툴바에서 보여 정상 OK이지만 [코드 0] 작동하지 않고, jQuery 어댑터를 사용하여 사용자 정의 단추를 추가하는 방법 ??



업데이트 [코드 0] :

$editor.ckeditor(function() { 
    var editor = this; 
    editor.on('pluginsLoaded', function(event) { 
     editor.ui.add('MyButton', CKEDITOR.UI_BUTTON, { 
      label: 'My Button', 
      command: 'test' 
     }); 
    }); 
}, 
{ 
    customConfig: '/ckeditor-config.js' 
}); 

답변

3

사용 pluginsLoaded 이벤트 (jsFiddle) :

$('textarea').ckeditor({ 
     on: { 
      pluginsLoaded: function() { 
       this.ui.add('MyButton', CKEDITOR.UI_BUTTON, { 
        label: 'My Button', 
        command: 'test' 
       }); 

       console.log(this.name + ' plugins ready!'); 
      } 
     }, 
     toolbar: [['MyButton']] 
    }, 
    function(textarea) { 
     console.log(this.name + ' instance ready!'); 
}); 
+0

나는 이것을 알고 있고 그래서 내 대답보다는 확실히 낫다하지 않았다 나는 그것을 제거했다. – jazZRo

+0

안녕하세요 oleq, [code 0]을 업데이트하고, 사용자 정의 구성 js를 사용한 다음 여전히 나를 위해 작동하지 않습니다. – CAM

관련 문제