@theia/secondary-window 1.77.0-next.88 → 1.77.0-next.94
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/browser/secondary-window-frontend-contribution.d.ts +22 -2
- package/lib/browser/secondary-window-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/secondary-window-frontend-contribution.js +112 -5
- package/lib/browser/secondary-window-frontend-contribution.js.map +1 -1
- package/lib/browser/secondary-window-frontend-module.d.ts.map +1 -1
- package/lib/browser/secondary-window-frontend-module.js +2 -0
- package/lib/browser/secondary-window-frontend-module.js.map +1 -1
- package/package.json +3 -3
- package/src/browser/secondary-window-frontend-contribution.ts +115 -8
- package/src/browser/secondary-window-frontend-module.ts +2 -0
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { CommandRegistry, CommandContribution, Command } from '@theia/core/lib/common/command';
|
|
2
|
+
import { MenuContribution, MenuModelRegistry, MenuPath } from '@theia/core/lib/common/menu';
|
|
3
|
+
import { Widget } from '@theia/core/lib/browser/widgets';
|
|
4
|
+
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
|
5
|
+
import { NativeTabDragService, TabDropOutsideWindowsEvent } from '@theia/core/lib/browser/shell/native-tab-drag-service';
|
|
2
6
|
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
3
7
|
import { SecondaryWindowHandler } from '@theia/core/lib/browser/secondary-window-handler';
|
|
4
8
|
export declare const EXTRACT_WIDGET: Command;
|
|
5
|
-
|
|
6
|
-
export declare
|
|
9
|
+
export declare const RESTORE_WIDGET: Command;
|
|
10
|
+
export declare const RESTORE_ALL_WIDGETS: Command;
|
|
11
|
+
export declare const SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW: MenuPath;
|
|
12
|
+
/**
|
|
13
|
+
* Contributes the commands to move widgets to secondary windows and back, and registers them in the toolbar and in the context menu of tabs.
|
|
14
|
+
* In addition, extracts widgets whose tab is dragged out of the application's windows.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SecondaryWindowContribution implements CommandContribution, MenuContribution, TabBarToolbarContribution {
|
|
7
17
|
protected readonly secondaryWindowHandler: SecondaryWindowHandler;
|
|
18
|
+
protected readonly nativeTabDragService: NativeTabDragService;
|
|
19
|
+
protected readonly shell: ApplicationShell;
|
|
20
|
+
protected init(): void;
|
|
21
|
+
protected onDidDropTabOutsideWindows({ title, screenX, screenY }: TabDropOutsideWindowsEvent): void;
|
|
8
22
|
registerCommands(commands: CommandRegistry): void;
|
|
23
|
+
registerMenus(menus: MenuModelRegistry): void;
|
|
9
24
|
registerToolbarItems(registry: TabBarToolbarRegistry): void;
|
|
25
|
+
/**
|
|
26
|
+
* @returns the widget a command is executed for: the widget passed by the tab bar toolbar, the widget of the tab
|
|
27
|
+
* whose context menu has been opened, or the current widget if no argument is passed, e.g. from the command palette
|
|
28
|
+
*/
|
|
29
|
+
protected getTargetWidget(arg: unknown): Widget | undefined;
|
|
10
30
|
}
|
|
11
31
|
//# sourceMappingURL=secondary-window-frontend-contribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondary-window-frontend-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"secondary-window-frontend-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAA8B,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iDAAiD,CAAC;AAEnF,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAC;AACzH,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACjH,OAAO,EAA4D,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAEpJ,eAAO,MAAM,cAAc,SAGgB,CAAC;AAE5C,eAAO,MAAM,cAAc,SAGgB,CAAC;AAE5C,eAAO,MAAM,mBAAmB,SAGgB,CAAC;AAEjD,eAAO,MAAM,qCAAqC,EAAE,QAA8D,CAAC;AAEnH;;;GAGG;AACH,qBACa,2BAA4B,YAAW,mBAAmB,EAAE,gBAAgB,EAAE,yBAAyB;IAGhH,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAG9D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IAG3C,SAAS,CAAC,IAAI,IAAI,IAAI;IAItB,SAAS,CAAC,0BAA0B,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,0BAA0B,GAAG,IAAI;IAWnG,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAsCjD,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAe7C,oBAAoB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IAc3D;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;CAU9D"}
|
|
@@ -15,23 +15,96 @@
|
|
|
15
15
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.SecondaryWindowContribution = exports.EXTRACT_WIDGET = void 0;
|
|
18
|
+
exports.SecondaryWindowContribution = exports.SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW = exports.RESTORE_ALL_WIDGETS = exports.RESTORE_WIDGET = exports.EXTRACT_WIDGET = void 0;
|
|
19
19
|
const tslib_1 = require("tslib");
|
|
20
20
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
21
|
const command_1 = require("@theia/core/lib/common/command");
|
|
22
22
|
const widgets_1 = require("@theia/core/lib/browser/widgets");
|
|
23
|
+
const application_shell_1 = require("@theia/core/lib/browser/shell/application-shell");
|
|
24
|
+
const tab_bars_1 = require("@theia/core/lib/browser/shell/tab-bars");
|
|
25
|
+
const native_tab_drag_service_1 = require("@theia/core/lib/browser/shell/native-tab-drag-service");
|
|
23
26
|
const secondary_window_handler_1 = require("@theia/core/lib/browser/secondary-window-handler");
|
|
24
27
|
exports.EXTRACT_WIDGET = command_1.Command.toLocalizedCommand({
|
|
25
28
|
id: 'extract-widget',
|
|
26
29
|
label: 'Move View to Secondary Window'
|
|
27
30
|
}, 'theia/secondary-window/extract-widget');
|
|
28
|
-
|
|
31
|
+
exports.RESTORE_WIDGET = command_1.Command.toLocalizedCommand({
|
|
32
|
+
id: 'restore-widget',
|
|
33
|
+
label: 'Move View to Main Window'
|
|
34
|
+
}, 'theia/secondary-window/restore-widget');
|
|
35
|
+
exports.RESTORE_ALL_WIDGETS = command_1.Command.toLocalizedCommand({
|
|
36
|
+
id: 'restore-all-widgets',
|
|
37
|
+
label: 'Move All Views to Main Window'
|
|
38
|
+
}, 'theia/secondary-window/restore-all-widgets');
|
|
39
|
+
exports.SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW = [...tab_bars_1.SHELL_TABBAR_CONTEXT_MENU, '6_secondaryWindow'];
|
|
40
|
+
/**
|
|
41
|
+
* Contributes the commands to move widgets to secondary windows and back, and registers them in the toolbar and in the context menu of tabs.
|
|
42
|
+
* In addition, extracts widgets whose tab is dragged out of the application's windows.
|
|
43
|
+
*/
|
|
29
44
|
let SecondaryWindowContribution = class SecondaryWindowContribution {
|
|
45
|
+
init() {
|
|
46
|
+
this.nativeTabDragService.onDidDropTabOutsideWindows(event => this.onDidDropTabOutsideWindows(event));
|
|
47
|
+
}
|
|
48
|
+
onDidDropTabOutsideWindows({ title, screenX, screenY }) {
|
|
49
|
+
const widget = title.owner;
|
|
50
|
+
const secondaryWindow = (0, secondary_window_handler_1.extractSecondaryWindow)(widget);
|
|
51
|
+
if (secondaryWindow && (0, secondary_window_handler_1.getAllWidgetsFromSecondaryWindow)(secondaryWindow)?.length === 1) {
|
|
52
|
+
// the widget is the only one in its secondary window, so move the window instead of opening a new one
|
|
53
|
+
secondaryWindow.moveTo(screenX, screenY);
|
|
54
|
+
}
|
|
55
|
+
else if (widgets_1.ExtractableWidget.is(widget)) {
|
|
56
|
+
this.secondaryWindowHandler.moveWidgetToSecondaryWindow(widget, { position: { x: screenX, y: screenY } });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
30
59
|
registerCommands(commands) {
|
|
60
|
+
const canExtract = (arg) => {
|
|
61
|
+
const widget = this.getTargetWidget(arg);
|
|
62
|
+
return widgets_1.ExtractableWidget.is(widget) && widget.secondaryWindow === undefined;
|
|
63
|
+
};
|
|
31
64
|
commands.registerCommand(exports.EXTRACT_WIDGET, {
|
|
32
|
-
execute: async (
|
|
33
|
-
|
|
34
|
-
|
|
65
|
+
execute: async (arg) => {
|
|
66
|
+
const widget = this.getTargetWidget(arg);
|
|
67
|
+
if (widgets_1.ExtractableWidget.is(widget)) {
|
|
68
|
+
this.secondaryWindowHandler.moveWidgetToSecondaryWindow(widget);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
isVisible: canExtract,
|
|
72
|
+
isEnabled: canExtract,
|
|
73
|
+
});
|
|
74
|
+
const isInSecondaryWindow = (arg) => (0, secondary_window_handler_1.extractSecondaryWindow)(this.getTargetWidget(arg)) !== undefined;
|
|
75
|
+
commands.registerCommand(exports.RESTORE_WIDGET, {
|
|
76
|
+
execute: async (arg) => {
|
|
77
|
+
const widget = this.getTargetWidget(arg);
|
|
78
|
+
if (widget) {
|
|
79
|
+
await this.secondaryWindowHandler.moveWidgetToMainWindow(widget);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
isVisible: isInSecondaryWindow,
|
|
83
|
+
isEnabled: isInSecondaryWindow,
|
|
84
|
+
});
|
|
85
|
+
commands.registerCommand(exports.RESTORE_ALL_WIDGETS, {
|
|
86
|
+
execute: async (arg) => {
|
|
87
|
+
const secondaryWindow = (0, secondary_window_handler_1.extractSecondaryWindow)(this.getTargetWidget(arg));
|
|
88
|
+
if (secondaryWindow) {
|
|
89
|
+
await this.secondaryWindowHandler.moveAllWidgetsToMainWindow(secondaryWindow);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
isVisible: isInSecondaryWindow,
|
|
93
|
+
isEnabled: isInSecondaryWindow,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
registerMenus(menus) {
|
|
97
|
+
menus.registerMenuAction(exports.SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW, {
|
|
98
|
+
commandId: exports.EXTRACT_WIDGET.id,
|
|
99
|
+
order: 'a'
|
|
100
|
+
});
|
|
101
|
+
menus.registerMenuAction(exports.SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW, {
|
|
102
|
+
commandId: exports.RESTORE_WIDGET.id,
|
|
103
|
+
order: 'b'
|
|
104
|
+
});
|
|
105
|
+
menus.registerMenuAction(exports.SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW, {
|
|
106
|
+
commandId: exports.RESTORE_ALL_WIDGETS.id,
|
|
107
|
+
order: 'c'
|
|
35
108
|
});
|
|
36
109
|
}
|
|
37
110
|
registerToolbarItems(registry) {
|
|
@@ -40,6 +113,26 @@ let SecondaryWindowContribution = class SecondaryWindowContribution {
|
|
|
40
113
|
command: exports.EXTRACT_WIDGET.id,
|
|
41
114
|
icon: (0, widgets_1.codicon)('window'),
|
|
42
115
|
});
|
|
116
|
+
registry.registerItem({
|
|
117
|
+
id: exports.RESTORE_WIDGET.id,
|
|
118
|
+
command: exports.RESTORE_WIDGET.id,
|
|
119
|
+
// TODO use `open-in-window` once the codicon font bundled with Monaco provides it, see #17789
|
|
120
|
+
icon: (0, widgets_1.codicon)('screen-normal'),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @returns the widget a command is executed for: the widget passed by the tab bar toolbar, the widget of the tab
|
|
125
|
+
* whose context menu has been opened, or the current widget if no argument is passed, e.g. from the command palette
|
|
126
|
+
*/
|
|
127
|
+
getTargetWidget(arg) {
|
|
128
|
+
if (arg instanceof widgets_1.Widget) {
|
|
129
|
+
return arg;
|
|
130
|
+
}
|
|
131
|
+
// not using `instanceof Event`, the event may come from a secondary window, i.e. from another JavaScript realm
|
|
132
|
+
if (arg?.target) {
|
|
133
|
+
return this.shell.findTargetedWidget(arg);
|
|
134
|
+
}
|
|
135
|
+
return arg === undefined ? this.shell.currentWidget : undefined;
|
|
43
136
|
}
|
|
44
137
|
};
|
|
45
138
|
exports.SecondaryWindowContribution = SecondaryWindowContribution;
|
|
@@ -47,6 +140,20 @@ tslib_1.__decorate([
|
|
|
47
140
|
(0, inversify_1.inject)(secondary_window_handler_1.SecondaryWindowHandler),
|
|
48
141
|
tslib_1.__metadata("design:type", secondary_window_handler_1.SecondaryWindowHandler)
|
|
49
142
|
], SecondaryWindowContribution.prototype, "secondaryWindowHandler", void 0);
|
|
143
|
+
tslib_1.__decorate([
|
|
144
|
+
(0, inversify_1.inject)(native_tab_drag_service_1.NativeTabDragService),
|
|
145
|
+
tslib_1.__metadata("design:type", native_tab_drag_service_1.NativeTabDragService)
|
|
146
|
+
], SecondaryWindowContribution.prototype, "nativeTabDragService", void 0);
|
|
147
|
+
tslib_1.__decorate([
|
|
148
|
+
(0, inversify_1.inject)(application_shell_1.ApplicationShell),
|
|
149
|
+
tslib_1.__metadata("design:type", application_shell_1.ApplicationShell)
|
|
150
|
+
], SecondaryWindowContribution.prototype, "shell", void 0);
|
|
151
|
+
tslib_1.__decorate([
|
|
152
|
+
(0, inversify_1.postConstruct)(),
|
|
153
|
+
tslib_1.__metadata("design:type", Function),
|
|
154
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
155
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
156
|
+
], SecondaryWindowContribution.prototype, "init", null);
|
|
50
157
|
exports.SecondaryWindowContribution = SecondaryWindowContribution = tslib_1.__decorate([
|
|
51
158
|
(0, inversify_1.injectable)()
|
|
52
159
|
], SecondaryWindowContribution);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondary-window-frontend-contribution.js","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,kFAAkF;AAClF,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,
|
|
1
|
+
{"version":3,"file":"secondary-window-frontend-contribution.js","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,kFAAkF;AAClF,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAiF;AACjF,4DAA+F;AAE/F,6DAAqF;AACrF,uFAAmF;AACnF,qEAAmF;AACnF,mGAAyH;AAEzH,+FAAoJ;AAEvI,QAAA,cAAc,GAAG,iBAAO,CAAC,kBAAkB,CAAC;IACrD,EAAE,EAAE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IAAK,GAAyB,EAAE,MAAM,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAY,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IACpE,CAAC;CACJ,CAAA;AA5GY,kEAA2B;AAGjB;IADlB,IAAA,kBAAM,EAAC,iDAAsB,CAAC;sCACY,iDAAsB;2EAAC;AAG/C;IADlB,IAAA,kBAAM,EAAC,8CAAoB,CAAC;sCACY,8CAAoB;yEAAC;AAG3C;IADlB,IAAA,kBAAM,EAAC,oCAAgB,CAAC;sCACC,oCAAgB;0DAAC;AAGjC;IADT,IAAA,yBAAa,GAAE;;;;uDAGf;sCAdQ,2BAA2B;IADvC,IAAA,sBAAU,GAAE;GACA,2BAA2B,CA4GvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondary-window-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;
|
|
1
|
+
{"version":3,"file":"secondary-window-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAM/D,wBAKG"}
|
|
@@ -18,10 +18,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
19
19
|
const secondary_window_frontend_contribution_1 = require("./secondary-window-frontend-contribution");
|
|
20
20
|
const command_1 = require("@theia/core/lib/common/command");
|
|
21
|
+
const menu_1 = require("@theia/core/lib/common/menu");
|
|
21
22
|
const tab_bar_toolbar_1 = require("@theia/core/lib/browser/shell/tab-bar-toolbar");
|
|
22
23
|
exports.default = new inversify_1.ContainerModule(bind => {
|
|
23
24
|
bind(secondary_window_frontend_contribution_1.SecondaryWindowContribution).toSelf().inSingletonScope();
|
|
24
25
|
bind(command_1.CommandContribution).toService(secondary_window_frontend_contribution_1.SecondaryWindowContribution);
|
|
26
|
+
bind(menu_1.MenuContribution).toService(secondary_window_frontend_contribution_1.SecondaryWindowContribution);
|
|
25
27
|
bind(tab_bar_toolbar_1.TabBarToolbarContribution).toService(secondary_window_frontend_contribution_1.SecondaryWindowContribution);
|
|
26
28
|
});
|
|
27
29
|
//# sourceMappingURL=secondary-window-frontend-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondary-window-frontend-module.js","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,kFAAkF;AAClF,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,qGAAuF;AACvF,4DAAqE;AACrE,mFAA0F;AAE1F,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,oEAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC9D,IAAI,CAAC,6BAAmB,CAAC,CAAC,SAAS,CAAC,oEAA2B,CAAC,CAAC;IACjE,IAAI,CAAC,2CAAyB,CAAC,CAAC,SAAS,CAAC,oEAA2B,CAAC,CAAC;AAC3E,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"secondary-window-frontend-module.js","sourceRoot":"","sources":["../../src/browser/secondary-window-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,kFAAkF;AAClF,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,qGAAuF;AACvF,4DAAqE;AACrE,sDAA+D;AAC/D,mFAA0F;AAE1F,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,oEAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC9D,IAAI,CAAC,6BAAmB,CAAC,CAAC,SAAS,CAAC,oEAA2B,CAAC,CAAC;IACjE,IAAI,CAAC,uBAAgB,CAAC,CAAC,SAAS,CAAC,oEAA2B,CAAC,CAAC;IAC9D,IAAI,CAAC,2CAAyB,CAAC,CAAC,SAAS,CAAC,oEAA2B,CAAC,CAAC;AAC3E,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/secondary-window",
|
|
3
|
-
"version": "1.77.0-next.
|
|
3
|
+
"version": "1.77.0-next.94+3490801c0",
|
|
4
4
|
"description": "Theia - Secondary Window Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.77.0-next.
|
|
6
|
+
"@theia/core": "1.77.0-next.94+3490801c0",
|
|
7
7
|
"tslib": "^2.8.1"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@theia/ext-scripts": "1.76.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "3490801c093594a70b74434088bc82705389bb31"
|
|
45
45
|
}
|
|
@@ -14,29 +14,115 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
17
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
18
18
|
import { CommandRegistry, CommandContribution, Command } from '@theia/core/lib/common/command';
|
|
19
|
-
import {
|
|
19
|
+
import { MenuContribution, MenuModelRegistry, MenuPath } from '@theia/core/lib/common/menu';
|
|
20
|
+
import { codicon, ExtractableWidget, Widget } from '@theia/core/lib/browser/widgets';
|
|
21
|
+
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
|
|
22
|
+
import { SHELL_TABBAR_CONTEXT_MENU } from '@theia/core/lib/browser/shell/tab-bars';
|
|
23
|
+
import { NativeTabDragService, TabDropOutsideWindowsEvent } from '@theia/core/lib/browser/shell/native-tab-drag-service';
|
|
20
24
|
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
21
|
-
import { SecondaryWindowHandler } from '@theia/core/lib/browser/secondary-window-handler';
|
|
25
|
+
import { extractSecondaryWindow, getAllWidgetsFromSecondaryWindow, SecondaryWindowHandler } from '@theia/core/lib/browser/secondary-window-handler';
|
|
22
26
|
|
|
23
27
|
export const EXTRACT_WIDGET = Command.toLocalizedCommand({
|
|
24
28
|
id: 'extract-widget',
|
|
25
29
|
label: 'Move View to Secondary Window'
|
|
26
30
|
}, 'theia/secondary-window/extract-widget');
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
export const RESTORE_WIDGET = Command.toLocalizedCommand({
|
|
33
|
+
id: 'restore-widget',
|
|
34
|
+
label: 'Move View to Main Window'
|
|
35
|
+
}, 'theia/secondary-window/restore-widget');
|
|
36
|
+
|
|
37
|
+
export const RESTORE_ALL_WIDGETS = Command.toLocalizedCommand({
|
|
38
|
+
id: 'restore-all-widgets',
|
|
39
|
+
label: 'Move All Views to Main Window'
|
|
40
|
+
}, 'theia/secondary-window/restore-all-widgets');
|
|
41
|
+
|
|
42
|
+
export const SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW: MenuPath = [...SHELL_TABBAR_CONTEXT_MENU, '6_secondaryWindow'];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Contributes the commands to move widgets to secondary windows and back, and registers them in the toolbar and in the context menu of tabs.
|
|
46
|
+
* In addition, extracts widgets whose tab is dragged out of the application's windows.
|
|
47
|
+
*/
|
|
29
48
|
@injectable()
|
|
30
|
-
export class SecondaryWindowContribution implements CommandContribution, TabBarToolbarContribution {
|
|
49
|
+
export class SecondaryWindowContribution implements CommandContribution, MenuContribution, TabBarToolbarContribution {
|
|
31
50
|
|
|
32
51
|
@inject(SecondaryWindowHandler)
|
|
33
52
|
protected readonly secondaryWindowHandler: SecondaryWindowHandler;
|
|
34
53
|
|
|
54
|
+
@inject(NativeTabDragService)
|
|
55
|
+
protected readonly nativeTabDragService: NativeTabDragService;
|
|
56
|
+
|
|
57
|
+
@inject(ApplicationShell)
|
|
58
|
+
protected readonly shell: ApplicationShell;
|
|
59
|
+
|
|
60
|
+
@postConstruct()
|
|
61
|
+
protected init(): void {
|
|
62
|
+
this.nativeTabDragService.onDidDropTabOutsideWindows(event => this.onDidDropTabOutsideWindows(event));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected onDidDropTabOutsideWindows({ title, screenX, screenY }: TabDropOutsideWindowsEvent): void {
|
|
66
|
+
const widget = title.owner;
|
|
67
|
+
const secondaryWindow = extractSecondaryWindow(widget);
|
|
68
|
+
if (secondaryWindow && getAllWidgetsFromSecondaryWindow(secondaryWindow)?.length === 1) {
|
|
69
|
+
// the widget is the only one in its secondary window, so move the window instead of opening a new one
|
|
70
|
+
secondaryWindow.moveTo(screenX, screenY);
|
|
71
|
+
} else if (ExtractableWidget.is(widget)) {
|
|
72
|
+
this.secondaryWindowHandler.moveWidgetToSecondaryWindow(widget, { position: { x: screenX, y: screenY } });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
35
76
|
registerCommands(commands: CommandRegistry): void {
|
|
77
|
+
const canExtract = (arg?: unknown) => {
|
|
78
|
+
const widget = this.getTargetWidget(arg);
|
|
79
|
+
return ExtractableWidget.is(widget) && widget.secondaryWindow === undefined;
|
|
80
|
+
};
|
|
36
81
|
commands.registerCommand(EXTRACT_WIDGET, {
|
|
37
|
-
execute: async
|
|
38
|
-
|
|
39
|
-
|
|
82
|
+
execute: async arg => {
|
|
83
|
+
const widget = this.getTargetWidget(arg);
|
|
84
|
+
if (ExtractableWidget.is(widget)) {
|
|
85
|
+
this.secondaryWindowHandler.moveWidgetToSecondaryWindow(widget);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
isVisible: canExtract,
|
|
89
|
+
isEnabled: canExtract,
|
|
90
|
+
});
|
|
91
|
+
const isInSecondaryWindow = (arg?: unknown) => extractSecondaryWindow(this.getTargetWidget(arg)) !== undefined;
|
|
92
|
+
commands.registerCommand(RESTORE_WIDGET, {
|
|
93
|
+
execute: async arg => {
|
|
94
|
+
const widget = this.getTargetWidget(arg);
|
|
95
|
+
if (widget) {
|
|
96
|
+
await this.secondaryWindowHandler.moveWidgetToMainWindow(widget);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
isVisible: isInSecondaryWindow,
|
|
100
|
+
isEnabled: isInSecondaryWindow,
|
|
101
|
+
});
|
|
102
|
+
commands.registerCommand(RESTORE_ALL_WIDGETS, {
|
|
103
|
+
execute: async arg => {
|
|
104
|
+
const secondaryWindow = extractSecondaryWindow(this.getTargetWidget(arg));
|
|
105
|
+
if (secondaryWindow) {
|
|
106
|
+
await this.secondaryWindowHandler.moveAllWidgetsToMainWindow(secondaryWindow);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
isVisible: isInSecondaryWindow,
|
|
110
|
+
isEnabled: isInSecondaryWindow,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
registerMenus(menus: MenuModelRegistry): void {
|
|
115
|
+
menus.registerMenuAction(SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW, {
|
|
116
|
+
commandId: EXTRACT_WIDGET.id,
|
|
117
|
+
order: 'a'
|
|
118
|
+
});
|
|
119
|
+
menus.registerMenuAction(SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW, {
|
|
120
|
+
commandId: RESTORE_WIDGET.id,
|
|
121
|
+
order: 'b'
|
|
122
|
+
});
|
|
123
|
+
menus.registerMenuAction(SHELL_TABBAR_CONTEXT_SECONDARY_WINDOW, {
|
|
124
|
+
commandId: RESTORE_ALL_WIDGETS.id,
|
|
125
|
+
order: 'c'
|
|
40
126
|
});
|
|
41
127
|
}
|
|
42
128
|
|
|
@@ -46,5 +132,26 @@ export class SecondaryWindowContribution implements CommandContribution, TabBarT
|
|
|
46
132
|
command: EXTRACT_WIDGET.id,
|
|
47
133
|
icon: codicon('window'),
|
|
48
134
|
});
|
|
135
|
+
registry.registerItem({
|
|
136
|
+
id: RESTORE_WIDGET.id,
|
|
137
|
+
command: RESTORE_WIDGET.id,
|
|
138
|
+
// TODO use `open-in-window` once the codicon font bundled with Monaco provides it, see #17789
|
|
139
|
+
icon: codicon('screen-normal'),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @returns the widget a command is executed for: the widget passed by the tab bar toolbar, the widget of the tab
|
|
145
|
+
* whose context menu has been opened, or the current widget if no argument is passed, e.g. from the command palette
|
|
146
|
+
*/
|
|
147
|
+
protected getTargetWidget(arg: unknown): Widget | undefined {
|
|
148
|
+
if (arg instanceof Widget) {
|
|
149
|
+
return arg;
|
|
150
|
+
}
|
|
151
|
+
// not using `instanceof Event`, the event may come from a secondary window, i.e. from another JavaScript realm
|
|
152
|
+
if ((arg as Event | undefined)?.target) {
|
|
153
|
+
return this.shell.findTargetedWidget(arg as Event);
|
|
154
|
+
}
|
|
155
|
+
return arg === undefined ? this.shell.currentWidget : undefined;
|
|
49
156
|
}
|
|
50
157
|
}
|
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
18
|
import { SecondaryWindowContribution } from './secondary-window-frontend-contribution';
|
|
19
19
|
import { CommandContribution } from '@theia/core/lib/common/command';
|
|
20
|
+
import { MenuContribution } from '@theia/core/lib/common/menu';
|
|
20
21
|
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
21
22
|
|
|
22
23
|
export default new ContainerModule(bind => {
|
|
23
24
|
bind(SecondaryWindowContribution).toSelf().inSingletonScope();
|
|
24
25
|
bind(CommandContribution).toService(SecondaryWindowContribution);
|
|
26
|
+
bind(MenuContribution).toService(SecondaryWindowContribution);
|
|
25
27
|
bind(TabBarToolbarContribution).toService(SecondaryWindowContribution);
|
|
26
28
|
});
|
|
27
29
|
|