@jupyterlite/repl-extension 0.8.0-beta.1 → 0.8.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.
- package/lib/index.js +189 -3
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +233 -3
package/lib/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { ILabStatus, IRouter, JupyterFrontEnd, Router } from '@jupyterlab/application';
|
|
4
|
-
import { IThemeManager, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
|
|
4
|
+
import { Clipboard, ICommandPalette, IThemeManager, IToolbarWidgetRegistry, Notification, } from '@jupyterlab/apputils';
|
|
5
5
|
import { IConsoleTracker } from '@jupyterlab/console';
|
|
6
6
|
import { ITranslator } from '@jupyterlab/translation';
|
|
7
|
+
import { shareIcon } from '@jupyterlab/ui-components';
|
|
7
8
|
import { SingleWidgetApp } from '@jupyterlite/application';
|
|
8
9
|
import { liteIcon } from '@jupyterlite/ui-components';
|
|
9
10
|
import { Widget } from '@lumino/widgets';
|
|
@@ -11,6 +12,37 @@ import { Widget } from '@lumino/widgets';
|
|
|
11
12
|
* The name of the translation bundle for internationalized strings.
|
|
12
13
|
*/
|
|
13
14
|
const I18N_BUNDLE = 'jupyterlite';
|
|
15
|
+
/**
|
|
16
|
+
* The command ids used by the REPL extension.
|
|
17
|
+
*/
|
|
18
|
+
var CommandIDs;
|
|
19
|
+
(function (CommandIDs) {
|
|
20
|
+
CommandIDs.copyShareableLink = 'repl:copy-shareable-link';
|
|
21
|
+
})(CommandIDs || (CommandIDs = {}));
|
|
22
|
+
const DEFAULT_REPL_CONFIG = {
|
|
23
|
+
clearCellsOnExecute: false,
|
|
24
|
+
clearCodeContentOnExecute: true,
|
|
25
|
+
hideCodeInput: false,
|
|
26
|
+
promptCellPosition: 'bottom',
|
|
27
|
+
showBanner: true,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Auto-close delay (in ms) for the link-copied notification. Notifications
|
|
31
|
+
* without a positive `autoClose` delay are silent and do not show as a toast.
|
|
32
|
+
*/
|
|
33
|
+
const COPY_NOTIFICATION_AUTO_CLOSE = 5000;
|
|
34
|
+
const SHAREABLE_PARAMETERS = [
|
|
35
|
+
'clearCellsOnExecute',
|
|
36
|
+
'clearCodeContentOnExecute',
|
|
37
|
+
'code',
|
|
38
|
+
'execute',
|
|
39
|
+
'hideCodeInput',
|
|
40
|
+
'kernel',
|
|
41
|
+
'promptCellPosition',
|
|
42
|
+
'showBanner',
|
|
43
|
+
'theme',
|
|
44
|
+
'toolbar',
|
|
45
|
+
];
|
|
14
46
|
/**
|
|
15
47
|
* A plugin to add buttons to the console toolbar.
|
|
16
48
|
*/
|
|
@@ -44,6 +76,114 @@ const buttons = {
|
|
|
44
76
|
}
|
|
45
77
|
},
|
|
46
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* A plugin to expose a shareable REPL link command and toolbar button.
|
|
81
|
+
*/
|
|
82
|
+
const share = {
|
|
83
|
+
id: '@jupyterlite/repl-extension:share',
|
|
84
|
+
description: 'Adds a command to copy a shareable link to the current REPL state.',
|
|
85
|
+
autoStart: true,
|
|
86
|
+
requires: [IConsoleTracker, ITranslator],
|
|
87
|
+
optional: [ICommandPalette, IThemeManager],
|
|
88
|
+
activate: (app, tracker, translator, palette, themeManager) => {
|
|
89
|
+
const trans = translator.load(I18N_BUNDLE);
|
|
90
|
+
const { commands } = app;
|
|
91
|
+
let copyNotificationId = '';
|
|
92
|
+
commands.addCommand(CommandIDs.copyShareableLink, {
|
|
93
|
+
execute: () => {
|
|
94
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
95
|
+
const panel = tracker.currentWidget;
|
|
96
|
+
if (!panel) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const url = new URL(window.location.href);
|
|
100
|
+
// We share the state via the URL fragment rather than the query
|
|
101
|
+
// string. Fragments are not subject to the same length limits and
|
|
102
|
+
// are not stripped by some hosting platforms, such as Read The Docs.
|
|
103
|
+
// xref https://github.com/jupyterlite/jupyterlite/issues/1983.
|
|
104
|
+
const params = Private.parseHashParams(url.hash);
|
|
105
|
+
SHAREABLE_PARAMETERS.forEach((parameter) => {
|
|
106
|
+
// clear params from query string
|
|
107
|
+
url.searchParams.delete(parameter);
|
|
108
|
+
// clear params from fragment
|
|
109
|
+
params.delete(parameter);
|
|
110
|
+
});
|
|
111
|
+
const config = Private.getConsoleConfig(panel);
|
|
112
|
+
const promptCode = (_b = (_a = panel.console.promptCell) === null || _a === void 0 ? void 0 : _a.model.sharedModel.getSource()) !== null && _b !== void 0 ? _b : '';
|
|
113
|
+
const kernelName = (_e = (_d = (_c = panel.sessionContext.session) === null || _c === void 0 ? void 0 : _c.kernel) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : '';
|
|
114
|
+
const theme = (_g = (_f = themeManager === null || themeManager === void 0 ? void 0 : themeManager.theme) === null || _f === void 0 ? void 0 : _f.trim()) !== null && _g !== void 0 ? _g : '';
|
|
115
|
+
if (!panel.toolbar.isDisposed) {
|
|
116
|
+
params.set('toolbar', '1');
|
|
117
|
+
}
|
|
118
|
+
if (kernelName) {
|
|
119
|
+
params.set('kernel', kernelName);
|
|
120
|
+
}
|
|
121
|
+
if (theme) {
|
|
122
|
+
params.set('theme', theme);
|
|
123
|
+
}
|
|
124
|
+
if (config.promptCellPosition !== DEFAULT_REPL_CONFIG.promptCellPosition) {
|
|
125
|
+
params.set('promptCellPosition', config.promptCellPosition);
|
|
126
|
+
}
|
|
127
|
+
if (config.clearCellsOnExecute) {
|
|
128
|
+
params.set('clearCellsOnExecute', '1');
|
|
129
|
+
}
|
|
130
|
+
if (!config.clearCodeContentOnExecute) {
|
|
131
|
+
params.set('clearCodeContentOnExecute', '0');
|
|
132
|
+
}
|
|
133
|
+
if (config.hideCodeInput) {
|
|
134
|
+
params.set('hideCodeInput', '1');
|
|
135
|
+
}
|
|
136
|
+
if (!config.showBanner) {
|
|
137
|
+
params.set('showBanner', '0');
|
|
138
|
+
}
|
|
139
|
+
if (promptCode !== '') {
|
|
140
|
+
params.set('execute', '0');
|
|
141
|
+
promptCode.split('\n').forEach((line) => {
|
|
142
|
+
params.append('code', line);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
url.hash = params.toString();
|
|
146
|
+
window.history.replaceState(window.history.state, document.title, `${url.pathname}${url.search}${url.hash}`);
|
|
147
|
+
Clipboard.copyToSystem(url.toString());
|
|
148
|
+
// update the existing notification if any to avoid stacking them up
|
|
149
|
+
const message = trans.__('Link copied to clipboard');
|
|
150
|
+
const updated = Notification.update({
|
|
151
|
+
id: copyNotificationId,
|
|
152
|
+
message,
|
|
153
|
+
autoClose: COPY_NOTIFICATION_AUTO_CLOSE,
|
|
154
|
+
});
|
|
155
|
+
if (!updated) {
|
|
156
|
+
copyNotificationId = Notification.info(message, {
|
|
157
|
+
autoClose: COPY_NOTIFICATION_AUTO_CLOSE,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return url.toString();
|
|
161
|
+
},
|
|
162
|
+
icon: (args) => (args['isPalette'] ? undefined : shareIcon),
|
|
163
|
+
isEnabled: () => !!tracker.currentWidget,
|
|
164
|
+
caption: trans.__('Copy a shareable link for this REPL with the current prompt and options'),
|
|
165
|
+
label: trans.__('Copy Shareable Link'),
|
|
166
|
+
describedBy: {
|
|
167
|
+
args: {
|
|
168
|
+
type: 'object',
|
|
169
|
+
properties: {
|
|
170
|
+
isPalette: {
|
|
171
|
+
type: 'boolean',
|
|
172
|
+
description: trans.__('Whether the command is executed from the palette'),
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
if (palette) {
|
|
179
|
+
palette.addItem({
|
|
180
|
+
command: CommandIDs.copyShareableLink,
|
|
181
|
+
category: trans.__('REPL'),
|
|
182
|
+
args: { isPalette: true },
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
};
|
|
47
187
|
/**
|
|
48
188
|
* A plugin to open a code console and
|
|
49
189
|
* parse custom parameters from the query string arguments.
|
|
@@ -59,8 +199,7 @@ const consolePlugin = {
|
|
|
59
199
|
return;
|
|
60
200
|
}
|
|
61
201
|
const { commands, started } = app;
|
|
62
|
-
const
|
|
63
|
-
const urlParams = new URLSearchParams(search);
|
|
202
|
+
const urlParams = Private.getShareableParams();
|
|
64
203
|
const code = urlParams.getAll('code');
|
|
65
204
|
const execute = urlParams.get('execute');
|
|
66
205
|
const kernel = urlParams.get('kernel') || undefined;
|
|
@@ -176,7 +315,54 @@ const plugins = [
|
|
|
176
315
|
consolePlugin,
|
|
177
316
|
paths,
|
|
178
317
|
router,
|
|
318
|
+
share,
|
|
179
319
|
status,
|
|
180
320
|
];
|
|
181
321
|
export default plugins;
|
|
322
|
+
var Private;
|
|
323
|
+
(function (Private) {
|
|
324
|
+
/**
|
|
325
|
+
* Parse a URL hash fragment as query-like parameters (`#key=value&...`)
|
|
326
|
+
* @param hash The URL hash fragment to parse.
|
|
327
|
+
* @returns A URLSearchParams object representing the parsed parameters.
|
|
328
|
+
*/
|
|
329
|
+
function parseHashParams(hash) {
|
|
330
|
+
let fragment = hash.startsWith('#') ? hash.slice(1) : hash;
|
|
331
|
+
if (fragment.startsWith('?')) {
|
|
332
|
+
fragment = fragment.slice(1);
|
|
333
|
+
}
|
|
334
|
+
return new URLSearchParams(fragment);
|
|
335
|
+
}
|
|
336
|
+
Private.parseHashParams = parseHashParams;
|
|
337
|
+
/**
|
|
338
|
+
* Collect the shareable parameters from the current location.
|
|
339
|
+
*
|
|
340
|
+
* Sharing stores the REPL state in the URL fragment. Embedding configures the
|
|
341
|
+
* REPL through the documented query parameters. Read the fragment when it
|
|
342
|
+
* carries any shareable parameter, and the query string otherwise.
|
|
343
|
+
*
|
|
344
|
+
* @returns A URLSearchParams object containing the shareable parameters from the URL.
|
|
345
|
+
*/
|
|
346
|
+
function getShareableParams() {
|
|
347
|
+
const hashParams = parseHashParams(window.location.hash);
|
|
348
|
+
if (SHAREABLE_PARAMETERS.some((parameter) => hashParams.has(parameter))) {
|
|
349
|
+
return hashParams;
|
|
350
|
+
}
|
|
351
|
+
return new URLSearchParams(window.location.search);
|
|
352
|
+
}
|
|
353
|
+
Private.getShareableParams = getShareableParams;
|
|
354
|
+
function getConsoleConfig(panel) {
|
|
355
|
+
var _a, _b, _c, _d, _e, _f;
|
|
356
|
+
// JupyterLab exposes config updates but not a public getter.
|
|
357
|
+
const config = ((_a = panel.console._config) !== null && _a !== void 0 ? _a : {});
|
|
358
|
+
return {
|
|
359
|
+
clearCellsOnExecute: (_b = config.clearCellsOnExecute) !== null && _b !== void 0 ? _b : DEFAULT_REPL_CONFIG.clearCellsOnExecute,
|
|
360
|
+
clearCodeContentOnExecute: (_c = config.clearCodeContentOnExecute) !== null && _c !== void 0 ? _c : DEFAULT_REPL_CONFIG.clearCodeContentOnExecute,
|
|
361
|
+
hideCodeInput: (_d = config.hideCodeInput) !== null && _d !== void 0 ? _d : DEFAULT_REPL_CONFIG.hideCodeInput,
|
|
362
|
+
promptCellPosition: (_e = config.promptCellPosition) !== null && _e !== void 0 ? _e : DEFAULT_REPL_CONFIG.promptCellPosition,
|
|
363
|
+
showBanner: (_f = config.showBanner) !== null && _f !== void 0 ? _f : DEFAULT_REPL_CONFIG.showBanner,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
Private.getConsoleConfig = getConsoleConfig;
|
|
367
|
+
})(Private || (Private = {}));
|
|
182
368
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAE,UAAU,EAAE,OA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,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IANe,0BAAkB,qBAMjC,CAAA;IAED,SAAgB,gBAAgB,CAAC,KAAmB;;QAClD,6DAA6D;QAC7D,MAAM,MAAM,GAAG,CAAC,MAAC,KAAK,CAAC,OAAe,CAAC,OAAO,mCAAI,EAAE,CAAwB,CAAC;QAE7E,OAAO;YACL,mBAAmB,EACjB,MAAA,MAAM,CAAC,mBAAmB,mCAAI,mBAAmB,CAAC,mBAAmB;YACvE,yBAAyB,EACvB,MAAA,MAAM,CAAC,yBAAyB,mCAChC,mBAAmB,CAAC,yBAAyB;YAC/C,aAAa,EAAE,MAAA,MAAM,CAAC,aAAa,mCAAI,mBAAmB,CAAC,aAAa;YACxE,kBAAkB,EAChB,MAAA,MAAM,CAAC,kBAAkB,mCAAI,mBAAmB,CAAC,kBAAkB;YACrE,UAAU,EAAE,MAAA,MAAM,CAAC,UAAU,mCAAI,mBAAmB,CAAC,UAAU;SAChE,CAAC;IACJ,CAAC;IAfe,wBAAgB,mBAe/B,CAAA;AACH,CAAC,EA/CS,OAAO,KAAP,OAAO,QA+ChB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlite/repl-extension",
|
|
3
|
-
"version": "0.8.0
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "JupyterLite - Console Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyterlite/jupyterlite",
|
|
6
6
|
"bugs": {
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"watch": "tsc -b --watch"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jupyterlab/application": "~4.6.0
|
|
42
|
-
"@jupyterlab/apputils": "~4.7.0
|
|
43
|
-
"@jupyterlab/console": "~4.6.0
|
|
44
|
-
"@jupyterlab/translation": "~4.6.0
|
|
45
|
-
"@jupyterlab/ui-components": "~4.6.0
|
|
46
|
-
"@jupyterlite/application": "^0.8.0
|
|
41
|
+
"@jupyterlab/application": "~4.6.0",
|
|
42
|
+
"@jupyterlab/apputils": "~4.7.0",
|
|
43
|
+
"@jupyterlab/console": "~4.6.0",
|
|
44
|
+
"@jupyterlab/translation": "~4.6.0",
|
|
45
|
+
"@jupyterlab/ui-components": "~4.6.0",
|
|
46
|
+
"@jupyterlite/application": "^0.8.0",
|
|
47
47
|
"@lumino/widgets": "^2.8.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -4,13 +4,21 @@
|
|
|
4
4
|
import type { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
5
5
|
import { ILabStatus, IRouter, JupyterFrontEnd, Router } from '@jupyterlab/application';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Clipboard,
|
|
9
|
+
ICommandPalette,
|
|
10
|
+
IThemeManager,
|
|
11
|
+
IToolbarWidgetRegistry,
|
|
12
|
+
Notification,
|
|
13
|
+
} from '@jupyterlab/apputils';
|
|
8
14
|
|
|
9
15
|
import type { CodeConsole, ConsolePanel } from '@jupyterlab/console';
|
|
10
16
|
import { IConsoleTracker } from '@jupyterlab/console';
|
|
11
17
|
|
|
12
18
|
import { ITranslator } from '@jupyterlab/translation';
|
|
13
19
|
|
|
20
|
+
import { shareIcon } from '@jupyterlab/ui-components';
|
|
21
|
+
|
|
14
22
|
import { SingleWidgetApp } from '@jupyterlite/application';
|
|
15
23
|
|
|
16
24
|
import { liteIcon } from '@jupyterlite/ui-components';
|
|
@@ -22,6 +30,40 @@ import { Widget } from '@lumino/widgets';
|
|
|
22
30
|
*/
|
|
23
31
|
const I18N_BUNDLE = 'jupyterlite';
|
|
24
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The command ids used by the REPL extension.
|
|
35
|
+
*/
|
|
36
|
+
namespace CommandIDs {
|
|
37
|
+
export const copyShareableLink = 'repl:copy-shareable-link';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const DEFAULT_REPL_CONFIG: Required<CodeConsole.IConfig> = {
|
|
41
|
+
clearCellsOnExecute: false,
|
|
42
|
+
clearCodeContentOnExecute: true,
|
|
43
|
+
hideCodeInput: false,
|
|
44
|
+
promptCellPosition: 'bottom',
|
|
45
|
+
showBanner: true,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Auto-close delay (in ms) for the link-copied notification. Notifications
|
|
50
|
+
* without a positive `autoClose` delay are silent and do not show as a toast.
|
|
51
|
+
*/
|
|
52
|
+
const COPY_NOTIFICATION_AUTO_CLOSE = 5000;
|
|
53
|
+
|
|
54
|
+
const SHAREABLE_PARAMETERS = [
|
|
55
|
+
'clearCellsOnExecute',
|
|
56
|
+
'clearCodeContentOnExecute',
|
|
57
|
+
'code',
|
|
58
|
+
'execute',
|
|
59
|
+
'hideCodeInput',
|
|
60
|
+
'kernel',
|
|
61
|
+
'promptCellPosition',
|
|
62
|
+
'showBanner',
|
|
63
|
+
'theme',
|
|
64
|
+
'toolbar',
|
|
65
|
+
];
|
|
66
|
+
|
|
25
67
|
/**
|
|
26
68
|
* A plugin to add buttons to the console toolbar.
|
|
27
69
|
*/
|
|
@@ -62,6 +104,145 @@ const buttons: JupyterFrontEndPlugin<void> = {
|
|
|
62
104
|
},
|
|
63
105
|
};
|
|
64
106
|
|
|
107
|
+
/**
|
|
108
|
+
* A plugin to expose a shareable REPL link command and toolbar button.
|
|
109
|
+
*/
|
|
110
|
+
const share: JupyterFrontEndPlugin<void> = {
|
|
111
|
+
id: '@jupyterlite/repl-extension:share',
|
|
112
|
+
description: 'Adds a command to copy a shareable link to the current REPL state.',
|
|
113
|
+
autoStart: true,
|
|
114
|
+
requires: [IConsoleTracker, ITranslator],
|
|
115
|
+
optional: [ICommandPalette, IThemeManager],
|
|
116
|
+
activate: (
|
|
117
|
+
app: JupyterFrontEnd,
|
|
118
|
+
tracker: IConsoleTracker,
|
|
119
|
+
translator: ITranslator,
|
|
120
|
+
palette: ICommandPalette | null,
|
|
121
|
+
themeManager: IThemeManager | null,
|
|
122
|
+
) => {
|
|
123
|
+
const trans = translator.load(I18N_BUNDLE);
|
|
124
|
+
const { commands } = app;
|
|
125
|
+
let copyNotificationId = '';
|
|
126
|
+
|
|
127
|
+
commands.addCommand(CommandIDs.copyShareableLink, {
|
|
128
|
+
execute: () => {
|
|
129
|
+
const panel = tracker.currentWidget;
|
|
130
|
+
if (!panel) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const url = new URL(window.location.href);
|
|
135
|
+
// We share the state via the URL fragment rather than the query
|
|
136
|
+
// string. Fragments are not subject to the same length limits and
|
|
137
|
+
// are not stripped by some hosting platforms, such as Read The Docs.
|
|
138
|
+
// xref https://github.com/jupyterlite/jupyterlite/issues/1983.
|
|
139
|
+
const params = Private.parseHashParams(url.hash);
|
|
140
|
+
SHAREABLE_PARAMETERS.forEach((parameter) => {
|
|
141
|
+
// clear params from query string
|
|
142
|
+
url.searchParams.delete(parameter);
|
|
143
|
+
// clear params from fragment
|
|
144
|
+
params.delete(parameter);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const config = Private.getConsoleConfig(panel);
|
|
148
|
+
const promptCode =
|
|
149
|
+
panel.console.promptCell?.model.sharedModel.getSource() ?? '';
|
|
150
|
+
const kernelName = panel.sessionContext.session?.kernel?.name ?? '';
|
|
151
|
+
const theme = themeManager?.theme?.trim() ?? '';
|
|
152
|
+
|
|
153
|
+
if (!panel.toolbar.isDisposed) {
|
|
154
|
+
params.set('toolbar', '1');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (kernelName) {
|
|
158
|
+
params.set('kernel', kernelName);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (theme) {
|
|
162
|
+
params.set('theme', theme);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (config.promptCellPosition !== DEFAULT_REPL_CONFIG.promptCellPosition) {
|
|
166
|
+
params.set('promptCellPosition', config.promptCellPosition);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (config.clearCellsOnExecute) {
|
|
170
|
+
params.set('clearCellsOnExecute', '1');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!config.clearCodeContentOnExecute) {
|
|
174
|
+
params.set('clearCodeContentOnExecute', '0');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (config.hideCodeInput) {
|
|
178
|
+
params.set('hideCodeInput', '1');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (!config.showBanner) {
|
|
182
|
+
params.set('showBanner', '0');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (promptCode !== '') {
|
|
186
|
+
params.set('execute', '0');
|
|
187
|
+
promptCode.split('\n').forEach((line) => {
|
|
188
|
+
params.append('code', line);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
url.hash = params.toString();
|
|
193
|
+
|
|
194
|
+
window.history.replaceState(
|
|
195
|
+
window.history.state,
|
|
196
|
+
document.title,
|
|
197
|
+
`${url.pathname}${url.search}${url.hash}`,
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
Clipboard.copyToSystem(url.toString());
|
|
201
|
+
|
|
202
|
+
// update the existing notification if any to avoid stacking them up
|
|
203
|
+
const message = trans.__('Link copied to clipboard');
|
|
204
|
+
const updated = Notification.update({
|
|
205
|
+
id: copyNotificationId,
|
|
206
|
+
message,
|
|
207
|
+
autoClose: COPY_NOTIFICATION_AUTO_CLOSE,
|
|
208
|
+
});
|
|
209
|
+
if (!updated) {
|
|
210
|
+
copyNotificationId = Notification.info(message, {
|
|
211
|
+
autoClose: COPY_NOTIFICATION_AUTO_CLOSE,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return url.toString();
|
|
216
|
+
},
|
|
217
|
+
icon: (args) => (args['isPalette'] ? undefined : shareIcon),
|
|
218
|
+
isEnabled: () => !!tracker.currentWidget,
|
|
219
|
+
caption: trans.__(
|
|
220
|
+
'Copy a shareable link for this REPL with the current prompt and options',
|
|
221
|
+
),
|
|
222
|
+
label: trans.__('Copy Shareable Link'),
|
|
223
|
+
describedBy: {
|
|
224
|
+
args: {
|
|
225
|
+
type: 'object',
|
|
226
|
+
properties: {
|
|
227
|
+
isPalette: {
|
|
228
|
+
type: 'boolean',
|
|
229
|
+
description: trans.__('Whether the command is executed from the palette'),
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
if (palette) {
|
|
237
|
+
palette.addItem({
|
|
238
|
+
command: CommandIDs.copyShareableLink,
|
|
239
|
+
category: trans.__('REPL'),
|
|
240
|
+
args: { isPalette: true },
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
|
|
65
246
|
/**
|
|
66
247
|
* A plugin to open a code console and
|
|
67
248
|
* parse custom parameters from the query string arguments.
|
|
@@ -81,8 +262,7 @@ const consolePlugin: JupyterFrontEndPlugin<void> = {
|
|
|
81
262
|
}
|
|
82
263
|
const { commands, started } = app;
|
|
83
264
|
|
|
84
|
-
const
|
|
85
|
-
const urlParams = new URLSearchParams(search);
|
|
265
|
+
const urlParams = Private.getShareableParams();
|
|
86
266
|
const code = urlParams.getAll('code');
|
|
87
267
|
const execute = urlParams.get('execute');
|
|
88
268
|
const kernel = urlParams.get('kernel') || undefined;
|
|
@@ -214,7 +394,57 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
|
|
|
214
394
|
consolePlugin,
|
|
215
395
|
paths,
|
|
216
396
|
router,
|
|
397
|
+
share,
|
|
217
398
|
status,
|
|
218
399
|
];
|
|
219
400
|
|
|
220
401
|
export default plugins;
|
|
402
|
+
|
|
403
|
+
namespace Private {
|
|
404
|
+
/**
|
|
405
|
+
* Parse a URL hash fragment as query-like parameters (`#key=value&...`)
|
|
406
|
+
* @param hash The URL hash fragment to parse.
|
|
407
|
+
* @returns A URLSearchParams object representing the parsed parameters.
|
|
408
|
+
*/
|
|
409
|
+
export function parseHashParams(hash: string): URLSearchParams {
|
|
410
|
+
let fragment = hash.startsWith('#') ? hash.slice(1) : hash;
|
|
411
|
+
if (fragment.startsWith('?')) {
|
|
412
|
+
fragment = fragment.slice(1);
|
|
413
|
+
}
|
|
414
|
+
return new URLSearchParams(fragment);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Collect the shareable parameters from the current location.
|
|
419
|
+
*
|
|
420
|
+
* Sharing stores the REPL state in the URL fragment. Embedding configures the
|
|
421
|
+
* REPL through the documented query parameters. Read the fragment when it
|
|
422
|
+
* carries any shareable parameter, and the query string otherwise.
|
|
423
|
+
*
|
|
424
|
+
* @returns A URLSearchParams object containing the shareable parameters from the URL.
|
|
425
|
+
*/
|
|
426
|
+
export function getShareableParams(): URLSearchParams {
|
|
427
|
+
const hashParams = parseHashParams(window.location.hash);
|
|
428
|
+
if (SHAREABLE_PARAMETERS.some((parameter) => hashParams.has(parameter))) {
|
|
429
|
+
return hashParams;
|
|
430
|
+
}
|
|
431
|
+
return new URLSearchParams(window.location.search);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export function getConsoleConfig(panel: ConsolePanel): Required<CodeConsole.IConfig> {
|
|
435
|
+
// JupyterLab exposes config updates but not a public getter.
|
|
436
|
+
const config = ((panel.console as any)._config ?? {}) as CodeConsole.IConfig;
|
|
437
|
+
|
|
438
|
+
return {
|
|
439
|
+
clearCellsOnExecute:
|
|
440
|
+
config.clearCellsOnExecute ?? DEFAULT_REPL_CONFIG.clearCellsOnExecute,
|
|
441
|
+
clearCodeContentOnExecute:
|
|
442
|
+
config.clearCodeContentOnExecute ??
|
|
443
|
+
DEFAULT_REPL_CONFIG.clearCodeContentOnExecute,
|
|
444
|
+
hideCodeInput: config.hideCodeInput ?? DEFAULT_REPL_CONFIG.hideCodeInput,
|
|
445
|
+
promptCellPosition:
|
|
446
|
+
config.promptCellPosition ?? DEFAULT_REPL_CONFIG.promptCellPosition,
|
|
447
|
+
showBanner: config.showBanner ?? DEFAULT_REPL_CONFIG.showBanner,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
}
|