Insert Paragraph Operation

특정 위치에 새 단락 노드를 삽입합니다.

개요

Insert paragraph operation은 새 단락 노드를 생성합니다. 일반적으로 사용자가 Enter 키를 누를 때 트리거됩니다.

인터페이스

interface InsertParagraphOperation extends Operation {
  type: 'insertParagraph';
  path: Path;
}

사용법

function insertParagraph(editor: Editor, position: Path) {
  const operation: InsertParagraphOperation = {
    type: 'insertParagraph',
    path: position
  };
  
  editor.applyOperation(operation);
}

// 역: 단락 삭제
const inverse = {
  type: 'deleteNode',
  path: position
};