@eclipse-glsp/client 1.0.0 → 1.1.0-RC01
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/base/types.d.ts +2 -0
- package/lib/base/types.d.ts.map +1 -1
- package/lib/features/layout/di.config.d.ts.map +1 -1
- package/lib/features/layout/di.config.js +2 -0
- package/lib/features/layout/di.config.js.map +1 -1
- package/lib/features/layout/hbox-layout.d.ts +1 -1
- package/lib/features/layout/hbox-layout.d.ts.map +1 -1
- package/lib/features/layout/hbox-layout.js +19 -7
- package/lib/features/layout/hbox-layout.js.map +1 -1
- package/lib/features/layout/layouter.d.ts +37 -0
- package/lib/features/layout/layouter.d.ts.map +1 -0
- package/lib/features/layout/layouter.js +131 -0
- package/lib/features/layout/layouter.js.map +1 -0
- package/lib/features/layout/tests/freeform-layout.spec.d.ts +3 -0
- package/lib/features/layout/tests/freeform-layout.spec.d.ts.map +1 -0
- package/lib/features/layout/tests/freeform-layout.spec.js +201 -0
- package/lib/features/layout/tests/freeform-layout.spec.js.map +1 -0
- package/lib/features/layout/tests/hbox-layout.spec.d.ts +3 -0
- package/lib/features/layout/tests/hbox-layout.spec.d.ts.map +1 -0
- package/lib/features/layout/tests/hbox-layout.spec.js +161 -0
- package/lib/features/layout/tests/hbox-layout.spec.js.map +1 -0
- package/lib/features/layout/tests/layouter-test-util.d.ts +34 -0
- package/lib/features/layout/tests/layouter-test-util.d.ts.map +1 -0
- package/lib/features/layout/tests/layouter-test-util.js +96 -0
- package/lib/features/layout/tests/layouter-test-util.js.map +1 -0
- package/lib/features/layout/tests/vbox-layout.spec.d.ts +3 -0
- package/lib/features/layout/tests/vbox-layout.spec.d.ts.map +1 -0
- package/lib/features/layout/tests/vbox-layout.spec.js +161 -0
- package/lib/features/layout/tests/vbox-layout.spec.js.map +1 -0
- package/lib/features/layout/vbox-layout.d.ts +1 -1
- package/lib/features/layout/vbox-layout.d.ts.map +1 -1
- package/lib/features/layout/vbox-layout.js +17 -5
- package/lib/features/layout/vbox-layout.js.map +1 -1
- package/lib/sprotty-reexport.d.ts +1 -1
- package/lib/sprotty-reexport.d.ts.map +1 -1
- package/lib/sprotty-reexport.js +6 -4
- package/lib/sprotty-reexport.js.map +1 -1
- package/lib/views/glsp-projection-view.d.ts.map +1 -1
- package/lib/views/glsp-projection-view.js +8 -2
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/package.json +6 -5
- package/src/features/layout/di.config.ts +3 -1
- package/src/features/layout/hbox-layout.ts +24 -7
- package/src/features/layout/layouter.ts +137 -0
- package/src/features/layout/tests/freeform-layout.spec.ts +216 -0
- package/src/features/layout/tests/hbox-layout.spec.ts +171 -0
- package/src/features/layout/tests/layouter-test-util.ts +122 -0
- package/src/features/layout/tests/vbox-layout.spec.ts +171 -0
- package/src/features/layout/vbox-layout.ts +22 -5
- package/src/sprotty-reexport.ts +6 -1
- package/src/views/glsp-projection-view.tsx +10 -3
|
@@ -49,6 +49,9 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
49
49
|
|
|
50
50
|
const fixedSize = this.getFixedContainerBounds(container, options, layouter);
|
|
51
51
|
|
|
52
|
+
const currentWidth = (boundsData.bounds?.width || 0) - options.paddingLeft - options.paddingRight;
|
|
53
|
+
const currentHeight = (boundsData.bounds?.height || 0) - options.paddingTop - options.paddingBottom;
|
|
54
|
+
|
|
52
55
|
const maxWidth =
|
|
53
56
|
options.paddingFactor *
|
|
54
57
|
(options.resizeContainer
|
|
@@ -60,8 +63,11 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
60
63
|
? Math.max(fixedSize.height - options.paddingTop - options.paddingBottom, childrenSize.height)
|
|
61
64
|
: Math.max(0, fixedSize.height - options.paddingTop - options.paddingBottom));
|
|
62
65
|
|
|
66
|
+
const width = Math.max(currentWidth, maxWidth);
|
|
67
|
+
const height = Math.max(currentHeight, maxHeight);
|
|
68
|
+
|
|
63
69
|
// Remaining size that can be grabbed by children with the vGrab option
|
|
64
|
-
const grabHeight: number =
|
|
70
|
+
const grabHeight: number = height - childrenSize.height;
|
|
65
71
|
// Number of children that request vGrab
|
|
66
72
|
// FIXME: This approach works fine when only 1 child uses VGrab, but may cause rounding issues
|
|
67
73
|
// when the grabHeight can't be equally shared by all children.
|
|
@@ -70,7 +76,7 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
70
76
|
.filter(opt => opt.vGrab).length;
|
|
71
77
|
|
|
72
78
|
if (maxWidth > 0 && maxHeight > 0) {
|
|
73
|
-
const offset = this.layoutChildren(container, layouter, options,
|
|
79
|
+
const offset = this.layoutChildren(container, layouter, options, width, height, grabHeight, grabbingChildren);
|
|
74
80
|
boundsData.bounds = this.getFinalContainerBounds(container, offset, options, childrenSize.width, childrenSize.height);
|
|
75
81
|
boundsData.boundsChanged = true;
|
|
76
82
|
}
|
|
@@ -155,7 +161,14 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
155
161
|
grabHeight?: number,
|
|
156
162
|
grabbingChildren?: number
|
|
157
163
|
): Point {
|
|
164
|
+
const hAlign = childOptions.hGrab ? 'left' : childOptions.hAlign;
|
|
165
|
+
const dx = this.getDx(hAlign, bounds, maxWidth);
|
|
158
166
|
let offset = super.layoutChild(child, boundsData, bounds, childOptions, containerOptions, currentOffset, maxWidth, maxHeight);
|
|
167
|
+
boundsData.bounds = {
|
|
168
|
+
...boundsData.bounds!,
|
|
169
|
+
x: currentOffset.x + dx,
|
|
170
|
+
y: currentOffset.y
|
|
171
|
+
};
|
|
159
172
|
if (childOptions.hGrab) {
|
|
160
173
|
boundsData.bounds = {
|
|
161
174
|
x: boundsData.bounds!.x,
|
|
@@ -197,7 +210,7 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
protected override getChildLayoutOptions(child: SChildElement, containerOptions: VBoxLayoutOptionsExt): VBoxLayoutOptionsExt {
|
|
200
|
-
return super.getChildLayoutOptions(child, containerOptions) as VBoxLayoutOptionsExt;
|
|
213
|
+
return super.getChildLayoutOptions(child, this.filterContainerOptions(containerOptions)) as VBoxLayoutOptionsExt;
|
|
201
214
|
}
|
|
202
215
|
|
|
203
216
|
protected override getLayoutOptions(element: SModelElement): VBoxLayoutOptionsExt {
|
|
@@ -250,7 +263,11 @@ export class VBoxLayouterExt extends VBoxLayouter {
|
|
|
250
263
|
};
|
|
251
264
|
}
|
|
252
265
|
|
|
253
|
-
protected
|
|
254
|
-
|
|
266
|
+
protected filterContainerOptions(containerOptions: VBoxLayoutOptionsExt): VBoxLayoutOptionsExt {
|
|
267
|
+
// Reset object-specific layout options to default before merging,
|
|
268
|
+
// to make sure they won't be inherited (grab, prefSize)
|
|
269
|
+
// eslint-disable-next-line no-null/no-null
|
|
270
|
+
const localOptions = { vGrab: false, hGrab: false, prefHeight: null, prefWidth: null };
|
|
271
|
+
return { ...containerOptions, ...localOptions };
|
|
255
272
|
}
|
|
256
273
|
}
|
package/src/sprotty-reexport.ts
CHANGED
|
@@ -104,7 +104,12 @@ export {
|
|
|
104
104
|
export * from 'sprotty/lib/features/bounds/stack-layout';
|
|
105
105
|
export * from 'sprotty/lib/features/bounds/vbox-layout';
|
|
106
106
|
export * from 'sprotty/lib/features/bounds/views';
|
|
107
|
-
export
|
|
107
|
+
export {
|
|
108
|
+
ButtonHandlerRegistry,
|
|
109
|
+
configureButtonHandler,
|
|
110
|
+
IButtonHandler,
|
|
111
|
+
IButtonHandlerRegistration
|
|
112
|
+
} from 'sprotty/lib/features/button/button-handler';
|
|
108
113
|
export * from 'sprotty/lib/features/button/model';
|
|
109
114
|
export * from 'sprotty/lib/features/command-palette/action-providers';
|
|
110
115
|
export * from 'sprotty/lib/features/command-palette/command-palette';
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
ProjectedViewportView,
|
|
26
26
|
ProjectionParams,
|
|
27
27
|
RenderingContext,
|
|
28
|
+
setAttr,
|
|
28
29
|
setClass,
|
|
29
30
|
ViewportRootElement,
|
|
30
31
|
ViewProjection
|
|
@@ -36,12 +37,18 @@ import {
|
|
|
36
37
|
@injectable()
|
|
37
38
|
export class GLSPProjectionView extends ProjectedViewportView {
|
|
38
39
|
override render(model: Readonly<ViewportRootElement>, context: RenderingContext, args?: IViewArgs): VNode {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const svgElem = this.renderSvg(model, context, args);
|
|
41
|
+
if (svgElem.data) {
|
|
42
|
+
svgElem.data!.class = { 'sprotty-graph': true };
|
|
43
|
+
}
|
|
44
|
+
const rootNode: VNode = (
|
|
45
|
+
<div class-sprotty-graph={false} style={{ width: '100%', height: '100%' }}>
|
|
46
|
+
{svgElem}
|
|
42
47
|
{this.renderProjections(model, context, args)}
|
|
43
48
|
</div>
|
|
44
49
|
);
|
|
50
|
+
setAttr(rootNode, 'tabindex', 0);
|
|
51
|
+
return rootNode;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
protected override renderSvg(model: Readonly<ViewportRootElement>, context: RenderingContext, args?: IViewArgs): VNode {
|