umd/fieldstack.js
/**
   * Converts from draft raw state to tree draft state
   */
Converts from draft raw state to tree draft state
Converts from draft raw state to tree draft state
function fromRawStateToRawTreeState(draftState) {
    var lastListDepthCacheRef = {};
    var transformedBlocks = [];
    draftState.blocks.forEach(function (block) {
      var isList = isListBlock(block);
      var depth = block.depth || 0;
      var treeBlock = _extends$10({}, block, {
        children: []
      });
      if (!isList) {
        lastListDepthCacheRef = {};
        transformedBlocks.push(treeBlock);
        return;
      }
      lastListDepthCacheRef[depth] = treeBlock;
      if (depth > 0) {
        var parent = lastListDepthCacheRef[depth - 1];
        !parent ? invariant_1(false, 'Invalid depth for RawDraftContentBlock') : void 0;
        parent.children.push(treeBlock);
        return;
      }
      transformedBlocks.push(treeBlock);
    });
    return _extends$10({}, draftState, {
      blocks: transformedBlocks
    });
  }
function fromRawStateToRawTreeState ( draftState ) { var lastListDepthCacheRef = { } ; var transformedBlocks = [ ] ; draftState . blocks . forEach ( function ( block ) { var isList = isListBlock ( block ) ; var depth = block . depth || 0 ; var treeBlock = _extends$10 ( { } , block , { children : [ ] } ) ; if ( ! isList ) { lastListDepthCacheRef = { } ; transformedBlocks . push ( treeBlock ) ; return ; } lastListDepthCacheRef [ depth ] = treeBlock ; if ( depth > 0 ) { var parent = lastListDepthCacheRef [ depth - 1 ] ; ! parent ? invariant_1 ( false , 'Invalid depth for RawDraftContentBlock' ) : void 0 ; parent . children . push ( treeBlock ) ; return ; } transformedBlocks . push ( treeBlock ) ; } ) ; return _extends$10 ( { } , draftState , { blocks : transformedBlocks } ) ; }
Converts from draft raw state to tree draft state
Converts from draft raw state to tree draft state
// reset the cache path // update our depth cache reference path // if we are greater than zero we must have seen a parent already // push nested list blocks // push root list blocks