Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace NotebookActions

A namespace for NotebookActions static methods.

Index

Functions

changeCellType

  • Change the selected cell type(s).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • value: 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

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

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

collapseAll

  • Collapse all cells in given notebook.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns any

copy

  • Copy the selected cell(s) data to a clipboard.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

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

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

deselectAll

  • Deselect all of the cells of the notebook.

    Parameters

    • notebook: Notebook

      the target notebook widget.

    Returns void

disableOutputScrolling

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

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

duplicate

  • duplicate(notebook: Notebook, mode?: "below" | "belowSelected" | "above" | "replace"): void
  • Duplicate selected cells in the notebook without using the application clipboard.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional mode: "below" | "belowSelected" | "above" | "replace"

      the mode of adding cells: 'below' (default) adds cells below the active cell, 'belowSelected' adds cells below all selected cells, 'above' adds cells above the active cell, and 'replace' removes the currently selected cells and adds 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

enableOutputScrolling

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

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

expandAllHeadings

  • expandAllHeadings(notebook: Notebook): any
  • Un-collapse all cells in given notebook.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns any

expandParent

  • Finds the "parent" heading of the given cell and expands. Used for the case that a cell becomes active that is within a collapsed heading.

    Parameters

    • cell: Cell

      "Child" cell that has become the active cell

    • notebook: Notebook

      The target notebook widget.

    Returns void

extendSelectionAbove

  • extendSelectionAbove(notebook: Notebook, toTop?: boolean): void
  • Extend the selection to the cell above.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional toTop: boolean

      If true, denotes selection to extend to the top.

      Notes

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

    Returns void

extendSelectionBelow

  • extendSelectionBelow(notebook: Notebook, toBottom?: boolean): void
  • Extend the selection to the cell below.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional toBottom: boolean

      If true, denotes selection to extend to the bottom.

      Notes

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

    Returns void

findNextParentHeading

  • findNextParentHeading(cell: Cell, notebook: Notebook): number
  • Finds the next heading that isn't a child of the given markdown heading.

    Parameters

    • cell: Cell

      "Child" cell that has become the active cell

    • notebook: Notebook

      The target notebook widget.

    Returns number

getHeadingInfo

  • getHeadingInfo(cell: Cell): { collapsed?: boolean; headingLevel: number; isHeading: boolean }
  • If given cell is a markdown heading, returns the heading level. If given cell is not markdown, returns 7 (there are only 6 levels of markdown headings)

    Parameters

    • cell: Cell

      The target cell widget.

    Returns { collapsed?: boolean; headingLevel: number; isHeading: boolean }

    • Optional collapsed?: boolean
    • headingLevel: number
    • isHeading: boolean

hideAllCode

  • Hide the code on all code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

hideAllOutputs

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

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

hideCode

  • Hide the code on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

hideOutput

  • Hide the output on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

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

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

mergeCells

  • mergeCells(notebook: Notebook, mergeAbove?: boolean): void
  • Merge the selected cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional mergeAbove: boolean

      If only one cell is selected, indicates whether to merge it with the cell above (true) or below (false, default).

      Notes

      The widget mode will be preserved. If only one cell is selected and mergeAbove is true, the above cell will be selected. If only one cell is selected and mergeAbove is false, the below 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

moveDown

  • Move the selected cell(s) down.

    Parameters

    • notebook: Notebook

      = The target notebook widget.

    Returns void

moveUp

  • Move the selected cell(s) up.

    Parameters

    Returns void

paste

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

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional mode: "below" | "belowSelected" | "above" | "replace"

      the mode of adding cells: 'below' (default) adds cells below the active cell, 'belowSelected' adds cells below all selected cells, 'above' adds cells above the active cell, and 'replace' removes the currently selected cells and adds 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

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

renderAllMarkdown

  • Parameters

    Returns Promise<boolean>

renderDefault

  • renderDefault(notebook: Notebook): void
  • Render not side-by-side.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

renderSideBySide

  • renderSideBySide(notebook: Notebook): void
  • Render side-by-side.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

replaceSelection

  • replaceSelection(notebook: Notebook, text: string): void
  • Replaces the selection in the active cell of the notebook.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • text: string

      The text to replace the selection.

    Returns void

run

  • Run the selected cell(s).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional sessionContext: ISessionContext

      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>

runAll

  • Run all of the cells in the notebook.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional sessionContext: ISessionContext

      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>

runAllAbove

  • Run all of the cells before the currently active cell (exclusive).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional sessionContext: ISessionContext

      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>

runAllBelow

  • Run all of the cells after the currently active cell (inclusive).

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional sessionContext: ISessionContext

      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>

runAndAdvance

  • Run the selected cell(s) and advance to the next cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional sessionContext: ISessionContext

      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>

runAndInsert

  • Run the selected cell(s) and insert a new code cell.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    • Optional sessionContext: ISessionContext

      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>

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

selectAll

  • Select all of the cells of the notebook.

    Parameters

    • notebook: Notebook

      the target notebook widget.

    Returns void

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

selectLastRunCell

  • selectLastRunCell(notebook: Notebook): void
  • Go to the last cell that is run or current if it is running.

    Note: This requires execution timing to be toggled on or this will have no effect.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

setCellCollapse

  • setCellCollapse(cell: Cell, collapsing: boolean): any
  • If cell is a markdown heading, sets the headingCollapsed field, and otherwise hides the cell.

    Parameters

    • cell: Cell

      The cell to collapse / expand

    • collapsing: boolean

      Whether to collapse or expand the given cell

    Returns any

setHeadingCollapse

  • Set the given cell and ** all "child" cells ** to the given collapse / expand if cell is a markdown header.

    Parameters

    • cell: Cell

      The cell

    • collapsing: boolean

      Whether to collapse or expand the cell

    • notebook: StaticNotebook

      The target notebook widget.

    Returns number

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

showAllCode

  • Show the code on all code cells.

    Parameters

    Returns void

showAllOutputs

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

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

showCode

  • Show the code on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

showOutput

  • Show the output on selected code cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns void

splitCell

  • Split the active cell into two or more cells.

    Parameters

    • notebook: Notebook

      The target notebook widget.

      Notes

      It will preserve the existing mode. The last cell will be activated if no selection is found. If text was selected, the cell containing the selection will be activated. The existing selection will be cleared. The activated cell will have focus and the cursor will remain in the initial position. The leading whitespace in the second cell will be removed. If there is no content, two empty cells will be created. Both cells will have the same type as the original cell. This action can be undone.

    Returns void

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

toggleCurrentHeadingCollapse

  • toggleCurrentHeadingCollapse(notebook: Notebook): any
  • Toggles the collapse state of the active cell of the given notebook and ** all of its "child" cells ** if the cell is a heading.

    Parameters

    • notebook: Notebook

      The target notebook widget.

    Returns any

trust

  • Trust the notebook after prompting the user.

    Parameters

    Returns Promise<void>

    a promise that resolves when the transaction is finished.

    Notes

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

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