Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove protocols from link dialog (ckeditor)

I want to remove the option for the "other" dialog in ckeditor (links -> protocol).

It's confusing for the user; they don't specify a protocol, then the link looks for a file on my server (instead of an external link, confusing the user).

I tried removing the "other" option from link.js, but that didn't work (still shows up). If I remove it from the language files, I get "undefined" instead of other. I've tried searching for everything like "ckeditor remove link protocol" without luck.

Can anyone help me with this?

like image 408
Raekye Avatar asked Nov 11 '12 20:11

Raekye


1 Answers

I found the solution - by making changes to the config.js file. (I always look for hours, finally decide to ask SO, then get a new idea and find the solution only a bit later >< )

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' )
    {
        dialogDefinition.getContents('info').get('protocol')['items'].splice(4, 1);

This part is somewhat well documented. Google search for "removing dropdown options" was more succesful.

dialogDefinition.getContents() gets the tab

get('protocol') gets the input item

['items'].splice(4, 1) gets the item property of the object returned above, and removes the last element from the list (I think I could use pop but whatever). So there's nolonger the other option.

like image 70
Raekye Avatar answered Sep 26 '22 07:09

Raekye