Delete Forward Operation

Delete content after the cursor position.

Overview

The delete forward operation removes content after the cursor. Typically triggered by Delete key.

Interface

interface DeleteForwardOperation extends Operation {
  type: 'deleteForward';
  path: Path;
  unit: 'character' | 'word' | 'line';
  deletedContent?: any;
}

Usage

function deleteForward(editor: Editor, position: Path, unit: 'character' | 'word' = 'character') {
  const operation: DeleteForwardOperation = {
    type: 'deleteForward',
    path: position,
    unit,
    deletedContent: editor.getContentAfter(position, unit)
  };
  
  editor.applyOperation(operation);
}

// Inverse: Re-insert deleted content
const inverse = {
  type: 'insertText',
  path: position,
  text: operation.deletedContent
};