text: /**
   * Copyright (c) 2013-present, Facebook, Inc. All rights reserved.
   *
   * This file provided by Facebook is for non-commercial testing and evaluation
   * purposes only. Facebook reserves all rights not expressly granted.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   */
  
  'use strict';
  
  import {EditorState, Modifier, SelectionState} from 'draft-js';
  
  export function removeTeXBlock(editorState, blockKey) {
    var content = editorState.getCurrentContent();
    var block = content.getBlockForKey(blockKey);
  
    var targetRange = new SelectionState({
      anchorKey: blockKey,
      anchorOffset: 0,
      focusKey: blockKey,
      focusOffset: block.getLength(),
    });
  
    var withoutTeX = Modifier.removeRange(content, targetRange, 'backward');
    var resetBlock = Modifier.setBlockType(
      withoutTeX,
      withoutTeX.getSelectionAfter(),
      'unstyled'
    );
  
    var newState = EditorState.push(editorState, resetBlock, 'remove-range');
    return EditorState.forceSelection(newState, resetBlock.getSelectionAfter());
  }
  