PrivateconstructorCreates a new NotebookDocument instance.
Document URI that determines collaborative vs local behavior
Initial notebook content as binary data
Delegate for webview interactions and content retrieval
Private Readonly_Protected_Collection of child disposables to clean up
Private_Private_Private Readonly_Private Readonly_Private Readonly_Private_Private Readonly_ReadonlyonReadonlyonReadonlyonCurrent notebook content as binary data.
Contains the serialized Jupyter notebook JSON structure. Updated automatically when edits are applied via makeEdit().
Binary representation of the notebook content
ProtectedisGets whether this instance has been disposed.
True if disposed, false otherwise
The notebook's URI.
The URI scheme determines the document's behavior:
datalayer://: Collaborative notebook with real-time synchronizationfile://: Local notebook with traditional file persistenceuntitled:: New unsaved notebookThe VS Code URI for this notebook document
Protected_Creates a backup of the notebook document.
Saves the current document state to a backup location and returns a backup descriptor for VS Code's backup/restore system.
URI for the backup location
Cancellation token for the backup operation
Promise resolving to backup descriptor with cleanup function
Disposes of the notebook document and cleans up resources.
Fires disposal events and calls the parent disposable cleanup. Should be called when the document is no longer needed to prevent memory leaks.
Records an edit operation on the notebook document.
Behavior differs based on the URI scheme:
datalayer://): Skips edit tracking since changes
are managed by the Datalayer platform's real-time synchronizationFor local notebooks, updates the document content and fires change events with undo/redo handlers for VS Code's edit history.
The edit operation to apply
Reverts the notebook document to its last saved state.
Reloads content from disk and restores the edit history to the last saved state. Fires document change events to notify the UI of the content restoration.
Cancellation token (currently unused)
Saves the notebook document to its original location.
Behavior differs based on the URI scheme:
datalayer://): No-op since changes are
automatically synchronized to the Datalayer platformCancellation token for the save operation
Saves the notebook document to a specified location.
Handles different scenarios based on URI schemes and target locations:
URI where to save the notebook
Cancellation token for the save operation
StaticcreateCreates a new NotebookDocument instance from a URI.
Handles both regular notebook files and backup restoration scenarios. For backup restoration, the backupId parameter should contain the backup file URI. Supports both local file URIs and collaborative Datalayer URIs.
The notebook URI to open
Optional backup ID for document restoration
Delegate for webview content retrieval and management
Promise resolving to the created notebook document instance
Private StaticgetReturns a minimal valid empty Jupyter notebook. Used when opening blank/empty .ipynb files.
Binary representation of an empty notebook
Private StaticreadReads notebook content from a URI.
Handles different URI schemes:
untitled: Returns empty content for new notebooksURI to read notebook content from
Binary representation of the notebook content
Represents a Jupyter notebook document in VS Code custom editor. Manages document lifecycle, content persistence, and edit tracking with support for both collaborative Datalayer notebooks and local file-based notebooks.
This class implements different behaviors based on the URI scheme:
datalayer://URIs: Collaborative notebooks with real-time sync (read-only locally)file://URIs: Local notebooks with full edit tracking and persistenceExample