@eclipse-glsp/client 2.3.0-next.391 → 2.3.0-next.392
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/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +4 -2
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.d.ts +18 -5
- package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +113 -10
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/feedback/feedback-emitter.d.ts +2 -2
- package/lib/base/feedback/feedback-emitter.d.ts.map +1 -1
- package/lib/base/feedback/feedback-emitter.js +1 -2
- package/lib/base/feedback/feedback-emitter.js.map +1 -1
- package/lib/features/context-menu/delete-element-context-menu.d.ts +19 -2
- package/lib/features/context-menu/delete-element-context-menu.d.ts.map +1 -1
- package/lib/features/context-menu/delete-element-context-menu.js +11 -7
- package/lib/features/context-menu/delete-element-context-menu.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager.d.ts +78 -2
- package/lib/features/helper-lines/helper-line-manager.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-manager.js +194 -0
- package/lib/features/helper-lines/helper-line-manager.js.map +1 -1
- package/lib/features/helper-lines/helper-line-module.js +2 -2
- package/lib/features/helper-lines/helper-line-module.js.map +1 -1
- package/lib/features/navigation/navigation-action-handler.d.ts +5 -1
- package/lib/features/navigation/navigation-action-handler.d.ts.map +1 -1
- package/lib/features/navigation/navigation-action-handler.js +11 -4
- package/lib/features/navigation/navigation-action-handler.js.map +1 -1
- package/lib/features/tools/base-tools.d.ts +2 -2
- package/lib/features/tools/base-tools.d.ts.map +1 -1
- package/lib/features/tools/base-tools.js.map +1 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/base/default.module.ts +3 -1
- package/src/base/feedback/feedback-action-dispatcher.ts +114 -11
- package/src/base/feedback/feedback-emitter.ts +2 -2
- package/src/features/context-menu/delete-element-context-menu.ts +11 -7
- package/src/features/helper-lines/helper-line-manager.ts +234 -2
- package/src/features/helper-lines/helper-line-module.ts +1 -1
- package/src/features/hints/type-hint-provider.spec.ts +1 -1
- package/src/features/navigation/navigation-action-handler.ts +9 -5
- package/src/features/tools/base-tools.ts +2 -2
- package/src/index.ts +0 -2
- package/lib/base/feedback/feedback-action-dispatcher-default.d.ts +0 -36
- package/lib/base/feedback/feedback-action-dispatcher-default.d.ts.map +0 -1
- package/lib/base/feedback/feedback-action-dispatcher-default.js +0 -133
- package/lib/base/feedback/feedback-action-dispatcher-default.js.map +0 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts +0 -95
- package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +0 -1
- package/lib/features/helper-lines/helper-line-manager-default.js +0 -197
- package/lib/features/helper-lines/helper-line-manager-default.js.map +0 -1
- package/src/base/feedback/feedback-action-dispatcher-default.ts +0 -130
- package/src/features/helper-lines/helper-line-manager-default.ts +0 -250
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023-2024 EclipseSource 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 WITH Classpath-exception-2.0
|
|
15
|
-
********************************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
Action,
|
|
18
|
-
GModelElement,
|
|
19
|
-
GModelRoot,
|
|
20
|
-
IActionHandler,
|
|
21
|
-
MoveAction,
|
|
22
|
-
Point,
|
|
23
|
-
SetBoundsAction,
|
|
24
|
-
TYPES,
|
|
25
|
-
Vector,
|
|
26
|
-
Writable
|
|
27
|
-
} from '@eclipse-glsp/sprotty';
|
|
28
|
-
import { inject, injectable, optional, postConstruct } from 'inversify';
|
|
29
|
-
import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
30
|
-
import { FeedbackEmitter } from '../../base/feedback/feedback-emitter';
|
|
31
|
-
import { ISelectionListener, SelectionService } from '../../base/selection-service';
|
|
32
|
-
import { SetBoundsFeedbackAction } from '../bounds/set-bounds-feedback-command';
|
|
33
|
-
import { GResizeHandle, ResizeHandleLocation } from '../change-bounds/model';
|
|
34
|
-
import { Grid } from '../grid/grid';
|
|
35
|
-
import { MoveFinishedEventAction, MoveInitializedEventAction } from '../tools/change-bounds/change-bounds-tool-feedback';
|
|
36
|
-
import {
|
|
37
|
-
AlignmentElementFilter,
|
|
38
|
-
DEFAULT_ALIGNABLE_ELEMENT_FILTER,
|
|
39
|
-
DEFAULT_DEBUG,
|
|
40
|
-
DEFAULT_ELEMENT_LINES,
|
|
41
|
-
DEFAULT_EPSILON,
|
|
42
|
-
DEFAULT_VIEWPORT_LINES,
|
|
43
|
-
DrawHelperLinesFeedbackAction,
|
|
44
|
-
RemoveHelperLinesFeedbackAction,
|
|
45
|
-
ViewportLineType
|
|
46
|
-
} from './helper-line-feedback';
|
|
47
|
-
import { IHelperLineManager } from './helper-line-manager';
|
|
48
|
-
import { Direction, HelperLine, HelperLineType, isHelperLine } from './model';
|
|
49
|
-
|
|
50
|
-
export interface IHelperLineOptions {
|
|
51
|
-
/**
|
|
52
|
-
* A list of helper line types that should be rendered when elements are aligned.
|
|
53
|
-
* Defaults to all possible alignments.
|
|
54
|
-
*/
|
|
55
|
-
elementLines?: HelperLineType[];
|
|
56
|
-
/**
|
|
57
|
-
* A list of helper line types that should be rendered when an element is aligned with the viewport.
|
|
58
|
-
* Defaults to middle and center alignment.
|
|
59
|
-
*/
|
|
60
|
-
viewportLines?: ViewportLineType[];
|
|
61
|
-
/**
|
|
62
|
-
* The minimum difference between two coordinates
|
|
63
|
-
* Defaults to 1 or zero (perfect match) if the optional grid module is loaded.
|
|
64
|
-
*/
|
|
65
|
-
alignmentEpsilon?: number;
|
|
66
|
-
/**
|
|
67
|
-
* A filter that is applied to determine on which elements the alignment calculation is performed.
|
|
68
|
-
* By default all top-level bounds-aware, non-routable elements that are visible on the canvas are considered.
|
|
69
|
-
*/
|
|
70
|
-
alignmentElementFilter?: AlignmentElementFilter;
|
|
71
|
-
/**
|
|
72
|
-
* The minimum move delta that is necessary for an element to break through a helper line.
|
|
73
|
-
* Defaults to { x: 1, y: 1 } whereas the x represents the horizontal distance and y represents the vertical distance.
|
|
74
|
-
* If the optional grid module is loaded, defaults to twice the grid size, i.e., two grid moves to break through a helper line.
|
|
75
|
-
*/
|
|
76
|
-
minimumMoveDelta?: Point;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Produces debug output.
|
|
80
|
-
* Defaults to false.
|
|
81
|
-
*/
|
|
82
|
-
debug?: boolean;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const DEFAULT_MOVE_DELTA = { x: 1, y: 1 };
|
|
86
|
-
|
|
87
|
-
export const DEFAULT_HELPER_LINE_OPTIONS: Required<IHelperLineOptions> = {
|
|
88
|
-
elementLines: DEFAULT_ELEMENT_LINES,
|
|
89
|
-
viewportLines: DEFAULT_VIEWPORT_LINES,
|
|
90
|
-
alignmentEpsilon: DEFAULT_EPSILON,
|
|
91
|
-
alignmentElementFilter: DEFAULT_ALIGNABLE_ELEMENT_FILTER,
|
|
92
|
-
minimumMoveDelta: DEFAULT_MOVE_DELTA,
|
|
93
|
-
debug: DEFAULT_DEBUG
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
@injectable()
|
|
97
|
-
export class HelperLineManager implements IActionHandler, ISelectionListener, IHelperLineManager {
|
|
98
|
-
@inject(TYPES.IFeedbackActionDispatcher) protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
99
|
-
@inject(SelectionService) protected selectionService: SelectionService;
|
|
100
|
-
@optional() @inject(TYPES.IHelperLineOptions) protected userOptions?: IHelperLineOptions;
|
|
101
|
-
@optional() @inject(TYPES.Grid) protected grid?: Grid;
|
|
102
|
-
|
|
103
|
-
protected options: Required<IHelperLineOptions>;
|
|
104
|
-
protected feedback: FeedbackEmitter;
|
|
105
|
-
|
|
106
|
-
@postConstruct()
|
|
107
|
-
protected init(): void {
|
|
108
|
-
this.feedback = this.feedbackDispatcher.createEmitter();
|
|
109
|
-
const dynamicOptions: IHelperLineOptions = {};
|
|
110
|
-
if (this.grid) {
|
|
111
|
-
dynamicOptions.alignmentEpsilon = 0;
|
|
112
|
-
dynamicOptions.minimumMoveDelta = Point.multiplyScalar(this.grid, 2);
|
|
113
|
-
}
|
|
114
|
-
this.options = { ...DEFAULT_HELPER_LINE_OPTIONS, ...dynamicOptions, ...this.userOptions };
|
|
115
|
-
this.selectionService.addListener(this);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
handle(action: Action): void {
|
|
119
|
-
if (MoveInitializedEventAction.is(action)) {
|
|
120
|
-
this.handleMoveInitializedAction(action);
|
|
121
|
-
} else if (MoveAction.is(action)) {
|
|
122
|
-
this.handleMoveAction(action);
|
|
123
|
-
} else if (MoveFinishedEventAction.is(action)) {
|
|
124
|
-
this.handleMoveFinishedAction(action);
|
|
125
|
-
} else if (SetBoundsAction.is(action) || SetBoundsFeedbackAction.is(action)) {
|
|
126
|
-
this.handleSetBoundsAction(action);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
protected handleMoveInitializedAction(_action: MoveInitializedEventAction): void {
|
|
131
|
-
this.submitHelperLineFeedback();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
protected handleMoveFinishedAction(_action: MoveFinishedEventAction): void {
|
|
135
|
-
this.feedback.dispose();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
protected handleMoveAction(action: MoveAction): void {
|
|
139
|
-
if (!action.finished) {
|
|
140
|
-
this.submitHelperLineFeedback(action.moves.map(move => move.elementId));
|
|
141
|
-
} else {
|
|
142
|
-
this.feedback.dispose();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
protected submitHelperLineFeedback(elementIds: string[] = this.selectionService.getSelectedElementIDs()): void {
|
|
147
|
-
const feedback = this.createHelperLineFeedback(elementIds);
|
|
148
|
-
this.feedback.add(feedback, [RemoveHelperLinesFeedbackAction.create()]).submit();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
protected createHelperLineFeedback(elementIds: string[]): DrawHelperLinesFeedbackAction {
|
|
152
|
-
return DrawHelperLinesFeedbackAction.create({ elementIds, ...this.options });
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
protected handleSetBoundsAction(action: SetBoundsAction | SetBoundsFeedbackAction): void {
|
|
156
|
-
this.submitHelperLineFeedback(action.bounds.map(bound => bound.elementId));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[], deselectedElements?: string[] | undefined): void {
|
|
160
|
-
this.feedback.dispose();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
getMinimumMoveDelta(element: GModelElement, isSnap: boolean, direction: Direction): number {
|
|
164
|
-
if (!isSnap) {
|
|
165
|
-
return 0;
|
|
166
|
-
}
|
|
167
|
-
const minimumMoveDelta = this.options.minimumMoveDelta;
|
|
168
|
-
return direction === Direction.Left || direction === Direction.Right ? minimumMoveDelta.x : minimumMoveDelta.y;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
getMinimumMoveVector(element: GModelElement, isSnap: boolean, move: Direction[]): Vector | undefined {
|
|
172
|
-
if (!isSnap) {
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const state = this.getHelperLineState(element);
|
|
177
|
-
if (state.helperLines.length === 0) {
|
|
178
|
-
return undefined;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const minimum: Writable<Vector> = { ...Vector.ZERO };
|
|
182
|
-
const resize =
|
|
183
|
-
element instanceof GResizeHandle
|
|
184
|
-
? ResizeHandleLocation.direction(element.location)
|
|
185
|
-
: [Direction.Left, Direction.Right, Direction.Up, Direction.Down];
|
|
186
|
-
|
|
187
|
-
if ((state.types.left || state.types.center) && move.includes(Direction.Left) && resize.includes(Direction.Left)) {
|
|
188
|
-
minimum.x = this.getMinimumMoveDelta(element, isSnap, Direction.Left);
|
|
189
|
-
} else if ((state.types.right || state.types.center) && move.includes(Direction.Right) && resize.includes(Direction.Right)) {
|
|
190
|
-
minimum.x = this.getMinimumMoveDelta(element, isSnap, Direction.Right);
|
|
191
|
-
}
|
|
192
|
-
if ((state.types.top || state.types.middle) && move.includes(Direction.Up) && resize.includes(Direction.Up)) {
|
|
193
|
-
minimum.y = this.getMinimumMoveDelta(element, isSnap, Direction.Up);
|
|
194
|
-
} else if ((state.types.bottom || state.types.middle) && move.includes(Direction.Down) && resize.includes(Direction.Down)) {
|
|
195
|
-
minimum.y = this.getMinimumMoveDelta(element, isSnap, Direction.Down);
|
|
196
|
-
}
|
|
197
|
-
return Vector.isZero(minimum) ? undefined : minimum;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
protected getHelperLineState(element: GModelElement): HelperLineState {
|
|
201
|
-
const helperLines = element.root.children.filter(isHelperLine) || [];
|
|
202
|
-
const types = {
|
|
203
|
-
left: false,
|
|
204
|
-
right: false,
|
|
205
|
-
top: false,
|
|
206
|
-
bottom: false,
|
|
207
|
-
center: false,
|
|
208
|
-
middle: false
|
|
209
|
-
};
|
|
210
|
-
for (const line of helperLines) {
|
|
211
|
-
switch (line.lineType) {
|
|
212
|
-
case HelperLineType.Left:
|
|
213
|
-
case HelperLineType.LeftRight:
|
|
214
|
-
types.left = true;
|
|
215
|
-
break;
|
|
216
|
-
case HelperLineType.Right:
|
|
217
|
-
case HelperLineType.RightLeft:
|
|
218
|
-
types.right = true;
|
|
219
|
-
break;
|
|
220
|
-
case HelperLineType.Top:
|
|
221
|
-
case HelperLineType.TopBottom:
|
|
222
|
-
types.top = true;
|
|
223
|
-
break;
|
|
224
|
-
case HelperLineType.Bottom:
|
|
225
|
-
case HelperLineType.BottomTop:
|
|
226
|
-
types.bottom = true;
|
|
227
|
-
break;
|
|
228
|
-
case HelperLineType.Center:
|
|
229
|
-
types.center = true;
|
|
230
|
-
break;
|
|
231
|
-
case HelperLineType.Middle:
|
|
232
|
-
types.middle = true;
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return { helperLines, types };
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export interface HelperLineState {
|
|
241
|
-
helperLines: HelperLine[];
|
|
242
|
-
types: {
|
|
243
|
-
left: boolean;
|
|
244
|
-
right: boolean;
|
|
245
|
-
top: boolean;
|
|
246
|
-
bottom: boolean;
|
|
247
|
-
center: boolean;
|
|
248
|
-
middle: boolean;
|
|
249
|
-
};
|
|
250
|
-
}
|