@eclipse-glsp/client 2.7.0-next.2 → 2.7.0-next.3
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/features/label-edit-ui/label-edit-ui.d.ts +3 -0
- package/lib/features/label-edit-ui/label-edit-ui.d.ts.map +1 -1
- package/lib/features/label-edit-ui/label-edit-ui.js +37 -0
- package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
- package/package.json +3 -3
- package/src/features/label-edit-ui/label-edit-ui.ts +35 -2
|
@@ -14,8 +14,11 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { EditLabelUI } from '@eclipse-glsp/sprotty';
|
|
17
|
+
import { EditorContextService } from '../../base/editor-context-service';
|
|
17
18
|
export declare class GlspEditLabelUI extends EditLabelUI {
|
|
19
|
+
protected editorContextService: EditorContextService;
|
|
18
20
|
protected initializeContents(containerElement: HTMLElement): void;
|
|
19
21
|
protected setContainerVisible(visible: boolean): void;
|
|
22
|
+
protected isLabelInVisibleViewport(): boolean;
|
|
20
23
|
}
|
|
21
24
|
//# sourceMappingURL=label-edit-ui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-edit-ui.d.ts","sourceRoot":"","sources":["../../../src/features/label-edit-ui/label-edit-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,
|
|
1
|
+
{"version":3,"file":"label-edit-ui.d.ts","sourceRoot":"","sources":["../../../src/features/label-edit-ui/label-edit-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAU,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAGzE,qBACa,eAAgB,SAAQ,WAAW;IAE5C,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;cAElC,kBAAkB,CAAC,gBAAgB,EAAE,WAAW,GAAG,IAAI;cAkBvD,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAS9D,SAAS,CAAC,wBAAwB,IAAI,OAAO;CAehD"}
|
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.GlspEditLabelUI = void 0;
|
|
10
13
|
/********************************************************************************
|
|
@@ -24,11 +27,26 @@ exports.GlspEditLabelUI = void 0;
|
|
|
24
27
|
********************************************************************************/
|
|
25
28
|
const sprotty_1 = require("@eclipse-glsp/sprotty");
|
|
26
29
|
const inversify_1 = require("inversify");
|
|
30
|
+
const editor_context_service_1 = require("../../base/editor-context-service");
|
|
27
31
|
const ui_extension_1 = require("../../base/ui-extension/ui-extension");
|
|
28
32
|
let GlspEditLabelUI = class GlspEditLabelUI extends sprotty_1.EditLabelUI {
|
|
29
33
|
initializeContents(containerElement) {
|
|
30
34
|
super.initializeContents(containerElement);
|
|
31
35
|
containerElement.classList.add(ui_extension_1.CSS_UI_EXTENSION_CLASS);
|
|
36
|
+
this.editorContextService.onViewportChanged(() => {
|
|
37
|
+
window.requestAnimationFrame(() => {
|
|
38
|
+
if (this.isActive && this.containerElement) {
|
|
39
|
+
if (this.isLabelInVisibleViewport()) {
|
|
40
|
+
this.setPosition(this.containerElement);
|
|
41
|
+
this.applyFontStyling();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Cancel editing if the label moved out of the visible viewport
|
|
45
|
+
this.hide();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
32
50
|
}
|
|
33
51
|
setContainerVisible(visible) {
|
|
34
52
|
var _a, _b;
|
|
@@ -40,8 +58,27 @@ let GlspEditLabelUI = class GlspEditLabelUI extends sprotty_1.EditLabelUI {
|
|
|
40
58
|
(_b = this.containerElement) === null || _b === void 0 ? void 0 : _b.classList.add(ui_extension_1.CSS_HIDDEN_EXTENSION_CLASS);
|
|
41
59
|
}
|
|
42
60
|
}
|
|
61
|
+
isLabelInVisibleViewport() {
|
|
62
|
+
if (!this.labelElement) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const canvasBounds = this.editorContextService.canvasBounds;
|
|
66
|
+
const scroll = { x: window.scrollX, y: window.scrollY };
|
|
67
|
+
const canvasScreenBounds = {
|
|
68
|
+
x: canvasBounds.x - scroll.x,
|
|
69
|
+
y: canvasBounds.y - scroll.y,
|
|
70
|
+
width: canvasBounds.width,
|
|
71
|
+
height: canvasBounds.height
|
|
72
|
+
};
|
|
73
|
+
const labelBounds = this.labelElement.getBoundingClientRect();
|
|
74
|
+
return sprotty_1.Bounds.overlap(labelBounds, canvasScreenBounds);
|
|
75
|
+
}
|
|
43
76
|
};
|
|
44
77
|
exports.GlspEditLabelUI = GlspEditLabelUI;
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, inversify_1.inject)(editor_context_service_1.EditorContextService),
|
|
80
|
+
__metadata("design:type", editor_context_service_1.EditorContextService)
|
|
81
|
+
], GlspEditLabelUI.prototype, "editorContextService", void 0);
|
|
45
82
|
exports.GlspEditLabelUI = GlspEditLabelUI = __decorate([
|
|
46
83
|
(0, inversify_1.injectable)()
|
|
47
84
|
], GlspEditLabelUI);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-edit-ui.js","sourceRoot":"","sources":["../../../src/features/label-edit-ui/label-edit-ui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"label-edit-ui.js","sourceRoot":"","sources":["../../../src/features/label-edit-ui/label-edit-ui.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAA4D;AAC5D,yCAA+C;AAC/C,8EAAyE;AACzE,uEAA0G;AAGnG,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,qBAAW;IAIzB,kBAAkB,CAAC,gBAA6B;QAC/D,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;QAC3C,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,qCAAsB,CAAC,CAAC;QACvD,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,GAAG,EAAE;YAC7C,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;gBAC9B,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACzC,IAAI,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC;wBAClC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;wBACxC,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBAC5B,CAAC;yBAAM,CAAC;wBACJ,gEAAgE;wBAChE,IAAI,CAAC,IAAI,EAAE,CAAC;oBAChB,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEkB,mBAAmB,CAAC,OAAgB;;QACnD,IAAI,OAAO,EAAE,CAAC;YACV,MAAA,IAAI,CAAC,gBAAgB,0CAAE,SAAS,CAAC,MAAM,CAAC,yCAA0B,CAAC,CAAC;YACpE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;aAAM,CAAC;YACJ,MAAA,IAAI,CAAC,gBAAgB,0CAAE,SAAS,CAAC,GAAG,CAAC,yCAA0B,CAAC,CAAC;QACrE,CAAC;IACL,CAAC;IAES,wBAAwB;QAC9B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC;QAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACxD,MAAM,kBAAkB,GAAW;YAC/B,CAAC,EAAE,YAAY,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;YAC5B,CAAC,EAAE,YAAY,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;YAC5B,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,MAAM,EAAE,YAAY,CAAC,MAAM;SAC9B,CAAC;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,CAAC;QAC9D,OAAO,gBAAM,CAAC,OAAO,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AA9CY,0CAAe;AAEd;IADT,IAAA,kBAAM,EAAC,6CAAoB,CAAC;8BACG,6CAAoB;6DAAC;0BAF5C,eAAe;IAD3B,IAAA,sBAAU,GAAE;GACA,eAAe,CA8C3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/client",
|
|
3
|
-
"version": "2.7.0-next.
|
|
3
|
+
"version": "2.7.0-next.3+d60eef8",
|
|
4
4
|
"description": "A sprotty-based client for GLSP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"watch": "tsc -w"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@eclipse-glsp/sprotty": "2.7.0-next.
|
|
49
|
+
"@eclipse-glsp/sprotty": "2.7.0-next.3+d60eef8",
|
|
50
50
|
"autocompleter": "^9.1.2",
|
|
51
51
|
"file-saver": "^2.0.5",
|
|
52
52
|
"lodash": "4.17.23",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "d60eef80376ff83a706d3cd536a9fe049afb70cd"
|
|
67
67
|
}
|
|
@@ -13,15 +13,32 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { EditLabelUI } from '@eclipse-glsp/sprotty';
|
|
17
|
-
import { injectable } from 'inversify';
|
|
16
|
+
import { Bounds, EditLabelUI } from '@eclipse-glsp/sprotty';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { EditorContextService } from '../../base/editor-context-service';
|
|
18
19
|
import { CSS_HIDDEN_EXTENSION_CLASS, CSS_UI_EXTENSION_CLASS } from '../../base/ui-extension/ui-extension';
|
|
19
20
|
|
|
20
21
|
@injectable()
|
|
21
22
|
export class GlspEditLabelUI extends EditLabelUI {
|
|
23
|
+
@inject(EditorContextService)
|
|
24
|
+
protected editorContextService: EditorContextService;
|
|
25
|
+
|
|
22
26
|
protected override initializeContents(containerElement: HTMLElement): void {
|
|
23
27
|
super.initializeContents(containerElement);
|
|
24
28
|
containerElement.classList.add(CSS_UI_EXTENSION_CLASS);
|
|
29
|
+
this.editorContextService.onViewportChanged(() => {
|
|
30
|
+
window.requestAnimationFrame(() => {
|
|
31
|
+
if (this.isActive && this.containerElement) {
|
|
32
|
+
if (this.isLabelInVisibleViewport()) {
|
|
33
|
+
this.setPosition(this.containerElement);
|
|
34
|
+
this.applyFontStyling();
|
|
35
|
+
} else {
|
|
36
|
+
// Cancel editing if the label moved out of the visible viewport
|
|
37
|
+
this.hide();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
25
42
|
}
|
|
26
43
|
|
|
27
44
|
protected override setContainerVisible(visible: boolean): void {
|
|
@@ -32,4 +49,20 @@ export class GlspEditLabelUI extends EditLabelUI {
|
|
|
32
49
|
this.containerElement?.classList.add(CSS_HIDDEN_EXTENSION_CLASS);
|
|
33
50
|
}
|
|
34
51
|
}
|
|
52
|
+
|
|
53
|
+
protected isLabelInVisibleViewport(): boolean {
|
|
54
|
+
if (!this.labelElement) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const canvasBounds = this.editorContextService.canvasBounds;
|
|
58
|
+
const scroll = { x: window.scrollX, y: window.scrollY };
|
|
59
|
+
const canvasScreenBounds: Bounds = {
|
|
60
|
+
x: canvasBounds.x - scroll.x,
|
|
61
|
+
y: canvasBounds.y - scroll.y,
|
|
62
|
+
width: canvasBounds.width,
|
|
63
|
+
height: canvasBounds.height
|
|
64
|
+
};
|
|
65
|
+
const labelBounds = this.labelElement.getBoundingClientRect();
|
|
66
|
+
return Bounds.overlap(labelBounds, canvasScreenBounds);
|
|
67
|
+
}
|
|
35
68
|
}
|