2017-10-04 10 views
0

위젯 코드의 'editables'부분에있는 툴바에서 특정 위젯을 비활성화 할 수 있는지 궁금합니다. 현재 위젯에 대해 아래 코드를 설정했습니다. 이러한 선택기 내에서 사용자가 ToolBar의 특정 위젯에 추가하는 것을 원하지 않습니다.커서가 위젯의 편집 가능한 부분에있는 동안 툴바에서 특정 버튼을 비활성화 하시겠습니까? (CKEditor 버전 4.5.11)

this.editables = { 
    content1: { 
     selector: '.content1', 
     allowedContent: this.allowedContent 

    }, 
    content2: { 
     selector: '.content2', 
     allowedContent: this.allowedContent 
    }, 
    content3: { 
     selector: '.content3', 
     allowedContent: this.allowedContent 
    } 
    }; 

아래의 로직을 추가하려고했지만 코드가 손상됩니다.

var oWidget= editor.getCommand('customWidget') 
oWidget.setState(CKEDITOR.TRISTATE_DISABLED); 

모든 조언을 주시면 감사하겠습니다.

감사합니다.

답변

0

사용자 선택 이벤트를 확인하고 editable portion enable 명령을 선택해야합니다. 이 같은

뭔가 -

CKEDITOR.instances["textarea"].on('selectionChange', function(evt) { 
    // get desired command from ckeditor 
    var myCommand = this.getCommand('CKEDITOR_COMMAND_NAME'); 
    var mySelection = null; 
    // check if something is selected 
    var mySelection = this.getSelection().getNative() || this.window.$.getSelection() || this.document.$.selection; 
    if (!mySelection) { 
    // if not stay disable 
     myCommand.disable(); 
    } else { 
    //if yes enable command 
    myCommand.enable(); 
    } 

});