CKEditor Link Dialog Removal Protocol

In my CKEditor, I deleted the 'linkType' and 'protocol' input in the link dialog.

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

    });

However, evertype I type something like https://google.com , as soon as I type "g", https: // is deleted.
I checked the output and it always says http: // ignoring input.

How can I disable this stupid behavior?

+5
source share
5 answers

After much research, debugging and tuning, I finally managed to remove this!

Here is how I do it:

CKEDITOR.on('dialogDefinition', function(e) {
    // NOTE: this is an instance of CKEDITOR.dialog.definitionObject
    var dd = e.data.definition; 

    if (e.data.name === 'link') {
        dd.minHeight = 30;

        // remove the unwanted tabs
        dd.removeContents('advanced');
        dd.removeContents('target');
        dd.removeContents('upload');

        // remove all elements from the 'info' tab
        var tabInfo = dd.getContents('info');
        while (tabInfo.elements.length > 0) {
            tabInfo.remove(tabInfo.elements[0].id);
        }

        // add a simple URL text field
        tabInfo.add({
            type : 'text',
            id : 'urlNew',
            label : 'URL',
            setup : function(data) {
                var value = '';
                if (data.url) {
                    if (data.url.protocol) {
                        value += data.url.protocol;
                    }
                    if (data.url.url) {
                        value += data.url.url;
                    }
                } else if (data.email && data.email.address) {
                    value = 'mailto:' + data.email.address;
                }
                this.setValue(value);
            },
            commit : function(data) {
                data.url = { protocol: '', url: this.getValue() };
            }
        });
    }
});
+11
source

I am afraid there is no way to change it. You must manually edit a few lines of code to make it work.

+1

v4.5.1:

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('protocol');

        var url = infoTab.get('url');
        url.onKeyUp = function(){};
        url.setup = function(data) {
            this.allowOnChange = false;
            if (data.url) {
                var value = '';
                if (data.url.protocol) {
                    value += data.url.protocol;
                }
                if (data.url.url) {
                    value += data.url.url;
                }
                this.setValue(value);
            }
            this.allowOnChange = true;
        };
        url.commit = function(data) {
            data.url = { protocol: '', url: this.getValue() };
        };
    }
});
+1

, , :

  • ///link.js
  • find d=/^(http|https|ftp|news):\/\/(?=.)/i.exec(b);
  • http|https|ftp|
  • ,

, . , ckeditor . .

0

, ( , , ), dispaly : none :

infoTab.get( 'linkType' ).style = 'display: none';

Hope this helps someone!

0
source

All Articles