@api-client/ui 0.2.2 → 0.2.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/package.json +7 -2
- package/test/env.ts +15 -0
- package/test/tsconfig.json +1 -7
- package/web-test-runner.config.js +5 -1
- package/build/src/visualization/elements/VizAssociationElement.d.ts +0 -4
- package/build/src/visualization/elements/VizAssociationElement.d.ts.map +0 -1
- package/build/src/visualization/elements/VizAssociationElement.js +0 -4
- package/build/src/visualization/elements/VizAssociationElement.js.map +0 -1
- package/build/src/visualization/elements/VizWorkspaceElement.d.ts +0 -110
- package/build/src/visualization/elements/VizWorkspaceElement.d.ts.map +0 -1
- package/build/src/visualization/elements/VizWorkspaceElement.js +0 -321
- package/build/src/visualization/elements/VizWorkspaceElement.js.map +0 -1
- package/build/src/visualization/elements/WorkspaceStyles.d.ts +0 -3
- package/build/src/visualization/elements/WorkspaceStyles.d.ts.map +0 -1
- package/build/src/visualization/elements/WorkspaceStyles.js +0 -168
- package/build/src/visualization/elements/WorkspaceStyles.js.map +0 -1
- package/build/src/visualization/lib/AnchorFinder.d.ts +0 -64
- package/build/src/visualization/lib/AnchorFinder.d.ts.map +0 -1
- package/build/src/visualization/lib/AnchorFinder.js +0 -107
- package/build/src/visualization/lib/AnchorFinder.js.map +0 -1
- package/build/src/visualization/lib/AnchorUtils.d.ts +0 -10
- package/build/src/visualization/lib/AnchorUtils.d.ts.map +0 -1
- package/build/src/visualization/lib/AnchorUtils.js +0 -44
- package/build/src/visualization/lib/AnchorUtils.js.map +0 -1
- package/build/src/visualization/lib/AssociationAnchors.d.ts +0 -134
- package/build/src/visualization/lib/AssociationAnchors.d.ts.map +0 -1
- package/build/src/visualization/lib/AssociationAnchors.js +0 -351
- package/build/src/visualization/lib/AssociationAnchors.js.map +0 -1
- package/build/src/visualization/lib/LabelSketch.d.ts +0 -16
- package/build/src/visualization/lib/LabelSketch.d.ts.map +0 -1
- package/build/src/visualization/lib/LabelSketch.js +0 -53
- package/build/src/visualization/lib/LabelSketch.js.map +0 -1
- package/build/src/visualization/lib/LineSketch.d.ts +0 -26
- package/build/src/visualization/lib/LineSketch.d.ts.map +0 -1
- package/build/src/visualization/lib/LineSketch.js +0 -55
- package/build/src/visualization/lib/LineSketch.js.map +0 -1
- package/build/src/visualization/lib/Point.d.ts +0 -74
- package/build/src/visualization/lib/Point.d.ts.map +0 -1
- package/build/src/visualization/lib/Point.js +0 -121
- package/build/src/visualization/lib/Point.js.map +0 -1
- package/build/src/visualization/lib/PositionUtils.d.ts +0 -65
- package/build/src/visualization/lib/PositionUtils.d.ts.map +0 -1
- package/build/src/visualization/lib/PositionUtils.js +0 -205
- package/build/src/visualization/lib/PositionUtils.js.map +0 -1
- package/build/src/visualization/lib/SelectionManager.d.ts +0 -183
- package/build/src/visualization/lib/SelectionManager.d.ts.map +0 -1
- package/build/src/visualization/lib/SelectionManager.js +0 -481
- package/build/src/visualization/lib/SelectionManager.js.map +0 -1
- package/build/src/visualization/lib/ShapeArtist.d.ts +0 -45
- package/build/src/visualization/lib/ShapeArtist.d.ts.map +0 -1
- package/build/src/visualization/lib/ShapeArtist.js +0 -209
- package/build/src/visualization/lib/ShapeArtist.js.map +0 -1
- package/build/src/visualization/lib/SvgMarkers.d.ts +0 -14
- package/build/src/visualization/lib/SvgMarkers.d.ts.map +0 -1
- package/build/src/visualization/lib/SvgMarkers.js +0 -77
- package/build/src/visualization/lib/SvgMarkers.js.map +0 -1
- package/build/src/visualization/lib/TipSketch.d.ts +0 -26
- package/build/src/visualization/lib/TipSketch.d.ts.map +0 -1
- package/build/src/visualization/lib/TipSketch.js +0 -77
- package/build/src/visualization/lib/TipSketch.js.map +0 -1
- package/build/src/visualization/lib/TouchSupport.d.ts +0 -14
- package/build/src/visualization/lib/TouchSupport.d.ts.map +0 -1
- package/build/src/visualization/lib/TouchSupport.js +0 -55
- package/build/src/visualization/lib/TouchSupport.js.map +0 -1
- package/build/src/visualization/lib/Utils.d.ts +0 -25
- package/build/src/visualization/lib/Utils.d.ts.map +0 -1
- package/build/src/visualization/lib/Utils.js +0 -59
- package/build/src/visualization/lib/Utils.js.map +0 -1
- package/build/src/visualization/lib/VisualizationTypes.d.ts +0 -216
- package/build/src/visualization/lib/VisualizationTypes.d.ts.map +0 -1
- package/build/src/visualization/lib/VisualizationTypes.js +0 -3
- package/build/src/visualization/lib/VisualizationTypes.js.map +0 -1
- package/build/src/visualization/lib/WorkspaceAlignment.d.ts +0 -51
- package/build/src/visualization/lib/WorkspaceAlignment.d.ts.map +0 -1
- package/build/src/visualization/lib/WorkspaceAlignment.js +0 -243
- package/build/src/visualization/lib/WorkspaceAlignment.js.map +0 -1
- package/build/src/visualization/lib/WorkspaceDebugging.d.ts +0 -104
- package/build/src/visualization/lib/WorkspaceDebugging.d.ts.map +0 -1
- package/build/src/visualization/lib/WorkspaceDebugging.js +0 -286
- package/build/src/visualization/lib/WorkspaceDebugging.js.map +0 -1
- package/build/src/visualization/lib/WorkspaceEdges.d.ts +0 -293
- package/build/src/visualization/lib/WorkspaceEdges.d.ts.map +0 -1
- package/build/src/visualization/lib/WorkspaceEdges.js +0 -1073
- package/build/src/visualization/lib/WorkspaceEdges.js.map +0 -1
- package/build/src/visualization/lib/WorkspaceGestures.d.ts +0 -119
- package/build/src/visualization/lib/WorkspaceGestures.d.ts.map +0 -1
- package/build/src/visualization/lib/WorkspaceGestures.js +0 -376
- package/build/src/visualization/lib/WorkspaceGestures.js.map +0 -1
- package/build/src/visualization/lib/WorkspaceSizing.d.ts +0 -66
- package/build/src/visualization/lib/WorkspaceSizing.d.ts.map +0 -1
- package/build/src/visualization/lib/WorkspaceSizing.js +0 -168
- package/build/src/visualization/lib/WorkspaceSizing.js.map +0 -1
- package/build/src/visualization/lib/lines/RectilinearLine.d.ts +0 -114
- package/build/src/visualization/lib/lines/RectilinearLine.d.ts.map +0 -1
- package/build/src/visualization/lib/lines/RectilinearLine.js +0 -605
- package/build/src/visualization/lib/lines/RectilinearLine.js.map +0 -1
- package/build/src/visualization/lib/tips/RectilinearTip.d.ts +0 -26
- package/build/src/visualization/lib/tips/RectilinearTip.d.ts.map +0 -1
- package/build/src/visualization/lib/tips/RectilinearTip.js +0 -149
- package/build/src/visualization/lib/tips/RectilinearTip.js.map +0 -1
- package/build/src/visualization/lib/tips/TipArtist.d.ts +0 -22
- package/build/src/visualization/lib/tips/TipArtist.d.ts.map +0 -1
- package/build/src/visualization/lib/tips/TipArtist.js +0 -31
- package/build/src/visualization/lib/tips/TipArtist.js.map +0 -1
- package/build/src/visualization/lib/types.d.ts +0 -164
- package/build/src/visualization/lib/types.d.ts.map +0 -1
- package/build/src/visualization/lib/types.js +0 -2
- package/build/src/visualization/lib/types.js.map +0 -1
- package/build/src/visualization/plugin/dnd/DragAndDropPlugin.d.ts +0 -126
- package/build/src/visualization/plugin/dnd/DragAndDropPlugin.d.ts.map +0 -1
- package/build/src/visualization/plugin/dnd/DragAndDropPlugin.js +0 -260
- package/build/src/visualization/plugin/dnd/DragAndDropPlugin.js.map +0 -1
- package/build/src/visualization/plugin/group-selection/GroupSelection.d.ts +0 -93
- package/build/src/visualization/plugin/group-selection/GroupSelection.d.ts.map +0 -1
- package/build/src/visualization/plugin/group-selection/GroupSelection.js +0 -250
- package/build/src/visualization/plugin/group-selection/GroupSelection.js.map +0 -1
- package/build/src/visualization/plugin/positioning/DataModelLayout.d.ts +0 -10
- package/build/src/visualization/plugin/positioning/DataModelLayout.d.ts.map +0 -1
- package/build/src/visualization/plugin/positioning/DataModelLayout.js +0 -105
- package/build/src/visualization/plugin/positioning/DataModelLayout.js.map +0 -1
- package/build/src/visualization/plugin/positioning/WorkspaceLayout.d.ts +0 -93
- package/build/src/visualization/plugin/positioning/WorkspaceLayout.d.ts.map +0 -1
- package/build/src/visualization/plugin/positioning/WorkspaceLayout.js +0 -96
- package/build/src/visualization/plugin/positioning/WorkspaceLayout.js.map +0 -1
- package/build/src/visualization/viz-association.d.ts +0 -7
- package/build/src/visualization/viz-association.d.ts.map +0 -1
- package/build/src/visualization/viz-association.js +0 -3
- package/build/src/visualization/viz-association.js.map +0 -1
- package/build/src/visualization/viz-workspace.d.ts +0 -7
- package/build/src/visualization/viz-workspace.d.ts.map +0 -1
- package/build/src/visualization/viz-workspace.js +0 -3
- package/build/src/visualization/viz-workspace.js.map +0 -1
- package/src/visualization/elements/VizAssociationElement.ts +0 -3
- package/src/visualization/elements/VizWorkspaceElement.ts +0 -302
- package/src/visualization/elements/WorkspaceStyles.ts +0 -168
- package/src/visualization/lib/AnchorFinder.ts +0 -112
- package/src/visualization/lib/AnchorUtils.ts +0 -53
- package/src/visualization/lib/AssociationAnchors.ts +0 -418
- package/src/visualization/lib/LabelSketch.ts +0 -67
- package/src/visualization/lib/LineSketch.ts +0 -62
- package/src/visualization/lib/Point.ts +0 -134
- package/src/visualization/lib/PositionUtils.ts +0 -218
- package/src/visualization/lib/SelectionManager.ts +0 -513
- package/src/visualization/lib/ShapeArtist.ts +0 -222
- package/src/visualization/lib/SvgMarkers.ts +0 -80
- package/src/visualization/lib/TipSketch.ts +0 -91
- package/src/visualization/lib/TouchSupport.ts +0 -72
- package/src/visualization/lib/Utils.ts +0 -63
- package/src/visualization/lib/VisualizationTypes.ts +0 -232
- package/src/visualization/lib/WorkspaceAlignment.ts +0 -261
- package/src/visualization/lib/WorkspaceDebugging.ts +0 -313
- package/src/visualization/lib/WorkspaceEdges.ts +0 -1153
- package/src/visualization/lib/WorkspaceGestures.ts +0 -400
- package/src/visualization/lib/WorkspaceSizing.ts +0 -181
- package/src/visualization/lib/lines/RectilinearLine.ts +0 -589
- package/src/visualization/lib/tips/RectilinearTip.ts +0 -156
- package/src/visualization/lib/tips/TipArtist.ts +0 -34
- package/src/visualization/lib/types.ts +0 -173
- package/src/visualization/plugin/dnd/DragAndDropPlugin.ts +0 -294
- package/src/visualization/plugin/group-selection/GroupSelection.ts +0 -271
- package/src/visualization/plugin/positioning/DataModelLayout.ts +0 -114
- package/src/visualization/plugin/positioning/WorkspaceLayout.ts +0 -149
- package/src/visualization/viz-association.ts +0 -9
- package/src/visualization/viz-workspace.ts +0 -9
- package/test/env.d.ts +0 -9
- package/test/env.js +0 -7
- package/test/visualization/lib/AnchorFinder.test.ts +0 -313
- package/test/visualization/lib/AnchorUtils.test.ts +0 -178
- package/test/visualization/lib/PositionUtils.test.ts +0 -406
- package/test/visualization/lib/test-styles.css +0 -80
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
// new visualization types
|
|
2
|
-
|
|
3
|
-
import { Point } from './Point.js'
|
|
4
|
-
import { IWorkspaceEdge } from './types.js'
|
|
5
|
-
|
|
6
|
-
export interface IShapeOrientation {
|
|
7
|
-
/**
|
|
8
|
-
* The transformation origin of the shape. It consists of `x y` coordinates
|
|
9
|
-
* expressed in pixel unit.
|
|
10
|
-
* E.g. "20px 100px" meaning that all transformations applied to the shape are relative to this point.
|
|
11
|
-
*/
|
|
12
|
-
transformOrigin: string
|
|
13
|
-
/**
|
|
14
|
-
* The rotation of the object relative to the workspace.
|
|
15
|
-
* It may not be set for shapes that are not rotated (like lines).
|
|
16
|
-
*/
|
|
17
|
-
rotate?: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* A base class for a shape present in the SVG part of the visualization workspace.
|
|
22
|
-
*/
|
|
23
|
-
export interface IVisualizationShape extends IShapeOrientation {
|
|
24
|
-
/**
|
|
25
|
-
* For the shapes that supports this. It is a value to be added to SVG's element `points` or `d` attribute.
|
|
26
|
-
*/
|
|
27
|
-
path?: string
|
|
28
|
-
/**
|
|
29
|
-
* The list of points that describe the shape.
|
|
30
|
-
* For a line this would be the start and end coordinates of the shape.
|
|
31
|
-
* For a triangle these are the coordinates of each vertex of it.
|
|
32
|
-
*/
|
|
33
|
-
coordinates?: Point[]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Represents the selection state of the shape.
|
|
38
|
-
*/
|
|
39
|
-
export interface IVisualizationShapeSelection {
|
|
40
|
-
/**
|
|
41
|
-
* Whether the shape has the primary selection state.
|
|
42
|
-
* @default false;
|
|
43
|
-
*/
|
|
44
|
-
primary?: boolean
|
|
45
|
-
/**
|
|
46
|
-
* Whether the shape has the secondary selection state.
|
|
47
|
-
* Using primary and the secondary selection is discouraged.
|
|
48
|
-
* @default false;
|
|
49
|
-
*/
|
|
50
|
-
secondary?: boolean
|
|
51
|
-
/**
|
|
52
|
-
* When set the shape should be hidden.
|
|
53
|
-
*/
|
|
54
|
-
hidden?: boolean
|
|
55
|
-
/**
|
|
56
|
-
* Whether the item is currently hovered.
|
|
57
|
-
*/
|
|
58
|
-
hover?: boolean
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface ISelectableShape {
|
|
62
|
-
/**
|
|
63
|
-
* The selection state of the shape.
|
|
64
|
-
*/
|
|
65
|
-
selection?: IVisualizationShapeSelection
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export type AssociationShapeType = 'linear' | 'rectilinear'
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* A base class for association related shapes
|
|
72
|
-
*/
|
|
73
|
-
export interface IVisualizationAssociationShape extends IVisualizationShape {
|
|
74
|
-
/**
|
|
75
|
-
* The type of the line. This is defined in `lib/LineSketch`.
|
|
76
|
-
*/
|
|
77
|
-
type: AssociationShapeType
|
|
78
|
-
startPoint: Point
|
|
79
|
-
endPoint: Point
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Association description for rectilinear style line.
|
|
84
|
-
*/
|
|
85
|
-
export interface IVisualizationRectilinearLineShape extends IVisualizationAssociationShape {
|
|
86
|
-
/**
|
|
87
|
-
* The list of points where the line breaks.
|
|
88
|
-
*/
|
|
89
|
-
controlPoints: Point[]
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Cubic Bezier curve control points.
|
|
94
|
-
*/
|
|
95
|
-
export interface ICubicControlPoints {
|
|
96
|
-
/**
|
|
97
|
-
* Coordinates of the first control point
|
|
98
|
-
*/
|
|
99
|
-
cp1: Point
|
|
100
|
-
/**
|
|
101
|
-
* Coordinates of the second control point
|
|
102
|
-
*/
|
|
103
|
-
cp2: Point
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The definition of an SVG shape that represents an association (edge) line between
|
|
108
|
-
* two other shapes.
|
|
109
|
-
*/
|
|
110
|
-
export interface IAssociationShape extends ISelectableShape {
|
|
111
|
-
/**
|
|
112
|
-
* Name of a CSS class to add to the line class attribute
|
|
113
|
-
*/
|
|
114
|
-
style?: string
|
|
115
|
-
/**
|
|
116
|
-
* The association label. May not be set when the association object does not have a label.
|
|
117
|
-
*/
|
|
118
|
-
label?: IAssociationLabelShape
|
|
119
|
-
/**
|
|
120
|
-
* The definition of the line start and end tips.
|
|
121
|
-
*/
|
|
122
|
-
tips?: ILineTips
|
|
123
|
-
/**
|
|
124
|
-
* Name of the slots to use when calculating the association line's start and end points.
|
|
125
|
-
*/
|
|
126
|
-
slots?: IAssociationSlots
|
|
127
|
-
/**
|
|
128
|
-
* The line definition for the shape.
|
|
129
|
-
*/
|
|
130
|
-
line: IVisualizationAssociationShape
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface IAssociationLabelShape extends IShapeOrientation {
|
|
134
|
-
/**
|
|
135
|
-
* The x coordinate of the label
|
|
136
|
-
*/
|
|
137
|
-
x: number
|
|
138
|
-
/**
|
|
139
|
-
* The y coordinate of the label
|
|
140
|
-
*/
|
|
141
|
-
y: number
|
|
142
|
-
/**
|
|
143
|
-
* The label's text value
|
|
144
|
-
*/
|
|
145
|
-
value: string
|
|
146
|
-
/**
|
|
147
|
-
* The value to set on the `text-anchor` attribute of the `<text>`'s element.
|
|
148
|
-
*/
|
|
149
|
-
anchor?: string
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface IAssociationTip extends IVisualizationShape {
|
|
153
|
-
/**
|
|
154
|
-
* Name of a CSS class to add to the tip's class attribute
|
|
155
|
-
*/
|
|
156
|
-
style?: string
|
|
157
|
-
/**
|
|
158
|
-
* The name of the SVG element to use to visualize the tip.
|
|
159
|
-
* @default polygon
|
|
160
|
-
*/
|
|
161
|
-
svg?: string
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Dictionary for a line tips.
|
|
166
|
-
*/
|
|
167
|
-
export interface ILineTips {
|
|
168
|
-
/**
|
|
169
|
-
* The tip placed where the line starts.
|
|
170
|
-
*/
|
|
171
|
-
start?: IAssociationTip
|
|
172
|
-
/**
|
|
173
|
-
* The tip placed where the line ends.
|
|
174
|
-
*/
|
|
175
|
-
end?: IAssociationTip
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Definition of slots used by an association
|
|
180
|
-
*/
|
|
181
|
-
export interface IAssociationSlots {
|
|
182
|
-
/**
|
|
183
|
-
* The name of the slot in the source object
|
|
184
|
-
*/
|
|
185
|
-
source?: string
|
|
186
|
-
/**
|
|
187
|
-
* The name of the slot in the target object
|
|
188
|
-
*/
|
|
189
|
-
target?: string
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface IAssociationVertexes {
|
|
193
|
-
/**
|
|
194
|
-
* The line's start position
|
|
195
|
-
*/
|
|
196
|
-
start?: Point
|
|
197
|
-
/**
|
|
198
|
-
* The line's end position
|
|
199
|
-
*/
|
|
200
|
-
end?: Point
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* A definition used by the `lib/LineSketch` class sketch a line
|
|
205
|
-
*/
|
|
206
|
-
export interface ILineSketchOptions {
|
|
207
|
-
/**
|
|
208
|
-
* The computation of `DOMRect` for the source element.
|
|
209
|
-
*/
|
|
210
|
-
source: DOMRect
|
|
211
|
-
/**
|
|
212
|
-
* The computation of `DOMRect` for the target element.
|
|
213
|
-
*/
|
|
214
|
-
target: DOMRect
|
|
215
|
-
/**
|
|
216
|
-
* The position where the line starts
|
|
217
|
-
*/
|
|
218
|
-
startPoint: Point
|
|
219
|
-
/**
|
|
220
|
-
* The position where the line ends
|
|
221
|
-
*/
|
|
222
|
-
endPoint: Point
|
|
223
|
-
/**
|
|
224
|
-
* The type of the line to draw. Depending on the type the result of the computation can be different.
|
|
225
|
-
* Uses the default when missing
|
|
226
|
-
*/
|
|
227
|
-
type?: AssociationShapeType
|
|
228
|
-
/**
|
|
229
|
-
* Other associations already built between the two objects.
|
|
230
|
-
*/
|
|
231
|
-
others?: IWorkspaceEdge[]
|
|
232
|
-
}
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import VizWorkspaceElement from '../elements/VizWorkspaceElement.js'
|
|
3
|
-
import { getObjectBoundingClientRect, notifyMoved } from './PositionUtils.js'
|
|
4
|
-
|
|
5
|
-
interface IPositionInfo {
|
|
6
|
-
node: HTMLElement
|
|
7
|
-
box: DOMRect
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A class that adds support for the nodes alignment on the workspace.
|
|
12
|
-
* It adds methods that can align and distribute selected nodes.
|
|
13
|
-
*/
|
|
14
|
-
export class WorkspaceAlignment {
|
|
15
|
-
/**
|
|
16
|
-
* @return Currently selected on the workspace items.
|
|
17
|
-
*/
|
|
18
|
-
get items(): HTMLElement[] {
|
|
19
|
-
const { workspace } = this
|
|
20
|
-
const result: HTMLElement[] = []
|
|
21
|
-
workspace.selection.selected.forEach((i) => {
|
|
22
|
-
const item = workspace.querySelector(`[data-key="${i.id}"][data-alignable]`) as HTMLElement | null
|
|
23
|
-
if (item) {
|
|
24
|
-
result.push(item)
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
return result
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
constructor(public workspace: VizWorkspaceElement) {}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @returns True when the number of selected items is above 1.
|
|
34
|
-
*/
|
|
35
|
-
multiSelection(): boolean {
|
|
36
|
-
return this.items.length > 1
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Aligns selected items vertically to the top.
|
|
41
|
-
*/
|
|
42
|
-
verticalTop(): void {
|
|
43
|
-
if (!this.multiSelection()) {
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
const { items } = this
|
|
47
|
-
const first = items.shift()!
|
|
48
|
-
const box = getObjectBoundingClientRect(first, this.workspace)
|
|
49
|
-
items.forEach(async (node) => {
|
|
50
|
-
const nodeBox = getObjectBoundingClientRect(node, this.workspace)
|
|
51
|
-
const dy = box.y - nodeBox.y
|
|
52
|
-
if (dy !== 0) {
|
|
53
|
-
notifyMoved(node, 0, dy)
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Aligns selected items vertically to the middle.
|
|
60
|
-
*/
|
|
61
|
-
verticalCenter(): void {
|
|
62
|
-
if (!this.multiSelection()) {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
const { items } = this
|
|
66
|
-
const first = items.shift()!
|
|
67
|
-
const box = getObjectBoundingClientRect(first, this.workspace)
|
|
68
|
-
const middle = box.height / 2 + box.y
|
|
69
|
-
items.forEach((node) => {
|
|
70
|
-
const nodeBox = getObjectBoundingClientRect(node, this.workspace)
|
|
71
|
-
const nodeMiddle = nodeBox.height / 2 + nodeBox.y
|
|
72
|
-
const dy = middle - nodeMiddle
|
|
73
|
-
if (dy !== 0) {
|
|
74
|
-
notifyMoved(node, 0, dy)
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Aligns selected items vertically to the bottom.
|
|
81
|
-
*/
|
|
82
|
-
verticalBottom(): void {
|
|
83
|
-
if (!this.multiSelection()) {
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
const { items } = this
|
|
87
|
-
const first = items.shift()
|
|
88
|
-
const box = getObjectBoundingClientRect(first!, this.workspace)
|
|
89
|
-
const end = box.height + box.top
|
|
90
|
-
items.forEach((node) => {
|
|
91
|
-
const nodeBox = getObjectBoundingClientRect(node, this.workspace)
|
|
92
|
-
const dy = end - nodeBox.height - nodeBox.y
|
|
93
|
-
if (dy !== 0) {
|
|
94
|
-
notifyMoved(node, 0, dy)
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Distributes selected items vertically.
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
verticalDistribute(): void {
|
|
104
|
-
if (!this.multiSelection()) {
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
const { items } = this
|
|
108
|
-
let maxStart = 0 // minimum y value
|
|
109
|
-
let maxEnd = 0 // maximum y value
|
|
110
|
-
const positioned: IPositionInfo[] = []
|
|
111
|
-
items.forEach((node) => {
|
|
112
|
-
const box = getObjectBoundingClientRect(node, this.workspace)
|
|
113
|
-
positioned.push({
|
|
114
|
-
node,
|
|
115
|
-
box,
|
|
116
|
-
})
|
|
117
|
-
const heightY = box.height + box.y
|
|
118
|
-
if (!maxStart || box.y <= maxStart) {
|
|
119
|
-
maxStart = box.y
|
|
120
|
-
}
|
|
121
|
-
if (!maxEnd || heightY >= maxEnd) {
|
|
122
|
-
maxEnd = heightY
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
const first = positioned.shift()!
|
|
127
|
-
const last = positioned.pop()!
|
|
128
|
-
|
|
129
|
-
// The first element is to be positioned to the top line.
|
|
130
|
-
notifyMoved(first.node, 0, maxStart - first.box.y)
|
|
131
|
-
// The last element is to be positioned to the bottom line,
|
|
132
|
-
notifyMoved(last.node, 0, maxEnd - last.box.height - last.box.y)
|
|
133
|
-
// Elements in between to be positioned to the remaining space between the first and the last
|
|
134
|
-
// split into equal sections, and positioned in the middle of each section.
|
|
135
|
-
const distributionLength = maxEnd - last.box.height - (maxStart + first.box.height)
|
|
136
|
-
const boxesLength = positioned.reduce((result, item) => result + item.box.height, 0)
|
|
137
|
-
const spaceAvailable = distributionLength - boxesLength
|
|
138
|
-
const spaceLength = spaceAvailable / (positioned.length + 1)
|
|
139
|
-
let current = maxStart + first.box.height
|
|
140
|
-
positioned.forEach((item) => {
|
|
141
|
-
const { node, box } = item
|
|
142
|
-
const newY = current + spaceLength
|
|
143
|
-
const dy = newY - box.y
|
|
144
|
-
current += spaceLength + box.height
|
|
145
|
-
if (dy !== 0) {
|
|
146
|
-
notifyMoved(node, 0, dy)
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Aligns selected items horizontally to the left.
|
|
153
|
-
*/
|
|
154
|
-
horizontalLeft(): void {
|
|
155
|
-
if (!this.multiSelection()) {
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
const { items } = this
|
|
159
|
-
const first = items.shift()
|
|
160
|
-
const box = getObjectBoundingClientRect(first!, this.workspace)
|
|
161
|
-
items.forEach((node) => {
|
|
162
|
-
const nodeBox = getObjectBoundingClientRect(node, this.workspace)
|
|
163
|
-
const dx = box.x - nodeBox.x
|
|
164
|
-
if (dx !== 0) {
|
|
165
|
-
notifyMoved(node, dx, 0)
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Aligns selected items horizontally to the center.
|
|
172
|
-
*/
|
|
173
|
-
horizontalCenter(): void {
|
|
174
|
-
if (!this.multiSelection()) {
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
const { items } = this
|
|
178
|
-
const first = items.shift()
|
|
179
|
-
const box = getObjectBoundingClientRect(first!, this.workspace)
|
|
180
|
-
const middle = box.width / 2 + box.x
|
|
181
|
-
items.forEach((node) => {
|
|
182
|
-
const nodeBox = getObjectBoundingClientRect(node, this.workspace)
|
|
183
|
-
const nodeMiddle = nodeBox.width / 2 + nodeBox.x
|
|
184
|
-
const dx = middle - nodeMiddle
|
|
185
|
-
if (dx !== 0) {
|
|
186
|
-
notifyMoved(node, dx, 0)
|
|
187
|
-
}
|
|
188
|
-
})
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Aligns selected items horizontally to the bottom.
|
|
193
|
-
*/
|
|
194
|
-
horizontalRight(): void {
|
|
195
|
-
if (!this.multiSelection()) {
|
|
196
|
-
return
|
|
197
|
-
}
|
|
198
|
-
const { items } = this
|
|
199
|
-
const first = items.shift()
|
|
200
|
-
const box = getObjectBoundingClientRect(first!, this.workspace)
|
|
201
|
-
const end = box.width + box.x
|
|
202
|
-
items.forEach((node) => {
|
|
203
|
-
const nodeBox = getObjectBoundingClientRect(node, this.workspace)
|
|
204
|
-
const dx = end - nodeBox.width - nodeBox.x
|
|
205
|
-
if (dx !== 0) {
|
|
206
|
-
notifyMoved(node, dx, 0)
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Distributes selected items horizontally.
|
|
213
|
-
*/
|
|
214
|
-
horizontalDistribute(): void {
|
|
215
|
-
if (!this.multiSelection()) {
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
const { items } = this
|
|
219
|
-
let maxStart = 0 // minimum x value
|
|
220
|
-
let maxEnd = 0 // maximum x value
|
|
221
|
-
const positioned: IPositionInfo[] = []
|
|
222
|
-
items.forEach((node) => {
|
|
223
|
-
const box = getObjectBoundingClientRect(node, this.workspace)
|
|
224
|
-
positioned.push({
|
|
225
|
-
node,
|
|
226
|
-
box,
|
|
227
|
-
})
|
|
228
|
-
const widthX = box.width + box.x
|
|
229
|
-
if (!maxStart || box.x <= maxStart) {
|
|
230
|
-
maxStart = box.x
|
|
231
|
-
}
|
|
232
|
-
if (!maxEnd || widthX >= maxEnd) {
|
|
233
|
-
maxEnd = widthX
|
|
234
|
-
}
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
const first = positioned.shift()!
|
|
238
|
-
const last = positioned.pop()!
|
|
239
|
-
|
|
240
|
-
// The first element is to be positioned to the left line.
|
|
241
|
-
notifyMoved(first.node, maxStart - first.box.x, 0)
|
|
242
|
-
// The last element is to be positioned to the right line,
|
|
243
|
-
notifyMoved(last.node, maxEnd - last.box.width - last.box.x, 0)
|
|
244
|
-
// Elements in between to be positioned to the remaining space between the first and the last
|
|
245
|
-
// split into equal sections, and positioned in the middle of each section.
|
|
246
|
-
const distributionLength = maxEnd - last.box.width - (maxStart + first.box.width)
|
|
247
|
-
const boxesLength = positioned.reduce((result, item) => result + item.box.width, 0)
|
|
248
|
-
const spaceAvailable = distributionLength - boxesLength
|
|
249
|
-
const spaceLength = spaceAvailable / (positioned.length + 1)
|
|
250
|
-
let current = maxStart + first.box.width
|
|
251
|
-
positioned.forEach((item) => {
|
|
252
|
-
const { node, box } = item
|
|
253
|
-
const newX = current + spaceLength
|
|
254
|
-
const dx = newX - box.x
|
|
255
|
-
current += spaceLength + box.width
|
|
256
|
-
if (dx !== 0) {
|
|
257
|
-
notifyMoved(node, dx, 0)
|
|
258
|
-
}
|
|
259
|
-
})
|
|
260
|
-
}
|
|
261
|
-
}
|