2011-07-22 101 views

回答

5

想通了

if (dialogName == 'link') 
    { 
     var infoTab = dialogDefinition.getContents('info'); 
     var linktypeField = infoTab.get('linkType'); 

     /* Remove it from the array of items */ 
     linktypeField['items'].splice(1, 1); 

    } 
3

dialogDefinition允許您完全重新設計對話框。

我做了這樣的基礎上,例如在http://nightly.ckeditor.com/7156/_samples/api_dialog.html

CKEDITOR.on('dialogDefinition', function(ev) 
{ 
    // Take the dialog name and its definition from the event 
    // data. 
    var dialogName = ev.data.name; 
    var dialogDefinition = ev.data.definition; 

    // Check if the definition is from the dialog we're 
    // interested on (the "Link" dialog). 
    if (dialogName == 'link') 
    { 
     // Get a reference to the "Link Info" tab. 
     var infoTab = dialogDefinition.getContents('info'); 
     infoTab.remove('linkType'); 
    } 
}); 

$("#mydiv").ckeditor(function(){}, { 
    removeDialogTabs: 'link:advanced;link:target' 
    // any other customizations go here. 
}); 
+0

只是爲了確保我明白了,你的答案會刪除下拉一起。所以要從下拉列表中只刪除一個選項,我必須刪除現有的選項並添加一個自定義的選項? – montrealmike

+0

我以爲你想讓盒子完全消失。我看到你已經找到了解決問題的方法。 –

0

這是我的解決方案:

CKEDITOR.on('dialogDefinition', function (ev) { 
// Take the dialog name and its definition from the event data. 
var dialogName = ev.data.name; 
var dialogDefinition = ev.data.definition; 
// Check if the definition is from the dialog we're 
// interested in (the 'link' dialog). 
if (dialogName == 'link') { 
    // Remove the 'Target' and 'Advanced' tabs from the 'Link' dialog. 
    //dialogDefinition.removeContents('target'); 
    //dialogDefinition.removeContents('advanced'); 

    // Get a reference to the 'Link Info' tab. 
    var infoTab = dialogDefinition.getContents('info'); 
    infoTab.remove('protocol'); 
    infoTab.get('linkType').style = 'display: none'; 
} 

});

如果您擺脫使用infoTab.remove('linkType');鏈接類型它將無法創建鏈接