@visuallyjs/browser-ui 1.2.3 → 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 +6 -2
- package/types/browser-ui/pan-zoom.d.ts +4 -2
- 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-plugin.d.ts +8 -0
- package/types/browser-ui/surface-renderer/plugins/lasso/lasso.d.ts +19 -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 +23 -3
- package/types/core/layout/bowtie/bowtie-layout.d.ts +69 -0
- package/types/core/layout/bowtie/index.d.ts +1 -0
- package/types/core/layout/hierarchy/definitions.d.ts +2 -2
- package/types/core/layout/hierarchy/parent-relative-placement.d.ts +2 -2
- package/types/core/layout/index.d.ts +1 -0
- package/types/core/model/graph.d.ts +8 -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 +47 -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
package/package.json
CHANGED
|
@@ -4,13 +4,6 @@ import { PointXY } from "../core/util";
|
|
|
4
4
|
import { BrowserElement } from "./util";
|
|
5
5
|
import { ElementAttributes } from "./svg-util";
|
|
6
6
|
import { ElementType } from "../ui";
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
* @param el
|
|
10
|
-
* @param selector
|
|
11
|
-
* @param ctx
|
|
12
|
-
*/
|
|
13
|
-
export declare function matchesSelector(el: BrowserElement, selector: string, ctx?: BrowserElement): boolean;
|
|
14
7
|
/**
|
|
15
8
|
* Consume the given event, using `stopPropagation()` if present or `returnValue` if not, and optionally
|
|
16
9
|
* also calling `preventDefault()`.
|
|
@@ -569,6 +569,7 @@ export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement
|
|
|
569
569
|
* @internal
|
|
570
570
|
*/
|
|
571
571
|
$reRenderNode(n: Node): void;
|
|
572
|
+
$isGroupDefinedAsLocked(g: Group): boolean;
|
|
572
573
|
/**
|
|
573
574
|
* Renders the given group. For internal use.
|
|
574
575
|
* @param g
|
|
@@ -35,6 +35,14 @@ export declare const RESET_SELECTION_PATH = "M2,5 V2 H5 M9,2 H11 M13,2 H15 M19,2
|
|
|
35
35
|
export declare const CLEAR_VIEW_BOX = "0 0 24 24";
|
|
36
36
|
/** @internal */
|
|
37
37
|
export declare const CLEAR_PATH = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";
|
|
38
|
+
/** @internal */
|
|
39
|
+
export declare const UNDO_VIEW_BOX = "0 0 24 24";
|
|
40
|
+
/** @internal */
|
|
41
|
+
export declare const UNDO_PATH = "M3 7v6h6 M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13";
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare const REDO_VIEW_BOX = "0 0 24 24";
|
|
44
|
+
/** @internal */
|
|
45
|
+
export declare const REDO_PATH = "M21 7v6h-6 M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13";
|
|
38
46
|
export declare const ZOOM_IN_OUT_VIEW_BOX = "0 0 32 32";
|
|
39
47
|
export declare const ZOOM_IN_PATH = "M 13 6 L 13 20 M 6 13 L 20 13 M 22,22 L 30,30 M1, 13 a 12,12 0 1,0 24,0 a 12,12 0 1,0 -24,0";
|
|
40
48
|
export declare const ZOOM_OUT_PATH = "M 6 13 L 20 13 M 22,22 L 30,30 M1, 13 a 12,12 0 1,0 24,0 a 12,12 0 1,0 -24,0";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { RectangleXY, Edge, Vertex, Node, Port } from "../../../core";
|
|
2
|
+
import { BrowserElement } from "../../util";
|
|
3
|
+
import { Palette } from "./palette";
|
|
4
|
+
import { LineStyle, SingleAnchorSpec, UICore, ViewportNodeElement } from "../../../ui";
|
|
5
|
+
export type AutoConnectTerminus = {
|
|
6
|
+
el: BrowserElement;
|
|
7
|
+
portId: string | null;
|
|
8
|
+
vertex: Vertex;
|
|
9
|
+
resolvedPort: Port | null;
|
|
10
|
+
isSource: boolean;
|
|
11
|
+
edgeType: string;
|
|
12
|
+
scope: string;
|
|
13
|
+
anchor?: SingleAnchorSpec;
|
|
14
|
+
edge?: Edge;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An internal class to manage auto edge connect during a drag from the palette.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare class AutoEdgeConnectManager {
|
|
21
|
+
private ui;
|
|
22
|
+
private palette;
|
|
23
|
+
private activeClass;
|
|
24
|
+
private _autoSourceElementsRTree;
|
|
25
|
+
private _autoTargetElementsRTree;
|
|
26
|
+
private _proximitySources;
|
|
27
|
+
private _proximityTargets;
|
|
28
|
+
private _proximityThreshold;
|
|
29
|
+
private _canvasSourceElements;
|
|
30
|
+
private _canvasTargetElements;
|
|
31
|
+
private _focusSourceElements;
|
|
32
|
+
private _focusTargetElements;
|
|
33
|
+
_key: string;
|
|
34
|
+
_mode: "onDemand" | "eager";
|
|
35
|
+
_status: "primed" | "idle" | "active";
|
|
36
|
+
_lineStyle: LineStyle;
|
|
37
|
+
/**
|
|
38
|
+
* Edges created during a drag. At the end of the drag, if the new vertex is being retained, all of these edges need to be reconnected to the new vertex in the model - as part of a transaction. If the vertex is discarded, these edges all need to be removed (prior to removing the transient vertex)
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
private _transientEdges;
|
|
42
|
+
private _keyListener;
|
|
43
|
+
private _getSourceTargetElements;
|
|
44
|
+
constructor(ui: UICore<any>, palette: Palette<any>, activeClass: string, mode: "eager" | "onDemand", lineStyle: LineStyle, key: string);
|
|
45
|
+
private _clearProximityState;
|
|
46
|
+
private _toggleCssClasses;
|
|
47
|
+
private _setStatus;
|
|
48
|
+
begin(dragElement: BrowserElement, transientInfo: {
|
|
49
|
+
vertex: Node;
|
|
50
|
+
el: ViewportNodeElement<BrowserElement>;
|
|
51
|
+
}, nodesInViewport: Array<{
|
|
52
|
+
el: ViewportNodeElement<BrowserElement>;
|
|
53
|
+
bb: RectangleXY;
|
|
54
|
+
}>, groupsInViewport: Array<{
|
|
55
|
+
el: ViewportNodeElement<BrowserElement>;
|
|
56
|
+
bb: RectangleXY;
|
|
57
|
+
}>): void;
|
|
58
|
+
move(dragElementBoundingBox: RectangleXY): void;
|
|
59
|
+
reset(): void;
|
|
60
|
+
cleanupDrag(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Adds a transient edge, connected to `otherVertex` (which is a vertex on the canvas already) and to the current transient vertex which was created as the user began dragging a new vertex to the canvas. If there is no transient vertex this method does nothing, silently.
|
|
63
|
+
*
|
|
64
|
+
* The transient edge is pushed to the list of edges added since the latest operation began, and if the operation is not cancelled, will be converted to a concrete edge once the new vertex has been added to the canvas.
|
|
65
|
+
*
|
|
66
|
+
* @param otherVertex existing vertex in the model to connect to
|
|
67
|
+
* @param asSource Whether or not our transient vertex is the source of this edge
|
|
68
|
+
* @param portId Optional ID of the port the edge should end up attached to.
|
|
69
|
+
* @param anchor Optional anchor to use
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
private _addTransientEdge;
|
|
73
|
+
getEdges(): Array<Edge>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BrowserElement } from "../../util";
|
|
2
|
+
import { IntersectingObjectData } from "../../pan-zoom";
|
|
3
|
+
import { Edge, Group, Node } from "../../../core";
|
|
4
|
+
import { Connection, Connector, ViewportGroupElement, ViewportNodeElement } from "../../../ui";
|
|
5
|
+
/**
|
|
6
|
+
* NOTE: This interface inherits `r`, the bounding box, from `IntersectingObjectData`. In this class,
|
|
7
|
+
* `r` is in CANVAS coordinates (after a recent change from when it was originally in window coords)
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export interface CurrentNode extends IntersectingObjectData {
|
|
11
|
+
vertex: Node;
|
|
12
|
+
element: BrowserElement;
|
|
13
|
+
canDrop: boolean;
|
|
14
|
+
managedElement: ViewportNodeElement<BrowserElement>;
|
|
15
|
+
cssElement: BrowserElement;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* NOTE: This interface inherits `r`, the bounding box, from `IntersectingObjectData`. In this class,
|
|
19
|
+
* `r` is in CANVAS coordinates (after a recent change from when it was originally in window coords)
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export interface CurrentGroup extends IntersectingObjectData {
|
|
23
|
+
vertex: Group;
|
|
24
|
+
element: BrowserElement;
|
|
25
|
+
canDrop: boolean;
|
|
26
|
+
depth: number;
|
|
27
|
+
managedElement: ViewportGroupElement<BrowserElement>;
|
|
28
|
+
cssElement: BrowserElement;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* NOTE: This interface inherits `r`, the bounding box, from `IntersectingObjectData`. In this class,
|
|
32
|
+
* `r` is in _window_ coordinates. To convert to canvas coordinates you must
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export interface EdgeSpec extends IntersectingObjectData {
|
|
36
|
+
objectType: typeof Edge.objectType;
|
|
37
|
+
connection: Connection<BrowserElement>;
|
|
38
|
+
connector: Connector;
|
|
39
|
+
edge: Edge;
|
|
40
|
+
element: BrowserElement;
|
|
41
|
+
canDrop: boolean;
|
|
42
|
+
cssElement: BrowserElement;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The default CSS selector used with the Palette and the library integration wrappers around it
|
|
46
|
+
* @group Components
|
|
47
|
+
* @category Palette
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare const DEFAULT_PALETTE_SELECTOR = "[data-vjs-type]";
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { BrowserElement } from "../../util";
|
|
2
2
|
import { CanvasDropFilter, DataGeneratorFunction, DragFunction, GroupIdentifierFunction, OnVertexAddedCallback, TypeGeneratorFunction } from "../../definitions";
|
|
3
|
-
import { ObjectData, PointXY, Size, Node, Group } from "../../../core";
|
|
3
|
+
import { ObjectData, PointXY, Size, Node, Group, Vertex, Edge } from "../../../core";
|
|
4
|
+
import { LineStyle, SingleAnchorSpec } from "../../../ui";
|
|
4
5
|
export declare const PALETTE_MODE_DRAG = "drag";
|
|
5
6
|
export declare const PALETTE_MODE_TAP = "tap";
|
|
6
7
|
export declare const PALETTE_MODE_DRAW = "draw";
|
|
7
8
|
export type PaletteMode = typeof PALETTE_MODE_TAP | typeof PALETTE_MODE_DRAG | typeof PALETTE_MODE_DRAW;
|
|
9
|
+
export type CanDropOnEdgeFilter<T> = (d: T) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Defines the source/target port ids to use on a vertex dropped on an edge.
|
|
12
|
+
* @group Components
|
|
13
|
+
* @category Palette
|
|
14
|
+
*/
|
|
15
|
+
export type EdgeDropInfo = {
|
|
16
|
+
newEdgeSourcePortId?: string | null;
|
|
17
|
+
originalEdgeTargetPortId?: string | null;
|
|
18
|
+
sourceAnchor?: SingleAnchorSpec | null;
|
|
19
|
+
targetAnchor?: SingleAnchorSpec | null;
|
|
20
|
+
};
|
|
8
21
|
/**
|
|
9
22
|
* Options for a Palette
|
|
10
23
|
* @group Components
|
|
@@ -38,7 +51,14 @@ export interface PaletteOptions<T> {
|
|
|
38
51
|
/**
|
|
39
52
|
* Defaults to false. Allows items to be dropped onto edges in the canvas. A drop on an edge causes that edge to be split, with one edge having the new vertex as a target, and another edge with the new vertex as source.
|
|
40
53
|
*/
|
|
41
|
-
allowDropOnEdge?: boolean
|
|
54
|
+
allowDropOnEdge?: boolean | CanDropOnEdgeFilter<T>;
|
|
55
|
+
/**
|
|
56
|
+
* If `allowDropOnEdge` is true, this function can be provided, to customise the behaviour of the drop. By default, the new vertex is used as the target of the original edge and the source of the new edge. But you might want to connect to ports on the new vertex, and this method allows you to do that: you can return the ID of a port to use for the existing edge's target, a port ID to use for the new edge's source, a source anchor or a target anchor.
|
|
57
|
+
* @param newVertex The newly dropped vertex
|
|
58
|
+
* @param originalEdge The edge that the vertex was dropped on.
|
|
59
|
+
* @advanced
|
|
60
|
+
*/
|
|
61
|
+
edgeDropHandler?: (newVertex: Vertex, originalEdge: Edge) => EdgeDropInfo;
|
|
42
62
|
/**
|
|
43
63
|
* Defaults to true. Allows items to be dropped onto groups in the canvas.
|
|
44
64
|
*/
|
|
@@ -144,6 +164,14 @@ export interface PaletteOptions<T> {
|
|
|
144
164
|
* Class to set on an element being dragged.
|
|
145
165
|
*/
|
|
146
166
|
dragElementClass?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Whether or not to allow rotation of elements being dragged. Defaults to true.
|
|
169
|
+
*/
|
|
170
|
+
allowRotation?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
|
|
173
|
+
*/
|
|
174
|
+
rotationSpeed?: number;
|
|
147
175
|
/**
|
|
148
176
|
* Optional function to invoke as the user is dragging a new element, or has tapped an element and is moving the mouse over the canvas.
|
|
149
177
|
*/
|
|
@@ -156,4 +184,33 @@ export interface PaletteOptions<T> {
|
|
|
156
184
|
* Optional data that will be used in conjunction with `contentTemplate` to generate the HTML content of the palette.
|
|
157
185
|
*/
|
|
158
186
|
data?: ObjectData;
|
|
187
|
+
/**
|
|
188
|
+
* 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.
|
|
189
|
+
*/
|
|
190
|
+
autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Options for auto edge connect.
|
|
194
|
+
*/
|
|
195
|
+
export interface AutoEdgeConnectOptions {
|
|
196
|
+
/**
|
|
197
|
+
* Whether or not auto edge connect is enabled.
|
|
198
|
+
*/
|
|
199
|
+
enabled: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* The mode to run the auto connect functionality in. "onDemand" is the default, meaning the user has to press the Meta key in order to activate the edge auto connect. In "eager" mode, the edge auto connect is switched on as soon as drag starts.
|
|
202
|
+
*/
|
|
203
|
+
connectMode?: "onDemand" | "eager";
|
|
204
|
+
/**
|
|
205
|
+
* Style to use for an automatically created edge (while the user is still dragging the new element). Defaults to a gray dashed line.
|
|
206
|
+
*/
|
|
207
|
+
lineStyle?: LineStyle;
|
|
208
|
+
/**
|
|
209
|
+
* Class to set on the UI canvas when drag starts and auto edge connect is active
|
|
210
|
+
*/
|
|
211
|
+
activeClass?: string;
|
|
212
|
+
/**
|
|
213
|
+
* The key to listen for to switch from primed to active when connect mode is `onDemand`
|
|
214
|
+
*/
|
|
215
|
+
key?: string;
|
|
159
216
|
}
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import { PaletteOptions } from "./palette-options";
|
|
2
2
|
import { BrowserElement } from "../../util";
|
|
3
|
-
import {
|
|
3
|
+
import { ViewportNodeElement } from "../../../ui";
|
|
4
|
+
import { Node, ObjectData } from "../../../core";
|
|
4
5
|
import { BrowserUI } from "../../browser-visuallyjs-instance";
|
|
5
|
-
/**
|
|
6
|
-
* Default data generator for palettes. Extract `data-vjs-***` attributes from element.
|
|
7
|
-
* @param el
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare function defaultDataGenerator<T = any>(el: BrowserElement): T;
|
|
11
|
-
/**
|
|
12
|
-
* The default CSS selector used with the Palette and the library integration wrappers around it
|
|
13
|
-
* @group Components
|
|
14
|
-
* @category Palette
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export declare const DEFAULT_PALETTE_SELECTOR = "[data-vjs-type]";
|
|
18
6
|
/**
|
|
19
7
|
* This component allows you to configure elements to drag and drop onto a surface.
|
|
20
8
|
*
|
|
@@ -28,6 +16,7 @@ export declare class Palette<T> {
|
|
|
28
16
|
private readonly _selector;
|
|
29
17
|
private readonly _ignoreGrid;
|
|
30
18
|
private readonly _dragActiveClass;
|
|
19
|
+
private readonly _autoEdgeConnectActiveClass;
|
|
31
20
|
private readonly _dragHoverClass;
|
|
32
21
|
private readonly _dragElementClass;
|
|
33
22
|
private readonly _dragHoverCannotDropClass;
|
|
@@ -55,6 +44,8 @@ export declare class Palette<T> {
|
|
|
55
44
|
private _$_eventManager;
|
|
56
45
|
private _currentNodeList;
|
|
57
46
|
private _currentGroupList;
|
|
47
|
+
private _nodeRtree;
|
|
48
|
+
private _groupRtree;
|
|
58
49
|
private _currentEdgeList;
|
|
59
50
|
private _candidateData;
|
|
60
51
|
private _dropCandidate;
|
|
@@ -68,7 +59,15 @@ export declare class Palette<T> {
|
|
|
68
59
|
* current element being dragged
|
|
69
60
|
* @internal
|
|
70
61
|
*/
|
|
71
|
-
private
|
|
62
|
+
private $dragElement;
|
|
63
|
+
/**
|
|
64
|
+
* Information about the transient vertex used during drag.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
$transientInfo: {
|
|
68
|
+
vertex: Node;
|
|
69
|
+
el: ViewportNodeElement<BrowserElement>;
|
|
70
|
+
};
|
|
72
71
|
/**
|
|
73
72
|
* Size to use for the current drag element. This is set if there was a dragSizeGenerator function supplied, and that returned something on drag start, or if a class-wide drag size was set in the constructor.
|
|
74
73
|
* @internal
|
|
@@ -85,12 +84,18 @@ export declare class Palette<T> {
|
|
|
85
84
|
private readonly _$_ignoreDropOnNodes;
|
|
86
85
|
private readonly _$_allowDropOnGroups;
|
|
87
86
|
private readonly _$_allowDropOnEdges;
|
|
87
|
+
private readonly _edgeDropHandler;
|
|
88
88
|
private readonly _canDrop?;
|
|
89
89
|
private readonly _$_dragSize;
|
|
90
90
|
private _$_candidateTapObject;
|
|
91
91
|
private _$_previousCandidateTapObject;
|
|
92
92
|
private _contentGenerator;
|
|
93
93
|
private readonly _keyListener;
|
|
94
|
+
private _rotateManager;
|
|
95
|
+
private _allowRotation;
|
|
96
|
+
private _rotationSpeed;
|
|
97
|
+
private readonly _autoEdgeConnect;
|
|
98
|
+
private _autoEdgeConnectManager;
|
|
94
99
|
constructor(ui: BrowserUI, options: PaletteOptions<T>);
|
|
95
100
|
/**
|
|
96
101
|
* Sets the enabled state of the palette
|
|
@@ -123,5 +128,10 @@ export declare class Palette<T> {
|
|
|
123
128
|
private _addNewVertexToCanvas;
|
|
124
129
|
private _onVertexAdded;
|
|
125
130
|
private _reset;
|
|
131
|
+
/**
|
|
132
|
+
* returns whether or not rotation is allowed, and if so, the rotation stops to use (which may be null or an empty array, for free rotation)
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
private _isAllowRotation;
|
|
126
136
|
private _$_initDrawMode;
|
|
127
137
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BrowserElement } from "../../util";
|
|
2
|
+
import { RectangleXY } from "../../../core";
|
|
3
|
+
/**
|
|
4
|
+
* Default data generator for palettes. Extract `data-vjs-***` attributes from element.
|
|
5
|
+
* @param el
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare function defaultDataGenerator<T = any>(el: BrowserElement): T;
|
|
9
|
+
/**
|
|
10
|
+
* Convert a region that is in page coordinates into canvas coordinates, given a rectangle defining the canvas bounds (in canvas coords), a rectangle defining the viewport pounds (in page coords), and a region (in page coords). The approach is to redefine `region` in terms of its position and size wrt the viewport bounds. We compute the region's width/height as a ratio of the viewport's width/height, and we compute its origin as a ratio of the width/height of the viewport
|
|
11
|
+
* @param canvasBounds
|
|
12
|
+
* @param viewportBounds
|
|
13
|
+
* @param region
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function convertPageCoordsToCanvasCoords(canvasBounds: RectangleXY, viewportBounds: RectangleXY, region: RectangleXY): {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class RotateManager {
|
|
2
|
+
private _rotationKeyListener;
|
|
3
|
+
private _isRotationKeyDown;
|
|
4
|
+
private _isAllowRotation;
|
|
5
|
+
private _rotationSpeed;
|
|
6
|
+
private _rotationInterval;
|
|
7
|
+
private _currentRotation;
|
|
8
|
+
private _rotationUpdated;
|
|
9
|
+
private _currentTarget;
|
|
10
|
+
private _key;
|
|
11
|
+
private _getInitialRotation;
|
|
12
|
+
constructor(options: {
|
|
13
|
+
isAllowRotation: (e: KeyboardEvent) => [boolean, Array<number>];
|
|
14
|
+
rotationSpeed?: number;
|
|
15
|
+
rotationUpdated: (r: number) => any;
|
|
16
|
+
key?: string;
|
|
17
|
+
getInitialRotation?: () => number;
|
|
18
|
+
});
|
|
19
|
+
activate(target: Element | Document): void;
|
|
20
|
+
deactivate(): void;
|
|
21
|
+
getRotation(): number;
|
|
22
|
+
reset(): void;
|
|
23
|
+
private _handleRotationTriggerPressed;
|
|
24
|
+
private _rotateByStep;
|
|
25
|
+
private _writeRotation;
|
|
26
|
+
private _stopAutoRotation;
|
|
27
|
+
}
|
|
@@ -24,13 +24,16 @@ export declare const ATTRIBUTE_GROUP_COLLAPSED_CONTENT = "data-vjs-collapsed-con
|
|
|
24
24
|
* Specifies whether or not some drag source/target is enabled.
|
|
25
25
|
* @group Nodes and Groups
|
|
26
26
|
* @category DOM Attributes
|
|
27
|
+
* @domAttribute
|
|
28
|
+
* @context edge-dragging
|
|
27
29
|
*/
|
|
28
30
|
export declare const ATTRIBUTE_VJS_ENABLED = "data-vjs-enabled";
|
|
29
31
|
/**
|
|
30
|
-
* Specifies the value for 'scope' for an edge dragged from some element. Edges will only be able to be dragged to target elements
|
|
31
|
-
* that have the same value for `data-vjs-scope`.
|
|
32
|
+
* Specifies the value for 'scope' for an edge dragged from some element. Edges will only be able to be dragged to target elements that have the same value for `data-vjs-scope`.
|
|
32
33
|
* @group Nodes and Groups
|
|
33
34
|
* @category DOM Attributes
|
|
35
|
+
* @domAttribute
|
|
36
|
+
* @context edge-dragging
|
|
34
37
|
*/
|
|
35
38
|
export declare const ATTRIBUTE_VJS_SCOPE = "data-vjs-scope";
|
|
36
39
|
/**
|
|
@@ -404,6 +404,14 @@ export declare const CLASS_PALETTE_DRAG_ACTIVE = "vjs-palette-drag-active";
|
|
|
404
404
|
* @category Shape Palette
|
|
405
405
|
*/
|
|
406
406
|
export declare const CLASS_PALETTE_DRAG_HOVER = "vjs-palette-drag-hover";
|
|
407
|
+
/**
|
|
408
|
+
* Assigned to the UI's canvas when a drag has started and auto edge connect is active.
|
|
409
|
+
* @cssClass
|
|
410
|
+
* @context palette
|
|
411
|
+
* @group Components
|
|
412
|
+
* @category Palette
|
|
413
|
+
*/
|
|
414
|
+
export declare const CLASS_PALETTE_AUTO_EDGE_CONNECT_ACTIVE = "vjs-palette-auto-edge-connect-active";
|
|
407
415
|
/**
|
|
408
416
|
* Assigned to a vertex or the canvas when an element that is being dragged from the palette is hovering over it but drop is not allowed.
|
|
409
417
|
* @cssClass
|
|
@@ -447,7 +455,7 @@ export declare const CLASS_DRAG_ORIGINAL_GROUP = "vjs-drag-original-group";
|
|
|
447
455
|
/**
|
|
448
456
|
* Assigned to any element that is a candidate drop target for an edge that is being dragged
|
|
449
457
|
* @cssClass
|
|
450
|
-
* @context element-dragging,
|
|
458
|
+
* @context element-dragging,nodes-and-groups
|
|
451
459
|
* @group Components
|
|
452
460
|
* @category Surface
|
|
453
461
|
*/
|
|
@@ -455,7 +463,7 @@ export declare const CLASS_DRAG_ACTIVE = "vjs-drag-active";
|
|
|
455
463
|
/**
|
|
456
464
|
* Assigned to any element that is the current drop target for an edge that is being dragged
|
|
457
465
|
* @cssClass
|
|
458
|
-
* @context element-dragging,
|
|
466
|
+
* @context element-dragging,nodes-and-groups
|
|
459
467
|
* @group Components
|
|
460
468
|
* @category Surface
|
|
461
469
|
*/
|
|
@@ -499,3 +507,21 @@ export declare const CLASS_TRANSIENT_VERTEX = "vjs-transient-vertex";
|
|
|
499
507
|
* @context click-to-add-edges
|
|
500
508
|
*/
|
|
501
509
|
export declare const CLASS_EDGE_CLICK_ENTRY = "vjs-edge-click-entry-method";
|
|
510
|
+
/**
|
|
511
|
+
* Assigned to source elements on the canvas and the drag vertex during a drag
|
|
512
|
+
* @cssClass
|
|
513
|
+
* @context shapePalette
|
|
514
|
+
* @group Diagrams
|
|
515
|
+
* @category CSS Classes
|
|
516
|
+
*/
|
|
517
|
+
export declare const CLASS_AUTO_EDGE_SOURCE = "vjs-auto-edge-source";
|
|
518
|
+
/**
|
|
519
|
+
* Assigned to target elements on the canvas and the drag vertex during a drag
|
|
520
|
+
* @cssClass
|
|
521
|
+
* @context shapePalette
|
|
522
|
+
* @group Diagrams
|
|
523
|
+
* @category CSS Classes
|
|
524
|
+
*/
|
|
525
|
+
export declare const CLASS_AUTO_EDGE_TARGET = "vjs-auto-edge-target";
|
|
526
|
+
export declare const CLASS_AUTO_EDGE_PROXIMITY_SOURCE = "vjs-auto-edge-proximity-source";
|
|
527
|
+
export declare const CLASS_AUTO_EDGE_PROXIMITY_TARGET = "vjs-auto-edge-proximity-target";
|
|
@@ -2,7 +2,7 @@ import { BrowserElement } from "./util";
|
|
|
2
2
|
import { BoundingBox, Edge, Group, Node, ObjectData, Port, Vertex, VisuallyJsModel, VisuallyJsSelection } from "../core";
|
|
3
3
|
import { PointXY, Size } from "../core";
|
|
4
4
|
import { UICoreDefaults, UICoreOptions, UIEdgeOptions, DragOptions, Overlay, Connection, EdgePropertyMappings, AlignContentOptions } from "../ui";
|
|
5
|
-
import { EdgeInputMethod } from "./edge-
|
|
5
|
+
import { EdgeInputMethod } from "./edge-handler-base";
|
|
6
6
|
import { ShapeLibrary, ShapeSet } from "./shape-library/shape-library-definitions";
|
|
7
7
|
import { VisuallyJSDOMElement } from "./element-facade";
|
|
8
8
|
import { VertexMapping } from "../ui";
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { Surface } from "./surface-renderer";
|
|
2
2
|
import { BrowserElement } from "./util";
|
|
3
3
|
import { VisuallyJSDOMElement } from "./element-facade";
|
|
4
|
+
import { SingleAnchorSpec } from "../ui";
|
|
4
5
|
import { Vertex, BoundingBox, PointXY, RectangleXY, RTree, AnchorOrientationHint, ObjectAnchorSpec, ObjectData } from "../core";
|
|
5
|
-
import { EdgeInputMethod } from "./edge-input-handler";
|
|
6
6
|
import { ElementModelInfo } from "./definitions";
|
|
7
|
+
/**
|
|
8
|
+
* Defines the drag method of creating new edges with the mouse/touch events
|
|
9
|
+
* @group Edges
|
|
10
|
+
* @constant
|
|
11
|
+
*/
|
|
12
|
+
export declare const EDGE_INPUT_METHOD_DRAG = "drag";
|
|
13
|
+
/**
|
|
14
|
+
* Defines the click method of creating new edges with the mouse/touch events
|
|
15
|
+
* @group Edges
|
|
16
|
+
* @constant
|
|
17
|
+
*/
|
|
18
|
+
export declare const EDGE_INPUT_METHOD_CLICK = "click";
|
|
19
|
+
/**
|
|
20
|
+
* Defines the available methods of edge creation with mouse/touch events
|
|
21
|
+
* @group Edges
|
|
22
|
+
*/
|
|
23
|
+
export type EdgeInputMethod = typeof EDGE_INPUT_METHOD_CLICK | typeof EDGE_INPUT_METHOD_DRAG;
|
|
7
24
|
/**
|
|
8
25
|
* Defines the default behaviour for edge snap to target - for small targets (width + height is less than 30 pixels), snap to the center. For larger targets, snap to the perimeter. When the mouse is over the target, do not snap.
|
|
9
26
|
* @group Edges
|
|
@@ -58,6 +75,7 @@ export interface EdgeSnapOptions {
|
|
|
58
75
|
*/
|
|
59
76
|
requireMagnets?: boolean;
|
|
60
77
|
}
|
|
78
|
+
export declare function decodeAnchorFromAttribute(spec: string): SingleAnchorSpec | null;
|
|
61
79
|
/**
|
|
62
80
|
* @internal
|
|
63
81
|
*/
|
|
@@ -86,6 +104,7 @@ export type DropTarget = {
|
|
|
86
104
|
anchor?: ObjectAnchorSpec;
|
|
87
105
|
anchorIndex?: number;
|
|
88
106
|
targetEl: VisuallyJSDOMElement;
|
|
107
|
+
targetAnchor?: SingleAnchorSpec;
|
|
89
108
|
targetPortType?: string;
|
|
90
109
|
magnet?: boolean;
|
|
91
110
|
positionOnElement?: PointXY;
|
|
@@ -2,25 +2,8 @@ import { LightweightAnchor, Connection, ViewportElement } from "../ui";
|
|
|
2
2
|
import { BrowserElement } from "./util";
|
|
3
3
|
import { Edge, Node, Vertex } from "../core";
|
|
4
4
|
import { PointXY } from "../core";
|
|
5
|
-
import { EdgeHandlerBase, EdgeHandlerBaseOptions } from "./edge-handler-base";
|
|
5
|
+
import { EdgeHandlerBase, EdgeHandlerBaseOptions, EdgeInputMethod } from "./edge-handler-base";
|
|
6
6
|
export declare const EVENT_KEYUP = "keyup";
|
|
7
|
-
/**
|
|
8
|
-
* Defines the drag method of creating new edges with the mouse/touch events
|
|
9
|
-
* @group Edges
|
|
10
|
-
* @constant
|
|
11
|
-
*/
|
|
12
|
-
export declare const EDGE_INPUT_METHOD_DRAG = "drag";
|
|
13
|
-
/**
|
|
14
|
-
* Defines the click method of creating new edges with the mouse/touch events
|
|
15
|
-
* @group Edges
|
|
16
|
-
* @constant
|
|
17
|
-
*/
|
|
18
|
-
export declare const EDGE_INPUT_METHOD_CLICK = "click";
|
|
19
|
-
/**
|
|
20
|
-
* Defines the available methods of edge creation with mouse/touch events
|
|
21
|
-
* @group Edges
|
|
22
|
-
*/
|
|
23
|
-
export type EdgeInputMethod = typeof EDGE_INPUT_METHOD_CLICK | typeof EDGE_INPUT_METHOD_DRAG;
|
|
24
7
|
export declare const EDGE_INPUT_STATE_IDLE = "idle";
|
|
25
8
|
declare const EDGE_INPUT_STATE_DRAGGING = "dragging";
|
|
26
9
|
declare const EDGE_INPUT_STATE_AWAITING_CLICK = "awaitingClick";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SupportsElementDragging, VertexDragFilter, ViewportGroupElement, ViewportNodeElement
|
|
1
|
+
import { SupportsElementDragging, VertexDragFilter, ViewportElement, ViewportGroupElement, ViewportNodeElement } from "../ui";
|
|
2
2
|
import { BrowserElement } from "./util";
|
|
3
|
-
import {
|
|
3
|
+
import { Grid, PointXY } from "../core";
|
|
4
4
|
import { BrowserUI } from "./browser-visuallyjs-instance";
|
|
5
5
|
declare enum DragStates {
|
|
6
6
|
idle = "idle",
|
|
@@ -117,6 +117,8 @@ export declare class ElementDragHandler2 {
|
|
|
117
117
|
private _canvasShift;
|
|
118
118
|
private _currentSurfaceZoom;
|
|
119
119
|
private _activeEffectiveZoom;
|
|
120
|
+
_isRotatable: boolean;
|
|
121
|
+
_rotationStops: Array<number>;
|
|
120
122
|
/**
|
|
121
123
|
* This is the current element (and associated model object) that is being dragged.
|
|
122
124
|
*/
|
|
@@ -17,13 +17,14 @@ export * from './copy-paste';
|
|
|
17
17
|
export * from './storage';
|
|
18
18
|
export * from './icons';
|
|
19
19
|
export * from './svg-export';
|
|
20
|
+
export * from './keyboard';
|
|
20
21
|
export * from './edge-handler-base';
|
|
21
22
|
export * from './edge-input-handler';
|
|
22
23
|
export * from './edge-relocate-handler';
|
|
23
24
|
export * from './element-drag-handler-2';
|
|
24
25
|
export * from './element-dragger';
|
|
25
26
|
export * from './element-facade';
|
|
26
|
-
export
|
|
27
|
+
export * from './event-manager';
|
|
27
28
|
export * from './fixed-layer';
|
|
28
29
|
export * from './group-layout-adapter';
|
|
29
30
|
export * from './html-element-overlay';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./keyboard-listener";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type KeyboardEventCallback = ((e: KeyboardEvent, event: string) => any);
|
|
2
|
+
export declare class KeyboardListener {
|
|
3
|
+
_mappings: Record<string, EventListenerOrEventListenerObject>;
|
|
4
|
+
constructor(mappings: Record<string, KeyboardEventCallback>);
|
|
5
|
+
bindAll(target: Element | Document): void;
|
|
6
|
+
unbindAll(target: Element | Document): void;
|
|
7
|
+
}
|
|
@@ -89,6 +89,11 @@ export interface WheelOptions {
|
|
|
89
89
|
* Optional CSS 3 selector to check if the wheel should be enabled for the current event target.
|
|
90
90
|
*/
|
|
91
91
|
cssFilter?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Defaults to true. When true, holding the SHIFT key while using the mouse wheel will toggle the wheel's mode:
|
|
94
|
+
* if the wheel is currently set to pan, it will zoom. If it is currently set to zoom, it will pan.
|
|
95
|
+
*/
|
|
96
|
+
shiftToChangeMode?: boolean;
|
|
92
97
|
}
|
|
93
98
|
/**
|
|
94
99
|
* @internal
|
|
@@ -236,8 +241,7 @@ export interface PanZoomOptions {
|
|
|
236
241
|
*/
|
|
237
242
|
enabled?: boolean;
|
|
238
243
|
/**
|
|
239
|
-
* Optional filter that will be called on down event, with the event target and the event. Returning true
|
|
240
|
-
* from this function means the widget should respond to the event.
|
|
244
|
+
* Optional filter that will be called on down event, with the event target and the event. Returning true from this function means the widget should respond to the event.
|
|
241
245
|
*/
|
|
242
246
|
filter?: Function;
|
|
243
247
|
/**
|