如何从CKeditor中的“链接”编辑器中删除“链接到锚点”

时间:2011-07-22 14:40:55

标签: ckeditor

基本上我删除了锚点按钮,因此在我的链接窗口中不应该有一个指向锚点选项的链接。

删除该下拉选项的任何方法

enter image description here

3 个答案:

答案 0 :(得分:6)

想出来

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

    }

答案 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.
});

答案 2 :(得分: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');摆脱链接类型,则无法创建链接