UNPKG

3.29 kBPlain TextView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3
4import { IWidgetTracker } from '@jupyterlab/apputils';
5import { Cell } from '@jupyterlab/cells';
6import { Token } from '@lumino/coreutils';
7import { ISignal } from '@lumino/signaling';
8import { Widget } from '@lumino/widgets';
9import { NotebookTools } from './notebooktools';
10import { NotebookPanel } from './panel';
11import { NotebookWidgetFactory } from './widgetfactory';
12
13/**
14 * The notebook widget factory token.
15 */
16export const INotebookWidgetFactory = new Token<NotebookWidgetFactory.IFactory>(
17 '@jupyterlab/notebook:INotebookWidgetFactory',
18 'A service to create the notebook viewer.'
19);
20
21/**
22 * The notebook tools token.
23 */
24export const INotebookTools = new Token<INotebookTools>(
25 '@jupyterlab/notebook:INotebookTools',
26 `A service for the "Notebook Tools" panel in the
27 right sidebar. Use this to add your own functionality to the panel.`
28);
29
30/**
31 * The interface for notebook metadata tools.
32 */
33export interface INotebookTools extends Widget {
34 activeNotebookPanel: NotebookPanel | null;
35 activeCell: Cell | null;
36 selectedCells: Cell[];
37 addItem(options: NotebookTools.IAddOptions): void;
38 addSection(options: NotebookTools.IAddSectionOptions): void;
39}
40
41/**
42 * The namespace for NotebookTools class statics.
43 */
44export namespace INotebookTools {
45 /**
46 * The options used to add an item to the notebook tools.
47 */
48 export interface IAddOptions {
49 /**
50 * The tool to add to the notebook tools area.
51 */
52 tool: ITool;
53
54 /**
55 * The section to which the tool should be added.
56 */
57 section: 'advanced' | string;
58
59 /**
60 * The rank order of the widget among its siblings.
61 */
62 rank?: number;
63 }
64
65 /**
66 * The options used to add a section to the notebook tools.
67 */
68 export interface IAddSectionOptions {
69 /**
70 * The name of the new section.
71 */
72 sectionName: string;
73
74 /**
75 * The tool to add to the notebook tools area.
76 */
77 tool?: INotebookTools.ITool;
78
79 /**
80 * The label of the new section.
81 */
82 label?: string;
83
84 /**
85 * The rank order of the section among its siblings.
86 */
87 rank?: number;
88 }
89
90 export interface ITool extends Widget {
91 /**
92 * The notebook tools object.
93 */
94 notebookTools: INotebookTools;
95 }
96}
97
98/**
99 * The notebook tracker token.
100 */
101export const INotebookTracker = new Token<INotebookTracker>(
102 '@jupyterlab/notebook:INotebookTracker',
103 `A widget tracker for notebooks.
104 Use this if you want to be able to iterate over and interact with notebooks
105 created by the application.`
106);
107
108/**
109 * An object that tracks notebook widgets.
110 */
111export interface INotebookTracker extends IWidgetTracker<NotebookPanel> {
112 /**
113 * The currently focused cell.
114 *
115 * #### Notes
116 * If there is no cell with the focus, then this value is `null`.
117 */
118 readonly activeCell: Cell | null;
119
120 /**
121 * A signal emitted when the current active cell changes.
122 *
123 * #### Notes
124 * If there is no cell with the focus, then `null` will be emitted.
125 */
126 readonly activeCellChanged: ISignal<this, Cell | null>;
127
128 /**
129 * A signal emitted when the selection state changes.
130 */
131 readonly selectionChanged: ISignal<this, void>;
132}