简体   繁体   中英

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. 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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