Skip to content

Commit

Permalink
Support multiple cells
Browse files Browse the repository at this point in the history
  • Loading branch information
nichochar committed Jul 17, 2024
1 parent ba4991e commit ac84ceb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/web/src/routes/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,19 @@ function Session(props: { session: SessionType; channel: SessionChannel; config:
}

async function insertGeneratedCells(idx: number, cells: Array<CodeCellType | MarkdownCellType>) {
for (const cell of cells) {
for (let i = 0; i < cells.length; i++) {
const cell = cells[i];
const insertIdx = idx + i;
let newCell;
switch (cell.type) {
case 'code':
newCell = createCodeCell(idx, session.metadata.language, cell);
newCell = createCodeCell(insertIdx, session.metadata.language, cell);
break;
case 'markdown':
newCell = createMarkdownCell(idx, cell);
newCell = createMarkdownCell(insertIdx, cell);
break;
}
channel.push('cell:create', { sessionId: session.id, index: idx, cell: newCell });
channel.push('cell:create', { sessionId: session.id, index: insertIdx, cell: newCell });
}
}

Expand Down

0 comments on commit ac84ceb

Please sign in to comment.