Javascript 如何从链接对话框(ckeditor)中删除协议
我想删除ckeditor(links->protocol)中“other”对话框的选项 这让用户感到困惑;他们没有指定协议,然后链接在我的服务器上查找文件(而不是外部链接,这会让用户感到困惑) 我尝试从link.js中删除“other”选项,但没有成功(仍然显示)。如果我从语言文件中删除它,我会得到“未定义”而不是其他。我尝试过搜索像“ckeditor删除链接协议”这样的东西,但运气不好Javascript 如何从链接对话框(ckeditor)中删除协议,javascript,hyperlink,dialog,ckeditor,protocols,Javascript,Hyperlink,Dialog,Ckeditor,Protocols,我想删除ckeditor(links->protocol)中“other”对话框的选项 这让用户感到困惑;他们没有指定协议,然后链接在我的服务器上查找文件(而不是外部链接,这会让用户感到困惑) 我尝试从link.js中删除“other”选项,但没有成功(仍然显示)。如果我从语言文件中删除它,我会得到“未定义”而不是其他。我尝试过搜索像“ckeditor删除链接协议”这样的东西,但运气不好 有人能帮我解决这个问题吗?我们遇到了类似的问题,我们还从下拉列表中删除了另一个选项 在plugins\lin
有人能帮我解决这个问题吗?我们遇到了类似的问题,我们还从下拉列表中删除了另一个选项 在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://']]
它应该很好用。请参见下面的屏幕截图
我通过修改config.js文件找到了解决方案。(我总是找几个小时,最后决定这样问,然后得到一个新的想法,再过一会儿就找到解决办法><) 这一部分有很好的文档记录。谷歌搜索“删除下拉选项”更成功
dialogDefinition.getContents()
获取选项卡
get('protocol')
获取输入项
splice(4,1)获取上面返回的对象的item属性,并从列表中删除最后一个元素(我想我可以使用pop,但不管怎样)。因此不再有其他
选项
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 plugin的config.js中奇怪,这是我第一次尝试,但没有成功。我在下面用另一种方式修复了它,但是谢谢你的建议[+1]!在我意识到文件被缓存之前,这对我也不起作用。对于我之后的人,请确保在更改link.js后清除缓存…CTRL+F5对我不起作用,我必须在IE开发工具栏中清除。请参阅:有关自定义链接对话框的示例。
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');
}
});