Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NotebookActions

A collection of actions that run against notebooks. A namespace for NotebookActions static methods.

Notes

All of the actions are a no-op if there is no model on the notebook. The actions set the widget mode to 'command' unless otherwise specified. The actions will preserve the selection on the notebook widget unless otherwise specified.

Hierarchy

  • NotebookActions

Index

Constructors

Private constructor

  • A private constructor for the NotebookActions class.

    Notes

    This class can never be instantiated. Its static member executed will be merged with the NotebookActions namespace. The reason it exists as a standalone class is because at run time, the Private.executed variable does not yet exist, so it needs to be referenced via a getter.

    Returns NotebookActions

Accessors

Static executed

  • get executed(): ISignal<any, object>
  • A signal that emits whenever a cell is run.

    Returns ISignal<any, object>

Methods

Static changeCellType

  • changeCellType(notebook: Notebook, value: nbformat.CellType): void
  • Change the selected cell type(s).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • value: nbformat.CellType

      The target cell type.

      Notes

      It should preserve the widget mode. This action can be undone. The existing selection will be cleared. Any cells converted to markdown will be unrendered.

    Returns void

Static clearAllOutputs

  • clearAllOutputs(notebook: Notebook): void
  • Clear all the code outputs on the widget.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The widget mode will be preserved.

    Returns void

Static clearOutputs

  • clearOutputs(notebook: Notebook): void
  • Clear the code outputs of the selected cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The widget mode will be preserved.

    Returns void

Static copy

  • Copy the selected cell data to a clipboard.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static cut

  • Cut the selected cell data to a clipboard.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      This action can be undone. A new code cell is added if all cells are cut.

    Returns void

Static deleteCells

  • Delete the selected cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The cell after the last selected cell will be activated. It will add a code cell if all cells are deleted. This action can be undone.

    Returns void

Static deselectAll

  • Deselect all of the cells of the notebook.

    Parameters

    • notebook: Notebook

      the targe notebook widget.

    Returns void

Static disableOutputScrolling

  • disableOutputScrolling(notebook: Notebook): void
  • Disable output scrolling for all selected cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static enableOutputScrolling

  • enableOutputScrolling(notebook: Notebook): void
  • Enable output scrolling for all selected cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static extendSelectionAbove

  • extendSelectionAbove(notebook: Notebook): void
  • Extend the selection to the cell above.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      This is a no-op if the first cell is the active cell. The new cell will be activated.

    Returns void

Static extendSelectionBelow

  • extendSelectionBelow(notebook: Notebook): void
  • Extend the selection to the cell below.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      This is a no-op if the last cell is the active cell. The new cell will be activated.

    Returns void

Static hideAllCode

  • Hide the code on all code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static hideAllOutputs

  • hideAllOutputs(notebook: Notebook): void
  • Hide the output on all code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static hideCode

  • Hide the code on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static hideOutput

  • Hide the output on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static insertAbove

  • Insert a new code cell above the active cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The widget mode will be preserved. This action can be undone. The existing selection will be cleared. The new cell will the active cell.

    Returns void

Static insertBelow

  • Insert a new code cell below the active cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The widget mode will be preserved. This action can be undone. The existing selection will be cleared. The new cell will be the active cell.

    Returns void

Static mergeCells

  • Merge the selected cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The widget mode will be preserved. If only one cell is selected, the next cell will be selected. If the active cell is a code cell, its outputs will be cleared. This action can be undone. The final cell will have the same type as the active cell. If the active cell is a markdown cell, it will be unrendered.

    Returns void

Static moveDown

  • Move the selected cell(s) down.

    Parameters

    • notebook: Notebook

      = The target notebook widget.

    Returns void

Static moveUp

Static paste

  • paste(notebook: Notebook, mode?: "below" | "above" | "replace"): void
  • Paste cells from the application clipboard.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Default value mode: "below" | "above" | "replace" = "below"

      the mode of the paste operation: 'below' pastes cells below the active cell, 'above' pastes cells above the active cell, and 'replace' removes the currently selected cells and pastes cells in their place.

      Notes

      The last pasted cell becomes the active cell. This is a no-op if there is no cell data on the clipboard. This action can be undone.

    Returns void

Static redo

  • Redo a cell action.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      This is a no-op if there are no cell actions to redo.

    Returns void

Static renderAllMarkdown

  • renderAllMarkdown(notebook: Notebook, session?: IClientSession): Promise<boolean>
  • Parameters

    • notebook: Notebook
    • Optional session: IClientSession

    Returns Promise<boolean>

Static run

  • run(notebook: Notebook, session?: IClientSession): Promise<boolean>
  • Run the selected cell(s).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional session: IClientSession

      The optional client session object.

      Notes

      The last selected cell will be activated, but not scrolled into view. The existing selection will be cleared. An execution error will prevent the remaining code cells from executing. All markdown cells will be rendered.

    Returns Promise<boolean>

Static runAll

  • runAll(notebook: Notebook, session?: IClientSession): Promise<boolean>
  • Run all of the cells in the notebook.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional session: IClientSession

      The optional client session object.

      Notes

      The existing selection will be cleared. An execution error will prevent the remaining code cells from executing. All markdown cells will be rendered. The last cell in the notebook will be activated and scrolled into view.

    Returns Promise<boolean>

Static runAllAbove

  • runAllAbove(notebook: Notebook, session?: IClientSession): Promise<boolean>
  • Run all of the cells before the currently active cell (exclusive).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional session: IClientSession

      The optional client session object.

      Notes

      The existing selection will be cleared. An execution error will prevent the remaining code cells from executing. All markdown cells will be rendered. The currently active cell will remain selected.

    Returns Promise<boolean>

Static runAllBelow

  • runAllBelow(notebook: Notebook, session?: IClientSession): Promise<boolean>
  • Run all of the cells after the currently active cell (inclusive).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional session: IClientSession

      The optional client session object.

      Notes

      The existing selection will be cleared. An execution error will prevent the remaining code cells from executing. All markdown cells will be rendered. The last cell in the notebook will be activated and scrolled into view.

    Returns Promise<boolean>

Static runAndAdvance

  • runAndAdvance(notebook: Notebook, session?: IClientSession): Promise<boolean>
  • Run the selected cell(s) and advance to the next cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional session: IClientSession

      The optional client session object.

      Notes

      The existing selection will be cleared. The cell after the last selected cell will be activated and scrolled into view. An execution error will prevent the remaining code cells from executing. All markdown cells will be rendered. If the last selected cell is the last cell, a new code cell will be created in 'edit' mode. The new cell creation can be undone.

    Returns Promise<boolean>

Static runAndInsert

  • runAndInsert(notebook: Notebook, session?: IClientSession): Promise<boolean>
  • Run the selected cell(s) and insert a new code cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional session: IClientSession

      The optional client session object.

      Notes

      An execution error will prevent the remaining code cells from executing. All markdown cells will be rendered. The widget mode will be set to 'edit' after running. The existing selection will be cleared. The cell insert can be undone. The new cell will be scrolled into view.

    Returns Promise<boolean>

Static selectAbove

  • Select the above the active cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The widget mode will be preserved. This is a no-op if the first cell is the active cell. This will skip any collapsed cells. The existing selection will be cleared.

    Returns void

Static selectAll

  • Select all of the cells of the notebook.

    Parameters

    • notebook: Notebook

      the target notebook widget.

    Returns void

Static selectBelow

  • Select the cell below the active cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The widget mode will be preserved. This is a no-op if the last cell is the active cell. This will skip any collapsed cells. The existing selection will be cleared.

    Returns void

Static setMarkdownHeader

  • setMarkdownHeader(notebook: Notebook, level: number): void
  • Set the markdown header level.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • level: number

      The header level.

      Notes

      All selected cells will be switched to markdown. The level will be clamped between 1 and 6. If there is an existing header, it will be replaced. There will always be one blank space after the header. The cells will be unrendered.

    Returns void

Static showAllCode

Static showAllOutputs

  • showAllOutputs(notebook: Notebook): void
  • Show the output on all code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static showCode

  • Show the code on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static showOutput

  • Show the output on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

Static splitCell

Static toggleAllLineNumbers

  • toggleAllLineNumbers(notebook: Notebook): void
  • Toggle the line number of all cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      The original state is based on the state of the active cell. The mode of the widget will be preserved.

    Returns void

Static trust

  • trust(notebook: Notebook): Promise<void>
  • Trust the notebook after prompting the user.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns Promise<void>

    a promise that resolves when the transaction is finished.

    Notes

    No dialog will be presented if the notebook is already trusted.

Static undo

  • Undo a cell action.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      This is a no-op if if there are no cell actions to undo.

    Returns void

Generated using TypeDoc