Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DocumentRegistry

The document registry.

Hierarchy

  • DocumentRegistry

Implements

  • IDisposable

Index

Constructors

constructor

  • Construct a new document registry.

    Parameters

    Returns DocumentRegistry

Properties

Private _changed

_changed: any

Private _defaultRenderedWidgetFactories

_defaultRenderedWidgetFactories: any

Private _defaultWidgetFactories

_defaultWidgetFactories: any

Private _defaultWidgetFactory

_defaultWidgetFactory: any

Private _defaultWidgetFactoryOverrides

_defaultWidgetFactoryOverrides: any

Private _extenders

_extenders: any

Private _fileTypes

_fileTypes: any

Private _isDisposed

_isDisposed: any

Private _modelFactories

_modelFactories: any

Private _widgetFactories

_widgetFactories: any

Private _widgetFactoriesForFileType

_widgetFactoriesForFileType: any

Protected translator

translator: ITranslator

Accessors

changed

  • A signal emitted when the registry has changed.

    Returns ISignal<this, IChangedArgs>

isDisposed

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

    Returns boolean

Methods

addFileType

  • addFileType(fileType: Partial<IFileType>, factories?: string[]): IDisposable
  • Add a file type to the document registry.

    Parameters

    • fileType: Partial<IFileType>

      The file type object to register.

    • Optional factories: string[]

      Optional factories to use for the file type.

    Returns IDisposable

    A disposable which will unregister the command.

    Notes

    These are used to populate the "Create New" dialog.

    If no default factory exists for the file type, the first factory will be defined as default factory.

addModelFactory

  • Add a model factory to the registry.

    Parameters

    Returns IDisposable

    A disposable which will unregister the factory.

    Notes

    If a factory with the given name is already registered, or the given factory is already registered, a warning will be logged and this will be a no-op.

addWidgetExtension

  • addWidgetExtension(widgetName: string, extension: WidgetExtension): IDisposable
  • Add a widget extension to the registry.

    Parameters

    • widgetName: string

      The name of the widget factory.

    • extension: WidgetExtension

      A widget extension.

    Returns IDisposable

    A disposable which will unregister the extension.

    Notes

    If the extension is already registered for the given widget name, a warning will be logged and this will be a no-op.

addWidgetFactory

  • Add a widget factory to the registry.

    Parameters

    Returns IDisposable

    A disposable which will unregister the factory.

    Notes

    If a factory with the given 'name' is already registered, a warning will be logged, and this will be a no-op. If '*' is given as a default extension, the factory will be registered as the global default. If an extension or global default is already registered, this factory will override the existing default. The factory cannot be named an empty string or the string 'default'.

defaultRenderedWidgetFactory

  • Get the default rendered widget factory for a path.

    Parameters

    • path: string

      The path to for which to find a widget factory.

    Returns WidgetFactory

    The default rendered widget factory for the path.

    Notes

    If the widget factory has registered a separate set of defaultRendered file types and there is a match in that set, this returns that. Otherwise, this returns the same widget factory as defaultWidgetFactory.

defaultWidgetFactory

  • Get the default widget factory for a path.

    Parameters

    • Optional path: string

      An optional file path to filter the results.

    Returns WidgetFactory

    The default widget factory for an path.

    Notes

    This is equivalent to the first value in preferredWidgetFactories.

dispose

  • dispose(): void
  • Dispose of the resources held by the document registry.

    Returns void

fileTypes

  • Create an iterator over the file types that have been registered.

    Returns IIterator<IFileType>

    A new iterator of file types.

getFileType

  • Get a file type by name.

    Parameters

    • name: string

    Returns IFileType

getFileTypeForModel

  • Get the best file type given a contents model.

    Parameters

    • model: Partial<IModel>

      The contents model of interest.

    Returns IFileType

    The best matching file type.

getFileTypesForPath

  • getFileTypesForPath(path: string): IFileType[]
  • Get the file types that match a file name.

    Parameters

    • path: string

      The path of the file.

    Returns IFileType[]

    An ordered list of matching file types.

getKernelPreference

  • Get a kernel preference.

    Parameters

    • path: string

      The file path.

    • widgetName: string

      The name of the widget factory.

    • Optional kernel: Partial<IModel>

      An optional existing kernel model.

    Returns IKernelPreference

    A kernel preference.

getModelFactory

  • Get a model factory by name.

    Parameters

    • name: string

      The name of the model factory.

    Returns ModelFactory

    A model factory instance.

getWidgetFactory

  • Get a widget factory by name.

    Parameters

    • widgetName: string

      The name of the widget factory.

    Returns WidgetFactory

    A widget factory instance.

modelFactories

  • Create an iterator over the model factories that have been registered.

    Returns IIterator<ModelFactory>

    A new iterator of model factories.

preferredWidgetFactories

  • Get a list of the preferred widget factories.

    Parameters

    • path: string

      The file path to filter the results.

    Returns WidgetFactory[]

    A new array of widget factories.

    Notes

    Only the widget factories whose associated model factory have been registered will be returned. The first item is considered the default. The returned array has widget factories in the following order:

    • path-specific default factory
    • path-specific default rendered factory
    • global default factory
    • all other path-specific factories
    • all other global factories

setDefaultWidgetFactory

  • setDefaultWidgetFactory(fileType: string, factory: string): void
  • Set overrides for the default widget factory for a file type.

    Normally, a widget factory informs the document registry which file types it should be the default for using the defaultFor option in the IWidgetFactoryOptions. This function can be used to override that after the fact.

    Parameters

    • fileType: string
    • factory: string

    Returns void

widgetExtensions

  • Create an iterator over the registered extensions for a given widget.

    Parameters

    • widgetName: string

      The name of the widget factory.

    Returns IIterator<WidgetExtension>

    A new iterator over the widget extensions.

widgetFactories

  • Create an iterator over the widget factories that have been registered.

    Returns IIterator<WidgetFactory>

    A new iterator of widget factories.

Generated using TypeDoc