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

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 16:11:43

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/25025769/ckeditor-remove-link-type-option-but-set-url-as-default-link-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!