The interface for a widget factory.

interface IWidgetFactory<
    T extends IDocumentWidget,
    U extends DocumentRegistry.IModel,
> {
    autoStartDefault?: boolean;
    canStartKernel?: boolean;
    contentProviderId?: string;
    defaultFor?: readonly string[];
    defaultRendered?: readonly string[];
    fileTypes: readonly string[];
    isDisposed: boolean;
    label?: string;
    modelName?: string;
    name: string;
    preferKernel?: boolean;
    readOnly?: boolean;
    shutdownOnClose?: boolean;
    toolbarFactory?: (
        widget: Widget,
    ) =>
        | DocumentRegistry.IToolbarItem[]
        | IObservableList<DocumentRegistry.IToolbarItem>;
    translator?: IRenderMime.ITranslator;
    widgetCreated: ISignal<IWidgetFactory<T, U>, T>;
    createNew(context: IContext<U>, source?: T): T;
    dispose(): void;
}

Type Parameters

Hierarchy (View Summary)

Implemented by

Properties

autoStartDefault?: boolean

Whether to automatically start the preferred kernel

canStartKernel?: boolean

Whether the widgets can start a kernel when opened.

contentProviderId?: string

Identifier of the content provider required for the widget (if any).

defaultFor?: readonly string[]

The file types for which the factory should be the default.

defaultRendered?: readonly string[]

The file types for which the factory should be the default for rendering, if that is different than the default factory (which may be for editing) If undefined, then it will fall back on the default file type.

fileTypes: readonly string[]

The file types the widget can view.

isDisposed: boolean

Test whether the object has been disposed.

This property is always safe to access.

label?: string

The label of the widget to display in dialogs. If not given, name is used instead.

modelName?: string

The name of the document model type.

name: string

The name of the widget to display in dialogs.

preferKernel?: boolean

Whether the widgets prefer having a kernel started.

readOnly?: boolean

Whether the widget factory is read only.

shutdownOnClose?: boolean

Whether the kernel should be shutdown when the widget is closed.

toolbarFactory?: (
    widget: Widget,
) =>
    | DocumentRegistry.IToolbarItem[]
    | IObservableList<DocumentRegistry.IToolbarItem>

A function producing toolbar widgets, overriding the default toolbar widgets.

The application language translator.

widgetCreated: ISignal<IWidgetFactory<T, U>, T>

A signal emitted when a new widget is created.

Methods

  • 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.

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

    Returns void