Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the "link to anchor" from the "Link" editor in CKeditor

Tags:

ckeditor

Basically I removed the anchor button so there should not be a link to anchor option in my link window.

Any way to remove that dropdown option

enter image description here?

like image 214
montrealmike Avatar asked Jul 22 '11 14:07

montrealmike


2 Answers

Figured it out

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

    }
like image 154
montrealmike Avatar answered Sep 18 '22 16:09

montrealmike


dialogDefinition allows you to completely redesign dialog boxes.

I did it this way, based on the example at 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.
});
like image 42
Jeff Winkworth Avatar answered Sep 22 '22 16:09

Jeff Winkworth