import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
export const moveTargetIntoList = ({
  insertPosition,
  $target
}) => {
  var _$target$nodeAfter;
  // take the text content of the paragraph and insert after the paragraph up until before the the cut
  const from = insertPosition;
  const to = $target.pos + (((_$target$nodeAfter = $target.nodeAfter) === null || _$target$nodeAfter === void 0 ? void 0 : _$target$nodeAfter.nodeSize) || 0); //$cut.pos + $cut.nodeAfter.nodeSize;
  const gapFrom = $target.posAtIndex(0, $target.depth + 1); // start pos of the child
  const gapTo = $target.doc.resolve(gapFrom).end(); // end pos of the paragraph

  if (gapTo - gapFrom === 0) {
    return new ReplaceStep(from, to, $target.doc.slice(insertPosition, $target.pos));
  }
  const step = new ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
  return step;
};
// eslint-disable-next-line @atlaskit/editor/no-re-export
export { wrapTaskListIntoListAbove } from './wrapTaskListIntoListAbove';