@theia/core 1.52.0 → 1.53.0-next.18
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 +7 -7
- package/lib/browser/browser.d.ts +2 -0
- package/lib/browser/browser.d.ts.map +1 -1
- package/lib/browser/browser.js +6 -1
- package/lib/browser/browser.js.map +1 -1
- package/lib/browser/common-frontend-contribution.d.ts +4 -0
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +98 -3
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +5 -0
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/saveable-service.d.ts.map +1 -1
- package/lib/browser/saveable-service.js +6 -2
- package/lib/browser/saveable-service.js.map +1 -1
- package/lib/browser/saveable.d.ts +16 -1
- package/lib/browser/saveable.d.ts.map +1 -1
- package/lib/browser/saveable.js +59 -1
- package/lib/browser/saveable.js.map +1 -1
- package/lib/browser/undo-redo-handler.d.ts +22 -0
- package/lib/browser/undo-redo-handler.d.ts.map +1 -0
- package/lib/browser/undo-redo-handler.js +83 -0
- package/lib/browser/undo-redo-handler.js.map +1 -0
- package/lib/browser/widget-open-handler.d.ts +4 -1
- package/lib/browser/widget-open-handler.d.ts.map +1 -1
- package/lib/browser/widget-open-handler.js.map +1 -1
- package/lib/browser/widgets/index.d.ts +1 -0
- package/lib/browser/widgets/index.d.ts.map +1 -1
- package/lib/browser/widgets/index.js +1 -0
- package/lib/browser/widgets/index.js.map +1 -1
- package/lib/browser/widgets/split-widget.d.ts +45 -0
- package/lib/browser/widgets/split-widget.d.ts.map +1 -0
- package/lib/browser/widgets/split-widget.js +126 -0
- package/lib/browser/widgets/split-widget.js.map +1 -0
- package/lib/common/event.d.ts +2 -0
- package/lib/common/event.d.ts.map +1 -1
- package/lib/common/event.js +4 -0
- package/lib/common/event.js.map +1 -1
- package/lib/common/json-schema.d.ts +2 -0
- package/lib/common/json-schema.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/browser/browser.ts +10 -1
- package/src/browser/common-frontend-contribution.ts +112 -3
- package/src/browser/frontend-application-module.ts +6 -0
- package/src/browser/index.ts +1 -0
- package/src/browser/saveable-service.ts +6 -2
- package/src/browser/saveable.ts +65 -1
- package/src/browser/style/index.css +3 -1
- package/src/browser/style/split-widget.css +38 -0
- package/src/browser/undo-redo-handler.ts +85 -0
- package/src/browser/widget-open-handler.ts +4 -1
- package/src/browser/widgets/index.ts +1 -0
- package/src/browser/widgets/split-widget.ts +163 -0
- package/src/common/event.ts +6 -0
- package/src/common/json-schema.ts +2 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 1C-Soft LLC and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Emitter } from 'vscode-languageserver-protocol';
|
|
18
|
+
import { ApplicationShell, StatefulWidget } from '../shell';
|
|
19
|
+
import { BaseWidget, Message, PanelLayout, SplitPanel, Widget } from './widget';
|
|
20
|
+
import { CompositeSaveable, Saveable, SaveableSource } from '../saveable';
|
|
21
|
+
import { Navigatable } from '../navigatable-types';
|
|
22
|
+
import { URI } from '../../common';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A widget containing a number of panes in a split layout.
|
|
26
|
+
*/
|
|
27
|
+
export class SplitWidget extends BaseWidget implements ApplicationShell.TrackableWidgetProvider, SaveableSource, Navigatable, StatefulWidget {
|
|
28
|
+
|
|
29
|
+
protected readonly splitPanel: SplitPanel;
|
|
30
|
+
|
|
31
|
+
protected readonly onDidChangeTrackableWidgetsEmitter = new Emitter<Widget[]>();
|
|
32
|
+
readonly onDidChangeTrackableWidgets = this.onDidChangeTrackableWidgetsEmitter.event;
|
|
33
|
+
|
|
34
|
+
protected readonly compositeSaveable = new CompositeSaveable();
|
|
35
|
+
|
|
36
|
+
protected navigatable?: Navigatable;
|
|
37
|
+
|
|
38
|
+
constructor(options?: SplitPanel.IOptions & { navigatable?: Navigatable }) {
|
|
39
|
+
super();
|
|
40
|
+
|
|
41
|
+
this.toDispose.pushAll([this.onDidChangeTrackableWidgetsEmitter]);
|
|
42
|
+
|
|
43
|
+
this.addClass('theia-split-widget');
|
|
44
|
+
|
|
45
|
+
const layout = new PanelLayout();
|
|
46
|
+
this.layout = layout;
|
|
47
|
+
const that = this;
|
|
48
|
+
this.splitPanel = new class extends SplitPanel {
|
|
49
|
+
|
|
50
|
+
protected override onChildAdded(msg: Widget.ChildMessage): void {
|
|
51
|
+
super.onChildAdded(msg);
|
|
52
|
+
that.onPaneAdded(msg.child);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected override onChildRemoved(msg: Widget.ChildMessage): void {
|
|
56
|
+
super.onChildRemoved(msg);
|
|
57
|
+
that.onPaneRemoved(msg.child);
|
|
58
|
+
}
|
|
59
|
+
}({
|
|
60
|
+
spacing: 1, // --theia-border-width
|
|
61
|
+
...options
|
|
62
|
+
});
|
|
63
|
+
this.splitPanel.node.tabIndex = -1;
|
|
64
|
+
layout.addWidget(this.splitPanel);
|
|
65
|
+
|
|
66
|
+
this.navigatable = options?.navigatable;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get orientation(): SplitPanel.Orientation {
|
|
70
|
+
return this.splitPanel.orientation;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set orientation(value: SplitPanel.Orientation) {
|
|
74
|
+
this.splitPanel.orientation = value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
relativeSizes(): number[] {
|
|
78
|
+
return this.splitPanel.relativeSizes();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setRelativeSizes(sizes: number[]): void {
|
|
82
|
+
this.splitPanel.setRelativeSizes(sizes);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get handles(): readonly HTMLDivElement[] {
|
|
86
|
+
return this.splitPanel.handles;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get saveable(): Saveable {
|
|
90
|
+
return this.compositeSaveable;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getResourceUri(): URI | undefined {
|
|
94
|
+
return this.navigatable?.getResourceUri();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
createMoveToUri(resourceUri: URI): URI | undefined {
|
|
98
|
+
return this.navigatable?.createMoveToUri(resourceUri);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
storeState(): SplitWidget.State {
|
|
102
|
+
return { orientation: this.orientation, widgets: this.panes, relativeSizes: this.relativeSizes() };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
restoreState(oldState: SplitWidget.State): void {
|
|
106
|
+
const { orientation, widgets, relativeSizes } = oldState;
|
|
107
|
+
if (orientation) {
|
|
108
|
+
this.orientation = orientation;
|
|
109
|
+
}
|
|
110
|
+
for (const widget of widgets) {
|
|
111
|
+
this.addPane(widget);
|
|
112
|
+
}
|
|
113
|
+
if (relativeSizes) {
|
|
114
|
+
this.setRelativeSizes(relativeSizes);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get panes(): readonly Widget[] {
|
|
119
|
+
return this.splitPanel.widgets;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getTrackableWidgets(): Widget[] {
|
|
123
|
+
return [...this.panes];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
protected fireDidChangeTrackableWidgets(): void {
|
|
127
|
+
this.onDidChangeTrackableWidgetsEmitter.fire(this.getTrackableWidgets());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
addPane(pane: Widget): void {
|
|
131
|
+
this.splitPanel.addWidget(pane);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
insertPane(index: number, pane: Widget): void {
|
|
135
|
+
this.splitPanel.insertWidget(index, pane);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
protected onPaneAdded(pane: Widget): void {
|
|
139
|
+
if (Saveable.isSource(pane)) {
|
|
140
|
+
this.compositeSaveable.add(pane.saveable);
|
|
141
|
+
}
|
|
142
|
+
this.fireDidChangeTrackableWidgets();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
protected onPaneRemoved(pane: Widget): void {
|
|
146
|
+
if (Saveable.isSource(pane)) {
|
|
147
|
+
this.compositeSaveable.remove(pane.saveable);
|
|
148
|
+
}
|
|
149
|
+
this.fireDidChangeTrackableWidgets();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
protected override onActivateRequest(msg: Message): void {
|
|
153
|
+
this.splitPanel.node.focus();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export namespace SplitWidget {
|
|
158
|
+
export interface State {
|
|
159
|
+
orientation?: SplitPanel.Orientation;
|
|
160
|
+
widgets: readonly Widget[]; // note: don't rename this property; it has special meaning for `ShellLayoutRestorer`
|
|
161
|
+
relativeSizes?: number[];
|
|
162
|
+
}
|
|
163
|
+
}
|
package/src/common/event.ts
CHANGED
|
@@ -89,6 +89,12 @@ export namespace Event {
|
|
|
89
89
|
return new Promise(resolve => once(event)(resolve));
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
export function filter<T>(event: Event<T>, predicate: (e: T) => unknown): Event<T>;
|
|
93
|
+
export function filter<T, S extends T>(event: Event<T>, predicate: (e: T) => e is S): Event<S>;
|
|
94
|
+
export function filter<T>(event: Event<T>, predicate: (e: T) => unknown): Event<T> {
|
|
95
|
+
return (listener, thisArg, disposables) => event(e => predicate(e) && listener.call(thisArg, e), undefined, disposables);
|
|
96
|
+
}
|
|
97
|
+
|
|
92
98
|
/**
|
|
93
99
|
* Given an event and a `map` function, returns another event which maps each element
|
|
94
100
|
* through the mapping function.
|