public moveChildUpOne()

in src/plugin/fieldViews/RepeaterFieldView.ts [176:199]


  public moveChildUpOne(index: number) {
    if (index < 1 || index > this.node.childCount - 1) {
      console.error(
        `Cannot move index ${index} up: index out of range. Minimum 1, Maximum ${
          this.node.childCount - 1
        }`
      );
      return;
    }

    const tr = this.outerView.state.tr;
    const nodeToMove = this.node.child(index);
    const startOfNodeToMove = this.getStartOfChildNode(
      this.node,
      index,
      this.getPos(),
      this.offset
    );
    const endOfNodeToMove = startOfNodeToMove + nodeToMove.nodeSize;
    const previousNode = this.node.child(index - 1);
    tr.deleteRange(startOfNodeToMove, endOfNodeToMove);
    tr.insert(startOfNodeToMove - previousNode.nodeSize, nodeToMove);
    this.outerView.dispatch(tr);
  }