Forums / Cotonti / Extensions / Support / CKeditor - How can we change the output?

Macik
#34563 2012-06-04 00:18

There is another way that meet you needs. It's improvement of default Image dialog for adding Rel attribute.

Here is the sample code for (ckeditor/lib/plugins/image/dialogs/image.js):

{
    type : 'text',
    id : 'txtdlgGenRel',
    label : editor.lang.link.rel,
    'default' : '',
    validate : function() {
	var regexValidRel = /^\w+$|^$/i;
	var aMatch = this.getValue().match(regexValidRel), isValid = !!(aMatch);
	if (!isValid)
	    alert('Not allowed type of Rel');
	return isValid;
    },
    setup : function(type, element) {
	if (type == IMAGE) {
	    var genRel = element.getAttribute('rel');
	    if (!genRel && element.$.prop('rel'))
		genRel = element.$.prop('rel');
	    this.setValue(genRel);
	    var regexValidRel = /^\w+$|^$/i;
	    var rel = element.$.prop('rel');
	    aMatchRel = (rel ? rel : '').match(regexValidRel);

	    this.attributesInStyle = {
		rel : !!aMatchRel
	    };
	}
    },
    commit : function(type, element) {
	if (type == IMAGE && (this.getValue() || this.isChanged())) {
	    element.setAttribute('rel', this.getValue());
	}
    }
}

Full code is here: http://www.cotonti.com/pastebin/170

 

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F