deleteText = (transaction, currPos, length) => {
  const startLength = length;
  const startAttrs = map.copy(currPos.currentAttributes);
  const start = currPos.right;

  while (length > 0 && currPos.right !== null) {
    if (currPos.right.deleted === false) {
      switch (currPos.right.content.constructor) {
        case ContentType:
        case ContentEmbed:
        case ContentString:
          if (length < currPos.right.length) {
            getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length));
          }

          length -= currPos.right.length;
          currPos.right.delete(transaction);
          break;
      }
    }

    currPos.forward();
  }

  if (start) {
    cleanupFormattingGap(transaction, start, currPos.right, startAttrs, map.copy(currPos.currentAttributes));
  }

  const parent =
  /** @type {AbstractType<any>} */

  /** @type {Item} */
  (currPos.left || currPos.right).parent;

  if (parent._searchMarker) {
    updateMarkerChanges(parent._searchMarker, currPos.index, -startLength + length);
  }

  return currPos;
}
@param {Transaction} transaction
@param {ItemTextListPosition} currPos
@param {number} length
@return {ItemTextListPosition}

@private
@function