(cell: PercentCell, index: number, idGenerator: () => string)
| 255 | } |
| 256 | |
| 257 | function convertCellToBlock(cell: PercentCell, index: number, idGenerator: () => string): DeepnoteBlock { |
| 258 | // Map cell types to Deepnote block types |
| 259 | // Raw cells are treated as markdown but preserve original type in metadata |
| 260 | const blockType = cell.cellType === 'markdown' || cell.cellType === 'raw' ? 'markdown' : 'code' |
| 261 | |
| 262 | const metadata: Record<string, unknown> = {} |
| 263 | |
| 264 | // Preserve original cell type for raw cells so they can be restored |
| 265 | if (cell.cellType === 'raw') { |
| 266 | metadata.percent_cell_type = 'raw' |
| 267 | } |
| 268 | |
| 269 | if (cell.title) { |
| 270 | metadata.title = cell.title |
| 271 | } |
| 272 | if (cell.tags && cell.tags.length > 0) { |
| 273 | metadata.tags = cell.tags |
| 274 | } |
| 275 | |
| 276 | return { |
| 277 | blockGroup: idGenerator(), |
| 278 | content: cell.content, |
| 279 | id: idGenerator(), |
| 280 | metadata: Object.keys(metadata).length > 0 ? metadata : {}, |
| 281 | sortingKey: generateSortingKey(index), |
| 282 | type: blockType, |
| 283 | } |
| 284 | } |
no test coverage detected