Class DocumentManager

The document manager.

Notes

The document manager is used to register model and widget creators, and the file browser uses the document manager to create widgets. The document manager maintains a context for each path and model type that is open, and a list of widgets for each context. The document manager is in control of the proper closing and disposal of the widgets and contexts.

Hierarchy

  • DocumentManager

Implements

Constructors

Properties

_activateRequested: any
_autosave: any
_autosaveInterval: any
_contexts: any
_contextsForPath: any

Get the contexts for a given path.

Notes

There may be more than one context for a given path if the path is open with multiple model factories (for example, a notebook can be open with a notebook model factory and a text model factory).

_createContext: any

Create a context from a path and a model factory.

_createOrOpenDocument: any

Creates a new document, or loads one from disk, depending on the which argument. If which==='create', then it creates a new document. If which==='open', then it loads the document from disk.

The two cases differ in how the document context is handled, but the creation of the widget and launching of the kernel are identical.

_dialogs: any
_findContext: any

Find a context for a given path and factory name.

_isConnectedCallback: any
_isDisposed: any
_lastModifiedCheckMargin: any
_onActivateRequested: any

Handle an activateRequested signal from the widget manager.

_onContextDisposed: any

Handle a context disposal.

_opener: any
_renameUntitledFileOnSave: any
_setBusy: any
_stateChanged: any
_when: any
_widgetFactoryFor: any

Get the widget factory for a given widget name.

_widgetManager: any

The registry used by the manager.

The service manager used by the manager.

translator: ITranslator

Accessors

  • get activateRequested(): ISignal<this, string>
  • A signal emitted when one of the documents is activated.

    Returns ISignal<this, string>

  • get autosave(): boolean
  • Whether to autosave documents.

    Returns boolean

  • set autosave(value): void
  • Parameters

    • value: boolean

    Returns void

  • get autosaveInterval(): number
  • Determines the time interval for autosave in seconds.

    Returns number

  • set autosaveInterval(value): void
  • Parameters

    • value: number

    Returns void

  • get confirmClosingDocument(): boolean
  • Whether to ask confirmation to close a tab or not.

    Returns boolean

  • set confirmClosingDocument(value): void
  • Parameters

    • value: boolean

    Returns void

  • get isDisposed(): boolean
  • Get whether the document manager has been disposed.

    Returns boolean

  • get lastModifiedCheckMargin(): number
  • Defines max acceptable difference, in milliseconds, between last modified timestamps on disk and client

    Returns number

  • set lastModifiedCheckMargin(value): void
  • Parameters

    • value: number

    Returns void

  • get renameUntitledFileOnSave(): boolean
  • Whether to ask the user to rename untitled file on first manual save.

    Returns boolean

  • set renameUntitledFileOnSave(value): void
  • Parameters

    • value: boolean

    Returns void

Methods

  • Parameters

    Returns void

  • Close all of the open documents.

    Returns Promise<void>

    A promise resolving when the widgets are closed.

  • Close the widgets associated with a given path.

    Parameters

    • path: string

      The target path.

    Returns Promise<void>

    A promise resolving when the widgets are closed.

  • Get the document context for a widget.

    Parameters

    • widget: Widget

      The widget of interest.

    Returns DocumentRegistry.Context

    The context associated with the widget, or undefined if no such context exists.

  • Copy a file.

    Parameters

    • fromFile: string

      The full path of the original file.

    • toDir: string

      The full path to the target directory.

    Returns Promise<Contents.IModel>

    A promise which resolves to the contents of the file.

  • Create a new file and return the widget used to view it.

    Parameters

    • path: string

      The file path to create.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    • Optional kernel: Partial<Kernel.IModel>

      An optional kernel name/id to override the default.

    Returns Widget

    The created widget, or undefined.

    Notes

    This function will return undefined if a valid widget factory cannot be found.

  • Delete a file.

    Parameters

    • path: string

      The full path to the file to be deleted.

    Returns Promise<void>

    A promise which resolves when the file is deleted.

    Notes

    If there is a running session associated with the file and no other sessions are using the kernel, the session will be shut down.

  • Dispose of the resources held by the document manager.

    Returns void

  • Duplicate a file.

    Parameters

    • path: string

      The full path to the file to be duplicated.

    Returns Promise<Contents.IModel>

    A promise which resolves when the file is duplicated.

  • See if a widget already exists for the given path and widget name.

    Parameters

    • path: string

      The file path to use.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    Returns IDocumentWidget<Widget, DocumentRegistry.IModel>

    The found widget, or undefined.

    Notes

    This can be used to find an existing widget instead of opening a new widget.

  • Open a file and return the widget used to view it.

    Parameters

    • path: string

      The file path to open.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    • Optional kernel: Partial<Kernel.IModel>

      An optional kernel name/id to override the default.

    • Optional options: IOpenOptions

    Returns IDocumentWidget<Widget, DocumentRegistry.IModel>

    The created widget, or undefined.

    Notes

    This function will return undefined if a valid widget factory cannot be found.

  • Open a file and return the widget used to view it. Reveals an already existing editor.

    Parameters

    • path: string

      The file path to open.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    • Optional kernel: Partial<Kernel.IModel>

      An optional kernel name/id to override the default.

    • Optional options: IOpenOptions

    Returns IDocumentWidget<Widget, DocumentRegistry.IModel>

    The created widget, or undefined.

    Notes

    This function will return undefined if a valid widget factory cannot be found.

  • Overwrite a file.

    Parameters

    • oldPath: string

      The full path to the original file.

    • newPath: string

      The full path to the new file.

    Returns Promise<Contents.IModel>

    A promise containing the new file contents model.

  • Rename a file or directory.

    Parameters

    • oldPath: string

      The full path to the original file.

    • newPath: string

      The full path to the new file.

    Returns Promise<Contents.IModel>

    A promise containing the new file contents model. The promise will reject if the newPath already exists. Use [[overwrite]] to overwrite a file.

Generated using TypeDoc