@jupyterlab/cell-toolbar 3.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ import { ToolbarRegistry } from '@jupyterlab/apputils';
2
+ import { DocumentRegistry } from '@jupyterlab/docregistry';
3
+ import { Notebook, NotebookPanel } from '@jupyterlab/notebook';
4
+ import { IObservableList } from '@jupyterlab/observables';
5
+ import { CommandRegistry } from '@lumino/commands';
6
+ import { IDisposable } from '@lumino/disposable';
7
+ import { Widget } from '@lumino/widgets';
8
+ /**
9
+ * Watch a notebook so that a cell toolbar appears on the active cell
10
+ */
11
+ export declare class CellToolbarTracker implements IDisposable {
12
+ constructor(panel: NotebookPanel, toolbar: IObservableList<ToolbarRegistry.IToolbarItem>);
13
+ _onActiveCellChanged(notebook: Notebook): void;
14
+ get isDisposed(): boolean;
15
+ dispose(): void;
16
+ private _addToolbar;
17
+ private _getCell;
18
+ private _findToolbarWidgets;
19
+ private _removeToolbar;
20
+ /**
21
+ * Call back on settings changes
22
+ */
23
+ private _onToolbarChanged;
24
+ private _changedEventCallback;
25
+ private _resizeEventCallback;
26
+ private _updateCellForToolbarOverlap;
27
+ private _cellToolbarOverlapsContents;
28
+ /**
29
+ * Check for overlap between rendered Markdown and the cell toolbar
30
+ *
31
+ * @param activeCell A rendered MarkdownCell
32
+ * @returns `true` if the first line of the output overlaps with the cell toolbar, `false` otherwise
33
+ */
34
+ private _markdownOverlapsToolbar;
35
+ private _codeOverlapsToolbar;
36
+ private _cellEditorWidgetLeft;
37
+ private _cellEditorWidgetRight;
38
+ private _cellToolbarLeft;
39
+ private _isDisposed;
40
+ private _panel;
41
+ private _previousActiveCell;
42
+ private _toolbar;
43
+ }
44
+ /**
45
+ * Widget extension that creates a CellToolbarTracker each time a notebook is
46
+ * created.
47
+ */
48
+ export declare class CellBarExtension implements DocumentRegistry.WidgetExtension {
49
+ static FACTORY_NAME: string;
50
+ constructor(commands: CommandRegistry, toolbarFactory?: (widget: Widget) => IObservableList<ToolbarRegistry.IToolbarItem>);
51
+ protected get defaultToolbarFactory(): (widget: Widget) => IObservableList<ToolbarRegistry.IToolbarItem>;
52
+ createNew(panel: NotebookPanel): IDisposable;
53
+ private _commands;
54
+ private _toolbarFactory;
55
+ }
@@ -0,0 +1,260 @@
1
+ /* -----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+ import { createDefaultFactory, Toolbar } from '@jupyterlab/apputils';
6
+ import { ObservableList } from '@jupyterlab/observables';
7
+ import { each, toArray } from '@lumino/algorithm';
8
+ import { Signal } from '@lumino/signaling';
9
+ /**
10
+ * Widget cell toolbar classes
11
+ */
12
+ const CELL_TOOLBAR_CLASS = 'jp-cell-toolbar';
13
+ const CELL_MENU_CLASS = 'jp-cell-menu';
14
+ /**
15
+ * Class for a cell whose contents overlap with the cell toolbar
16
+ */
17
+ const TOOLBAR_OVERLAP_CLASS = 'jp-toolbar-overlap';
18
+ /**
19
+ * Watch a notebook so that a cell toolbar appears on the active cell
20
+ */
21
+ export class CellToolbarTracker {
22
+ constructor(panel, toolbar) {
23
+ this._isDisposed = false;
24
+ this._panel = panel;
25
+ this._previousActiveCell = this._panel.content.activeCell;
26
+ this._toolbar = toolbar;
27
+ this._onToolbarChanged();
28
+ this._toolbar.changed.connect(this._onToolbarChanged, this);
29
+ // Only add the toolbar to the notebook's active cell (if any) once it has fully rendered and been revealed.
30
+ void panel.revealed.then(() => this._onActiveCellChanged(panel.content));
31
+ // Handle subsequent changes of active cell.
32
+ panel.content.activeCellChanged.connect(this._onActiveCellChanged, this);
33
+ }
34
+ _onActiveCellChanged(notebook) {
35
+ if (this._previousActiveCell) {
36
+ this._removeToolbar(this._previousActiveCell.model);
37
+ }
38
+ const activeCell = notebook.activeCell;
39
+ if (!activeCell) {
40
+ return;
41
+ }
42
+ this._addToolbar(activeCell.model);
43
+ this._previousActiveCell = activeCell;
44
+ this._updateCellForToolbarOverlap(activeCell);
45
+ }
46
+ get isDisposed() {
47
+ return this._isDisposed;
48
+ }
49
+ dispose() {
50
+ var _a;
51
+ if (this.isDisposed) {
52
+ return;
53
+ }
54
+ this._isDisposed = true;
55
+ this._toolbar.changed.disconnect(this._onToolbarChanged, this);
56
+ const cells = (_a = this._panel) === null || _a === void 0 ? void 0 : _a.context.model.cells;
57
+ if (cells) {
58
+ each(cells.iter(), model => this._removeToolbar(model));
59
+ }
60
+ this._panel = null;
61
+ Signal.clearData(this);
62
+ }
63
+ _addToolbar(model) {
64
+ const cell = this._getCell(model);
65
+ if (cell) {
66
+ const toolbarWidget = new Toolbar();
67
+ toolbarWidget.addClass(CELL_MENU_CLASS);
68
+ toArray(this._toolbar).forEach(({ name, widget }) => {
69
+ toolbarWidget.addItem(name, widget);
70
+ });
71
+ toolbarWidget.addClass(CELL_TOOLBAR_CLASS);
72
+ cell.layout.insertWidget(0, toolbarWidget);
73
+ // For rendered markdown, watch for resize events.
74
+ cell.displayChanged.connect(this._resizeEventCallback, this);
75
+ // Watch for changes in the cell's contents.
76
+ cell.model.contentChanged.connect(this._changedEventCallback, this);
77
+ }
78
+ }
79
+ _getCell(model) {
80
+ var _a;
81
+ return (_a = this._panel) === null || _a === void 0 ? void 0 : _a.content.widgets.find(widget => widget.model === model);
82
+ }
83
+ _findToolbarWidgets(cell) {
84
+ const widgets = cell.layout.widgets;
85
+ // Search for header using the CSS class or use the first one if not found.
86
+ return widgets.filter(widget => widget.hasClass(CELL_TOOLBAR_CLASS)) || [];
87
+ }
88
+ _removeToolbar(model) {
89
+ const cell = this._getCell(model);
90
+ if (cell) {
91
+ this._findToolbarWidgets(cell).forEach(widget => widget.dispose());
92
+ // Attempt to remove the resize and changed event handlers.
93
+ cell.displayChanged.disconnect(this._resizeEventCallback, this);
94
+ cell.model.contentChanged.disconnect(this._changedEventCallback, this);
95
+ }
96
+ }
97
+ /**
98
+ * Call back on settings changes
99
+ */
100
+ _onToolbarChanged() {
101
+ var _a;
102
+ // Reset toolbar when settings changes
103
+ const activeCell = (_a = this._panel) === null || _a === void 0 ? void 0 : _a.content.activeCell;
104
+ if (activeCell) {
105
+ this._removeToolbar(activeCell.model);
106
+ this._addToolbar(activeCell.model);
107
+ }
108
+ }
109
+ _changedEventCallback() {
110
+ var _a;
111
+ const activeCell = (_a = this._panel) === null || _a === void 0 ? void 0 : _a.content.activeCell;
112
+ if (activeCell === null || activeCell === undefined) {
113
+ return;
114
+ }
115
+ this._updateCellForToolbarOverlap(activeCell);
116
+ }
117
+ _resizeEventCallback() {
118
+ var _a;
119
+ const activeCell = (_a = this._panel) === null || _a === void 0 ? void 0 : _a.content.activeCell;
120
+ if (activeCell === null || activeCell === undefined) {
121
+ return;
122
+ }
123
+ this._updateCellForToolbarOverlap(activeCell);
124
+ }
125
+ _updateCellForToolbarOverlap(activeCell) {
126
+ // Remove the "toolbar overlap" class from the cell, rendering the cell's toolbar
127
+ const activeCellElement = activeCell.node;
128
+ activeCellElement.classList.remove(TOOLBAR_OVERLAP_CLASS);
129
+ if (this._cellToolbarOverlapsContents(activeCell)) {
130
+ // Add the "toolbar overlap" class to the cell, completely concealing the toolbar,
131
+ // if the first line of the content overlaps with it at all
132
+ activeCellElement.classList.add(TOOLBAR_OVERLAP_CLASS);
133
+ }
134
+ }
135
+ _cellToolbarOverlapsContents(activeCell) {
136
+ const cellType = activeCell.model.type;
137
+ // If the toolbar is too large for the current cell, hide it.
138
+ const cellLeft = this._cellEditorWidgetLeft(activeCell);
139
+ const cellRight = this._cellEditorWidgetRight(activeCell);
140
+ const toolbarLeft = this._cellToolbarLeft(activeCell);
141
+ if (toolbarLeft === null) {
142
+ return false;
143
+ }
144
+ // The toolbar should not take up more than 50% of the cell.
145
+ if ((cellLeft + cellRight) / 2 > toolbarLeft) {
146
+ return true;
147
+ }
148
+ if (cellType === 'markdown' && activeCell.rendered) {
149
+ // Check for overlap in rendered markdown content
150
+ return this._markdownOverlapsToolbar(activeCell);
151
+ }
152
+ // Check for overlap in code content
153
+ return this._codeOverlapsToolbar(activeCell);
154
+ }
155
+ /**
156
+ * Check for overlap between rendered Markdown and the cell toolbar
157
+ *
158
+ * @param activeCell A rendered MarkdownCell
159
+ * @returns `true` if the first line of the output overlaps with the cell toolbar, `false` otherwise
160
+ */
161
+ _markdownOverlapsToolbar(activeCell) {
162
+ const markdownOutput = activeCell.inputArea; // Rendered markdown appears in the input area
163
+ // Get the rendered markdown as a widget.
164
+ const markdownOutputWidget = markdownOutput.renderedInput;
165
+ const markdownOutputElement = markdownOutputWidget.node;
166
+ const firstOutputElementChild = markdownOutputElement.firstElementChild;
167
+ if (firstOutputElementChild === null) {
168
+ return false;
169
+ }
170
+ // Temporarily set the element's max width so that the bounding client rectangle only encompasses the content.
171
+ const oldMaxWidth = firstOutputElementChild.style.maxWidth;
172
+ firstOutputElementChild.style.maxWidth = 'max-content';
173
+ const lineRight = firstOutputElementChild.getBoundingClientRect().right;
174
+ // Reinstate the old max width.
175
+ firstOutputElementChild.style.maxWidth = oldMaxWidth;
176
+ const toolbarLeft = this._cellToolbarLeft(activeCell);
177
+ return toolbarLeft === null ? false : lineRight > toolbarLeft;
178
+ }
179
+ _codeOverlapsToolbar(activeCell) {
180
+ const editorWidget = activeCell.editorWidget;
181
+ const editor = activeCell.editor;
182
+ if (editor.lineCount < 1) {
183
+ return false; // Nothing in the editor
184
+ }
185
+ const codeMirrorLines = editorWidget.node.getElementsByClassName('CodeMirror-line');
186
+ if (codeMirrorLines.length < 1) {
187
+ return false; // No lines present
188
+ }
189
+ const lineRight = codeMirrorLines[0].children[0] // First span under first pre
190
+ .getBoundingClientRect().right;
191
+ const toolbarLeft = this._cellToolbarLeft(activeCell);
192
+ return toolbarLeft === null ? false : lineRight > toolbarLeft;
193
+ }
194
+ _cellEditorWidgetLeft(activeCell) {
195
+ return activeCell.editorWidget.node.getBoundingClientRect().left;
196
+ }
197
+ _cellEditorWidgetRight(activeCell) {
198
+ return activeCell.editorWidget.node.getBoundingClientRect().right;
199
+ }
200
+ _cellToolbarLeft(activeCell) {
201
+ const toolbarWidgets = this._findToolbarWidgets(activeCell);
202
+ if (toolbarWidgets.length < 1) {
203
+ return null;
204
+ }
205
+ const activeCellToolbar = toolbarWidgets[0].node;
206
+ return activeCellToolbar.getBoundingClientRect().left;
207
+ }
208
+ }
209
+ const defaultToolbarItems = [
210
+ {
211
+ command: 'notebook:duplicate-below',
212
+ name: 'duplicate-cell'
213
+ },
214
+ {
215
+ command: 'notebook:move-cell-up',
216
+ name: 'move-cell-up'
217
+ },
218
+ {
219
+ command: 'notebook:move-cell-down',
220
+ name: 'move-cell-down'
221
+ },
222
+ {
223
+ command: 'notebook:insert-cell-above',
224
+ name: 'insert-cell-above'
225
+ },
226
+ {
227
+ command: 'notebook:insert-cell-below',
228
+ name: 'insert-cell-below'
229
+ },
230
+ {
231
+ command: 'notebook:delete-cell',
232
+ name: 'delete-cell'
233
+ }
234
+ ];
235
+ /**
236
+ * Widget extension that creates a CellToolbarTracker each time a notebook is
237
+ * created.
238
+ */
239
+ export class CellBarExtension {
240
+ constructor(commands, toolbarFactory) {
241
+ this._commands = commands;
242
+ this._toolbarFactory = toolbarFactory !== null && toolbarFactory !== void 0 ? toolbarFactory : this.defaultToolbarFactory;
243
+ }
244
+ get defaultToolbarFactory() {
245
+ const itemFactory = createDefaultFactory(this._commands);
246
+ return (widget) => new ObservableList({
247
+ values: defaultToolbarItems.map(item => {
248
+ return {
249
+ name: item.name,
250
+ widget: itemFactory(CellBarExtension.FACTORY_NAME, widget, item)
251
+ };
252
+ })
253
+ });
254
+ }
255
+ createNew(panel) {
256
+ return new CellToolbarTracker(panel, this._toolbarFactory(panel));
257
+ }
258
+ }
259
+ CellBarExtension.FACTORY_NAME = 'Cell';
260
+ //# sourceMappingURL=celltoolbartracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"celltoolbartracker.js","sourceRoot":"","sources":["../src/celltoolbartracker.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AC;SACH,CAAC,CAAC;IACP,CAAC;IAED,SAAS,CAAC,KAAoB;QAC5B,OAAO,IAAI,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,CAAC;;AA7BM,6BAAY,GAAG,MAAM,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module cell-toolbar
4
+ */
5
+ export { CellBarExtension } from './celltoolbartracker';
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /* -----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+ /**
6
+ * @packageDocumentation
7
+ * @module cell-toolbar
8
+ */
9
+ export { CellBarExtension } from './celltoolbartracker';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@jupyterlab/cell-toolbar",
3
+ "version": "3.4.0-alpha.0",
4
+ "description": "Contextual cell toolbar adapted from jlab-enhanced-cell-toolbar",
5
+ "homepage": "https://github.com/jupyterlab/jupyterlab",
6
+ "bugs": {
7
+ "url": "https://github.com/jupyterlab/jupyterlab/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jupyterlab/jupyterlab.git"
12
+ },
13
+ "license": "BSD-3-Clause",
14
+ "author": "Project Jupyter",
15
+ "sideEffects": [
16
+ "style/**/*"
17
+ ],
18
+ "main": "lib/index.js",
19
+ "types": "lib/index.d.ts",
20
+ "style": "style/index.css",
21
+ "directories": {
22
+ "lib": "lib",
23
+ "test": "test"
24
+ },
25
+ "files": [
26
+ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
27
+ "schema/*.json",
28
+ "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
29
+ "style/index.js"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc -b",
33
+ "build:all": "npm run build",
34
+ "build:test": "tsc --build tsconfig.test.json",
35
+ "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
36
+ "test": "jest",
37
+ "test:cov": "jest --collect-coverage",
38
+ "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
39
+ "test:debug:watch": "node --inspect-brk node_modules/.bin/jest --runInBand --watch",
40
+ "watch": "tsc -b --watch"
41
+ },
42
+ "dependencies": {
43
+ "@jupyterlab/apputils": "^3.4.0-alpha.0",
44
+ "@jupyterlab/cells": "^3.4.0-alpha.0",
45
+ "@jupyterlab/docregistry": "^3.4.0-alpha.0",
46
+ "@jupyterlab/notebook": "^3.4.0-alpha.0",
47
+ "@jupyterlab/observables": "^4.4.0-alpha.0",
48
+ "@lumino/algorithm": "^1.9.0",
49
+ "@lumino/commands": "^1.19.0",
50
+ "@lumino/disposable": "^1.10.0",
51
+ "@lumino/signaling": "^1.10.0",
52
+ "@lumino/widgets": "^1.30.0"
53
+ },
54
+ "devDependencies": {
55
+ "@jupyterlab/testutils": "^3.4.0-alpha.0",
56
+ "@types/jest": "^26.0.10",
57
+ "jest": "^26.4.2",
58
+ "rimraf": "~3.0.0",
59
+ "ts-jest": "^26.3.0",
60
+ "typescript": "~4.1.3"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ },
65
+ "styleModule": "style/index.js"
66
+ }
package/style/base.css ADDED
@@ -0,0 +1,77 @@
1
+ .jp-cell-button .jp-icon3[fill] {
2
+ fill: var(--jp-inverse-layout-color4);
3
+ }
4
+
5
+ .jp-cell-button:hover .jp-icon3[fill] {
6
+ fill: var(--jp-inverse-layout-color2);
7
+ }
8
+
9
+ .jp-toolbar-overlap .jp-cell-toolbar {
10
+ display: none;
11
+ }
12
+
13
+ .jp-cell-toolbar {
14
+ display: flex;
15
+ flex-direction: row;
16
+ padding: 2px 0;
17
+ min-height: 25px;
18
+ z-index: 10;
19
+ position: absolute;
20
+ top: 5px;
21
+ right: 8px;
22
+
23
+ /* Override .jp-Toolbar */
24
+ background-color: inherit;
25
+ border-bottom: inherit;
26
+ box-shadow: inherit;
27
+ }
28
+
29
+ /* Overrides for mobile view: Move cell toolbar up, don't hide it if it overlaps */
30
+ @media only screen and (max-width: 760px) {
31
+ .jp-toolbar-overlap .jp-cell-toolbar {
32
+ display: block;
33
+ }
34
+
35
+ .jp-cell-toolbar {
36
+ top: -5px;
37
+ }
38
+ }
39
+
40
+ .jp-cell-menu {
41
+ display: flex;
42
+ flex-direction: row;
43
+ }
44
+
45
+ .jp-cell-menu button.jp-ToolbarButtonComponent {
46
+ cursor: pointer;
47
+ }
48
+
49
+ .jp-cell-menu .jp-ToolbarButton button {
50
+ display: none;
51
+ }
52
+
53
+ .jp-cell-menu .jp-ToolbarButton .jp-cell-all,
54
+ .jp-CodeCell .jp-ToolbarButton .jp-cell-code,
55
+ .jp-MarkdownCell .jp-ToolbarButton .jp-cell-markdown,
56
+ .jp-RawCell .jp-ToolbarButton .jp-cell-raw {
57
+ display: block;
58
+ }
59
+
60
+ .jp-cell-toolbar .jp-Toolbar-spacer {
61
+ flex: 1 1 auto;
62
+ }
63
+
64
+ .jp-cell-mod-click {
65
+ cursor: pointer;
66
+ }
67
+
68
+ /* Custom styling for rendered markdown cells so that cell toolbar is visible */
69
+ .jp-MarkdownOutput {
70
+ border-width: var(--jp-border-width);
71
+ border-color: transparent;
72
+ border-style: solid;
73
+ }
74
+
75
+ .jp-mod-active .jp-MarkdownOutput {
76
+ border-color: var(--jp-cell-editor-border-color);
77
+ }
@@ -0,0 +1,13 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ /* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
7
+ @import url('~@lumino/widgets/style/index.css');
8
+ @import url('~@jupyterlab/apputils/style/index.css');
9
+ @import url('~@jupyterlab/docregistry/style/index.css');
10
+ @import url('~@jupyterlab/cells/style/index.css');
11
+ @import url('~@jupyterlab/notebook/style/index.css');
12
+
13
+ @import url('./base.css');
package/style/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ /* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
7
+ import '@lumino/widgets/style/index.js';
8
+ import '@jupyterlab/apputils/style/index.js';
9
+ import '@jupyterlab/docregistry/style/index.js';
10
+ import '@jupyterlab/cells/style/index.js';
11
+ import '@jupyterlab/notebook/style/index.js';
12
+
13
+ import './base.css';