@jupyterlab/cell-toolbar-extension 4.6.0-alpha.2 → 4.6.0-alpha.4
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.
- package/lib/index.d.ts +1 -1
- package/lib/index.js +44 -1
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/schema/plugin.json +7 -1
- package/src/index.ts +53 -2
package/lib/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module cell-toolbar-extension
|
|
4
4
|
*/
|
|
5
|
-
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
5
|
+
import type { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
6
6
|
declare const cellToolbar: JupyterFrontEndPlugin<void>;
|
|
7
7
|
export default cellToolbar;
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
10
10
|
import { CellBarExtension } from '@jupyterlab/cell-toolbar';
|
|
11
|
-
import { createToolbarFactory, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
|
|
11
|
+
import { createToolbarFactory, Dialog, IToolbarWidgetRegistry, showDialog } from '@jupyterlab/apputils';
|
|
12
12
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
13
13
|
const PLUGIN_ID = '@jupyterlab/cell-toolbar-extension:plugin';
|
|
14
14
|
const cellToolbar = {
|
|
@@ -16,6 +16,49 @@ const cellToolbar = {
|
|
|
16
16
|
description: 'Add the cells toolbar.',
|
|
17
17
|
autoStart: true,
|
|
18
18
|
activate: async (app, settingRegistry, toolbarRegistry, translator) => {
|
|
19
|
+
const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
|
|
20
|
+
app.commands.addCommand('cell-toolbar:delete', {
|
|
21
|
+
label: trans.__('Delete Cell'),
|
|
22
|
+
caption: trans.__('Delete the cell'),
|
|
23
|
+
describedBy: {
|
|
24
|
+
args: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
execute: async (args) => {
|
|
30
|
+
let shouldConfirmDelete = true;
|
|
31
|
+
let setting;
|
|
32
|
+
if (settingRegistry) {
|
|
33
|
+
setting = await settingRegistry.load(PLUGIN_ID);
|
|
34
|
+
shouldConfirmDelete = setting.get('askCellDeleteConfirmation')
|
|
35
|
+
.composite;
|
|
36
|
+
}
|
|
37
|
+
if (!shouldConfirmDelete) {
|
|
38
|
+
return app.commands.execute('notebook:delete-cell', args);
|
|
39
|
+
}
|
|
40
|
+
const result = await showDialog({
|
|
41
|
+
title: trans.__('Delete Cell'),
|
|
42
|
+
body: trans.__('Are you sure you want to delete this cell?'),
|
|
43
|
+
buttons: [
|
|
44
|
+
Dialog.cancelButton(),
|
|
45
|
+
Dialog.warnButton({ label: trans.__('Delete') })
|
|
46
|
+
],
|
|
47
|
+
checkbox: settingRegistry
|
|
48
|
+
? {
|
|
49
|
+
label: trans.__('Do not ask me again'),
|
|
50
|
+
caption: trans.__('Ignore this warning for future deletions.')
|
|
51
|
+
}
|
|
52
|
+
: null
|
|
53
|
+
});
|
|
54
|
+
if (result.button.accept) {
|
|
55
|
+
if (result.isChecked && setting) {
|
|
56
|
+
await setting.set('askCellDeleteConfirmation', false);
|
|
57
|
+
}
|
|
58
|
+
return app.commands.execute('notebook:delete-cell', args);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
19
62
|
/**
|
|
20
63
|
* Load the settings for this extension
|
|
21
64
|
*
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,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for cell toolbar adapted from jlab-enhanced-cell-toolbar",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"watch": "tsc -b --watch"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@jupyterlab/application": "^4.6.0-alpha.
|
|
38
|
-
"@jupyterlab/apputils": "^4.7.0-alpha.
|
|
39
|
-
"@jupyterlab/cell-toolbar": "^4.6.0-alpha.
|
|
40
|
-
"@jupyterlab/settingregistry": "^4.6.0-alpha.
|
|
41
|
-
"@jupyterlab/translation": "^4.6.0-alpha.
|
|
37
|
+
"@jupyterlab/application": "^4.6.0-alpha.4",
|
|
38
|
+
"@jupyterlab/apputils": "^4.7.0-alpha.4",
|
|
39
|
+
"@jupyterlab/cell-toolbar": "^4.6.0-alpha.4",
|
|
40
|
+
"@jupyterlab/settingregistry": "^4.6.0-alpha.4",
|
|
41
|
+
"@jupyterlab/translation": "^4.6.0-alpha.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rimraf": "~5.0.5",
|
|
45
|
-
"typescript": "~5.
|
|
45
|
+
"typescript": "~5.9.3"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
package/schema/plugin.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"command": "notebook:insert-cell-below"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
"command": "
|
|
22
|
+
"command": "cell-toolbar:delete",
|
|
23
23
|
"icon": "ui-components:delete",
|
|
24
24
|
"name": "delete-cell"
|
|
25
25
|
}
|
|
@@ -33,6 +33,12 @@
|
|
|
33
33
|
"type": "boolean",
|
|
34
34
|
"default": true
|
|
35
35
|
},
|
|
36
|
+
"askCellDeleteConfirmation": {
|
|
37
|
+
"title": "Delete confirmation",
|
|
38
|
+
"description": "Whether to ask for confirmation when deleting a cell via the toolbar.",
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"default": true
|
|
41
|
+
},
|
|
36
42
|
"toolbar": {
|
|
37
43
|
"title": "List of toolbar items",
|
|
38
44
|
"description": "An item is defined by a 'name', a 'command' name, and an 'icon' name",
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module cell-toolbar-extension
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import type {
|
|
11
11
|
JupyterFrontEnd,
|
|
12
12
|
JupyterFrontEndPlugin
|
|
13
13
|
} from '@jupyterlab/application';
|
|
@@ -15,7 +15,9 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
|
15
15
|
import { CellBarExtension } from '@jupyterlab/cell-toolbar';
|
|
16
16
|
import {
|
|
17
17
|
createToolbarFactory,
|
|
18
|
-
|
|
18
|
+
Dialog,
|
|
19
|
+
IToolbarWidgetRegistry,
|
|
20
|
+
showDialog
|
|
19
21
|
} from '@jupyterlab/apputils';
|
|
20
22
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
21
23
|
|
|
@@ -31,6 +33,55 @@ const cellToolbar: JupyterFrontEndPlugin<void> = {
|
|
|
31
33
|
toolbarRegistry: IToolbarWidgetRegistry | null,
|
|
32
34
|
translator: ITranslator | null
|
|
33
35
|
) => {
|
|
36
|
+
const trans = (translator ?? nullTranslator).load('jupyterlab');
|
|
37
|
+
|
|
38
|
+
app.commands.addCommand('cell-toolbar:delete', {
|
|
39
|
+
label: trans.__('Delete Cell'),
|
|
40
|
+
caption: trans.__('Delete the cell'),
|
|
41
|
+
describedBy: {
|
|
42
|
+
args: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
execute: async args => {
|
|
48
|
+
let shouldConfirmDelete = true;
|
|
49
|
+
let setting: ISettingRegistry.ISettings | undefined;
|
|
50
|
+
|
|
51
|
+
if (settingRegistry) {
|
|
52
|
+
setting = await settingRegistry.load(PLUGIN_ID);
|
|
53
|
+
shouldConfirmDelete = setting.get('askCellDeleteConfirmation')
|
|
54
|
+
.composite as boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!shouldConfirmDelete) {
|
|
58
|
+
return app.commands.execute('notebook:delete-cell', args);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = await showDialog({
|
|
62
|
+
title: trans.__('Delete Cell'),
|
|
63
|
+
body: trans.__('Are you sure you want to delete this cell?'),
|
|
64
|
+
buttons: [
|
|
65
|
+
Dialog.cancelButton(),
|
|
66
|
+
Dialog.warnButton({ label: trans.__('Delete') })
|
|
67
|
+
],
|
|
68
|
+
checkbox: settingRegistry
|
|
69
|
+
? {
|
|
70
|
+
label: trans.__('Do not ask me again'),
|
|
71
|
+
caption: trans.__('Ignore this warning for future deletions.')
|
|
72
|
+
}
|
|
73
|
+
: null
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (result.button.accept) {
|
|
77
|
+
if (result.isChecked && setting) {
|
|
78
|
+
await setting.set('askCellDeleteConfirmation', false);
|
|
79
|
+
}
|
|
80
|
+
return app.commands.execute('notebook:delete-cell', args);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
34
85
|
/**
|
|
35
86
|
* Load the settings for this extension
|
|
36
87
|
*
|