nl_tokens: Inserts an <img > If selection is already an image link it removes it
pl_tokens: function ( composer , command , value ) { value = typeof ( value ) === "object" ? value : { src : value } ; var doc = composer . doc , image = this . state ( composer ) , textNode , i , parent ; if ( image ) { // Image already selected, set the caret before it and delete it composer . selection . setBefore ( image ) ; parent = image . parentNode ; parent . removeChild ( image ) ; // and it's parent <a> too if it hasn't got any other relevant child nodes wysihtml5 . dom . removeEmptyTextNodes ( parent ) ; if ( parent . nodeName === "A" && ! parent . firstChild ) { composer . selection . setAfter ( parent ) ; parent . parentNode . removeChild ( parent ) ; } // firefox and ie sometimes don't remove the image handles, even though the image got removed wysihtml5 . quirks . redraw ( composer . <mask> ) ; return ; } image = doc . createElement ( NODE_NAME ) ; for ( i in value ) { image [ i ] = value [ i ] ; } composer . selection . insertNode ( image ) ; if ( wysihtml5 . browser . hasProblemsSettingCaretAfterImg ( ) ) { textNode = doc . createTextNode ( wysihtml5 . INVISIBLE_SPACE ) ; composer . selection . insertNode ( textNode ) ; composer . selection . setAfter ( textNode ) ; } else { composer . selection . setAfter ( image ) ; } }