lib/utils.js
function condenseBlocks(editorState, blocks, options) {
  blocks = blocks || editorState.getCurrentContent().getBlocksAsArray();
  var text = (0, _immutable.List)();
  var characterList = (0, _immutable.List)();

  // Gather all the text/characterList and concat them
  blocks.forEach(function (block) {
    // Atomic blocks should be ignored (stripped)
    if (block.getType() !== 'atomic') {
      text = text.push(replaceNewlines(block.getText()));
      characterList = characterList.concat(block.getCharacterList());
    }
  });

  // Strip entities?
  if (options.stripEntities) {
    characterList = characterList.map(stripEntityFromCharacterMetadata);
  }

  // Create a new content block
  var contentBlock = new _draftJs.ContentBlock({
    key: (0, _draftJs.genKey)(),
    text: text.join(''),
    type: 'unstyled',
    characterList: characterList,
    depth: 0
  });

  // Update the editor state with the compressed version
  var newContentState = _draftJs.ContentState.createFromBlockArray([contentBlock]);
  // Create the new state as an undoable action
  editorState = _draftJs.EditorState.push(editorState, newContentState, 'remove-range');
  // Move the selection to the end
  return _draftJs.EditorState.moveFocusToEnd(editorState);
}
function condenseBlocks(editorState, blocks, options) {
  blocks = blocks || editorState.getCurrentContent().getBlocksAsArray();
  var text = (0, _immutable.List)();
  var characterList = (0, _immutable.List)();

  // Gather all the text/characterList and concat them
  blocks.forEach(function (block) {
    // Atomic blocks should be ignored (stripped)
    if (block.getType() !== 'atomic') {
      text = text.push(replaceNewlines(block.getText()));
      characterList = characterList.concat(block.getCharacterList());
    }
  });

  // Strip entities?
  if (options.stripEntities) {
    characterList = characterList.map(stripEntityFromCharacterMetadata);
  }

  // Create a new content block
  var contentBlock = new _draftJs.ContentBlock({
    key: (0, _draftJs.genKey)(),
    text: text.join(''),
    type: 'unstyled',
    characterList: characterList,
    depth: 0
  });

  // Update the editor state with the compressed version
  var newContentState = _draftJs.ContentState.createFromBlockArray([contentBlock]);
  // Create the new state as an undoable action
  editorState = _draftJs.EditorState.push(editorState, newContentState, 'remove-range');
  // Move the selection to the end
  return _draftJs.EditorState.moveFocusToEnd(editorState);
}
Condense an array of content blocks into a single block
@param  {EditorState} editorState draft-js EditorState instance
@param  {Array} blocks Array of ContentBlocks
@param  {Object} options
@return {EditorState} A modified EditorState instance