xtralab 0.15.0 → 0.15.1
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/README.md +10 -0
- package/lib/about/icons.d.ts +0 -5
- package/lib/about/icons.js +0 -5
- package/lib/about/index.d.ts +4 -8
- package/lib/about/index.js +6 -17
- package/lib/agentSessions.d.ts +9 -29
- package/lib/agentSessions.js +2 -7
- package/lib/askAgent/editorSelection.d.ts +20 -26
- package/lib/askAgent/editorSelection.js +11 -26
- package/lib/askAgent/icons.d.ts +2 -3
- package/lib/askAgent/icons.js +2 -3
- package/lib/askAgent/index.d.ts +4 -26
- package/lib/askAgent/index.js +54 -158
- package/lib/askAgent/popup.d.ts +12 -16
- package/lib/askAgent/popup.js +18 -37
- package/lib/askAgent/prompt.d.ts +3 -5
- package/lib/askAgent/prompt.js +6 -19
- package/lib/askAgent/queue.d.ts +11 -21
- package/lib/askAgent/queue.js +9 -19
- package/lib/askAgent/queuePanel.d.ts +13 -18
- package/lib/askAgent/queuePanel.js +15 -37
- package/lib/askAgent/targetPicker.d.ts +2 -9
- package/lib/askAgent/targetPicker.js +6 -11
- package/lib/askAgent/tokens.d.ts +32 -46
- package/lib/askAgent/tokens.js +4 -6
- package/lib/commandBar/index.d.ts +4 -13
- package/lib/commandBar/index.js +21 -39
- package/lib/customPanel/index.js +15 -0
- package/lib/editorBreadcrumbs/index.d.ts +3 -6
- package/lib/editorBreadcrumbs/index.js +10 -6
- package/lib/editorBreadcrumbs/widget.d.ts +17 -4
- package/lib/editorBreadcrumbs/widget.js +11 -17
- package/lib/editorIndent/index.d.ts +4 -12
- package/lib/editorIndent/index.js +8 -23
- package/lib/fileBrowser/commands.d.ts +28 -19
- package/lib/fileBrowser/commands.js +39 -98
- package/lib/fileBrowser/contents.d.ts +3 -0
- package/lib/fileBrowser/dragAndDrop.d.ts +17 -4
- package/lib/fileBrowser/dragAndDrop.js +2 -7
- package/lib/fileBrowser/fileBrowser.d.ts +19 -9
- package/lib/fileBrowser/fileBrowser.js +68 -216
- package/lib/fileBrowser/gitStatus.d.ts +4 -9
- package/lib/fileBrowser/gitStatus.js +7 -17
- package/lib/fileBrowser/gitignore.d.ts +4 -17
- package/lib/fileBrowser/gitignore.js +4 -25
- package/lib/fileBrowser/icons.d.ts +7 -17
- package/lib/fileBrowser/icons.js +25 -80
- package/lib/fileBrowser/index.js +2 -4
- package/lib/fileBrowser/widget.d.ts +126 -48
- package/lib/fileBrowser/widget.js +89 -4
- package/lib/fileTypeIcons/index.js +0 -10
- package/lib/git/api.d.ts +5 -13
- package/lib/git/api.js +10 -36
- package/lib/git/askRequest.d.ts +4 -8
- package/lib/git/askRequest.js +6 -20
- package/lib/git/commands.d.ts +40 -5
- package/lib/git/commands.js +16 -10
- package/lib/git/diffModel.js +4 -0
- package/lib/git/diffSurface.d.ts +41 -55
- package/lib/git/diffSurface.js +42 -117
- package/lib/git/diffWidget.d.ts +81 -2
- package/lib/git/diffWidget.js +62 -12
- package/lib/git/imageDiff.d.ts +5 -6
- package/lib/git/imageDiff.js +18 -48
- package/lib/git/index.d.ts +0 -3
- package/lib/git/index.js +3 -8
- package/lib/git/notebookDiff.d.ts +110 -33
- package/lib/git/notebookDiff.js +52 -195
- package/lib/git/tokens.d.ts +73 -31
- package/lib/git/tokens.js +2 -3
- package/lib/highlight/index.d.ts +4 -10
- package/lib/highlight/index.js +10 -41
- package/lib/index.d.ts +0 -9
- package/lib/index.js +0 -9
- package/lib/launcher/agents.d.ts +55 -51
- package/lib/launcher/agents.js +15 -57
- package/lib/launcher/availability.d.ts +3 -9
- package/lib/launcher/availability.js +3 -9
- package/lib/launcher/commands.d.ts +7 -32
- package/lib/launcher/commands.js +14 -45
- package/lib/launcher/dashboard.d.ts +19 -24
- package/lib/launcher/dashboard.js +21 -67
- package/lib/launcher/editorRegistry.d.ts +10 -22
- package/lib/launcher/editorRegistry.js +14 -18
- package/lib/launcher/editors.d.ts +39 -45
- package/lib/launcher/editors.js +8 -34
- package/lib/launcher/icons.d.ts +0 -12
- package/lib/launcher/icons.js +5 -39
- package/lib/launcher/index.js +12 -55
- package/lib/launcher/invocation.d.ts +4 -10
- package/lib/launcher/invocation.js +7 -22
- package/lib/launcher/registry.d.ts +9 -7
- package/lib/launcher/registry.js +9 -7
- package/lib/launcher/tokens.d.ts +10 -22
- package/lib/launcher/tokens.js +5 -8
- package/lib/menuBar/index.d.ts +3 -10
- package/lib/menuBar/index.js +11 -28
- package/lib/menus/index.d.ts +3 -9
- package/lib/menus/index.js +14 -30
- package/lib/omnibox/files.d.ts +2 -4
- package/lib/omnibox/files.js +5 -11
- package/lib/omnibox/index.d.ts +4 -14
- package/lib/omnibox/index.js +9 -27
- package/lib/omnibox/model.d.ts +38 -10
- package/lib/omnibox/model.js +15 -33
- package/lib/omnibox/recents.d.ts +15 -17
- package/lib/omnibox/recents.js +12 -17
- package/lib/omnibox/tokens.d.ts +5 -10
- package/lib/omnibox/tokens.js +2 -6
- package/lib/omnibox/widget.d.ts +11 -7
- package/lib/omnibox/widget.js +8 -16
- package/lib/searchReplace/index.d.ts +4 -20
- package/lib/searchReplace/index.js +7 -27
- package/lib/showOutput/index.d.ts +3 -12
- package/lib/showOutput/index.js +6 -22
- package/lib/sidebar/index.d.ts +4 -7
- package/lib/sidebar/index.js +5 -12
- package/lib/terminalNotifications/index.d.ts +4 -10
- package/lib/terminalNotifications/index.js +6 -20
- package/lib/terminals/agentTerminals.d.ts +12 -5
- package/lib/terminals/agentTerminals.js +25 -44
- package/lib/terminals/detection.d.ts +4 -8
- package/lib/terminals/detection.js +4 -8
- package/lib/terminals/index.d.ts +0 -35
- package/lib/terminals/index.js +12 -101
- package/lib/terminals/model.d.ts +64 -139
- package/lib/terminals/model.js +80 -220
- package/lib/terminals/tokens.d.ts +11 -22
- package/lib/terminals/tokens.js +2 -2
- package/lib/terminals/widget.d.ts +43 -13
- package/lib/terminals/widget.js +33 -18
- package/lib/topBar/icons.d.ts +3 -8
- package/lib/topBar/icons.js +3 -8
- package/lib/topBar/index.d.ts +4 -11
- package/lib/topBar/index.js +10 -38
- package/lib/walkthrough/index.d.ts +4 -9
- package/lib/walkthrough/index.js +6 -20
- package/lib/walkthrough/panel.d.ts +40 -9
- package/lib/walkthrough/panel.js +4 -10
- package/package.json +2 -2
- package/src/about/icons.ts +0 -5
- package/src/about/index.tsx +6 -17
- package/src/agentSessions.ts +9 -29
- package/src/askAgent/editorSelection.ts +22 -29
- package/src/askAgent/icons.ts +2 -3
- package/src/askAgent/index.ts +54 -158
- package/src/askAgent/popup.tsx +23 -45
- package/src/askAgent/prompt.ts +6 -19
- package/src/askAgent/queue.ts +13 -24
- package/src/askAgent/queuePanel.tsx +21 -46
- package/src/askAgent/targetPicker.tsx +5 -15
- package/src/askAgent/tokens.ts +32 -46
- package/src/commandBar/index.ts +24 -39
- package/src/customPanel/index.ts +15 -0
- package/src/editorBreadcrumbs/index.ts +10 -6
- package/src/editorBreadcrumbs/widget.ts +23 -17
- package/src/editorIndent/index.ts +17 -23
- package/src/fileBrowser/commands.ts +57 -98
- package/src/fileBrowser/contents.ts +3 -0
- package/src/fileBrowser/dragAndDrop.ts +17 -7
- package/src/fileBrowser/fileBrowser.tsx +84 -223
- package/src/fileBrowser/gitStatus.ts +7 -17
- package/src/fileBrowser/gitignore.ts +4 -25
- package/src/fileBrowser/icons.ts +25 -80
- package/src/fileBrowser/index.ts +2 -4
- package/src/fileBrowser/widget.tsx +149 -50
- package/src/fileTypeIcons/index.ts +0 -10
- package/src/git/api.ts +10 -36
- package/src/git/askRequest.ts +6 -20
- package/src/git/commands.ts +70 -10
- package/src/git/diffModel.ts +25 -0
- package/src/git/diffSurface.tsx +71 -159
- package/src/git/diffWidget.tsx +104 -14
- package/src/git/imageDiff.tsx +45 -51
- package/src/git/index.ts +3 -8
- package/src/git/notebookDiff.tsx +211 -238
- package/src/git/tokens.ts +73 -31
- package/src/highlight/index.ts +10 -41
- package/src/index.ts +0 -9
- package/src/launcher/agents.ts +64 -95
- package/src/launcher/availability.ts +3 -9
- package/src/launcher/commands.ts +14 -51
- package/src/launcher/dashboard.tsx +49 -88
- package/src/launcher/editorRegistry.ts +21 -29
- package/src/launcher/editors.ts +39 -58
- package/src/launcher/icons.ts +5 -39
- package/src/launcher/index.ts +12 -55
- package/src/launcher/invocation.ts +7 -22
- package/src/launcher/registry.ts +9 -7
- package/src/launcher/tokens.ts +10 -22
- package/src/menuBar/index.ts +11 -28
- package/src/menus/index.ts +14 -30
- package/src/omnibox/files.ts +10 -14
- package/src/omnibox/index.ts +9 -27
- package/src/omnibox/model.ts +50 -38
- package/src/omnibox/recents.ts +17 -22
- package/src/omnibox/tokens.ts +5 -10
- package/src/omnibox/widget.tsx +14 -19
- package/src/searchReplace/index.ts +7 -27
- package/src/showOutput/index.ts +6 -22
- package/src/sidebar/index.ts +20 -12
- package/src/terminalNotifications/index.ts +42 -25
- package/src/terminals/agentTerminals.ts +25 -49
- package/src/terminals/detection.ts +4 -8
- package/src/terminals/index.ts +12 -101
- package/src/terminals/model.ts +130 -246
- package/src/terminals/tokens.ts +11 -22
- package/src/terminals/widget.tsx +48 -31
- package/src/topBar/icons.ts +3 -8
- package/src/topBar/index.ts +21 -44
- package/src/walkthrough/index.ts +6 -20
- package/src/walkthrough/panel.ts +40 -10
- package/style/about.css +2 -7
- package/style/askAgent.css +8 -40
- package/style/base.css +9 -45
- package/style/chrome.css +108 -308
- package/style/commandBar.css +4 -20
- package/style/customPanel.css +1 -4
- package/style/git.css +22 -184
- package/style/highlight.css +1 -3
- package/style/launcher.css +6 -70
- package/style/omnibox.css +2 -14
- package/style/showOutput.css +0 -6
- package/style/sidebar.css +29 -9
- package/style/tabs.css +5 -13
- package/style/terminals.css +6 -53
- package/style/topBar.css +2 -22
- package/style/walkthrough.css +0 -8
|
@@ -5,11 +5,9 @@ import { addIcon, closeIcon, collapseAllIcon, CommandToolbarButton, copyIcon, do
|
|
|
5
5
|
import { toCanonicalPath, toServerPath } from './contents';
|
|
6
6
|
import { FILE_BROWSER_ID } from './widget';
|
|
7
7
|
/**
|
|
8
|
-
* Command
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* via `IFileBrowserFactory.tracker` — our widget is not a `FileBrowser`, so
|
|
12
|
-
* those handlers would never see it.
|
|
8
|
+
* Command ids for the xtralab browser. Namespaced `xtralab:` rather than
|
|
9
|
+
* reusing the `filebrowser:` ids: the core handlers resolve their target via
|
|
10
|
+
* `IFileBrowserFactory.tracker`, which never sees this widget.
|
|
13
11
|
*/
|
|
14
12
|
export var CommandIDs;
|
|
15
13
|
(function (CommandIDs) {
|
|
@@ -29,18 +27,13 @@ export var CommandIDs;
|
|
|
29
27
|
CommandIDs.revealInFileTree = 'xtralab:reveal-in-file-tree';
|
|
30
28
|
})(CommandIDs || (CommandIDs = {}));
|
|
31
29
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* core's populator does not try to fill ours with items derived from the
|
|
35
|
-
* default file browser's selection.
|
|
30
|
+
* "Open With" submenu id. Distinct from the core `jp-contextmenu-open-with`
|
|
31
|
+
* so the core's populator does not fill ours from its own selection.
|
|
36
32
|
*/
|
|
37
33
|
const OPEN_WITH_SUBMENU_ID = 'jp-contextmenu-xtralab-open-with';
|
|
38
34
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* items match a selector — and fall back to the first item in the tree's
|
|
42
|
-
* selection if the command was invoked without an active contextmenu event
|
|
43
|
-
* (e.g. from the command palette).
|
|
35
|
+
* Path of the right-clicked item, from the contextmenu event's target;
|
|
36
|
+
* falls back to the tree selection when invoked without one (the palette).
|
|
44
37
|
*/
|
|
45
38
|
function getTargetPath(app, browser) {
|
|
46
39
|
const node = app.contextMenuHitTest(n => n.dataset !== undefined && n.dataset.type === 'item');
|
|
@@ -50,25 +43,15 @@ function getTargetPath(app, browser) {
|
|
|
50
43
|
}
|
|
51
44
|
return browser.selectedPaths[0];
|
|
52
45
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Resolve the kind of the item that was right-clicked, based on the data
|
|
55
|
-
* attributes emitted by `@pierre/trees` rows. Returns `undefined` if no
|
|
56
|
-
* contextmenu event is active or the target is not a tree item.
|
|
57
|
-
*/
|
|
58
46
|
function getTargetKind(app) {
|
|
59
47
|
const node = app.contextMenuHitTest(n => n.dataset !== undefined && n.dataset.type === 'item');
|
|
60
48
|
const kind = node === null || node === void 0 ? void 0 : node.dataset.itemType;
|
|
61
49
|
return kind === 'file' || kind === 'folder' ? kind : undefined;
|
|
62
50
|
}
|
|
63
51
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* "Open" on any file in a multi-selection opens them all. If the
|
|
68
|
-
* right-clicked row is *not* in the selection, only that row is opened.
|
|
69
|
-
*
|
|
70
|
-
* Folders are always filtered out: there is no "current directory" in
|
|
71
|
-
* this tree, so opening a folder via "Open" is a no-op.
|
|
52
|
+
* Canonical paths "Open" acts on: the whole selection when the right-clicked
|
|
53
|
+
* row is part of it (matching the default browser), else just that row.
|
|
54
|
+
* Folders are filtered out — this tree has no "current directory".
|
|
72
55
|
*/
|
|
73
56
|
function getOpenPaths(app, browser) {
|
|
74
57
|
const node = app.contextMenuHitTest(n => n.dataset !== undefined && n.dataset.type === 'item');
|
|
@@ -83,18 +66,13 @@ function getOpenPaths(app, browser) {
|
|
|
83
66
|
}
|
|
84
67
|
return candidates.filter(path => !path.endsWith('/'));
|
|
85
68
|
}
|
|
86
|
-
/**
|
|
87
|
-
* True iff there is an actionable target for a command on the right-click.
|
|
88
|
-
*/
|
|
89
69
|
function hasTarget(app, browser) {
|
|
90
70
|
return getTargetPath(app, browser) !== undefined;
|
|
91
71
|
}
|
|
92
72
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* when the tree has no selection — that matches the contents API's
|
|
97
|
-
* convention for "the root directory".
|
|
73
|
+
* Working directory for create actions: a selected folder is its own cwd, a
|
|
74
|
+
* file falls back to its parent; empty string (the contents-API root) when
|
|
75
|
+
* nothing is selected.
|
|
98
76
|
*/
|
|
99
77
|
function getWorkingDirectory(browser) {
|
|
100
78
|
const first = browser.selectedPaths[0];
|
|
@@ -108,14 +86,10 @@ function getWorkingDirectory(browser) {
|
|
|
108
86
|
return PathExt.dirname(serverPath);
|
|
109
87
|
}
|
|
110
88
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* Valid only during a context-menu invocation: `contextMenuHitTest` reads the
|
|
117
|
-
* last context-menu event, which is not cleared when the menu closes, so
|
|
118
|
-
* {@link documentPathToReveal} gates this to avoid resolving a stale tab.
|
|
89
|
+
* Main-area widget whose tab is the target of the current context-menu
|
|
90
|
+
* event, or `null`. `contextMenuHitTest` reads the last context-menu event,
|
|
91
|
+
* which is not cleared when the menu closes, so callers must gate against
|
|
92
|
+
* resolving a stale tab.
|
|
119
93
|
*/
|
|
120
94
|
function contextMenuTabWidget(app) {
|
|
121
95
|
const node = app.contextMenuHitTest(n => n.dataset !== undefined && n.dataset.type === 'document-title');
|
|
@@ -131,10 +105,9 @@ function contextMenuTabWidget(app) {
|
|
|
131
105
|
return null;
|
|
132
106
|
}
|
|
133
107
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* `path` is already canonical. Returns `undefined` when nothing resolves.
|
|
108
|
+
* Canonical path of the document to reveal: the right-clicked tab when
|
|
109
|
+
* `fromContextMenu` is true (the file-tab menu), else the active main-area
|
|
110
|
+
* widget (the palette).
|
|
138
111
|
*/
|
|
139
112
|
function documentPathToReveal(app, docManager, fromContextMenu) {
|
|
140
113
|
var _a, _b, _c;
|
|
@@ -146,14 +119,10 @@ function documentPathToReveal(app, docManager, fromContextMenu) {
|
|
|
146
119
|
return path.length > 0 ? path : undefined;
|
|
147
120
|
}
|
|
148
121
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* `@jupyterlab/filebrowser-extension:open-with` pattern: the schema declares
|
|
152
|
-
* an empty submenu by id, and we look it up on the open context menu and
|
|
153
|
-
* fill it before the user can hover.
|
|
154
|
-
*
|
|
122
|
+
* Build the populator that fills the "Open With" submenu on every
|
|
123
|
+
* context-menu open, mirroring `filebrowser-extension:open-with`.
|
|
155
124
|
* `preferredWidgetFactories(path)` is path-only, so the populator stays
|
|
156
|
-
* synchronous and the submenu is ready before the user can hover
|
|
125
|
+
* synchronous and the submenu is ready before the user can hover.
|
|
157
126
|
*/
|
|
158
127
|
function makeOpenWithUpdater(app, browser) {
|
|
159
128
|
let items = [];
|
|
@@ -182,13 +151,9 @@ function makeOpenWithUpdater(app, browser) {
|
|
|
182
151
|
};
|
|
183
152
|
}
|
|
184
153
|
/**
|
|
185
|
-
* Register
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* @returns A function that detaches the menu items and signal listener.
|
|
190
|
-
* The commands themselves are owned by the registry for the lifetime of
|
|
191
|
-
* the plugin.
|
|
154
|
+
* Register the xtralab commands, context-menu wiring, and the dynamic
|
|
155
|
+
* "Open With" populator. Returns a detach function; the commands themselves
|
|
156
|
+
* stay owned by the registry.
|
|
192
157
|
*/
|
|
193
158
|
export function registerCommands(opts) {
|
|
194
159
|
var _a;
|
|
@@ -403,22 +368,15 @@ export function registerCommands(opts) {
|
|
|
403
368
|
browser.toggleFileFilter();
|
|
404
369
|
}
|
|
405
370
|
});
|
|
406
|
-
//
|
|
407
|
-
//
|
|
408
|
-
// the tree focused opens a search session.
|
|
371
|
+
// The filter can also auto-show when typing with the tree focused, so
|
|
372
|
+
// track visibility changes rather than the command's own executions.
|
|
409
373
|
const onFilterVisibleChanged = () => {
|
|
410
374
|
commands.notifyCommandChanged(CommandIDs.toggleFileFilter);
|
|
411
375
|
};
|
|
412
376
|
browser.fileFilterVisibleChanged.connect(onFilterVisibleChanged);
|
|
413
|
-
// Public reveal seam
|
|
414
|
-
//
|
|
415
|
-
//
|
|
416
|
-
// of the contract: the tree is hidden behind a tab and a reveal that
|
|
417
|
-
// does not surface the panel would silently no-op from the user's
|
|
418
|
-
// point of view. An empty path is the "workspace root" gesture —
|
|
419
|
-
// there is no tree row for the root itself, so the browser is asked
|
|
420
|
-
// to scroll back to the top and clear its selection instead.
|
|
421
|
-
// The tree is movable, so surface whichever sidebar widget holds it.
|
|
377
|
+
// Public reveal seam for other plugins; an empty path is the workspace-root
|
|
378
|
+
// gesture (the root has no tree row of its own). The tree is movable, so
|
|
379
|
+
// surface whichever sidebar widget holds it.
|
|
422
380
|
const activateTreeHost = () => {
|
|
423
381
|
for (const area of ['left', 'right']) {
|
|
424
382
|
for (const widget of app.shell.widgets(area)) {
|
|
@@ -444,8 +402,6 @@ export function registerCommands(opts) {
|
|
|
444
402
|
}
|
|
445
403
|
}
|
|
446
404
|
});
|
|
447
|
-
// Reveal the resolved document in the tree browser via the reveal-path
|
|
448
|
-
// command, which surfaces the sidebar and scrolls to the target.
|
|
449
405
|
commands.addCommand(CommandIDs.revealInFileTree, {
|
|
450
406
|
label: trans.__('Show in File Tree'),
|
|
451
407
|
caption: trans.__('Show this file in the xtralab file browser'),
|
|
@@ -480,41 +436,29 @@ export function registerCommands(opts) {
|
|
|
480
436
|
commands.addCommand(CommandIDs.newLauncher, {
|
|
481
437
|
label: trans.__('New Launcher'),
|
|
482
438
|
caption: trans.__('Open a new launcher'),
|
|
483
|
-
//
|
|
484
|
-
//
|
|
485
|
-
// styling expects the raw `jp-icon3` paths from `addIcon` so it can
|
|
486
|
-
// recolor them against the brand background.
|
|
439
|
+
// Raw `addIcon`, no `menuItem` bindprops: the launcher-extension's blue
|
|
440
|
+
// toolbar-button styling recolors the raw `jp-icon3` paths.
|
|
487
441
|
icon: addIcon,
|
|
488
442
|
execute: () => {
|
|
489
443
|
const cwd = getWorkingDirectory(browser);
|
|
490
444
|
return commands.execute('launcher:create', { cwd });
|
|
491
445
|
}
|
|
492
446
|
});
|
|
493
|
-
// Re-evaluate enabled/visible state when the user changes the tree
|
|
494
|
-
// selection, in case a command's predicate depends on the selection.
|
|
495
447
|
browser.selectionChanged.connect(() => {
|
|
496
448
|
for (const id of Object.values(CommandIDs)) {
|
|
497
449
|
commands.notifyCommandChanged(id);
|
|
498
450
|
}
|
|
499
451
|
});
|
|
500
|
-
// This command's enabled state tracks the active widget, not the tree
|
|
501
|
-
// selection, so re-evaluate it on current-widget changes. `currentChanged`
|
|
502
|
-
// is optional on the shell interface.
|
|
503
452
|
const onCurrentChanged = () => {
|
|
504
453
|
commands.notifyCommandChanged(CommandIDs.revealInFileTree);
|
|
505
454
|
};
|
|
506
455
|
(_a = app.shell.currentChanged) === null || _a === void 0 ? void 0 : _a.connect(onCurrentChanged);
|
|
507
|
-
// Also surface it in the palette (acts on the active editor); the file-tab
|
|
508
|
-
// context-menu entry is declared in `schema/plugin.json`.
|
|
509
456
|
const paletteItem = palette === null || palette === void 0 ? void 0 : palette.addItem({
|
|
510
457
|
command: CommandIDs.revealInFileTree,
|
|
511
458
|
category: trans.__('File Browser')
|
|
512
459
|
});
|
|
513
|
-
//
|
|
514
|
-
//
|
|
515
|
-
// schema also declares an empty submenu placeholder with id
|
|
516
|
-
// `OPEN_WITH_SUBMENU_ID`; we fill it on every open from the document
|
|
517
|
-
// factories that can open the right-clicked file.
|
|
460
|
+
// Static context-menu items live in `schema/plugin.json` so users can
|
|
461
|
+
// override them; the schema declares the empty "Open With" placeholder.
|
|
518
462
|
const updateOpenWithMenu = makeOpenWithUpdater(app, browser);
|
|
519
463
|
app.contextMenu.opened.connect(updateOpenWithMenu);
|
|
520
464
|
return () => {
|
|
@@ -526,9 +470,8 @@ export function registerCommands(opts) {
|
|
|
526
470
|
};
|
|
527
471
|
}
|
|
528
472
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
* than commands.
|
|
473
|
+
* Toolbar item names, distinct from {@link CommandIDs}: the toolbar API
|
|
474
|
+
* uses opaque names rather than commands.
|
|
532
475
|
*/
|
|
533
476
|
export var ToolbarNames;
|
|
534
477
|
(function (ToolbarNames) {
|
|
@@ -539,10 +482,8 @@ export var ToolbarNames;
|
|
|
539
482
|
ToolbarNames.toggleFileFilter = 'toggle-file-filter';
|
|
540
483
|
})(ToolbarNames || (ToolbarNames = {}));
|
|
541
484
|
/**
|
|
542
|
-
* Populate the
|
|
543
|
-
*
|
|
544
|
-
* button, a refresh button, a collapse-all button, and the file filter
|
|
545
|
-
* toggle.
|
|
485
|
+
* Populate the toolbar with the buttons that mirror the default JupyterLab
|
|
486
|
+
* file browser.
|
|
546
487
|
*/
|
|
547
488
|
export function populateToolbar(opts) {
|
|
548
489
|
const { app, browser } = opts;
|
|
@@ -26,6 +26,9 @@ export declare function canonicalBasename(canonicalPath: string): string;
|
|
|
26
26
|
* paths so the value can be sent to the Jupyter contents API.
|
|
27
27
|
*/
|
|
28
28
|
export declare function toServerPath(canonicalPath: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* The immediate children of a directory, as canonical `@pierre/trees` paths.
|
|
31
|
+
*/
|
|
29
32
|
interface IListedDirectory {
|
|
30
33
|
/**
|
|
31
34
|
* Canonical paths for every immediate child of the requested directory.
|
|
@@ -4,7 +4,13 @@ import type { FileTree, FileTreeDragAndDropConfig, FileTreeDropContext, FileTree
|
|
|
4
4
|
* One tree-model move a drop performs, as canonical paths.
|
|
5
5
|
*/
|
|
6
6
|
export interface IDropMove {
|
|
7
|
+
/**
|
|
8
|
+
* The canonical path of the dragged item.
|
|
9
|
+
*/
|
|
7
10
|
from: string;
|
|
11
|
+
/**
|
|
12
|
+
* The canonical destination path: its basename under the target directory.
|
|
13
|
+
*/
|
|
8
14
|
to: string;
|
|
9
15
|
}
|
|
10
16
|
/**
|
|
@@ -46,8 +52,17 @@ export declare function computeRootDropMoves(paths: readonly string[]): IDropMov
|
|
|
46
52
|
* highlight for all-no-op drops, which the library would accept.
|
|
47
53
|
*/
|
|
48
54
|
export declare function createTreeDragAndDropConfig(handlerRef: React.RefObject<ITreeDropHandler | null>): FileTreeDragAndDropConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Options for {@link useRootDropZone}.
|
|
57
|
+
*/
|
|
49
58
|
interface IRootDropZoneOptions {
|
|
59
|
+
/**
|
|
60
|
+
* The tree model, queried for the selection at drag start.
|
|
61
|
+
*/
|
|
50
62
|
model: FileTree;
|
|
63
|
+
/**
|
|
64
|
+
* The drop handler ref, filled by the contents-sync effect.
|
|
65
|
+
*/
|
|
51
66
|
handlerRef: React.RefObject<ITreeDropHandler | null>;
|
|
52
67
|
/**
|
|
53
68
|
* The light-DOM wrapper around the tree host; composed drag events
|
|
@@ -57,10 +72,8 @@ interface IRootDropZoneOptions {
|
|
|
57
72
|
}
|
|
58
73
|
/**
|
|
59
74
|
* Accept drops on the empty space below the last row as moves to the
|
|
60
|
-
* workspace root — the tree resolves a drop target only while the
|
|
61
|
-
*
|
|
62
|
-
* records the dragged paths; a drop whose composed path contains no
|
|
63
|
-
* row hands them over as a root move.
|
|
75
|
+
* workspace root — the tree resolves a drop target only while the cursor
|
|
76
|
+
* is over a row and silently discards such drops.
|
|
64
77
|
*/
|
|
65
78
|
export declare function useRootDropZone(options: IRootDropZoneOptions): void;
|
|
66
79
|
export {};
|
|
@@ -12,9 +12,6 @@ export function computeDropMoves(context) {
|
|
|
12
12
|
.filter(path => parentOf(path) !== dir)
|
|
13
13
|
.map(path => ({ from: path, to: `${dir}${canonicalBasename(path)}` }));
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* The drop target the tree reports for a move to the workspace root.
|
|
17
|
-
*/
|
|
18
15
|
const ROOT_DROP_TARGET = {
|
|
19
16
|
directoryPath: null,
|
|
20
17
|
flattenedSegmentPath: null,
|
|
@@ -48,10 +45,8 @@ export function createTreeDragAndDropConfig(handlerRef) {
|
|
|
48
45
|
}
|
|
49
46
|
/**
|
|
50
47
|
* Accept drops on the empty space below the last row as moves to the
|
|
51
|
-
* workspace root — the tree resolves a drop target only while the
|
|
52
|
-
*
|
|
53
|
-
* records the dragged paths; a drop whose composed path contains no
|
|
54
|
-
* row hands them over as a root move.
|
|
48
|
+
* workspace root — the tree resolves a drop target only while the cursor
|
|
49
|
+
* is over a row and silently discards such drops.
|
|
55
50
|
*/
|
|
56
51
|
export function useRootDropZone(options) {
|
|
57
52
|
const { model, handlerRef, wrapperRef } = options;
|
|
@@ -3,25 +3,35 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
|
3
3
|
import { Contents } from '@jupyterlab/services';
|
|
4
4
|
import { ITranslator } from '@jupyterlab/translation';
|
|
5
5
|
import type { XtralabFileBrowser } from './widget';
|
|
6
|
+
/**
|
|
7
|
+
* Props for {@link FileBrowserComponent}.
|
|
8
|
+
*/
|
|
6
9
|
interface IFileBrowserProps {
|
|
10
|
+
/**
|
|
11
|
+
* The Jupyter contents manager backing the tree.
|
|
12
|
+
*/
|
|
7
13
|
contentsManager: Contents.IManager;
|
|
14
|
+
/**
|
|
15
|
+
* The document manager used to rename files on drag-and-drop moves.
|
|
16
|
+
*/
|
|
8
17
|
docManager: IDocumentManager;
|
|
18
|
+
/**
|
|
19
|
+
* Called with the server path of an activated file.
|
|
20
|
+
*/
|
|
9
21
|
onOpenFile?: (serverPath: string) => void;
|
|
22
|
+
/**
|
|
23
|
+
* The application translator; defaults to `nullTranslator`.
|
|
24
|
+
*/
|
|
10
25
|
translator?: ITranslator;
|
|
11
26
|
/**
|
|
12
|
-
* The host widget
|
|
13
|
-
* commands can react to what the user has selected.
|
|
27
|
+
* The host widget; selection changes are pushed up for command handlers.
|
|
14
28
|
*/
|
|
15
29
|
widget?: XtralabFileBrowser;
|
|
16
30
|
}
|
|
17
31
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* the tree is populated lazily: the root is fetched on mount, and each
|
|
22
|
-
* directory is fetched the first time the user expands it. Expansion is
|
|
23
|
-
* detected by subscribing to the model and diffing against an in-memory load
|
|
24
|
-
* state map.
|
|
32
|
+
* A `@pierre/trees` file tree backed by the Jupyter contents API. The API
|
|
33
|
+
* returns one directory level per request, so directories load lazily on
|
|
34
|
+
* first expand, detected by diffing the model against a load-state map.
|
|
25
35
|
*/
|
|
26
36
|
export declare function FileBrowserComponent(props: IFileBrowserProps): React.ReactElement;
|
|
27
37
|
export {};
|