dist/hashedit.js
function(html) {

      var x, newNode, node, firstChild;

      // create a new node
      newNode = document.createElement('div');
      newNode.innerHTML = html;

      // get new new node
      newNode = newNode.childNodes[0];
      newNode.setAttribute('hashedit-element', '');

      hashedit.setupElementMenu(newNode);

      // get existing node
      node = document.querySelector('[hashedit-sortable] [data-selector]');

      if (node === null) {

        if (hashedit.current.node !== null) {

          // insert after current node
          hashedit.current.node.parentNode.insertBefore(newNode, hashedit.current.node.nextSibling);

        }

      }
      else {
        // replace existing node with newNode
        node.parentNode.replaceChild(newNode, node);
      }

      var types = 'p, h1, h2, h3, h4, h5, li, td, th, blockquote, pre';

      // set editable children
      var editable = newNode.querySelectorAll(types);

      for (x = 0; x < editable.length; x += 1) {
        editable[x].setAttribute('contentEditable', 'true');
      }

      if (types.indexOf(newNode.nodeName.toLowerCase()) != -1) {
        newNode.setAttribute('contentEditable', 'true');
      }

      // select element
      function selectElementContents(el) {
        var range = document.createRange();
        range.selectNodeContents(el);
        var sel = window.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
      }

      // focus on first element
      if (editable.length > 0) {

        editable[0].focus();
        selectElementContents(editable[0]);

        // show edit options for the text
        hashedit.showTextOptions(editable[0]);

        // select editable contents, #ref: http://bit.ly/1jxd8er
        hashedit.selectElementContents(editable[0]);
      }
      else {

        if(newNode.matches(types)) {

          newNode.focus();
          selectElementContents(newNode);

        }

      }

      return newNode;

    }
function(html) {

      var x, newNode, node, firstChild;

      // create a new node
      newNode = document.createElement('div');
      newNode.innerHTML = html;

      // get new new node
      newNode = newNode.childNodes[0];
      newNode.setAttribute('hashedit-element', '');

      hashedit.setupElementMenu(newNode);

      // get existing node
      node = document.querySelector('[hashedit-sortable] [data-selector]');

      if (node === null) {

        if (hashedit.current.node !== null) {

          // insert after current node
          hashedit.current.node.parentNode.insertBefore(newNode, hashedit.current.node.nextSibling);

        }

      }
      else {
        // replace existing node with newNode
        node.parentNode.replaceChild(newNode, node);
      }

      var types = 'p, h1, h2, h3, h4, h5, li, td, th, blockquote, pre';

      // set editable children
      var editable = newNode.querySelectorAll(types);

      for (x = 0; x < editable.length; x += 1) {
        editable[x].setAttribute('contentEditable', 'true');
      }

      if (types.indexOf(newNode.nodeName.toLowerCase()) != -1) {
        newNode.setAttribute('contentEditable', 'true');
      }

      // select element
      function selectElementContents(el) {
        var range = document.createRange();
        range.selectNodeContents(el);
        var sel = window.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
      }

      // focus on first element
      if (editable.length > 0) {

        editable[0].focus();
        selectElementContents(editable[0]);

        // show edit options for the text
        hashedit.showTextOptions(editable[0]);

        // select editable contents, #ref: http://bit.ly/1jxd8er
        hashedit.selectElementContents(editable[0]);
      }
      else {

        if(newNode.matches(types)) {

          newNode.focus();
          selectElementContents(newNode);

        }

      }

      return newNode;

    }
function ( html ) { var x , newNode , node , firstChild ; // create a new node newNode = document . createElement ( 'div' ) ; newNode . innerHTML = html ; // get new new node newNode = newNode . childNodes [ 0 ] ; newNode . setAttribute ( 'hashedit-element' , '' ) ; hashedit . setupElementMenu ( newNode ) ; // get existing node node = document . querySelector ( '[hashedit-sortable] [data-selector]' ) ; if ( node === null ) { if ( hashedit . current . node !== null ) { // insert after current node hashedit . current . node . parentNode . insertBefore ( newNode , hashedit . current . node . nextSibling ) ; } } else { // replace existing node with newNode node . parentNode . replaceChild ( newNode , node ) ; } var types = 'p, h1, h2, h3, h4, h5, li, td, th, blockquote, pre' ; // set editable children var editable = newNode . querySelectorAll ( types ) ; for ( x = 0 ; x < editable . length ; x += 1 ) { editable [ x ] . setAttribute ( 'contentEditable' , 'true' ) ; } if ( types . indexOf ( newNode . nodeName . toLowerCase ( ) ) != - 1 ) { newNode . setAttribute ( 'contentEditable' , 'true' ) ; } // select element function selectElementContents ( el ) { var range = document . createRange ( ) ; range . selectNodeContents ( el ) ; var sel = window . getSelection ( ) ; sel . removeAllRanges ( ) ; sel . addRange ( range ) ; } // focus on first element if ( editable . length > 0 ) { editable [ 0 ] . focus ( ) ; selectElementContents ( editable [ 0 ] ) ; // show edit options for the text hashedit . showTextOptions ( editable [ 0 ] ) ; // select editable contents, #ref: http://bit.ly/1jxd8er hashedit . selectElementContents ( editable [ 0 ] ) ; } else { if ( newNode . matches ( types ) ) { newNode . focus ( ) ; selectElementContents ( newNode ) ; } } return newNode ; }
Appends items to the editor
Appends items to the editor