@visuallyjs/browser-ui 1.2.4 → 1.2.5
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/css/visuallyjs.css +34 -16
- package/js/visuallyjs.browser-ui.cjs.js +91 -59
- package/js/visuallyjs.browser-ui.esm.js +91 -59
- package/package.json +1 -1
- package/types/browser-ui/browser-util.d.ts +0 -7
- package/types/browser-ui/browser-visuallyjs-instance.d.ts +1 -0
- package/types/browser-ui/components/controls/controls-component.d.ts +8 -0
- package/types/browser-ui/components/index.d.ts +1 -0
- package/types/browser-ui/components/palette/auto-edge-connect.d.ts +74 -0
- package/types/browser-ui/components/palette/definitions.d.ts +50 -0
- package/types/browser-ui/components/palette/index.d.ts +3 -0
- package/types/browser-ui/components/palette/palette-options.d.ts +59 -2
- package/types/browser-ui/components/palette/palette.d.ts +25 -15
- package/types/browser-ui/components/palette/util.d.ts +21 -0
- package/types/browser-ui/components/rotate-manager.d.ts +27 -0
- package/types/browser-ui/constants.d.ts +5 -2
- package/types/browser-ui/css-constants.d.ts +28 -2
- package/types/browser-ui/definitions.d.ts +1 -1
- package/types/browser-ui/edge-handler-base.d.ts +20 -1
- package/types/browser-ui/edge-input-handler.d.ts +1 -18
- package/types/browser-ui/element-drag-handler-2.d.ts +4 -2
- package/types/browser-ui/event-manager.d.ts +7 -0
- package/types/browser-ui/index.d.ts +2 -1
- package/types/browser-ui/keyboard/index.d.ts +1 -0
- package/types/browser-ui/keyboard/keyboard-listener.d.ts +7 -0
- package/types/browser-ui/pan-zoom-options.d.ts +5 -0
- package/types/browser-ui/pan-zoom.d.ts +2 -1
- package/types/browser-ui/paper-renderer/paper.d.ts +1 -0
- package/types/browser-ui/positioning-and-sizing-utils.d.ts +5 -0
- package/types/browser-ui/shape-library/shape-library-definitions.d.ts +28 -8
- package/types/browser-ui/shape-library/shape-library.d.ts +3 -3
- package/types/browser-ui/surface-renderer/css-classes.d.ts +8 -0
- package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +41 -4
- package/types/browser-ui/surface-renderer/diagrams/diagram.d.ts +11 -1
- package/types/browser-ui/surface-renderer/diagrams/mediator.d.ts +7 -7
- package/types/browser-ui/surface-renderer/plugins/lasso/lasso.d.ts +1 -1
- package/types/browser-ui/surface-renderer/plugins/resizing-tools/resizing-tools-plugin.d.ts +4 -3
- package/types/browser-ui/surface-renderer/shape-palette-options.d.ts +31 -3
- package/types/browser-ui/surface-renderer/shape-palette.d.ts +1 -0
- package/types/browser-ui/surface-renderer/surface.d.ts +15 -1
- package/types/core/datasource.d.ts +1 -1
- package/types/core/geom.d.ts +6 -0
- package/types/core/io.d.ts +17 -3
- package/types/core/model/graph.d.ts +6 -2
- package/types/core/model/group-template.d.ts +4 -2
- package/types/core/params.d.ts +4 -4
- package/types/core/rtree/definitions.d.ts +5 -5
- package/types/core/rtree/rtree.d.ts +2 -2
- package/types/core/rtree/util.d.ts +2 -1
- package/types/core/toolkit.d.ts +7 -3
- package/types/test-support/test-support.d.ts +45 -1
- package/types/ui/common/anchor.d.ts +0 -4
- package/types/ui/common/overlay.d.ts +13 -1
- package/types/ui/core/constants.d.ts +24 -0
- package/types/ui/core/core.d.ts +40 -8
- package/types/ui/core/definitions.d.ts +12 -5
- package/types/ui/core/factory/anchor-record-factory.d.ts +6 -1
- package/types/ui/core/type-descriptors.d.ts +2 -2
- package/types/ui/core/view/group-options.d.ts +4 -0
- package/types/version.d.ts +1 -1
|
@@ -62,5 +62,6 @@ export declare class Paper extends BrowserUI {
|
|
|
62
62
|
zoomOut(canvasLoc?: PointXY): void;
|
|
63
63
|
zoomIn(canvasLoc?: PointXY): void;
|
|
64
64
|
getVisibleCanvasBounds(): RectangleXY;
|
|
65
|
+
$isConsideredCanvasEvent(e: MouseEvent): boolean;
|
|
65
66
|
}
|
|
66
67
|
export declare function createPaper(container: BrowserElement, options?: PaperOptions, modelOptions?: ModelOptions, data?: any): Paper;
|
|
@@ -14,6 +14,11 @@ export declare const ATTRIBUTE_TRANSFORM = "transform";
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function getElementSize(el: Element): Size;
|
|
16
16
|
export declare function getPosition(el: BrowserElement, knownElementSize?: Size): PointXY;
|
|
17
|
+
/**
|
|
18
|
+
* If the given point p is not null and neither p.x nor p.y are NaN, returns p. Otherwise, returns a point with x and y both set to 0.
|
|
19
|
+
* @param p
|
|
20
|
+
*/
|
|
21
|
+
export declare function nullSafePoint(p: PointXY): PointXY;
|
|
17
22
|
export declare function setPosition(el: BrowserElement, p: PointXY): void;
|
|
18
23
|
/**
|
|
19
24
|
* Gets the position of an element relative to the some other SVG,
|
|
@@ -41,6 +41,10 @@ export interface ShapeType {
|
|
|
41
41
|
* Label to use for the shape type when displayed in a palette
|
|
42
42
|
*/
|
|
43
43
|
label?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional label padding when labels are top/bottom to use for this shape type. The shape library will default to any labelPadding set on the shape set, or the system default.
|
|
46
|
+
*/
|
|
47
|
+
labelPadding?: number;
|
|
44
48
|
/**
|
|
45
49
|
* Can be shown in a palette to give a user more information about a shape
|
|
46
50
|
*/
|
|
@@ -79,8 +83,7 @@ export interface ShapeType {
|
|
|
79
83
|
*/
|
|
80
84
|
icon?: string;
|
|
81
85
|
/**
|
|
82
|
-
* A list of configurable properties exposed by this shape's template.
|
|
83
|
-
* An inspector can read this array to automatically generate an editing UI.
|
|
86
|
+
* A list of configurable properties exposed by this shape's template. An inspector can read this array to automatically generate an editing UI.
|
|
84
87
|
*/
|
|
85
88
|
properties?: Array<ShapePropertyDefinition>;
|
|
86
89
|
/**
|
|
@@ -92,14 +95,19 @@ export interface ShapeType {
|
|
|
92
95
|
*/
|
|
93
96
|
labelPosition?: LabelPosition;
|
|
94
97
|
/**
|
|
95
|
-
*
|
|
98
|
+
* Optional name of the group to which the shape belongs. This is not the same concept as a "group" inside the data model: this is a grouping of shape types, used to organise them in the UI.
|
|
96
99
|
*/
|
|
97
100
|
group?: string;
|
|
98
101
|
/**
|
|
99
|
-
* Optional blueprint for child vertices and edges to be created when this group is added.
|
|
100
|
-
* Only relevant when objectType is Group.
|
|
102
|
+
* Optional blueprint for child vertices and edges to be created when this group is added. Only relevant when objectType is Group.
|
|
101
103
|
*/
|
|
102
104
|
members?: GroupTemplate;
|
|
105
|
+
/**
|
|
106
|
+
* For groups, indicates that the group is locked and no edits can occur to the child vertices. This is intended for use with the `members` option, for groups that gather a set of elements together to form a more complex building block. As an example in the real world, consider a Binary Adder: it is a group of logic gates whose relationships are fixed.
|
|
107
|
+
*/
|
|
108
|
+
locked?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface RealisedShapeType extends ShapeType {
|
|
103
111
|
}
|
|
104
112
|
/**
|
|
105
113
|
* Start placement for shape icon - in x axis this means the left; in y axis it means the top.
|
|
@@ -137,6 +145,10 @@ export interface ShapeSet {
|
|
|
137
145
|
icons?: Array<IconDefinition>;
|
|
138
146
|
defs?: Record<string, string>;
|
|
139
147
|
children?: Array<ShapeSet>;
|
|
148
|
+
/**
|
|
149
|
+
* Optional label padding when labels are top/bottom to use as a default for all shapes. Individual shapes can set their own values. This defaults to 10 pixels.
|
|
150
|
+
*/
|
|
151
|
+
labelPadding?: number;
|
|
140
152
|
/**
|
|
141
153
|
* A list of configurable properties exposed by shapes in this set.
|
|
142
154
|
*/
|
|
@@ -148,14 +160,15 @@ export interface ShapeSet {
|
|
|
148
160
|
export interface RenderedShapeSet extends ShapeSet {
|
|
149
161
|
children: Array<RenderedShapeSet>;
|
|
150
162
|
parent?: string;
|
|
163
|
+
shapes: Array<RealisedShapeType>;
|
|
151
164
|
}
|
|
152
165
|
/**
|
|
153
166
|
* Defines a library that acts as a factory for shapes.
|
|
154
167
|
* @internal
|
|
155
168
|
*/
|
|
156
169
|
export interface ShapeLibrary<T extends ObjectData> {
|
|
157
|
-
$getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string):
|
|
158
|
-
getShapeDefinition(type: string, set?: string):
|
|
170
|
+
$getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): RealisedShapeType;
|
|
171
|
+
getShapeDefinition(type: string, set?: string): RealisedShapeType;
|
|
159
172
|
renderCompiledShape(data: T, strokeWidth?: number): BrowserElement;
|
|
160
173
|
renderShapeLabel(data: ObjectData, labelProperty: string, strokeWidth: string, label: string, fill: string, stroke: string, font: FontSpec): SVGTextElement;
|
|
161
174
|
getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string): CustomTagOptions;
|
|
@@ -250,9 +263,16 @@ export interface ShapePropertyDefinition {
|
|
|
250
263
|
*/
|
|
251
264
|
description?: string;
|
|
252
265
|
/**
|
|
253
|
-
* For "number" types, optional min
|
|
266
|
+
* For "number" types, optional min constraints.
|
|
254
267
|
*/
|
|
255
268
|
min?: number;
|
|
269
|
+
/**
|
|
270
|
+
* For "number" types, optional max constraints.
|
|
271
|
+
*/
|
|
256
272
|
max?: number;
|
|
273
|
+
/**
|
|
274
|
+
* Optional set of values to pick current value from
|
|
275
|
+
*/
|
|
276
|
+
values?: Array<any>;
|
|
257
277
|
}
|
|
258
278
|
export type LabelPosition = "top" | "bottom" | "center";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet,
|
|
1
|
+
import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet, LabelPosition, RealisedShapeType } from "./shape-library-definitions";
|
|
2
2
|
import { BrowserElement } from "../util";
|
|
3
3
|
import { CustomTagOptions, Recado, AbstractEntry, ObjectData } from "../../core";
|
|
4
4
|
import { IconDefinition } from "../icons";
|
|
@@ -187,12 +187,12 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
|
|
|
187
187
|
* @param type
|
|
188
188
|
* @param set
|
|
189
189
|
*/
|
|
190
|
-
getShapeDefinition(type: string, set?: string):
|
|
190
|
+
getShapeDefinition(type: string, set?: string): RealisedShapeType;
|
|
191
191
|
/**
|
|
192
192
|
* Gets the definition for some data object, using the default type/category parameters, or specific ones that you supply. May return null.
|
|
193
193
|
* @internal
|
|
194
194
|
*/
|
|
195
|
-
$getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string):
|
|
195
|
+
$getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): RealisedShapeType;
|
|
196
196
|
/**
|
|
197
197
|
* Gets the template for the given shape type in the given set. If no template is resolved then we return
|
|
198
198
|
* DEFAULT_TEMPLATE (and log the issue to the console).
|
|
@@ -54,6 +54,14 @@ export declare const CLASS_PALETTE_SET_TITLE = "vjs-shape-library-palette-set-ti
|
|
|
54
54
|
* @category CSS Classes
|
|
55
55
|
*/
|
|
56
56
|
export declare const CLASS_PALETTE_SET_SHAPES = "vjs-shape-library-palette-set-shapes";
|
|
57
|
+
/**
|
|
58
|
+
* Assigned to a group title element in the shape palette.
|
|
59
|
+
* @cssClass
|
|
60
|
+
* @context shapePalette
|
|
61
|
+
* @group Diagrams
|
|
62
|
+
* @category CSS Classes
|
|
63
|
+
*/
|
|
64
|
+
export declare const CLASS_PALETTE_SET_SHAPE_GROUP_TITLE = "vjs-shape-library-palette-shape-group-title";
|
|
57
65
|
/**
|
|
58
66
|
* When in `tap` mode, this class is added to the lasso used to draw new vertices
|
|
59
67
|
* @cssClass
|
|
@@ -4,13 +4,12 @@ import { DiagramCell } from "./diagram-cell";
|
|
|
4
4
|
import { GridOptions, UIExportOptions, UICoreDefaults, EdgeEventOptions, OverlaySpec, ConnectorSpec, NodeEventOptions, GroupMapping, NodeMapping, AnchorSpec, EdgePropertyMappings, MagnetizeOptions, PaintStyle, OverlayVisibility, EdgeDeleteConfirmationFunction } from "../../../ui";
|
|
5
5
|
import { SurfaceSaveData } from "../definitions";
|
|
6
6
|
import { BrowserElement } from "../../util";
|
|
7
|
-
import { PaletteMode } from "../../components/palette/palette-options";
|
|
7
|
+
import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../../components/palette/palette-options";
|
|
8
8
|
import { PanOptions, WheelOptions, ZoomOptions } from "../../pan-zoom-options";
|
|
9
9
|
import { MiniviewPluginOptions, LassoPluginOptions, ResizingToolsModelUpdater, ResizingToolsHandlerFactory, DragGroupsPluginOptions, ResizingToolsResizeMethod, SnaplinesPluginOptions, PanButtonsPluginOptions, LineCrossingsPluginOptions } from "../plugins";
|
|
10
|
-
import { EdgeSnapOptions } from "../../edge-handler-base";
|
|
10
|
+
import { EdgeSnapOptions, EdgeInputMethod } from "../../edge-handler-base";
|
|
11
11
|
import { DiagramActionMediator } from "./mediator";
|
|
12
12
|
import { OnVertexAddedCallback, FontSpec } from "../../definitions";
|
|
13
|
-
import { EdgeInputMethod } from "../../edge-input-handler";
|
|
14
13
|
import { PreparedShape } from "../shape-palette-options";
|
|
15
14
|
/**
|
|
16
15
|
* Options for the {@link Diagram.addLink method}
|
|
@@ -66,6 +65,14 @@ export interface DiagramOptions {
|
|
|
66
65
|
* Defaults to true, meaning the user can edit the diagram.
|
|
67
66
|
*/
|
|
68
67
|
editable?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether or not to allow rotation of elements being dragged from the palette. Defaults to true.
|
|
70
|
+
*/
|
|
71
|
+
allowRotation?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
|
|
74
|
+
*/
|
|
75
|
+
rotationSpeed?: number;
|
|
69
76
|
edges?: {
|
|
70
77
|
/**
|
|
71
78
|
* Whether or not to disable drop targets on which an edge from some current source may not be dropped when drag starts. Defaults to true.
|
|
@@ -459,9 +466,14 @@ export interface DiagramPaletteOptions {
|
|
|
459
466
|
*/
|
|
460
467
|
dragSize?: Size;
|
|
461
468
|
/**
|
|
462
|
-
*
|
|
469
|
+
* When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
|
|
463
470
|
*/
|
|
464
471
|
inspector?: boolean;
|
|
472
|
+
/**
|
|
473
|
+
* When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`.
|
|
474
|
+
* This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
|
|
475
|
+
*/
|
|
476
|
+
updateTypeOnPaletteTap?: boolean;
|
|
465
477
|
/**
|
|
466
478
|
* Optional size to use for icons. Defaults to 150x100 pixels. If you provide this but not `dragSize` this size will also be used for an icon that is being dragged.
|
|
467
479
|
*/
|
|
@@ -495,6 +507,15 @@ export interface DiagramPaletteOptions {
|
|
|
495
507
|
* Defaults to true: when in 'tap' mode and a new group/node has been drawn on the canvas, the UI is set back to pan mode.
|
|
496
508
|
*/
|
|
497
509
|
autoExitDrawMode?: boolean;
|
|
510
|
+
/**
|
|
511
|
+
* If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
|
|
512
|
+
*/
|
|
513
|
+
allowDropOnEdge?: boolean | CanDropOnEdgeFilter<BrowserElement>;
|
|
514
|
+
/**
|
|
515
|
+
* If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
|
|
516
|
+
* @advanced
|
|
517
|
+
*/
|
|
518
|
+
connectToPortsOnEdgeDrop?: boolean;
|
|
498
519
|
/**
|
|
499
520
|
* When true (which is the default), a newly dropped shape will be set as the underlying model's selection.
|
|
500
521
|
*/
|
|
@@ -515,6 +536,22 @@ export interface DiagramPaletteOptions {
|
|
|
515
536
|
* Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
|
|
516
537
|
*/
|
|
517
538
|
preparedShapes?: Array<PreparedShape>;
|
|
539
|
+
/**
|
|
540
|
+
* Whether or not to allow rotation of elements being dragged. Defaults to true.
|
|
541
|
+
*/
|
|
542
|
+
allowRotation?: boolean;
|
|
543
|
+
/**
|
|
544
|
+
* The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
|
|
545
|
+
*/
|
|
546
|
+
rotationSpeed?: number;
|
|
547
|
+
/**
|
|
548
|
+
* Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
|
|
549
|
+
*/
|
|
550
|
+
autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
|
|
551
|
+
/**
|
|
552
|
+
* Whether or not to show groups in the palette. Defaults to true.
|
|
553
|
+
*/
|
|
554
|
+
showGroups?: boolean;
|
|
518
555
|
}
|
|
519
556
|
/**
|
|
520
557
|
* Save options for a Diagram
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ObjectData, PriorityQueue, SaveOptions, ModelOptions, Edge } from "../../../core";
|
|
1
|
+
import { Group, ObjectData, PriorityQueue, SaveOptions, ModelOptions, Edge } from "../../../core";
|
|
2
2
|
import { PropertyTracker, ZoomToFitOptions, ZoomToFitIfNecessaryOptions } from "../../../ui";
|
|
3
3
|
import { BrowserElement } from "../../util";
|
|
4
4
|
import { BrowserUIModel } from "../../browser-ui";
|
|
@@ -204,6 +204,16 @@ export declare class Diagram {
|
|
|
204
204
|
* @tags zoom
|
|
205
205
|
*/
|
|
206
206
|
zoomToFitIfNecessary(params?: ZoomToFitIfNecessaryOptions): void;
|
|
207
|
+
/**
|
|
208
|
+
* Mark a group as "locked" : edges inside of it cannot be detached, removed or have their paths edited, edges cannot be established to child vertices.
|
|
209
|
+
* @param groupIdOrGroup
|
|
210
|
+
*/
|
|
211
|
+
lockGroup(groupOrGroupId: string | Group): void;
|
|
212
|
+
/**
|
|
213
|
+
* Unlock a group
|
|
214
|
+
* @param groupOrGroupId
|
|
215
|
+
*/
|
|
216
|
+
unlockGroup(groupOrGroupId: string | Group): void;
|
|
207
217
|
}
|
|
208
218
|
/**
|
|
209
219
|
* Create a new DiagramPalette in the given container element, and attach it to the given Diagram.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Group,
|
|
1
|
+
import { Group, Node, ObjectData, Size } from "../../../core";
|
|
2
2
|
import { ShapeType } from "../../shape-library";
|
|
3
3
|
import { BrowserElement } from "../../util";
|
|
4
4
|
/**
|
|
@@ -13,42 +13,42 @@ export interface DiagramActionMediator {
|
|
|
13
13
|
* @param shape
|
|
14
14
|
* @param el
|
|
15
15
|
*/
|
|
16
|
-
canClone?: (v:
|
|
16
|
+
canClone?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
|
|
17
17
|
/**
|
|
18
18
|
* Returns whether or not the given vertex should be deletable in the UI. Defaults to true, meaning the delete icon will be present in the diagram tools when the vertex is selected.
|
|
19
19
|
* @param v
|
|
20
20
|
* @param shape
|
|
21
21
|
* @param el
|
|
22
22
|
*/
|
|
23
|
-
canDelete?: (v:
|
|
23
|
+
canDelete?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
|
|
24
24
|
/**
|
|
25
25
|
* Returns whether or not the given vertex should be linkable via edge drag in the UI. Defaults to true, meaning the link icon will be present in the diagram tools when the vertex is selected.
|
|
26
26
|
* @param v
|
|
27
27
|
* @param shape
|
|
28
28
|
* @param el
|
|
29
29
|
*/
|
|
30
|
-
canLink?: (v:
|
|
30
|
+
canLink?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the resize handles will be present in the diagram tools when the vertex is selected.
|
|
33
33
|
* @param v
|
|
34
34
|
* @param shape
|
|
35
35
|
* @param el
|
|
36
36
|
*/
|
|
37
|
-
canResize?: (v:
|
|
37
|
+
canResize?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
|
|
38
38
|
/**
|
|
39
39
|
* Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the rotate handle and leader will be present in the diagram tools when the vertex is selected.
|
|
40
40
|
* @param v
|
|
41
41
|
* @param shape
|
|
42
42
|
* @param el
|
|
43
43
|
*/
|
|
44
|
-
canRotate?: (v:
|
|
44
|
+
canRotate?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Returns whether or not the given vertex should be draggable in the UI. Defaults to true.
|
|
47
47
|
* @param v
|
|
48
48
|
* @param shape
|
|
49
49
|
* @param el
|
|
50
50
|
*/
|
|
51
|
-
canDrag?: (v:
|
|
51
|
+
canDrag?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Returns whether or not the given vertex should be droppable on the given target, which may either be another vertex (if `targetVertex` is set), or the diagram canvas (if `isOnCanvas` is set). This method will never be called with both `targetVertex` set an `isOnCanvas` true - it's one or the other.
|
|
54
54
|
* @param v
|
|
@@ -53,7 +53,7 @@ export declare class Lasso {
|
|
|
53
53
|
visibleOrigin: PointXY;
|
|
54
54
|
size: Size;
|
|
55
55
|
_generateLassoContent: (origin: PointXY, e: MouseEvent) => BrowserElement;
|
|
56
|
-
el:
|
|
56
|
+
el: BrowserElement;
|
|
57
57
|
_extentTrackerEl: BrowserElement;
|
|
58
58
|
masks: Record<string, HTMLElement>;
|
|
59
59
|
origin: PointXY;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Grid,
|
|
1
|
+
import { ResizeDirection, ResizeHandler, ResizingToolsPluginOptions } from "./definitions";
|
|
2
|
+
import { Grid, Group, Node, ObjectData, PointXY, Size, Vertex, VertexUpdatedReason, VisuallyJsModel } from "../../../../core";
|
|
3
3
|
import { Surface } from "../../surface";
|
|
4
4
|
import { BrowserElement } from "../../../util";
|
|
5
|
-
import {
|
|
5
|
+
import { GroupContentAreaInfo, GroupMapping, GroupResizeResult, ViewportElement, ViewportGroupElement } from "../../../../ui";
|
|
6
6
|
import { BaseBrowserUIPlugin, BrowserUIPlugin } from "../../../plugins";
|
|
7
7
|
import { ElasticGroupManager } from "../../elastic-group-manager";
|
|
8
8
|
/**
|
|
@@ -108,6 +108,7 @@ export declare class ResizingToolsPlugin extends BaseBrowserUIPlugin implements
|
|
|
108
108
|
destroy(): void;
|
|
109
109
|
_handleDragHandlers: Record<string, ResizeHandler>;
|
|
110
110
|
_borderDragHandlers: Record<string, ResizeHandler>;
|
|
111
|
+
$getRotationStopsArray(): Array<number>;
|
|
111
112
|
initialise(surface: Surface, options: ResizingToolsPluginOptions): boolean;
|
|
112
113
|
private _configureGroupParent;
|
|
113
114
|
private _handleMouseDown;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Group, ObjectData, Size, Node } from "../../core";
|
|
2
2
|
import { ShapeLibrary } from "../shape-library";
|
|
3
3
|
import { DataGeneratorFunction, OnVertexAddedCallback } from "../definitions";
|
|
4
|
-
import { PaletteMode } from "../components";
|
|
4
|
+
import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../components";
|
|
5
5
|
/**
|
|
6
6
|
* Options for a shape palette.
|
|
7
7
|
* @group Components
|
|
@@ -41,9 +41,13 @@ export interface ShapePaletteOptions<T extends ObjectData> {
|
|
|
41
41
|
*/
|
|
42
42
|
selectAfterDrop?: boolean;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
|
|
45
45
|
*/
|
|
46
46
|
inspector?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`. This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
|
|
49
|
+
*/
|
|
50
|
+
updateTypeOnPaletteTap?: boolean;
|
|
47
51
|
/**
|
|
48
52
|
* Stroke width to use for shapes in palette. Defaults to 1.
|
|
49
53
|
*/
|
|
@@ -95,12 +99,36 @@ export interface ShapePaletteOptions<T extends ObjectData> {
|
|
|
95
99
|
* Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
|
|
96
100
|
*/
|
|
97
101
|
preparedShapes?: Array<PreparedShape>;
|
|
102
|
+
/**
|
|
103
|
+
* If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
|
|
104
|
+
*/
|
|
105
|
+
allowDropOnEdge?: boolean | CanDropOnEdgeFilter<T>;
|
|
106
|
+
/**`
|
|
107
|
+
* If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
|
|
108
|
+
* @advanced
|
|
109
|
+
*/
|
|
110
|
+
connectToPortsOnEdgeDrop?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Whether or not to allow rotation of elements being dragged. Defaults to true.
|
|
113
|
+
*/
|
|
114
|
+
allowRotation?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
|
|
117
|
+
*/
|
|
118
|
+
rotationSpeed?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
|
|
121
|
+
*/
|
|
122
|
+
autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
|
|
123
|
+
/**
|
|
124
|
+
* Whether or not to show groups in the palette. Defaults to true.
|
|
125
|
+
*/
|
|
126
|
+
showGroups?: boolean;
|
|
98
127
|
}
|
|
99
128
|
/**
|
|
100
129
|
* Defines a wrapper around a shape with some `type` and `category` that adds properties (to be used to define the shape's appearance) and, optionally, the shape's initial size.
|
|
101
130
|
* @group Components
|
|
102
131
|
* @category Shape Palette
|
|
103
|
-
* @internal
|
|
104
132
|
*/
|
|
105
133
|
export interface PreparedShape {
|
|
106
134
|
/**
|
|
@@ -9,7 +9,6 @@ import { Base, Node, Group, Edge, Port, Vertex, ObjectData, VisuallyJsSelection,
|
|
|
9
9
|
import { Connection, SupportsElementDragging, DragOptions, Overlay, ViewportBounds, UIExportOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions, ZoomToElementsOptions, ViewportNodeElement, ViewportElement, ViewportGroupElement, CenterContentOptions, AlignContentOptions, AlignContentToFaceOptions, CenterContentHorizontallyOptions, CenterContentVerticallyOptions, VertexDragFilter } from "../../ui";
|
|
10
10
|
import { BrowserUI } from "../browser-visuallyjs-instance";
|
|
11
11
|
import { BrowserElement } from "../util";
|
|
12
|
-
import { EdgeInputMethod } from "../edge-input-handler";
|
|
13
12
|
import { ModelEventCallback, SurfaceEvents, SurfaceMode, SurfaceSaveData, SurfaceVertexCloneOptions } from "./definitions";
|
|
14
13
|
import { EdgePathEditor } from "../connector-editors";
|
|
15
14
|
import { ConnectorEditorActivateParams } from "../connector-editor";
|
|
@@ -17,6 +16,7 @@ import { ElementDragHandler2, InternalDragGroupSpec } from "../element-drag-hand
|
|
|
17
16
|
import { Background, DragGroupSpec, SupportsPathEditing, SupportsViewportManipulation, ZoomToExtentsOptions } from "../definitions";
|
|
18
17
|
import { BrowserUIModel } from "../browser-ui";
|
|
19
18
|
import { MiniviewPluginOptions } from "./plugins";
|
|
19
|
+
import { EdgeInputMethod } from "../edge-handler-base";
|
|
20
20
|
/**
|
|
21
21
|
* Provides a canvas on which nodes, groups and edges can be rendered, with support for pan/zoom, layouts and various plugins. This is not a class that API users should instantiate directly: for users of a library integration, a Surface will be created internally by the appropriate component; for users of vanilla VisuallyJs, a Surface is created either via the {@link createSurface} factory method, or via a `render` call on an instance of the {@link BrowserUIModel}.
|
|
22
22
|
* @group Components
|
|
@@ -72,6 +72,14 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
|
|
|
72
72
|
* @internal
|
|
73
73
|
*/
|
|
74
74
|
$groupRemoved(deletion: GroupRemovedParams): ViewportGroupElement<BrowserElement>;
|
|
75
|
+
/**
|
|
76
|
+
* Returns whether or not the given event is considered for all practical reasons to have occurred on the surface canvas. Tests if the event target is the surface root or canvas element, or if the panZoom considers it to be a background element.
|
|
77
|
+
*
|
|
78
|
+
* This method is used when deciding to fire a canvas click event, and also by the lasso, to make the decision to switch to auto arm.
|
|
79
|
+
* @internal
|
|
80
|
+
* @param e
|
|
81
|
+
*/
|
|
82
|
+
$isConsideredCanvasEvent(e: MouseEvent): boolean;
|
|
75
83
|
/**
|
|
76
84
|
* @internal
|
|
77
85
|
*/
|
|
@@ -271,6 +279,12 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
|
|
|
271
279
|
* @param els Elements to remove from drag groups.
|
|
272
280
|
*/
|
|
273
281
|
removeFromDragGroup(...els: Array<string | BrowserElement | Node | Group>): void;
|
|
282
|
+
/**
|
|
283
|
+
* Remove the given viewport element from a drag group it may be in. This method can be invoked after an element has been removed and it has no managed element tracked anymore, so internal invocations go through this method rather than the one above.
|
|
284
|
+
* @param vel
|
|
285
|
+
* @private
|
|
286
|
+
*/
|
|
287
|
+
private _removeFromDragGroup;
|
|
274
288
|
/**
|
|
275
289
|
* Sets the active/passive state for the given element(s) in their respective drag groups (if any). You don't need to supply the drag group id, as elements can only be in one drag group anyway.
|
|
276
290
|
* @param state true for active, false for passive.
|
|
@@ -38,7 +38,7 @@ export interface DataSource extends FilterableDataset {
|
|
|
38
38
|
getPortType(port: ObjectData): string;
|
|
39
39
|
getPortId(port: ObjectData): string;
|
|
40
40
|
getDescendants(vertex: Group): Array<Node | Group>;
|
|
41
|
-
getAncestors(vertex:
|
|
41
|
+
getAncestors(vertex: Vertex): Array<Group>;
|
|
42
42
|
isAncestor(focus: Node | Group, possibleAncestor: Group): boolean;
|
|
43
43
|
isDescendantGroup(possibleDescendant: Group, ancestor: Group): boolean;
|
|
44
44
|
getEdgeCount(): number;
|
package/types/core/geom.d.ts
CHANGED
|
@@ -310,6 +310,12 @@ export declare function clampAngle(angle: number): number;
|
|
|
310
310
|
export interface RotatedRectangle extends RectangleXY {
|
|
311
311
|
r?: number;
|
|
312
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Returns the four corner points of a rotated rectangle.
|
|
315
|
+
* @param rect The rotated rectangle.
|
|
316
|
+
* @returns An array of four PointXY objects representing the corners.
|
|
317
|
+
*/
|
|
318
|
+
export declare function getRotatedCorners(rect: RotatedRectangle): PointXY[];
|
|
313
319
|
/**
|
|
314
320
|
* Determines if two rotated rectangles intersect using the Separating Axis Theorem (SAT).
|
|
315
321
|
* @param r1 The first rotated rectangle.
|
package/types/core/io.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type Parser = (data: any, instance: VisuallyJsModel, parameters?: any) =>
|
|
|
29
29
|
*/
|
|
30
30
|
export type Exporter = (instance: VisuallyJsModel, parameters: any) => any;
|
|
31
31
|
/**
|
|
32
|
-
* The default type that represents an edge in a dataset to load or a saved dataset
|
|
32
|
+
* The default type that represents an edge in a dataset to load or a saved dataset. Edges differ slightly from nodes and groups in that there are fields which are mandatory: `source` and `data`. Edges also differ from nodes and groups in that any backing data for an edge (including its `id` and/or `type`) need to be provided in the `data` member of the edge, not in the root as with nodes and groups.
|
|
33
33
|
* @group Model
|
|
34
34
|
*/
|
|
35
35
|
export interface EdgeData {
|
|
@@ -66,12 +66,12 @@ export interface EdgeData {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* The default type that represents a node in a dataset to load or a saved dataset
|
|
69
|
+
* The default type that represents a node in a dataset to load or a saved dataset. While there are no specific requirements for the entries in node data, the default configuration expects that you will at the minimum have provided an `id`. Nodes have an associated `type`, which VisuallyJs will set to "default" in the absence of you providing one; as you start to build more complex interfaces with VisuallyJs you will want to provide the `type` member.
|
|
70
70
|
* @group Data Model
|
|
71
71
|
*/
|
|
72
72
|
export type NodeData = Record<string, any>;
|
|
73
73
|
/**
|
|
74
|
-
* The default type that represents a group in a dataset to load or a saved dataset
|
|
74
|
+
* The default type that represents a group in a dataset to load or a saved dataset. While there are no specific requirements for the entries in groups data, the default configuration expects that you will at the minimum have provided an `id`. Groups have an associated `type`, which VisuallyJs will set to "default" in the absence of you providing one; as you start to build more complex interfaces with VisuallyJs you will want to provide the `type` member.
|
|
75
75
|
* @group Data Model
|
|
76
76
|
*/
|
|
77
77
|
export type GroupData = Record<string, any>;
|
|
@@ -94,6 +94,20 @@ export interface VisuallyJsDefaultJSON {
|
|
|
94
94
|
*/
|
|
95
95
|
groups?: Array<GroupData>;
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* An entry in the hierarchical json format.
|
|
99
|
+
* @group Data Model
|
|
100
|
+
* @category Input and Output
|
|
101
|
+
*/
|
|
102
|
+
export interface VisuallyJsHierarchicalJSONEntry extends ObjectData {
|
|
103
|
+
children?: Array<VisuallyJsHierarchicalJSONEntry>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The Hierarchical JSON format. Consists of a single root entry, which has a children array, each of which may have children, etc.
|
|
107
|
+
* @group Data Model
|
|
108
|
+
* @category Input and Output
|
|
109
|
+
*/
|
|
110
|
+
export type VisuallyJsHierarchicalJSON = VisuallyJsHierarchicalJSONEntry;
|
|
97
111
|
/**
|
|
98
112
|
* Defines the default JSON datatype
|
|
99
113
|
*/
|
|
@@ -202,8 +202,8 @@ export interface InternalAddEdgeOptions {
|
|
|
202
202
|
directed?: boolean;
|
|
203
203
|
transient?: boolean;
|
|
204
204
|
anchors?: {
|
|
205
|
-
source?:
|
|
206
|
-
target?:
|
|
205
|
+
source?: any;
|
|
206
|
+
target?: any;
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
@@ -1045,6 +1045,10 @@ export declare class Group extends Node {
|
|
|
1045
1045
|
* @internal
|
|
1046
1046
|
*/
|
|
1047
1047
|
_memberMap: Record<string, Node>;
|
|
1048
|
+
/**
|
|
1049
|
+
* @internal
|
|
1050
|
+
*/
|
|
1051
|
+
locked: boolean;
|
|
1048
1052
|
constructor(graph: Graph, data?: any, idFunction?: IdFunction);
|
|
1049
1053
|
/**
|
|
1050
1054
|
* @internal
|
|
@@ -8,8 +8,10 @@ export interface GroupTemplate {
|
|
|
8
8
|
groupTemplate?: string | GroupTemplate;
|
|
9
9
|
}>;
|
|
10
10
|
edges?: Array<{
|
|
11
|
-
source
|
|
12
|
-
|
|
11
|
+
source?: string;
|
|
12
|
+
sourcePort?: string;
|
|
13
|
+
target?: string;
|
|
14
|
+
targetPort?: string;
|
|
13
15
|
data?: ObjectData;
|
|
14
16
|
}>;
|
|
15
17
|
}
|
package/types/core/params.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { VisuallyJsRenderer } from "./renderer";
|
|
|
3
3
|
import { PointXY } from "./util";
|
|
4
4
|
import { EdgeUpdatedReason, VertexUpdatedReason } from "./toolkit";
|
|
5
5
|
import { VisuallyJsSelection } from "./selection";
|
|
6
|
-
import {
|
|
6
|
+
import { LineStyle, SingleAnchorSpec } from "../ui";
|
|
7
7
|
/**
|
|
8
8
|
* Defines the payload for a node added event.
|
|
9
9
|
* @group Events
|
|
@@ -495,7 +495,7 @@ export interface AddEdgeOptions {
|
|
|
495
495
|
/**
|
|
496
496
|
* Optional backing data for the edge.
|
|
497
497
|
*/
|
|
498
|
-
data?:
|
|
498
|
+
data?: ObjectData & LineStyle;
|
|
499
499
|
/**
|
|
500
500
|
* Optional edge cost. Defaults to 1.
|
|
501
501
|
*/
|
|
@@ -512,7 +512,7 @@ export interface AddEdgeOptions {
|
|
|
512
512
|
* Optional anchors for the edge.
|
|
513
513
|
*/
|
|
514
514
|
anchors?: {
|
|
515
|
-
source?:
|
|
516
|
-
target?:
|
|
515
|
+
source?: SingleAnchorSpec;
|
|
516
|
+
target?: SingleAnchorSpec;
|
|
517
517
|
};
|
|
518
518
|
}
|
|
@@ -4,10 +4,10 @@ import { RectangleXY } from "../util";
|
|
|
4
4
|
* Base region used by RTree
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export interface RTreeRegion extends RectangleXY {
|
|
8
|
-
data?:
|
|
9
|
-
children: Array<RTreeRegion
|
|
10
|
-
parent?: RTreeRegion
|
|
7
|
+
export interface RTreeRegion<DataPayload extends ObjectData = ObjectData> extends RectangleXY {
|
|
8
|
+
data?: DataPayload;
|
|
9
|
+
children: Array<RTreeRegion<DataPayload>>;
|
|
10
|
+
parent?: RTreeRegion<DataPayload>;
|
|
11
11
|
id?: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -19,6 +19,6 @@ export declare const RTREE_DEFAULT_MAX_CHILD_ENTRIES = 4;
|
|
|
19
19
|
* A data node in an RTree
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
export interface RTreeDataNode extends RTreeRegion {
|
|
22
|
+
export interface RTreeDataNode<DataPayload extends ObjectData = ObjectData> extends RTreeRegion<DataPayload> {
|
|
23
23
|
id: string;
|
|
24
24
|
}
|
|
@@ -23,7 +23,7 @@ export interface RTreeSearchOptions {
|
|
|
23
23
|
* An RTree. Used internally to facilitate fast spatial querying.
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
|
-
export declare class RTree {
|
|
26
|
+
export declare class RTree<DataPayload extends ObjectData = ObjectData> {
|
|
27
27
|
private readonly _maxNodes;
|
|
28
28
|
private _root;
|
|
29
29
|
private _dataNodes;
|
|
@@ -33,7 +33,7 @@ export declare class RTree {
|
|
|
33
33
|
* @param searchBoundary
|
|
34
34
|
* @param options
|
|
35
35
|
*/
|
|
36
|
-
search(searchBoundary: RectangleXY, options?: RTreeSearchOptions): Array<RTreeDataNode
|
|
36
|
+
search(searchBoundary: RectangleXY, options?: RTreeSearchOptions): Array<RTreeDataNode<DataPayload>>;
|
|
37
37
|
/**
|
|
38
38
|
* Search the tree and find all entries that intersect the given rectangle, then rank them by the amount they overlap.
|
|
39
39
|
* @param searchBoundary
|