简体   繁体   English

CKEditor:删除“链接类型”选项,但是将URL设置为默认链接类型吗?

[英]CKEditor: Remove 'Link Type' option, but set URL as default Link Type?

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. 我正在使用CKEditor的链接插件,并且试图删除“链接类型”选项,以便用户可以在URL字段中输入地址,而不必设置“链接类型”选项。 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. 当我使用下面的代码时,它删除了“链接类型”选项,但是当您尝试单击它创建的链接时,它没有按预期方式打开链接。

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? 因此,我想知道如何设置默认的“链接类型”作为URL,以便可以成功打开链接,还可以删除手动设置“链接类型”的选项?

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

在此处输入图片说明

As I understand at the moment of writing this answer, if you get rid of Link Type using infoTab.remove('linkType'); 据我在撰写此答案时所了解,如果您使用infoTab.remove('linkType');摆脱了链接类型 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 : 我发现的解决方案是使用.style =来隐藏链接类型 ,如下所示:

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. 如果您找到其他解决方案,请随时与我们分享。

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

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