-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store isInteractiveWindowMessageCell at root level
- Loading branch information
1 parent
52429e6
commit b97a4fe
Showing
3 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { NotebookCellKind, type NotebookCell, type NotebookCellData } from 'vscode'; | ||
import type * as nbformat from '@jupyterlab/nbformat'; | ||
|
||
type JupyterCellMetadata = Pick<nbformat.IRawCell, 'id' | 'metadata' | 'attachments'> & | ||
Pick<nbformat.IMarkdownCell, 'id' | 'attachments'> & | ||
Pick<nbformat.ICodeCell, 'id' | 'metadata' | 'attachments'> & | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Record<string, any>; | ||
|
||
export function getCellMetadata(cell: NotebookCell | NotebookCellData): JupyterCellMetadata { | ||
const metadata: JupyterCellMetadata = cell.metadata?.custom || {}; | ||
if (cell.kind !== NotebookCellKind.Markup) { | ||
const cellMetadata = metadata as nbformat.IRawCell; | ||
// metadata property is never optional. | ||
cellMetadata.metadata = cellMetadata.metadata || {}; | ||
} | ||
|
||
return metadata; | ||
} |