function exec(composer, command, value) {
      value = (typeof value === "undefined" ? "undefined" : _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.element);
        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);
      }
    }
/**
     * Inserts an <img>
     * If selection is already an image link, it removes it
     * 
     * @example
     *    // either ...
     *    wysihtml5.commands.insertImage.exec(composer, "insertImage", "http://www.google.de/logo.jpg");
     *    // ... or ...
     *    wysihtml5.commands.insertImage.exec(composer, "insertImage", { src: "http://www.google.de/logo.jpg", title: "foo" });
     */
Inserts an 
If selection is already an image link, it removes it


Inserts an If selection is already an image link it removes it
function exec(composer, command, value) {
      value = (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" ? value : { src: value };
      var doc = composer.doc,
          image = this.state(composer),
          textNode,
          i,
          parent;
      if (image) {
        composer.selection.setBefore(image);
        parent = image.parentNode;
        parent.removeChild(image);
        wysihtml5.dom.removeEmptyTextNodes(parent);
        if (parent.nodeName === "A" && !parent.firstChild) {
          composer.selection.setAfter(parent);
          parent.parentNode.removeChild(parent);
        }
        wysihtml5.quirks.redraw(composer.element);
        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);
      }
    }
function exec ( composer , command , value ) { value = ( typeof value === "undefined" ? "undefined" : _typeof ( value ) ) === "object" ? value : { src : value } ; var doc = composer . doc , image = this . state ( composer ) , textNode , i , parent ; if ( image ) { composer . selection . setBefore ( image ) ; parent = image . parentNode ; parent . removeChild ( image ) ; wysihtml5 . dom . removeEmptyTextNodes ( parent ) ; if ( parent . nodeName === "A" && ! parent . firstChild ) { composer . selection . setAfter ( parent ) ; parent . parentNode . removeChild ( parent ) ; } wysihtml5 . quirks . redraw ( composer . element ) ; 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 ) ; } }
Inserts an <img>
 If selection is already an image link, it removes it
Inserts an <img > If selection is already an image link it removes it
// Image already selected, set the caret before it and delete it // and it's parent <a> too if it hasn't got any other relevant child nodes // firefox and ie sometimes don't remove the image handles, even though the image got removed