我想删除ckeditor中“其他”对话框的选项(链接->协议)。
这让用户感到困惑;他们没有指定协议,然后链接在我的服务器上查找文件(而不是外部链接,使用户感到困惑)。
我尝试从 link.js 中删除“其他”选项,但这不起作用(仍然显示)。如果我从语言文件中删除它,我会得到“未定义”而不是其他。我尝试过搜索“ckeditor remove link protocol”之类的所有内容,但没有运气。
谁能帮我这个?
我想删除ckeditor中“其他”对话框的选项(链接->协议)。
这让用户感到困惑;他们没有指定协议,然后链接在我的服务器上查找文件(而不是外部链接,使用户感到困惑)。
我尝试从 link.js 中删除“其他”选项,但这不起作用(仍然显示)。如果我从语言文件中删除它,我会得到“未定义”而不是其他。我尝试过搜索“ckeditor remove link protocol”之类的所有内容,但没有运气。
谁能帮我这个?
我找到了解决方案 - 通过更改 config.js 文件。(我总是找几个小时,最后决定问 SO,然后得到一个新想法,稍后才找到解决方案><)
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);
这部分是有据可查的。谷歌搜索“删除下拉选项”更成功。
dialogDefinition.getContents()获取标签
get('protocol')获取输入项
['items'].splice(4, 1)获取上面返回的对象的 item 属性,并从列表中删除最后一个元素(我想我可以使用 pop 但无论如何)。所以已经没有other选择了。
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');
    }
});
将上述代码放在ckeditor插件的config.js中
我们有类似的问题,我们还从下拉列表中删除了另一个选项。
修改 plugins\link\dialog 文件夹中的 link.js 文件中的以下文本
items:[['http://','http://'],['https://','https://'],['ftp://','ftp://'],['news://','news://'],[E.other,'']]
有了这个
items:[['http://','http://'],['https://','https://'],['ftp://','ftp://'],['news://','news://']]
它应该可以正常工作。请参阅下面的屏幕截图
