volume one
volume one

Reputation: 7543

CKEditor remove option from select

I want to remove two options from the linkType select element on the 'Link' tab in CKEditor.

How do I do this? It says in the docs to use the remove function but I don't understand how to point it at the right element.

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

Upvotes: 0

Views: 1360

Answers (2)

TheVillageIdiot
TheVillageIdiot

Reputation: 40497

We are using this to remove linkType and other extra stuff from dialog:

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

EDIT:- As described in this page and this answer, you can get element and specify options for it.

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

Upvotes: 3

volume one
volume one

Reputation: 7543

I just found the answer here: 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']];
    }
});

Upvotes: 0

Related Questions