Redactor / Documentation / Callbacks

Link

This callback is triggered after a link inserted into Redactor, including when a linkify event occurs (a plain text URL converted into a link)

Returns jQuery element of a link.

$('#redactor').redactor({
    callbacks: {
        insertedLink: function($link)
        {
            console.log($link);
        }
    }   
});

This callback is triggered whenever a link is being deleted by a user via toolbar Unlink option.

Returns a jQuery collection of deleted link elements.

$('#redactor').redactor({
    callbacks: {
        deletedLink: function($links)
        {
            $links.each(function(i,s)
            {
                console.log(s);
            }); 
        }
    }   
});

This callback triggers before a user insert a link into Redactor.

The callback passes the link object as argument:

  • url — link url
  • text - link text
  • target - link target (true or false)

Callback must return the link object.

$('#redactor').redactor({
    callbacks: {
        beforeInsertingLink: function(link)
        {
            link.url = link.url.replace(/^http://example.com/i, '');
            return link;
        }
    }	
});