MCPcopy Create free account
hub / github.com/deepnote/deepnote / convertCellToBlock

Function convertCellToBlock

packages/convert/src/percent-to-deepnote.ts:257–284  ·  view source on GitHub ↗
(cell: PercentCell, index: number, idGenerator: () => string)

Source from the content-addressed store, hash-verified

255}
256
257function 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}

Callers 1

Calls 1

generateSortingKeyFunction · 0.90

Tested by

no test coverage detected