Class Notebook

A notebook widget that supports interactivity.

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

_activeCell: any
_activeCellChanged: any
_activeCellIndex: any
_cellLayoutStateCache?: any
_checkCacheOnNextResize: any
_drag: any
_dragData: any
_ensureFocus: any

Ensure that the notebook has proper focus.

_evtContextMenuCapture: any

Handle contextmenu event.

_evtDblClick: any

Handle dblclick events for the widget.

_evtDocumentMousemove: any

Handle the 'mousemove' event for the widget.

_evtDocumentMouseup: any

Handle the 'mouseup' event on the document.

_evtDragEnter: any

Handle the 'lm-dragenter' event for the widget.

_evtDragLeave: any

Handle the 'lm-dragleave' event for the widget.

_evtDragOver: any

Handle the 'lm-dragover' event for the widget.

_evtDrop: any

Handle the 'lm-drop' event for the widget.

_evtFocusIn: any

Handle focus events for the widget.

_evtFocusOut: any

Handle focusout events for the notebook.

_evtMouseDown: any

Handle mousedown events for the widget.

_evtMouseDownCapture: any

Handle mousedown event in the capture phase for the widget.

_findCell: any

Find the cell index containing the target html element.

Notes

Returns -1 if the cell is not found.

_findEventTargetAndCell: any

Find the target of html mouse event and cell index containing this target.

Notes

Returned index is -1 if the cell is not found.

_lastClipboardInteraction: any
_mode: any
_mouseMode: any
_onEdgeRequest: any

Handle edge request signals from cells.

_parseFragment: any
_selectedCells: any
_selectionChanged: any
_startDrag: any

Start a drag event.

_stateChanged: any
_trimSelections: any

Remove selections from inactive cells to avoid spurious cursors.

_updateReadWrite: any

Update the notebook node with class indicating read-write state.

_updateSelectedCells: any
_viewModel: NotebookViewModel
cellsArray: Cell<ICellModel>[]

The cell factory used by the widget.

jumped: Signal<Notebook, number>

A signal that emits the index when the virtual scrollbar jumps to an item.

kernelHistory: INotebookHistory

Get the DOM node owned by the widget.

renderer: WindowedList.IRenderer<any>

The renderer for this windowed list. Set at instantiation.

The Rendermime instance used by the widget.

translator: ITranslator

Translator to be used by cell renderers

DEFAULT_WIDGET_SIZE: 50 = 50

Default widget size

Accessors

  • get activeCell(): Cell<ICellModel>
  • Get the active cell widget.

    Notes

    This is a cell or null if there is no active cell.

    Returns Cell<ICellModel>

  • get activeCellChanged(): ISignal<this, Cell<ICellModel>>
  • A signal emitted when the active cell changes.

    Notes

    This can be due to the active index changing or the cell at the active index changing.

    Returns ISignal<this, Cell<ICellModel>>

  • get activeCellIndex(): number
  • The active cell index of the notebook.

    Notes

    The index will be clamped to the bounds of the notebook cells.

    Returns number

  • set activeCellIndex(newValue): void
  • Parameters

    • newValue: number

    Returns void

  • get codeMimetype(): string
  • Get the mimetype for code cells.

    Returns string

  • get dataset(): DOMStringMap
  • The dataset for the widget's DOM node.

    Returns DOMStringMap

  • get disposed(): ISignal<this, void>
  • A signal emitted when the widget is disposed.

    Returns ISignal<this, void>

  • get editorConfig(): IEditorConfig
  • A configuration object for cell editor settings.

    Returns IEditorConfig

  • set editorConfig(value): void
  • Parameters

    Returns void

  • get hiddenMode(): HiddenMode
  • Get the method for hiding the widget.

    Returns HiddenMode

  • set hiddenMode(value): void
  • Set the method for hiding the widget.

    Parameters

    • value: HiddenMode

    Returns void

  • get id(): string
  • Get the id of the widget's DOM node.

    Returns string

  • set id(value): void
  • Set the id of the widget's DOM node.

    Parameters

    • value: string

    Returns void

  • get isAttached(): boolean
  • Test whether the widget's node is attached to the DOM.

    Returns boolean

  • get isDisposed(): boolean
  • Test whether the widget has been disposed.

    Returns boolean

  • get isHidden(): boolean
  • Test whether the widget is explicitly hidden.

    Returns boolean

  • get isParentHidden(): boolean
  • Whether the parent is hidden or not.

    This should be set externally if a container is hidden to stop updating the widget size when hidden.

    Returns boolean

  • set isParentHidden(v): void
  • Parameters

    • v: boolean

    Returns void

  • get isVisible(): boolean
  • Test whether the widget is visible.

    Notes

    A widget is visible when it is attached to the DOM, is not explicitly hidden, and has no explicitly hidden ancestors.

    Returns boolean

  • get lastClipboardInteraction(): "copy" | "cut" | "paste"
  • Returns "copy" | "cut" | "paste"

  • set lastClipboardInteraction(newValue): void
  • Parameters

    • newValue: "copy" | "cut" | "paste"

    Returns void

  • get layout(): WindowedLayout
  • Widget layout

    Returns WindowedLayout

  • get mode(): NotebookMode
  • The interactivity mode of the notebook.

    Returns NotebookMode

  • set mode(newValue): void
  • Parameters

    Returns void

  • get model(): INotebookModel
  • The model for the widget.

    Returns INotebookModel

  • set model(newValue): void
  • Parameters

    Returns void

  • get modelChanged(): ISignal<this, void>
  • A signal emitted when the model of the notebook changes.

    Returns ISignal<this, void>

  • get modelContentChanged(): ISignal<this, void>
  • A signal emitted when the model content changes.

    Notes

    This is a convenience signal that follows the current model.

    Returns ISignal<this, void>

  • get notebookConfig(): INotebookConfig
  • A configuration object for notebook settings.

    Returns INotebookConfig

  • set notebookConfig(value): void
  • Parameters

    Returns void

  • get outerNode(): HTMLElement
  • The outer container of the windowed list.

    Returns HTMLElement

  • get parent(): Widget
  • Get the parent of the widget.

    Returns Widget

  • set parent(value): void
  • Set the parent of the widget.

    Notes

    Children are typically added to a widget by using a layout, which means user code will not normally set the parent widget directly.

    The widget will be automatically removed from its old parent.

    This is a no-op if there is no effective parent change.

    Parameters

    Returns void

  • get renderingLayout(): RenderingLayout
  • Returns RenderingLayout

  • set renderingLayout(value): void
  • Parameters

    • value: RenderingLayout

    Returns void

  • get renderingLayoutChanged(): ISignal<this, RenderingLayout>
  • A signal emitted when the rendering layout of the notebook changes.

    Returns ISignal<this, RenderingLayout>

  • get scrollbar(): boolean
  • Flag to enable virtual scrollbar.

    Returns boolean

  • set scrollbar(enabled): void
  • Parameters

    • enabled: boolean

    Returns void

  • get selectedCells(): Cell<ICellModel>[]
  • List of selected and active cells

    Returns Cell<ICellModel>[]

  • get selectionChanged(): ISignal<this, void>
  • A signal emitted when the selection state of the notebook changes.

    Returns ISignal<this, void>

  • get stateChanged(): ISignal<this, IChangedArgs<any, any, string>>
  • A signal emitted when the state of the notebook changes.

    Returns ISignal<this, IChangedArgs<any, any, string>>

  • get title(): Title<Widget>
  • The title object for the widget.

    Notes

    The title object is used by some container widgets when displaying the widget alongside some title, such as a tab panel or side bar.

    Since not all widgets will use the title, it is created on demand.

    The owner property of the title is set to this widget.

    Returns Title<Widget>

  • get viewModel(): T
  • Windowed list view model

    Returns T

  • get viewportNode(): HTMLElement
  • Viewport

    Returns HTMLElement

  • get widgets(): readonly Cell<ICellModel>[]
  • A read-only sequence of the widgets in the notebook.

    Returns readonly Cell<ICellModel>[]

Methods

  • Find cell by its unique ID.

    Parameters

    • queryId: string

    Returns IScrollTarget

  • Find heading with given ID in any of the cells.

    Parameters

    • queryId: string

    Returns Promise<IScrollTarget>

  • Post an 'activate-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

  • Add a class name to the widget's DOM node.

    Parameters

    • name: string

      The class name to add to the node.

      Notes

      If the class name is already added to the node, this is a no-op.

      The class name must not contain whitespace.

    Returns void

  • Adds a footer to the notebook.

    Returns void

  • Adds a message to the notebook as a header.

    Returns void

  • Create an iterator over the widget's children.

    Returns IterableIterator<Widget>

    A new iterator over the children of the widget.

    Notes

    The widget must have a populated layout in order to have children.

    If a layout is not installed, the returned iterator will be empty.

  • Clear the given widget flag.

    Notes

    This will not typically be called directly by user code.

    Parameters

    • flag: Flag

    Returns void

  • Send a 'close-request' message to the widget.

    Notes

    This is a simple convenience method for sending the message.

    Returns void

  • Test whether a widget is a descendant of this widget.

    Parameters

    • widget: Widget

      The descendant widget of interest.

    Returns boolean

    true if the widget is a descendant, false otherwise.

  • Deselect a cell widget.

    Notes

    It is a no-op if the value does not change. It will emit the selectionChanged signal.

    Parameters

    Returns void

  • Deselect all of the cells.

    Returns void

  • Dispose of the resources held by the widget.

    Returns void

  • Move the head of an existing contiguous selection to extend the selection.

    Parameters

    • index: number

      The new head of the existing selection.

      Notes

      If there is no existing selection, the active cell is considered an existing one-cell selection.

      If the new selection is a single cell, that cell becomes the active cell and all cells are deselected.

      There is no change if there are no cells (i.e., activeCellIndex is -1).

    Returns void

  • Post a 'fit-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

  • Get the head and anchor of a contiguous cell selection.

    The head of a contiguous selection is always the active cell.

    If there are no cells selected, {head: null, anchor: null} is returned.

    Throws an error if the currently selected cells do not form a contiguous selection.

    Returns {
        anchor: number;
        head: number;
    } | {
        anchor: null;
        head: null;
    }

  • Handle the DOM events for the widget.

    Parameters

    • event: Event

      The DOM event sent to the widget.

      Notes

      This method implements the DOM EventListener interface and is called in response to events on the notebook panel's node. It should not be called directly by user code.

    Returns void

  • Test whether the widget's DOM node has the given class name.

    Parameters

    • name: string

      The class name of interest.

    Returns boolean

    true if the node has the class, false otherwise.

  • Hide the widget and make it hidden to its parent widget.

    Notes

    This causes the isHidden property to be true.

    If the widget is explicitly hidden, this is a no-op.

    Returns void

  • Whether a cell is selected.

    Parameters

    Returns boolean

  • Whether a cell is selected or is the active cell.

    Parameters

    Returns boolean

  • Move cells preserving widget view state.

    Notes

    This is required because at the model level a move is a deletion followed by an insertion. Hence the view state is not preserved.

    Parameters

    • from: number

      The index of the cell to move

    • to: number

      The new index of the cell

    • Optional n: number

      Number of cells to move

    Returns void

  • Invoke the message processing routine of the widget's layout.

    Parameters

    • msg: Message

      The message to dispatch to the layout.

      Notes

      This is a no-op if the widget does not have a layout.

      This will not typically be called directly by user code.

    Returns void

  • Handle 'activate-request' messages.

    Parameters

    • msg: Message

    Returns void

  • Handle after-attach messages for the widget.

    Parameters

    • msg: Message

    Returns void

  • A message handler invoked on an 'after-detach' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

  • A message handler invoked on an 'after-hide' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

  • A message handler invoked on an 'after-show' message.

    Parameters

    • msg: Message

    Returns void

  • A message handler invoked on a 'before-attach' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

  • Handle before-detach messages for the widget.

    Parameters

    • msg: Message

    Returns void

  • A message handler invoked on an 'before-hide' message.

    Parameters

    • msg: Message

    Returns void

  • A message handler invoked on a 'before-show' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

  • Handle a cell being inserted.

    Parameters

    Returns void

  • Handle a cell being removed.

    Parameters

    Returns void

  • A message handler invoked on a 'child-added' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: ChildMessage

    Returns void

  • A message handler invoked on a 'child-removed' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: ChildMessage

    Returns void

  • A message handler invoked on a 'close-request' message.

    Notes

    The default implementation unparents or detaches the widget.

    Parameters

    • msg: Message

    Returns void

  • A message handler invoked on a 'fit-request' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

  • Handle changes to the notebook model metadata.

    Notes

    The default implementation updates the mimetypes of the code cells when the language_info metadata changes.

    Parameters

    Returns void

  • Handle changes to the notebook model content.

    Notes

    The default implementation emits the modelContentChanged signal.

    Parameters

    Returns void

  • A message handler invoked on a 'resize' message.

    Parameters

    • msg: ResizeMessage

    Returns void

  • Callback on scroll event

    Parameters

    • event: Event

      Scroll event

    Returns void

  • Callback on view model change

    Parameters

    Returns void

  • Handle update-request messages sent to the widget.

    Parameters

    • msg: Message

    Returns void

  • Process a message sent to the widget.

    Parameters

    • msg: Message

      The message sent to the widget.

      Notes

      Subclasses may reimplement this method as needed.

    Returns void

  • Remove a class name from the widget's DOM node.

    Parameters

    • name: string

      The class name to remove from the node.

      Notes

      If the class name is not yet added to the node, this is a no-op.

      The class name must not contain whitespace.

    Returns void

  • Removes the header.

    Returns void

  • Force rendering the cell outputs of a given cell if it is still a placeholder.

    Notes

    The goal of this method is to allow search on cell outputs (that is based on DOM tree introspection).

    Parameters

    • index: number

      The cell index

    Returns void

  • Scroll to the specified offset scrollTop.

    Deprecated

    since v4 This is an internal helper. Prefer calling scrollToItem.

    Parameters

    • scrollOffset: number

      Offset to scroll

    Returns void

  • Scroll so that the given cell is in view. Selects and activates cell.

    Parameters

    Returns Promise<void>

  • Scroll to the specified item.

    By default, the list will scroll as little as possible to ensure the item is fully visible (auto). You can control the alignment of the item though by specifying a second alignment parameter. Acceptable values are:

    auto - Automatically align with the top or bottom minimising the amount scrolled, If alignPreference is given, follow such preferred alignment. If item is smaller than the viewport and fully visible, do not scroll at all. smart - If the item is significantly visible, don't scroll at all (regardless of whether it fits in the viewport). If the item is less than one viewport away, scroll so that it becomes fully visible (following the auto heuristics). If the item is more than one viewport away, scroll so that it is centered within the viewport (center if smaller than viewport, top-center otherwise). center - Align the middle of the item with the middle of the viewport (it only works well for items smaller than the viewport). top-center - Align the top of the item with the middle of the viewport (works well for items larger than the viewport). end - Align the bottom of the item to the bottom of the list. start - Align the top of item to the top of the list.

    Parameters

    • index: number

      Item index to scroll to

    • Optional align: ScrollToAlign

      Type of alignment

    • Optional margin: number

      In 'smart' mode the viewport proportion to add

    • Optional alignPreference: BaseScrollToAlignment

      Allows to override the alignment of item when the auto heuristic decides that the item needs to be scrolled into view.

    Returns Promise<void>

  • Select a cell widget.

    Notes

    It is a no-op if the value does not change. It will emit the selectionChanged signal.

    Parameters

    Returns void

  • Set the given widget flag.

    Notes

    This will not typically be called directly by user code.

    Parameters

    • flag: Flag

    Returns void

  • Set URI fragment identifier.

    Parameters

    • fragment: string

    Returns Promise<void>

  • Show or hide the widget according to a boolean value.

    Parameters

    • hidden: boolean

      true to hide the widget, or false to show it.

      Notes

      This is a convenience method for hide() and show().

    Returns void

  • Set the notebook mode.

    Parameters

    • newValue: NotebookMode

      Notebook mode

    • Optional options: {
          focus?: boolean;
      }

      Control mode side-effect

      • Optional focus?: boolean

        Whether to ensure focus (default) or not when setting the mode.

    Returns void

  • Show the widget and make it visible to its parent widget.

    Notes

    This causes the isHidden property to be false.

    If the widget is not explicitly hidden, this is a no-op.

    Returns void

  • Test whether the given widget flag is set.

    Notes

    This will not typically be called directly by user code.

    Parameters

    • flag: Flag

    Returns boolean

  • Toggle a class name on the widget's DOM node.

    Parameters

    • name: string

      The class name to toggle on the node.

    • Optional force: boolean

      Whether to force add the class (true) or force remove the class (false). If not provided, the presence of the class will be toggled from its current state.

    Returns boolean

    true if the class is now present, false otherwise.

    Notes

    The class name must not contain whitespace.

  • Post an 'update-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

Generated using TypeDoc