@theia/core 1.55.1 → 1.57.0-next.22
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 +43 -39
- package/i18n/nls.cs.json +0 -1
- package/i18n/nls.de.json +0 -1
- package/i18n/nls.es.json +0 -1
- package/i18n/nls.fr.json +0 -1
- package/i18n/nls.hu.json +0 -1
- package/i18n/nls.it.json +0 -1
- package/i18n/nls.ja.json +0 -1
- package/i18n/nls.json +0 -1
- package/i18n/nls.ko.json +0 -1
- package/i18n/nls.pl.json +0 -1
- package/i18n/nls.pt-br.json +0 -1
- package/i18n/nls.ru.json +0 -1
- package/i18n/nls.tr.json +0 -1
- package/i18n/nls.zh-cn.json +0 -1
- package/i18n/nls.zh-tw.json +0 -1
- package/lib/browser/catalog.json +42 -4
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +8 -2
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/dialogs.d.ts +2 -1
- package/lib/browser/dialogs.d.ts.map +1 -1
- package/lib/browser/dialogs.js +20 -2
- package/lib/browser/dialogs.js.map +1 -1
- package/lib/browser/hover-service.d.ts.map +1 -1
- package/lib/browser/hover-service.js +12 -4
- package/lib/browser/hover-service.js.map +1 -1
- package/lib/browser/progress-status-bar-item.d.ts +1 -1
- package/lib/browser/progress-status-bar-item.d.ts.map +1 -1
- package/lib/browser/shell/view-contribution.d.ts.map +1 -1
- package/lib/browser/shell/view-contribution.js +1 -0
- package/lib/browser/shell/view-contribution.js.map +1 -1
- package/lib/browser/tree/tree-decorator.d.ts.map +1 -1
- package/lib/browser/tree/tree-decorator.js +1 -0
- package/lib/browser/tree/tree-decorator.js.map +1 -1
- package/lib/browser/tree/tree-view-welcome-widget.d.ts +17 -11
- package/lib/browser/tree/tree-view-welcome-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-view-welcome-widget.js +65 -34
- package/lib/browser/tree/tree-view-welcome-widget.js.map +1 -1
- package/lib/browser/widgets/select-component.js +1 -1
- package/lib/browser/widgets/select-component.js.map +1 -1
- package/lib/browser/widgets/widget.d.ts +1 -1
- package/lib/browser/widgets/widget.d.ts.map +1 -1
- package/lib/browser/widgets/widget.js +21 -6
- package/lib/browser/widgets/widget.js.map +1 -1
- package/lib/common/performance/stopwatch.d.ts.map +1 -1
- package/lib/common/performance/stopwatch.js +1 -0
- package/lib/common/performance/stopwatch.js.map +1 -1
- package/lib/common/theme.d.ts +1 -1
- package/lib/common/theme.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-context-menu-renderer.js +10 -2
- package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts +1 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.js +7 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.js.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +4 -1
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
- package/lib/electron-main/theia-electron-window.js +11 -3
- package/lib/electron-main/theia-electron-window.js.map +1 -1
- package/package.json +8 -8
- package/src/browser/common-frontend-contribution.ts +8 -2
- package/src/browser/dialogs.ts +21 -5
- package/src/browser/hover-service.ts +12 -5
- package/src/browser/shell/view-contribution.ts +2 -2
- package/src/browser/tree/tree-decorator.ts +2 -2
- package/src/browser/tree/tree-view-welcome-widget.tsx +82 -46
- package/src/browser/widgets/select-component.tsx +1 -1
- package/src/browser/widgets/widget.ts +21 -6
- package/src/common/performance/stopwatch.ts +2 -2
- package/src/common/theme.ts +1 -1
- package/src/electron-browser/menu/electron-context-menu-renderer.ts +10 -2
- package/src/electron-browser/messaging/electron-local-ws-connection-source.ts +5 -0
- package/src/electron-main/electron-main-application.ts +2 -1
- package/src/electron-main/theia-electron-window.ts +11 -3
|
@@ -25,6 +25,10 @@ import '../../src/browser/style/hover-service.css';
|
|
|
25
25
|
|
|
26
26
|
export type HoverPosition = 'left' | 'right' | 'top' | 'bottom';
|
|
27
27
|
|
|
28
|
+
// Threshold, in milliseconds, over which a mouse movement is not considered
|
|
29
|
+
// quick enough as to be ignored
|
|
30
|
+
const quickMouseThresholdMillis = 200;
|
|
31
|
+
|
|
28
32
|
export namespace HoverPosition {
|
|
29
33
|
export function invertIfNecessary(position: HoverPosition, target: DOMRect, host: DOMRect, totalWidth: number, totalHeight: number): HoverPosition {
|
|
30
34
|
if (position === 'left') {
|
|
@@ -100,11 +104,13 @@ export class HoverService {
|
|
|
100
104
|
if (request.target !== this.hoverTarget) {
|
|
101
105
|
this.cancelHover();
|
|
102
106
|
this.pendingTimeout = disposableTimeout(() => this.renderHover(request), this.getHoverDelay());
|
|
107
|
+
this.hoverTarget = request.target;
|
|
108
|
+
this.listenForMouseOut();
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
protected getHoverDelay(): number {
|
|
107
|
-
return Date.now() - this.lastHidHover <
|
|
113
|
+
return Date.now() - this.lastHidHover < quickMouseThresholdMillis
|
|
108
114
|
? 0
|
|
109
115
|
: this.preferences.get('workbench.hover.delay', isOSX ? 1500 : 500);
|
|
110
116
|
}
|
|
@@ -116,7 +122,6 @@ export class HoverService {
|
|
|
116
122
|
if (cssClasses) {
|
|
117
123
|
host.classList.add(...cssClasses);
|
|
118
124
|
}
|
|
119
|
-
this.hoverTarget = target;
|
|
120
125
|
if (content instanceof HTMLElement) {
|
|
121
126
|
host.appendChild(content);
|
|
122
127
|
firstChild = content;
|
|
@@ -155,8 +160,6 @@ export class HoverService {
|
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
});
|
|
158
|
-
|
|
159
|
-
this.listenForMouseOut();
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
protected setHostPosition(target: HTMLElement, host: HTMLElement, position: HoverPosition): HoverPosition {
|
|
@@ -197,7 +200,11 @@ export class HoverService {
|
|
|
197
200
|
protected listenForMouseOut(): void {
|
|
198
201
|
const handleMouseMove = (e: MouseEvent) => {
|
|
199
202
|
if (e.target instanceof Node && !this.hoverHost.contains(e.target) && !this.hoverTarget?.contains(e.target)) {
|
|
200
|
-
this.
|
|
203
|
+
this.disposeOnHide.push(disposableTimeout(() => {
|
|
204
|
+
if (!this.hoverHost.matches(':hover') && !this.hoverTarget?.matches(':hover')) {
|
|
205
|
+
this.cancelHover();
|
|
206
|
+
}
|
|
207
|
+
}, quickMouseThresholdMillis));
|
|
201
208
|
}
|
|
202
209
|
};
|
|
203
210
|
document.addEventListener('mousemove', handleMouseMove);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { injectable, inject, interfaces, optional } from 'inversify';
|
|
17
|
+
import { injectable, inject, interfaces, optional, unmanaged } from 'inversify';
|
|
18
18
|
import { Widget } from '@phosphor/widgets';
|
|
19
19
|
import {
|
|
20
20
|
MenuModelRegistry, Command, CommandContribution,
|
|
@@ -64,7 +64,7 @@ export abstract class AbstractViewContribution<T extends Widget> implements Comm
|
|
|
64
64
|
readonly toggleCommand?: Command;
|
|
65
65
|
|
|
66
66
|
constructor(
|
|
67
|
-
protected readonly options: ViewContributionOptions
|
|
67
|
+
@unmanaged() protected readonly options: ViewContributionOptions
|
|
68
68
|
) {
|
|
69
69
|
if (options.toggleCommandId) {
|
|
70
70
|
this.toggleCommand = {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { injectable } from 'inversify';
|
|
17
|
+
import { injectable, unmanaged } from 'inversify';
|
|
18
18
|
import { Tree, TreeNode } from './tree';
|
|
19
19
|
import { Event, Emitter, Disposable, DisposableCollection, MaybePromise } from '../../common';
|
|
20
20
|
import { WidgetDecoration } from '../widget-decoration';
|
|
@@ -170,7 +170,7 @@ export abstract class AbstractTreeDecoratorService implements TreeDecoratorServi
|
|
|
170
170
|
|
|
171
171
|
protected readonly toDispose = new DisposableCollection();
|
|
172
172
|
|
|
173
|
-
constructor(protected readonly decorators: ReadonlyArray<TreeDecorator>) {
|
|
173
|
+
constructor(@unmanaged() protected readonly decorators: ReadonlyArray<TreeDecorator>) {
|
|
174
174
|
this.toDispose.push(this.onDidChangeDecorationsEmitter);
|
|
175
175
|
this.toDispose.pushAll(this.decorators.map(decorator =>
|
|
176
176
|
decorator.onDidChangeDecorations(data =>
|
|
@@ -19,28 +19,35 @@
|
|
|
19
19
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
20
20
|
*--------------------------------------------------------------------------------------------*/
|
|
21
21
|
// some code is copied and modified from: https://github.com/microsoft/vscode/blob/573e5145ae3b50523925a6f6315d373e649d1b06/src/vs/base/common/linkedText.ts
|
|
22
|
+
// aligned the API and enablement behavior to https://github.com/microsoft/vscode/blob/c711bc9333ba339fde1a530de0094b3fa32f09de/src/vs/base/common/linkedText.ts
|
|
22
23
|
|
|
23
24
|
import React = require('react');
|
|
24
25
|
import { inject, injectable } from 'inversify';
|
|
25
|
-
import {
|
|
26
|
+
import { URI as CodeUri } from 'vscode-uri';
|
|
27
|
+
import { CommandRegistry, DisposableCollection } from '../../common';
|
|
28
|
+
import URI from '../../common/uri';
|
|
26
29
|
import { ContextKeyService } from '../context-key-service';
|
|
30
|
+
import { LabelIcon, LabelParser } from '../label-parser';
|
|
31
|
+
import { OpenerService, open } from '../opener-service';
|
|
32
|
+
import { codicon } from '../widgets';
|
|
33
|
+
import { WindowService } from '../window/window-service';
|
|
27
34
|
import { TreeModel } from './tree-model';
|
|
28
35
|
import { TreeWidget } from './tree-widget';
|
|
29
|
-
import { WindowService } from '../window/window-service';
|
|
30
36
|
|
|
31
|
-
interface ViewWelcome {
|
|
37
|
+
export interface ViewWelcome {
|
|
32
38
|
readonly view: string;
|
|
33
39
|
readonly content: string;
|
|
34
40
|
readonly when?: string;
|
|
41
|
+
readonly enablement?: string;
|
|
35
42
|
readonly order: number;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
interface IItem {
|
|
45
|
+
export interface IItem {
|
|
39
46
|
readonly welcomeInfo: ViewWelcome;
|
|
40
47
|
visible: boolean;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
interface ILink {
|
|
50
|
+
export interface ILink {
|
|
44
51
|
readonly label: string;
|
|
45
52
|
readonly href: string;
|
|
46
53
|
readonly title?: string;
|
|
@@ -60,6 +67,14 @@ export class TreeViewWelcomeWidget extends TreeWidget {
|
|
|
60
67
|
@inject(WindowService)
|
|
61
68
|
protected readonly windowService: WindowService;
|
|
62
69
|
|
|
70
|
+
@inject(LabelParser)
|
|
71
|
+
protected readonly labelParser: LabelParser;
|
|
72
|
+
|
|
73
|
+
@inject(OpenerService)
|
|
74
|
+
protected readonly openerService: OpenerService;
|
|
75
|
+
|
|
76
|
+
protected readonly toDisposeBeforeUpdateViewWelcomeNodes = new DisposableCollection();
|
|
77
|
+
|
|
63
78
|
protected viewWelcomeNodes: React.ReactNode[] = [];
|
|
64
79
|
protected defaultItem: IItem | undefined;
|
|
65
80
|
protected items: IItem[] = [];
|
|
@@ -130,13 +145,31 @@ export class TreeViewWelcomeWidget extends TreeWidget {
|
|
|
130
145
|
|
|
131
146
|
protected updateViewWelcomeNodes(): void {
|
|
132
147
|
this.viewWelcomeNodes = [];
|
|
148
|
+
this.toDisposeBeforeUpdateViewWelcomeNodes.dispose();
|
|
133
149
|
const items = this.visibleItems.sort((a, b) => a.order - b.order);
|
|
134
150
|
|
|
135
|
-
|
|
151
|
+
const enablementKeys: Set<string>[] = [];
|
|
152
|
+
// the plugin-view-registry will push the changes when there is a change in the `when` prop which controls the visibility
|
|
153
|
+
// this listener is to update the enablement of the components in the view welcome
|
|
154
|
+
this.toDisposeBeforeUpdateViewWelcomeNodes.push(
|
|
155
|
+
this.contextService.onDidChange(event => {
|
|
156
|
+
if (enablementKeys.some(keys => event.affects(keys))) {
|
|
157
|
+
this.updateViewWelcomeNodes();
|
|
158
|
+
this.update();
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
// Note: VS Code does not support the `renderSecondaryButtons` prop in welcome content either.
|
|
163
|
+
for (const { content, enablement } of items) {
|
|
164
|
+
const itemEnablementKeys = enablement
|
|
165
|
+
? this.contextService.parseKeys(enablement)
|
|
166
|
+
: undefined;
|
|
167
|
+
if (itemEnablementKeys) {
|
|
168
|
+
enablementKeys.push(itemEnablementKeys);
|
|
169
|
+
}
|
|
136
170
|
const lines = content.split('\n');
|
|
137
171
|
|
|
138
|
-
for (let
|
|
139
|
-
const lineKey = `${iIndex}-${lIndex}`;
|
|
172
|
+
for (let line of lines) {
|
|
140
173
|
line = line.trim();
|
|
141
174
|
|
|
142
175
|
if (!line) {
|
|
@@ -146,42 +179,35 @@ export class TreeViewWelcomeWidget extends TreeWidget {
|
|
|
146
179
|
const linkedTextItems = this.parseLinkedText(line);
|
|
147
180
|
|
|
148
181
|
if (linkedTextItems.length === 1 && typeof linkedTextItems[0] !== 'string') {
|
|
182
|
+
const node = linkedTextItems[0];
|
|
149
183
|
this.viewWelcomeNodes.push(
|
|
150
|
-
this.renderButtonNode(
|
|
184
|
+
this.renderButtonNode(
|
|
185
|
+
node,
|
|
186
|
+
this.viewWelcomeNodes.length,
|
|
187
|
+
enablement
|
|
188
|
+
)
|
|
151
189
|
);
|
|
152
190
|
} else {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const linkedTextKey = `${lineKey}-${nIndex}`;
|
|
157
|
-
|
|
158
|
-
if (typeof node === 'string') {
|
|
159
|
-
linkedTextNodes.push(
|
|
160
|
-
this.renderTextNode(node, linkedTextKey)
|
|
161
|
-
);
|
|
162
|
-
} else {
|
|
163
|
-
linkedTextNodes.push(
|
|
164
|
-
this.renderCommandLinkNode(node, linkedTextKey)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
191
|
+
const renderNode = (item: LinkedTextItem, index: number) => typeof item == 'string'
|
|
192
|
+
? this.renderTextNode(item, index)
|
|
193
|
+
: this.renderLinkNode(item, index, enablement);
|
|
168
194
|
|
|
169
195
|
this.viewWelcomeNodes.push(
|
|
170
|
-
<
|
|
171
|
-
{...
|
|
172
|
-
</
|
|
196
|
+
<p key={`p-${this.viewWelcomeNodes.length}`}>
|
|
197
|
+
{...linkedTextItems.flatMap(renderNode)}
|
|
198
|
+
</p>
|
|
173
199
|
);
|
|
174
200
|
}
|
|
175
201
|
}
|
|
176
202
|
}
|
|
177
203
|
}
|
|
178
204
|
|
|
179
|
-
protected renderButtonNode(node: ILink, lineKey: string): React.ReactNode {
|
|
205
|
+
protected renderButtonNode(node: ILink, lineKey: string | number, enablement: string | undefined): React.ReactNode {
|
|
180
206
|
return (
|
|
181
207
|
<div key={`line-${lineKey}`} className='theia-WelcomeViewButtonWrapper'>
|
|
182
208
|
<button title={node.title}
|
|
183
209
|
className='theia-button theia-WelcomeViewButton'
|
|
184
|
-
disabled={!this.isEnabledClick(
|
|
210
|
+
disabled={!this.isEnabledClick(enablement)}
|
|
185
211
|
onClick={e => this.openLinkOrCommand(e, node.href)}>
|
|
186
212
|
{node.label}
|
|
187
213
|
</button>
|
|
@@ -189,14 +215,22 @@ export class TreeViewWelcomeWidget extends TreeWidget {
|
|
|
189
215
|
);
|
|
190
216
|
}
|
|
191
217
|
|
|
192
|
-
protected renderTextNode(node: string, textKey: string): React.ReactNode {
|
|
193
|
-
return <span key={`text-${textKey}`}>
|
|
218
|
+
protected renderTextNode(node: string, textKey: string | number): React.ReactNode {
|
|
219
|
+
return <span key={`text-${textKey}`}>
|
|
220
|
+
{this.labelParser.parse(node)
|
|
221
|
+
.map((segment, index) =>
|
|
222
|
+
LabelIcon.is(segment)
|
|
223
|
+
? <span
|
|
224
|
+
key={index}
|
|
225
|
+
className={codicon(segment.name)}
|
|
226
|
+
/>
|
|
227
|
+
: <span key={index}>{segment}</span>)}</span>;
|
|
194
228
|
}
|
|
195
229
|
|
|
196
|
-
protected
|
|
230
|
+
protected renderLinkNode(node: ILink, linkKey: string | number, enablement: string | undefined): React.ReactNode {
|
|
197
231
|
return (
|
|
198
232
|
<a key={`link-${linkKey}`}
|
|
199
|
-
className={this.getLinkClassName(node.href)}
|
|
233
|
+
className={this.getLinkClassName(node.href, enablement)}
|
|
200
234
|
title={node.title || ''}
|
|
201
235
|
onClick={e => this.openLinkOrCommand(e, node.href)}>
|
|
202
236
|
{node.label}
|
|
@@ -204,37 +238,39 @@ export class TreeViewWelcomeWidget extends TreeWidget {
|
|
|
204
238
|
);
|
|
205
239
|
}
|
|
206
240
|
|
|
207
|
-
protected getLinkClassName(href: string): string {
|
|
241
|
+
protected getLinkClassName(href: string, enablement: string | undefined): string {
|
|
208
242
|
const classNames = ['theia-WelcomeViewCommandLink'];
|
|
209
|
-
|
|
243
|
+
// Only command-backed links can be disabled. All other, https:, file: remain enabled
|
|
244
|
+
if (href.startsWith('command:') && !this.isEnabledClick(enablement)) {
|
|
210
245
|
classNames.push('disabled');
|
|
211
246
|
}
|
|
212
247
|
return classNames.join(' ');
|
|
213
248
|
}
|
|
214
249
|
|
|
215
|
-
protected isEnabledClick(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
return true;
|
|
250
|
+
protected isEnabledClick(enablement: string | undefined): boolean {
|
|
251
|
+
return typeof enablement === 'string'
|
|
252
|
+
? this.contextService.match(enablement)
|
|
253
|
+
: true;
|
|
221
254
|
}
|
|
222
255
|
|
|
223
|
-
protected openLinkOrCommand = (event: React.MouseEvent,
|
|
256
|
+
protected openLinkOrCommand = (event: React.MouseEvent, value: string): void => {
|
|
224
257
|
event.stopPropagation();
|
|
225
258
|
|
|
226
|
-
if (
|
|
227
|
-
const command =
|
|
259
|
+
if (value.startsWith('command:')) {
|
|
260
|
+
const command = value.replace('command:', '');
|
|
228
261
|
this.commands.executeCommand(command);
|
|
262
|
+
} else if (value.startsWith('file:')) {
|
|
263
|
+
const uri = value.replace('file:', '');
|
|
264
|
+
open(this.openerService, new URI(CodeUri.file(uri).toString()));
|
|
229
265
|
} else {
|
|
230
|
-
this.windowService.openNewWindow(
|
|
266
|
+
this.windowService.openNewWindow(value, { external: true });
|
|
231
267
|
}
|
|
232
268
|
};
|
|
233
269
|
|
|
234
270
|
protected parseLinkedText(text: string): LinkedTextItem[] {
|
|
235
271
|
const result: LinkedTextItem[] = [];
|
|
236
272
|
|
|
237
|
-
const linkRegex = /\[([^\]]+)\]\(((?:https?:\/\/|command:)[^\)\s]+)(?: ("
|
|
273
|
+
const linkRegex = /\[([^\]]+)\]\(((?:https?:\/\/|command:|file:)[^\)\s]+)(?: (["'])(.+?)(\3))?\)/gi;
|
|
238
274
|
let index = 0;
|
|
239
275
|
let match: RegExpExecArray | null;
|
|
240
276
|
|
|
@@ -325,7 +325,7 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
|
|
|
325
325
|
|
|
326
326
|
return <div key="dropdown" className="theia-select-component-dropdown" style={{
|
|
327
327
|
top: invert ? 'none' : this.state.dimensions.bottom,
|
|
328
|
-
bottom: invert ? shellArea.top
|
|
328
|
+
bottom: invert ? shellArea.top - this.state.dimensions.top : 'none',
|
|
329
329
|
left: this.alignLeft ? this.state.dimensions.left : 'none',
|
|
330
330
|
right: this.alignLeft ? 'none' : shellArea.width - this.state.dimensions.right,
|
|
331
331
|
width: Math.min(Math.max(this.state.dimensions.width, this.optimalWidth), maxWidth),
|
|
@@ -24,6 +24,7 @@ import { KeyCode, KeysOrKeyCodes } from '../keyboard/keys';
|
|
|
24
24
|
|
|
25
25
|
import PerfectScrollbar from 'perfect-scrollbar';
|
|
26
26
|
import { PreviewableWidget } from '../widgets/previewable-widget';
|
|
27
|
+
import { Slot } from '@phosphor/signaling';
|
|
27
28
|
|
|
28
29
|
decorate(injectable(), Widget);
|
|
29
30
|
decorate(unmanaged(), Widget, 0);
|
|
@@ -116,7 +117,7 @@ export class BaseWidget extends Widget implements PreviewableWidget {
|
|
|
116
117
|
protected scrollBar?: PerfectScrollbar;
|
|
117
118
|
protected scrollOptions?: PerfectScrollbar.Options;
|
|
118
119
|
|
|
119
|
-
constructor(options?: Widget.IOptions) {
|
|
120
|
+
constructor(@unmanaged() options?: Widget.IOptions) {
|
|
120
121
|
super(options);
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -364,23 +365,37 @@ function waitForVisible(widget: Widget, visible: boolean, attached?: boolean): P
|
|
|
364
365
|
});
|
|
365
366
|
}
|
|
366
367
|
|
|
368
|
+
const pinnedTitles = new Map<Title<Widget>, [boolean, Slot<Widget, void>]>();
|
|
369
|
+
|
|
367
370
|
export function isPinned(title: Title<Widget>): boolean {
|
|
368
371
|
const pinnedState = !title.closable && title.className.includes(PINNED_CLASS);
|
|
369
372
|
return pinnedState;
|
|
370
373
|
}
|
|
371
374
|
|
|
372
|
-
export function unpin(title: Title<Widget>): void {
|
|
373
|
-
title.closable = true;
|
|
374
|
-
title.className = title.className.replace(PINNED_CLASS, '').trim();
|
|
375
|
-
}
|
|
376
|
-
|
|
377
375
|
export function pin(title: Title<Widget>): void {
|
|
376
|
+
const l = () => {
|
|
377
|
+
pinnedTitles.delete(title);
|
|
378
|
+
};
|
|
379
|
+
pinnedTitles.set(title, [title.closable, l]);
|
|
380
|
+
title.owner.disposed.connect(l);
|
|
378
381
|
title.closable = false;
|
|
379
382
|
if (!title.className.includes(PINNED_CLASS)) {
|
|
380
383
|
title.className += ` ${PINNED_CLASS}`;
|
|
381
384
|
}
|
|
382
385
|
}
|
|
383
386
|
|
|
387
|
+
export function unpin(title: Title<Widget>): void {
|
|
388
|
+
const entry = pinnedTitles.get(title);
|
|
389
|
+
if (entry) {
|
|
390
|
+
title.owner.disposed.disconnect(entry[1]);
|
|
391
|
+
title.closable = entry[0];
|
|
392
|
+
pinnedTitles.delete(title);
|
|
393
|
+
} else {
|
|
394
|
+
title.closable = true;
|
|
395
|
+
}
|
|
396
|
+
title.className = title.className.replace(PINNED_CLASS, '').trim();
|
|
397
|
+
}
|
|
398
|
+
|
|
384
399
|
export function isLocked(title: Title<Widget>): boolean {
|
|
385
400
|
return title.className.includes(LOCKED_CLASS);
|
|
386
401
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
18
|
|
|
19
|
-
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { inject, injectable, unmanaged } from 'inversify';
|
|
20
20
|
import { ILogger, LogLevel } from '../logger';
|
|
21
21
|
import { MaybePromise } from '../types';
|
|
22
22
|
import { Measurement, MeasurementOptions, MeasurementResult } from './measurement';
|
|
@@ -58,7 +58,7 @@ export abstract class Stopwatch {
|
|
|
58
58
|
return this.onDidAddMeasurementResultEmitter.event;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
constructor(protected readonly defaultLogOptions: LogOptions) {
|
|
61
|
+
constructor(@unmanaged() protected readonly defaultLogOptions: LogOptions) {
|
|
62
62
|
if (!defaultLogOptions.defaultLogLevel) {
|
|
63
63
|
defaultLogOptions.defaultLogLevel = DEFAULT_LOG_LEVEL;
|
|
64
64
|
}
|
package/src/common/theme.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import { ElectronMainMenuFactory } from './electron-main-menu-factory';
|
|
24
24
|
import { ContextMenuContext } from '../../browser/menu/context-menu-context';
|
|
25
25
|
import { MenuPath, MenuContribution, MenuModelRegistry } from '../../common';
|
|
26
|
-
import { BrowserContextMenuRenderer } from '../../browser/menu/browser-context-menu-renderer';
|
|
26
|
+
import { BrowserContextMenuAccess, BrowserContextMenuRenderer } from '../../browser/menu/browser-context-menu-renderer';
|
|
27
27
|
|
|
28
28
|
export class ElectronContextMenuAccess extends ContextMenuAccess {
|
|
29
29
|
constructor(readonly menuHandle: Promise<number>) {
|
|
@@ -115,7 +115,15 @@ export class ElectronContextMenuRenderer extends BrowserContextMenuRenderer {
|
|
|
115
115
|
this.context.resetAltPressed();
|
|
116
116
|
return new ElectronContextMenuAccess(menuHandle);
|
|
117
117
|
} else {
|
|
118
|
-
|
|
118
|
+
const menuAccess = super.doRender(options);
|
|
119
|
+
const node = (menuAccess as BrowserContextMenuAccess).menu.node;
|
|
120
|
+
const topPanelHeight = document.getElementById('theia-top-panel')?.clientHeight ?? 0;
|
|
121
|
+
// ensure the context menu is not displayed outside of the main area
|
|
122
|
+
if (node.style.top && parseInt(node.style.top.substring(0, node.style.top.length - 2)) < topPanelHeight) {
|
|
123
|
+
node.style.top = `${topPanelHeight}px`;
|
|
124
|
+
node.style.maxHeight = `calc(${node.style.maxHeight} - ${topPanelHeight}px)`;
|
|
125
|
+
}
|
|
126
|
+
return menuAccess;
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
|
|
@@ -23,6 +23,11 @@ export function getLocalPort(): string | undefined {
|
|
|
23
23
|
return params.get('localPort') ?? undefined;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
export function getCurrentPort(): string | undefined {
|
|
27
|
+
const params = new URLSearchParams(location.search);
|
|
28
|
+
return params.get('port') ?? undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
@injectable()
|
|
27
32
|
export class ElectronLocalWebSocketConnectionSource extends WebSocketConnectionSource {
|
|
28
33
|
|
|
@@ -272,6 +272,7 @@ export class ElectronMainApplication {
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
setBackgroundColor(webContents: WebContents, backgroundColor: string): void {
|
|
275
|
+
BrowserWindow.fromWebContents(webContents)?.setBackgroundColor(backgroundColor);
|
|
275
276
|
this.customBackgroundColor = backgroundColor;
|
|
276
277
|
this.saveState(webContents);
|
|
277
278
|
}
|
|
@@ -628,7 +629,7 @@ export class ElectronMainApplication {
|
|
|
628
629
|
y: bounds.y,
|
|
629
630
|
frame: this.useNativeWindowFrame,
|
|
630
631
|
screenLayout: this.getCurrentScreenLayout(),
|
|
631
|
-
backgroundColor: this.customBackgroundColor
|
|
632
|
+
backgroundColor: this.customBackgroundColor ?? electronWindow.getBackgroundColor()
|
|
632
633
|
};
|
|
633
634
|
this.electronStore.set('windowstate', options);
|
|
634
635
|
} catch (e) {
|
|
@@ -186,10 +186,18 @@ export class TheiaElectronWindow {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
protected restoreMaximizedState(): void {
|
|
189
|
-
|
|
190
|
-
this.
|
|
189
|
+
const restore = () => {
|
|
190
|
+
if (this.options.isMaximized) {
|
|
191
|
+
this._window.maximize();
|
|
192
|
+
} else {
|
|
193
|
+
this._window.unmaximize();
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
if (this._window.isVisible()) {
|
|
198
|
+
restore();
|
|
191
199
|
} else {
|
|
192
|
-
this._window.
|
|
200
|
+
this._window.once('show', () => restore());
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
203
|
|