CKEditor:删除“链接类型”选项,但将URL设置为默认链接类型? [英] CKEditor: Remove 'Link Type' option, but set URL as default Link Type?

查看:89
本文介绍了CKEditor:删除“链接类型”选项,但将URL设置为默认链接类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CKEditor的链接插件,我正在尝试删除链接类型选项,以便用户可以在URL字段中输入地址,而不必设置链接类型选项。当我使用下面的代码时,它会删除链接类型选项,但是当您尝试单击它创建的链接时,它不会按预期打开链接。

I'm using the Link plugin for CKEditor, and I'm trying to remove the 'Link Type' option so a user can input an address into the URL field and not have to set the 'Link Type' option. When I use the code below, it removes the 'Link Type' option, but when you try to click the link it creates, it doesn't open the link as intended.

所以我想知道如何将默认的链接类型设置为URL,以便可以成功打开链接,还可以删除手动设置链接类型的选项?

So I'm wondering how can I set the default 'Link Type' as a URL so the link can be opened successfully, but also remove the option to set 'Link Type' manually?

CKEDITOR.on('dialogDefinition', function (ev) {
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;

    if (dialogName == 'link') {
        var infoTab = dialogDefinition.getContents('info');
        infoTab.remove('linkType'); 
    }
});

推荐答案

据我所知,在撰写此答案的那一刻,如果你摆脱了链接类型使用 infoTab.remove('linkType'); 它将无法创建链接。我找到的解决方案是使用 .style = 隐藏链接类型,如下所示:

As I understand at the moment of writing this answer, if you get rid of Link Type using infoTab.remove('linkType'); it will fails to create the link. The solution I have found is to hide the Link Type using .style = as the following :

if ( dialogName == 'link' ) {
    var infoTab = dialogDefinition.getContents( 'info' );
    infoTab.get( 'linkType' ).style = 'display: none';
}

----- >>> 来源

----->>> Source

希望这有助于某人!如果您发现其他解决方案,请不要犹豫与我们分享。

Hope this help someone ! if you find another solution don't hesitate to share it with us.

这篇关于CKEditor:删除“链接类型”选项,但将URL设置为默认链接类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆