UNPKG

6.63 kBTypeScriptView Raw
1import { Cell } from '@jupyterlab/cells';
2import { WindowedLayout, WindowedList, WindowedListModel } from '@jupyterlab/ui-components';
3import { Message } from '@lumino/messaging';
4import { Widget } from '@lumino/widgets';
5/**
6 * Notebook view model for the windowed list.
7 */
8export declare class NotebookViewModel extends WindowedListModel {
9 protected cells: Cell[];
10 /**
11 * Default cell height
12 */
13 static DEFAULT_CELL_SIZE: number;
14 /**
15 * Default editor line height
16 */
17 static DEFAULT_EDITOR_LINE_HEIGHT: number;
18 /**
19 * Default cell margin (top + bottom)
20 */
21 static DEFAULT_CELL_MARGIN: number;
22 /**
23 * Construct a notebook windowed list model.
24 */
25 constructor(cells: Cell[], options?: WindowedList.IModelOptions);
26 /**
27 * Cell size estimator
28 *
29 * @param index Cell index
30 * @returns Cell height in pixels
31 */
32 estimateWidgetSize: (index: number) => number;
33 /**
34 * Set an estimated height for a cell
35 *
36 * @param cellId Cell ID
37 * @param size Cell height
38 */
39 setEstimatedWidgetSize(cellId: string, size: number | null): void;
40 /**
41 * Render the cell at index.
42 *
43 * @param index Cell index
44 * @returns Cell widget
45 */
46 widgetRenderer: (index: number) => Widget;
47 /**
48 * Threshold used to decide if the cell should be scrolled to in the `smart` mode.
49 * Defaults to scrolling when less than a full line of the cell is visible.
50 */
51 readonly scrollDownThreshold: number;
52 /**
53 * Threshold used to decide if the cell should be scrolled to in the `smart` mode.
54 * Defaults to scrolling when the cell margin or more is invisible.
55 */
56 readonly scrollUpThreshold: number;
57 /**
58 * Mapping between the cell ids and the cell estimated heights
59 *
60 * This height is not refreshed with the changes to the document.
61 * It is only used to measure cells outside the viewport on CPU
62 * idle cycle to improve UX scrolling.
63 */
64 protected cellsEstimatedHeight: Map<string, number>;
65 private _emitEstimatedHeightChanged;
66}
67/**
68 * Windowed list layout for the notebook.
69 */
70export declare class NotebookWindowedLayout extends WindowedLayout {
71 private _header;
72 private _footer;
73 /**
74 * Notebook's header
75 */
76 get header(): Widget | null;
77 set header(header: Widget | null);
78 /**
79 * Notebook widget's footer
80 */
81 get footer(): Widget | null;
82 set footer(footer: Widget | null);
83 /**
84 * Notebook's active cell
85 */
86 get activeCell(): Widget | null;
87 set activeCell(widget: Widget | null);
88 private _activeCell;
89 /**
90 * Dispose the layout
91 * */
92 dispose(): void;
93 /**
94 * * A message handler invoked on a `'child-removed'` message.
95 * *
96 * @param widget - The widget to remove from the layout.
97 *
98 * #### Notes
99 * A widget is automatically removed from the layout when its `parent`
100 * is set to `null`. This method should only be invoked directly when
101 * removing a widget from a layout which has yet to be installed on a
102 * parent widget.
103 *
104 * This method does *not* modify the widget's `parent`.
105 */
106 removeWidget(widget: Widget): void;
107 /**
108 * Attach a widget to the parent's DOM node.
109 *
110 * @param index - The current index of the widget in the layout.
111 *
112 * @param widget - The widget to attach to the parent.
113 *
114 * #### Notes
115 * This method is called automatically by the panel layout at the
116 * appropriate time. It should not be called directly by user code.
117 *
118 * The default implementation adds the widgets's node to the parent's
119 * node at the proper location, and sends the appropriate attach
120 * messages to the widget if the parent is attached to the DOM.
121 *
122 * Subclasses may reimplement this method to control how the widget's
123 * node is added to the parent's node.
124 */
125 protected attachWidget(index: number, widget: Widget): void;
126 /**
127 * Detach a widget from the parent's DOM node.
128 *
129 * @param index - The previous index of the widget in the layout.
130 *
131 * @param widget - The widget to detach from the parent.
132 *
133 * #### Notes
134 * This method is called automatically by the panel layout at the
135 * appropriate time. It should not be called directly by user code.
136 *
137 * The default implementation removes the widget's node from the
138 * parent's node, and sends the appropriate detach messages to the
139 * widget if the parent is attached to the DOM.
140 *
141 * Subclasses may reimplement this method to control how the widget's
142 * node is removed from the parent's node.
143 */
144 protected detachWidget(index: number, widget: Widget): void;
145 /**
146 * Move a widget in the parent's DOM node.
147 *
148 * @param fromIndex - The previous index of the widget in the layout.
149 *
150 * @param toIndex - The current index of the widget in the layout.
151 *
152 * @param widget - The widget to move in the parent.
153 *
154 * #### Notes
155 * This method is called automatically by the panel layout at the
156 * appropriate time. It should not be called directly by user code.
157 *
158 * The default implementation moves the widget's node to the proper
159 * location in the parent's node and sends the appropriate attach and
160 * detach messages to the widget if the parent is attached to the DOM.
161 *
162 * Subclasses may reimplement this method to control how the widget's
163 * node is moved in the parent's node.
164 */
165 protected moveWidget(fromIndex: number, toIndex: number, widget: Widget): void;
166 protected onAfterAttach(msg: Message): void;
167 protected onBeforeDetach(msg: Message): void;
168 /**
169 * A message handler invoked on a `'child-removed'` message.
170 *
171 * @param msg Message
172 */
173 protected onChildRemoved(msg: Widget.ChildMessage): void;
174 /**
175 * Toggle "soft" visibility of the widget.
176 *
177 * #### Notes
178 * To ensure that user events reach the CodeMirror editor, this method
179 * does not toggle `display` nor `visibility` which have side effects,
180 * but instead hides it in the compositor and ensures that the bounding
181 * box is has an area equal to zero.
182 * To ensure we do not trigger style recalculation, we set the styles
183 * directly on the node instead of using a class.
184 */
185 private _toggleSoftVisibility;
186 private _isSoftHidden;
187 private _findNearestChildBinarySearch;
188 private _willBeRemoved;
189 private _topHiddenCodeCells;
190}