title: Split Content on CKEDITOR and get HTML of each part
body: <p>I have a CKEDITOR and i am trying to split the content in n parts, the user indicates how many parts he wants, by puting the cursor on a specific position of the CKEDITOR, after that with an option at the context-menu the user selects "Split Block", this inserts a <hr> tag in HTML: </p>
  
  
  
  <p>the user can do this n times in CKEDITOR, it is to indicate how many blocks the user wants to split the content, each hr inserted is one block.</p>
  
  <p>So when the user finish, click at the context-menu "Process Split", this action should execute and split the content in n parts.</p>
  
  <p>this is my code to split the content:</p>
  
  <pre><code>var index = 0;
  var tmpItem = null;
  var ranges = new Array();
  
  var elements = editor.document.getElementsByTag( 'hr' );
  
  for ( var i = 0; i &lt; elements.count() ; i++ )
  {
  
      var item = elements.getItem( i );
  
      ranges[index] = new CKEDITOR.dom.range( editor.document );
  
      if(tmpItem!=null)
          ranges[index].setStart(tmpItem, CKEDITOR.POSITION_BEFORE_START);
  
      else{
          ranges[index].setStartAfter(editor.document.getBody().getFirst());
  
      }
  
  
      if(item.hasClass('split-end')){
  
          ranges[index].setEnd(item, CKEDITOR.POSITION_BEFORE_START);
          ranges[index].select();
  
          index++;
  
          var sel = editor.getSelection();
          var ran = sel.getRanges();
          var el = new CKEDITOR.dom.element("div");
  
          for (var j = 1, len = ran.length; j &lt; len-1; ++j) {
              el.append(ran[j].cloneContents());
          }
  
          console.log( el.getHtml() );
  
      }
  
      tmpItem = item;
  
  }
  </code></pre>
  
  <p>The problem is: how to select from begining of the document to the first HR and so on.</p>
  
  <p>Thanks a lot, i have been trying to do this for over a week, and i dont know what else try.</p>