The document context object.

interface IContext<T> {
    contentsModel: null | Omit<Contents.IModel, "content">;
    disposed: ISignal<IContext<T>, void>;
    fileChanged: ISignal<IContext<T>, Omit<Contents.IModel, "content">>;
    isDisposed: boolean;
    isReady: boolean;
    lastModifiedCheckMargin: number;
    localPath: string;
    model: T;
    path: string;
    pathChanged: ISignal<IContext<T>, string>;
    ready: Promise<void>;
    saveState: ISignal<IContext<T>, DocumentRegistry.SaveState>;
    sessionContext: ISessionContext;
    urlResolver: IRenderMime.IResolver;
    addSibling(widget, options?): IDisposable;
    createCheckpoint(): Promise<ICheckpointModel>;
    deleteCheckpoint(checkpointID): Promise<void>;
    dispose(): void;
    download(): Promise<void>;
    listCheckpoints(): Promise<ICheckpointModel[]>;
    rename(newName): Promise<void>;
    restoreCheckpoint(checkpointID?): Promise<void>;
    revert(): Promise<void>;
    save(): Promise<void>;
    saveAs(): Promise<void>;

Type Parameters


Implemented by


contentsModel: null | Omit<Contents.IModel, "content">

The document metadata, stored as a services contents model.


This will be null until the context is 'ready'. Since we only store metadata here, the content attribute is removed.

disposed: ISignal<IContext<T>, void>

A signal emitted when the context is disposed.

fileChanged: ISignal<IContext<T>, Omit<Contents.IModel, "content">>

A signal emitted when the contentsModel changes.

isDisposed: boolean

Test whether the object has been disposed.


This property is always safe to access.

isReady: boolean

Whether the context is ready.

lastModifiedCheckMargin: number

Configurable margin used to detect document modification conflicts, in milliseconds

localPath: string

The current local path associated with the document. If the document is in the default notebook file browser, this is the same as the path.

model: T

The data model for the document.

path: string

The current path associated with the document.

pathChanged: ISignal<IContext<T>, string>

A signal emitted when the path changes.

ready: Promise<void>

A promise that is fulfilled when the context is ready.

A signal emitted on the start and end of a saving operation.

sessionContext: ISessionContext

The session context object associated with the context.

urlResolver: IRenderMime.IResolver

The url resolver for the context.


  • Add a sibling widget to the document manager.


    • widget: Widget

      The widget to add to the document manager.

    • Optional options: IOpenOptions

      The desired options for adding the sibling.

    Returns IDisposable

    A disposable used to remove the sibling if desired.


    It is assumed that the widget has the same model and context as the original widget.

  • Delete a checkpoint for the file.


    • checkpointID: string

      The id of the checkpoint to delete.

    Returns Promise<void>

    A promise which resolves when the checkpoint is deleted.

  • Dispose of the resources held by the object.


    If the object's dispose method is called more than once, all calls made after the first will be a no-op.

    Undefined Behavior

    It is undefined behavior to use any functionality of the object after it has been disposed unless otherwise explicitly noted.

    Returns void

  • Restore the file to a known checkpoint state.


    • Optional checkpointID: string

      The optional id of the checkpoint to restore, defaults to the most recent checkpoint.

    Returns Promise<void>

    A promise which resolves when the checkpoint is restored.