CKEditor从select中删除选项

时间:2015-02-17 21:34:53

标签: javascript ckeditor

我想从CKEditor中“链接”标签上的linkType选择元素中删除两个选项。

我该怎么做?它在文档中说使用remove函数,但我不明白如何将它指向正确的元素。

http://docs.ckeditor.com/#!/api/CKEDITOR.ui.dialog.select

2 个答案:

答案 0 :(得分:2)

我们正在使用它从对话框中删除linkType和其他额外内容:

CKEDITOR.on('dialogDefinition', function(ev) {
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;
    if (dialogName == 'link') {
        //REMOVE NOT REQUIRED TABS
        dialogDefinition.removeContents('upload');
        dialogDefinition.removeContents('advanced');

        var infoTab = dialogDefinition.getContents('info');
        //REMOVE COMBO
        infoTab.remove('linkType');
    }
});

编辑: - 如this pagethis answer中所述,您可以获取元素并为其指定选项。

var infoTab = dialogDefinition.getContents('info');
//REMOVE COMBO
var lt=infoTab.get('linkType');
lt['items']=[['URL','Link to URL']];

答案 1 :(得分:0)

我刚刚在这里找到答案:http://ckeditor.com/forums/Support/Remove-options-link-drop-down

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');

        // Get a reference to the link type
        var linkOptions = infoTab.get('linkType');

        // set the array to your preference
        linkOptions['items'] = [['URL', 'url'], ['Link to anchor in the text', 'anchor']];
    }
});