Any good editor should have undo and redo commands. This will come with some careful design considerations.