Skip to content

Commit ff7eed4

Browse files
authored
refactor: Change how we handle blocks to make it possible to support more Deepnote ones. (#17)
1 parent c5b24c3 commit ff7eed4

21 files changed

+1673
-977
lines changed

src/notebooks/deepnote/MimeTypeProcessor.ts

Lines changed: 0 additions & 175 deletions
This file was deleted.

src/notebooks/deepnote/OutputTypeDetector.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { NotebookCellData } from 'vscode';
2+
3+
import type { DeepnoteBlock } from '../deepnoteTypes';
4+
5+
export interface BlockConverter {
6+
applyChangesToBlock(block: DeepnoteBlock, cell: NotebookCellData): void;
7+
canConvert(blockType: string): boolean;
8+
convertToCell(block: DeepnoteBlock): NotebookCellData;
9+
getSupportedTypes(): string[];
10+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { NotebookCellData, NotebookCellKind } from 'vscode';
2+
3+
import type { BlockConverter } from './blockConverter';
4+
import type { DeepnoteBlock } from '../deepnoteTypes';
5+
6+
export class CodeBlockConverter implements BlockConverter {
7+
applyChangesToBlock(block: DeepnoteBlock, cell: NotebookCellData): void {
8+
block.content = cell.value || '';
9+
}
10+
11+
canConvert(blockType: string): boolean {
12+
return blockType.toLowerCase() === 'code';
13+
}
14+
15+
convertToCell(block: DeepnoteBlock): NotebookCellData {
16+
const cell = new NotebookCellData(NotebookCellKind.Code, block.content || '', 'python');
17+
18+
return cell;
19+
}
20+
21+
getSupportedTypes(): string[] {
22+
return ['code'];
23+
}
24+
}

0 commit comments

Comments
 (0)