简体   繁体   English

如何从链接对话框中删除协议(ckeditor)

[英]How to remove protocols from link dialog (ckeditor)

I want to remove the option for the "other" dialog in ckeditor (links -> protocol). 我想删除ckeditor中的“其他”对话框的选项(链接 - >协议)。

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). 我尝试从link.js中删除“其他”选项,但这不起作用(仍然显示)。 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. 我试过没有运气搜索“ckeditor删除链接协议”之类的所有内容。

Can anyone help me with this? 谁能帮我这个?

I found the solution - by making changes to the config.js file. 我找到了解决方案 - 通过更改config.js文件。 (I always look for hours, finally decide to ask SO, then get a new idea and find the solution only a bit later >< ) (我总是看几个小时,最后决定问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);

This part is somewhat well documented. 这部分有一点记录。 Google search for "removing dropdown options" was more succesful. 谷歌搜索“删除下拉选项”更为成功。

dialogDefinition.getContents() gets the tab dialogDefinition.getContents()获取选项卡

get('protocol') gets the input item get('protocol')获取输入项

['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). ['items'].splice(4, 1)获取上面返回的对象的item属性,并从列表中删除最后一个元素(我想我可以使用pop但是无论如何)。 So there's nolonger the other option. 所以没有other选择了。

We had similar issue and we also removed the other option from the dropdown list. 我们遇到了类似的问题,我们也从下拉列表中删除了另一个选项。

Modify the following text in the link.js file from the plugins\\link\\dialog folder 从plugins \\ link \\ dialog文件夹修改link.js文件中的以下文本

items:[['http://‎','http://'],['https://‎','https://'],['ftp://‎','ftp://'],['news://‎','news://'],[E.other,'']]

with this 有了这个

items:[['http://‎','http://'],['https://‎','https://'],['ftp://‎','ftp://'],['news://‎','news://']]

and it should work fine. 它应该工作正常。 See the screen shot below 请参见下面的屏幕截图

在此输入图像描述

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

    }
});

Put the above code in config.js of ckeditor plugin 将上面的代码放在ckeditor插件的config.js中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM