-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📢 Notebook API announcements #93265
Comments
Does the edit API need to support reordering? Like could there any transient state in webview cell outputs that would not be represented in |
If I set And I think |
Extensions already use
This should probably be done by output in the webview sending its state through webview api to extensions.
It should be override IMHO.
I agree making metadata non-optional is clear to both us (for implementation) and extensions author (maybe) but it will make cell-default-metadata on document impossible, unless we use |
We could make this even more similar to export interface NotebookEditorCellEdit {
insert(content: string, language: string, type: CellKind, outputs: CellOutput[], metadata: NotebookCellMetadata | undefined): void;
delete(cell: NotebookCell): void;
// more
}
export interface NotebookEditor {
readonly document: NotebookDocument;
viewColumn?: ViewColumn;
readonly onDidReceiveMessage: Event<any>;
postMessage(message: any): Thenable<boolean>;
editCells(callback: (cellEdit: NotebookEditorCellEdit) => any): any
} |
Right, I mean having metadata non-optional but its properties can be optional, where |
Current state of the Notebook API: we added Document Edit API and make export interface NotebookEditorCellEdit {
insert(index: number, content: string, language: string, type: CellKind, outputs: CellOutput[], metadata: NotebookCellMetadata | undefined): void;
delete(index: number): void;
}
export interface NotebookEditor {
readonly document: NotebookDocument;
viewColumn?: ViewColumn;
readonly onDidReceiveMessage: Event<any>;
postMessage(message: any): Thenable<boolean>;
edit(callback: (editBuilder: NotebookEditorCellEdit) => void): Thenable<boolean>;
} The renderer API is also simplified as export interface NotebookOutputRenderer {
render(document: NotebookDocument, output: CellOutput, mimeType: string): string;
preloads?: Uri[];
} Note that we didn't pass |
When implementing it the NotebookOutputRenderer felt a little awkward. The types indicated that I need check the output kind and check that rich output had data matching the mime type I care about... and throw an error if it's not right? Or return an empty string? Hard to know. It's also a little confusing to me because it seems like render(document: vscode.NotebookDocument, output: vscode.CellOutput): string {
if (output.outputKind !== vscode.CellOutputKind.Rich) {
return '';
}
if (output.data[Constants.TableMimeType] === undefined) {
return '';
}
// actually do stuff...
} Maybe the NotebookOutputRenderer's render function could be |
@connor4312 thanks for the feedback. you are right that customs renderers should not check The API is changed to
No functionality changes under the hood, just making the type safe. We can discuss about whether we should return |
Discussion points for coming API sync (April 14th)
export interface NotebookEditorCellEdit {
insert(index: number, content: string | string[], language: string, type: CellKind, outputs: CellOutput[], metadata: NotebookCellMetadata | undefined): void;
delete(index: number): void;
+ replace(index: number, value: string): void;
} |
Not a fan, we should not bleed implementation details into the API and there is no obvious reason why cells should be kept as lines. Also, this would be different from the text document content provider API which returns a string. If performance is of outmost matter here then we should consider talking bytes instead of strings |
I am wondering if you are planning to have all cells one below the other, just like in a notebook. Or if we will be able to have one cell occupy 50% of the webview width, as customizable as an HTML textarea. I believe extensions can benefit from having native editors and HTML content side-by-side, even if having native editors is already a great win. |
@sguillia the current UX for the native notebook will be a list of cells, or in your words, one cell below the other. |
With the stable API, Is it currently possible to create a webview like the Interactive Playground, with Markdown interleaved with editable code areas? |
Please be aware of the following BREAKING change: |
Please be aware of the following BREAKING change: Support for the |
Please be aware of the following BREAKING change: |
Please be aware of the following BREAKING change: |
Please be aware of the following BREAKING changes
|
Please be aware of the following "SEMI BREAKING" change: we have renamed |
Please be aware of the following change: the namespace has been renamed to |
Please be aware of the following changes: |
Please be aware of the following BREAKING changes
|
BREAKING changes:
|
Please be aware of the following BREAKING changes:
|
Please be aware of the following BREAKING change: support for |
Please be aware of the following BREAKING change: the deprecated |
Please be aware of the following BREAKING change: the |
BREAKING change for the new renderer api: #125351 Renames a few types and functions, and also switches around some argument orders Working to update the published types and example extensions now |
Please be aware of the following BREAKING change: we have inlines the |
Please speak up if you are using the |
We use it in the python extension to support concating cells for intellisense. |
Ok, good to hear. In that case, I don't remove it ;-) |
Note that the order of arguments in 90aa979#diff-f127724f8c5dbf0c8371ad0a100f8a9bc0a398b6b8ec29aa6cd7f265bd01a096R11580 |
🔈 events concerning the notebook documents are moving into its own, consolidated proposal: #144662 (comment). As of today both variants are supported but extensions are asked to migrate onto the |
FYI that with 1.67(-insiders) the deprecated events from the |
@jrieken the new API has been adopted in the Jupyter extension |
Closing this in favor since we've finalized a good chunk of the notebook API. Will keep following up the remaining notebook proposals in individual issues |
We introduced a proposed API for Notebook but currently the API is majorly two managed object:
NotebookDocument
andNotebookCell
. We create them for extensions and listen to their properties changes. However this doesn't follow the principal ofTextEditor/Document
whereTextDocument
is always readonly andTextEditor
is the API for applying changes to the document.If we try to follow
TextEditor/Document
, the API can be shaped as belowThe text was updated successfully, but these errors were encountered: