@metadev/daga 1.5.0 → 1.5.1
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/Changelog.md +24 -2
- package/assets/icon/context/copy.svg +4 -0
- package/assets/icon/context/cross.svg +3 -0
- package/assets/icon/context/cut.svg +4 -0
- package/assets/icon/context/delete.svg +4 -0
- package/assets/icon/context/paste.svg +4 -0
- package/assets/styles/_context-menu.scss +32 -0
- package/assets/styles/daga.scss +1 -0
- package/fesm2022/metadev-daga.mjs +4849 -4204
- package/fesm2022/metadev-daga.mjs.map +1 -1
- package/lib/diagram-editor/diagram/collab/collab-action.d.ts +26 -2
- package/lib/diagram-editor/diagram/converters/daga-exporter.d.ts +18 -1
- package/lib/diagram-editor/diagram/converters/daga-importer.d.ts +10 -1
- package/lib/diagram-editor/diagram/converters/daga-model.d.ts +77 -89
- package/lib/diagram-editor/diagram/diagram-action.d.ts +33 -1
- package/lib/diagram-editor/diagram/diagram-canvas.d.ts +15 -2
- package/lib/diagram-editor/diagram/diagram-model.d.ts +7 -0
- package/lib/diagram-editor/diagram/diagram-object.d.ts +52 -0
- package/lib/interfaces/canvas.d.ts +46 -0
- package/lib/util/events.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Canvas } from '../../../interfaces/canvas';
|
|
2
2
|
import { Point } from '../../../util/canvas-util';
|
|
3
|
-
import {
|
|
3
|
+
import { DagaConnection, DagaNode } from '../converters/daga-model';
|
|
4
4
|
import { DiagramNodeGeometry } from '../diagram-node';
|
|
5
5
|
import { ValueSet } from '../diagram-property';
|
|
6
|
+
import { CollabTimestamp } from './primitives';
|
|
6
7
|
/**
|
|
7
8
|
* An action taken by a local or remote user.
|
|
8
9
|
*
|
|
@@ -31,7 +32,7 @@ export interface CollabAction {
|
|
|
31
32
|
/**
|
|
32
33
|
* @private
|
|
33
34
|
*/
|
|
34
|
-
export type CollabActionSerialized = AddNodeSerialized | SetGeometrySerialized | AddConnectionSerialized | EditFieldSerialized | UpdateValuesSerialized | SetSelfRemovedSerialized;
|
|
35
|
+
export type CollabActionSerialized = AddNodeSerialized | SetGeometrySerialized | AddConnectionSerialized | EditFieldSerialized | UpdateValuesSerialized | SetSelfRemovedSerialized | PasteSerialized;
|
|
35
36
|
/**
|
|
36
37
|
* @private
|
|
37
38
|
*/
|
|
@@ -210,3 +211,26 @@ export declare class SetSelfRemovedCollabAction implements CollabAction {
|
|
|
210
211
|
serialize(): CollabActionSerialized;
|
|
211
212
|
static deserialize(canvas: Canvas, serialized: SetSelfRemovedSerialized): SetSelfRemovedCollabAction;
|
|
212
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
export type PasteSerialized = {
|
|
218
|
+
type: 'paste';
|
|
219
|
+
readonly nodes: DagaNode[];
|
|
220
|
+
readonly connections: DagaConnection[];
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Collaborative action which consists of pasting elements from an external source into a diagram.
|
|
224
|
+
*
|
|
225
|
+
* @see PasteAction
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
export declare class PasteCollabAction implements CollabAction {
|
|
229
|
+
readonly canvas: Canvas;
|
|
230
|
+
readonly nodes: DagaNode[];
|
|
231
|
+
readonly connections: DagaConnection[];
|
|
232
|
+
constructor(canvas: Canvas, nodes: DagaNode[], connections: DagaConnection[]);
|
|
233
|
+
do(): void;
|
|
234
|
+
serialize(): CollabActionSerialized;
|
|
235
|
+
static deserialize(canvas: Canvas, serialized: PasteSerialized): PasteCollabAction;
|
|
236
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { DiagramConnection } from '../diagram-connection';
|
|
2
|
+
import { DiagramField } from '../diagram-field';
|
|
1
3
|
import { DiagramModel } from '../diagram-model';
|
|
2
|
-
import {
|
|
4
|
+
import { DiagramNode } from '../diagram-node';
|
|
5
|
+
import { DagaConnection, DagaModel, DagaNode } from './daga-model';
|
|
3
6
|
import { DiagramModelExporter } from './diagram-model-exporter';
|
|
4
7
|
/**
|
|
5
8
|
* Importer which exports a diagram to its daga model representation.
|
|
@@ -7,4 +10,18 @@ import { DiagramModelExporter } from './diagram-model-exporter';
|
|
|
7
10
|
*/
|
|
8
11
|
export declare class DagaExporter implements DiagramModelExporter<DagaModel> {
|
|
9
12
|
export(model: DiagramModel, includeCollabMeta?: boolean): DagaModel;
|
|
13
|
+
exportNode(node: DiagramNode, includeCollabMeta?: boolean): DagaNode;
|
|
14
|
+
exportConnection(connection: DiagramConnection, includeCollabMeta?: boolean): DagaConnection;
|
|
15
|
+
exportLabelCollabMeta({ label }: {
|
|
16
|
+
label?: DiagramField;
|
|
17
|
+
}): {
|
|
18
|
+
label: {
|
|
19
|
+
removed: boolean;
|
|
20
|
+
selfRemoved: boolean;
|
|
21
|
+
selfRemovedTimestamp: import("@metadev/daga").CollabTimestamp | null;
|
|
22
|
+
textTimestamp: import("@metadev/daga").CollabTimestamp | null;
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
label?: undefined;
|
|
26
|
+
};
|
|
10
27
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CollabTimestamp } from '../collab/primitives';
|
|
2
|
+
import { DiagramField } from '../diagram-field';
|
|
1
3
|
import { DiagramModel } from '../diagram-model';
|
|
2
|
-
import { DagaModel } from './daga-model';
|
|
4
|
+
import { DagaConnection, DagaModel, DagaNode } from './daga-model';
|
|
3
5
|
import { DiagramModelImporter } from './diagram-model-importer';
|
|
4
6
|
/**
|
|
5
7
|
* Importer which imports a diagram from its daga model representation.
|
|
@@ -7,4 +9,11 @@ import { DiagramModelImporter } from './diagram-model-importer';
|
|
|
7
9
|
*/
|
|
8
10
|
export declare class DagaImporter implements DiagramModelImporter<DagaModel> {
|
|
9
11
|
import(model: DiagramModel, data: DagaModel): DiagramModel;
|
|
12
|
+
importNode(model: DiagramModel, node: DagaNode): DiagramModel;
|
|
13
|
+
importConnection(model: DiagramModel, connection: DagaConnection): DiagramModel;
|
|
14
|
+
importLabelCollabMeta(newLabel?: DiagramField, labelCollabMeta?: {
|
|
15
|
+
selfRemoved: boolean;
|
|
16
|
+
selfRemovedTimestamp: CollabTimestamp | null;
|
|
17
|
+
textTimestamp: CollabTimestamp | null;
|
|
18
|
+
}): void;
|
|
10
19
|
}
|
|
@@ -19,108 +19,96 @@ export interface DagaModel {
|
|
|
19
19
|
createdAt: Date;
|
|
20
20
|
updatedAt: Date;
|
|
21
21
|
updatedDaysAgo?: string;
|
|
22
|
-
nodes:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
removed: boolean;
|
|
52
|
-
selfRemoved: boolean;
|
|
53
|
-
selfRemovedTimestamp: CollabTimestamp | null;
|
|
54
|
-
label?: {
|
|
55
|
-
removed: boolean;
|
|
56
|
-
selfRemoved: boolean;
|
|
57
|
-
selfRemovedTimestamp: CollabTimestamp | null;
|
|
58
|
-
textTimestamp: CollabTimestamp | null;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
}[];
|
|
62
|
-
ports?: {
|
|
63
|
-
id: string;
|
|
64
|
-
coords: Point;
|
|
65
|
-
direction: Side;
|
|
66
|
-
label: string;
|
|
67
|
-
collabMeta?: {
|
|
68
|
-
removed: boolean;
|
|
69
|
-
selfRemoved: boolean;
|
|
70
|
-
selfRemovedTimestamp: CollabTimestamp | null;
|
|
71
|
-
label?: {
|
|
72
|
-
removed: boolean;
|
|
73
|
-
selfRemoved: boolean;
|
|
74
|
-
selfRemovedTimestamp: CollabTimestamp | null;
|
|
75
|
-
textTimestamp: CollabTimestamp | null;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
}[];
|
|
79
|
-
label: string;
|
|
80
|
-
coords: Point;
|
|
81
|
-
width: number;
|
|
82
|
-
height: number;
|
|
83
|
-
data: {
|
|
84
|
-
[key: string]: unknown;
|
|
85
|
-
};
|
|
86
|
-
collabMeta?: {
|
|
22
|
+
nodes: DagaNode[];
|
|
23
|
+
connections: DagaConnection[];
|
|
24
|
+
data: {
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
collabMeta?: {
|
|
28
|
+
logicalClock: number;
|
|
29
|
+
dataTimestamps: CollabTimestampSet;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface DagaNode {
|
|
33
|
+
id: string;
|
|
34
|
+
type: string;
|
|
35
|
+
sections?: DagaSection[];
|
|
36
|
+
ports?: DagaPort[];
|
|
37
|
+
label: string;
|
|
38
|
+
coords: Point;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
data: {
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
collabMeta?: {
|
|
45
|
+
removed: boolean;
|
|
46
|
+
selfRemoved: boolean;
|
|
47
|
+
selfRemovedTimestamp: CollabTimestamp | null;
|
|
48
|
+
geometryTimestamp: CollabTimestamp | null;
|
|
49
|
+
dataTimestamps: CollabTimestampSet;
|
|
50
|
+
label?: {
|
|
87
51
|
removed: boolean;
|
|
88
52
|
selfRemoved: boolean;
|
|
89
53
|
selfRemovedTimestamp: CollabTimestamp | null;
|
|
90
|
-
|
|
91
|
-
dataTimestamps: CollabTimestampSet;
|
|
92
|
-
label?: {
|
|
93
|
-
removed: boolean;
|
|
94
|
-
selfRemoved: boolean;
|
|
95
|
-
selfRemovedTimestamp: CollabTimestamp | null;
|
|
96
|
-
textTimestamp: CollabTimestamp | null;
|
|
97
|
-
};
|
|
54
|
+
textTimestamp: CollabTimestamp | null;
|
|
98
55
|
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface DagaSection {
|
|
59
|
+
id: string;
|
|
60
|
+
ports?: DagaPort[];
|
|
61
|
+
label: string;
|
|
62
|
+
indexXInNode: number;
|
|
63
|
+
indexYInNode: number;
|
|
64
|
+
coords: Point;
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
collabMeta?: {
|
|
68
|
+
removed: boolean;
|
|
69
|
+
selfRemoved: boolean;
|
|
70
|
+
selfRemovedTimestamp: CollabTimestamp | null;
|
|
71
|
+
label?: {
|
|
72
|
+
removed: boolean;
|
|
73
|
+
selfRemoved: boolean;
|
|
74
|
+
selfRemovedTimestamp: CollabTimestamp | null;
|
|
75
|
+
textTimestamp: CollabTimestamp | null;
|
|
111
76
|
};
|
|
112
|
-
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface DagaPort {
|
|
80
|
+
id: string;
|
|
81
|
+
coords: Point;
|
|
82
|
+
direction: Side;
|
|
83
|
+
label: string;
|
|
84
|
+
collabMeta?: {
|
|
85
|
+
removed: boolean;
|
|
86
|
+
selfRemoved: boolean;
|
|
87
|
+
selfRemovedTimestamp: CollabTimestamp | null;
|
|
88
|
+
label?: {
|
|
113
89
|
removed: boolean;
|
|
114
90
|
selfRemoved: boolean;
|
|
115
91
|
selfRemovedTimestamp: CollabTimestamp | null;
|
|
116
|
-
|
|
92
|
+
textTimestamp: CollabTimestamp | null;
|
|
117
93
|
};
|
|
118
|
-
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export interface DagaConnection {
|
|
97
|
+
id: string;
|
|
98
|
+
type: string;
|
|
99
|
+
start: string;
|
|
100
|
+
end: string;
|
|
101
|
+
startLabel: string;
|
|
102
|
+
middleLabel: string;
|
|
103
|
+
endLabel: string;
|
|
104
|
+
points: Point[];
|
|
119
105
|
data: {
|
|
120
106
|
[key: string]: unknown;
|
|
121
107
|
};
|
|
122
108
|
collabMeta?: {
|
|
123
|
-
|
|
109
|
+
removed: boolean;
|
|
110
|
+
selfRemoved: boolean;
|
|
111
|
+
selfRemovedTimestamp: CollabTimestamp | null;
|
|
124
112
|
dataTimestamps: CollabTimestampSet;
|
|
125
113
|
};
|
|
126
114
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Canvas } from '../../interfaces/canvas';
|
|
2
2
|
import { Point } from '../../util/canvas-util';
|
|
3
|
+
import { DagaConnection, DagaNode } from './converters/daga-model';
|
|
3
4
|
import { DiagramConnectionType } from './diagram-connection';
|
|
4
|
-
import {
|
|
5
|
+
import { DiagramNodeGeometry, DiagramNodeType } from './diagram-node';
|
|
5
6
|
/**
|
|
6
7
|
* A queue of recent actions taken by the user that can be undone and redone.
|
|
7
8
|
* @private
|
|
@@ -85,6 +86,16 @@ export declare enum DiagramActions {
|
|
|
85
86
|
* @public
|
|
86
87
|
*/
|
|
87
88
|
AddNode = "add-node",
|
|
89
|
+
/**
|
|
90
|
+
* Action that corresponds to copying diagram elements to the clipboard.
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
Clipboard = "clipboard",
|
|
94
|
+
/**
|
|
95
|
+
* Action that corresponds to opening the context menu.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
ContextMenu = "context-menu",
|
|
88
99
|
/**
|
|
89
100
|
* Action that corresponds to the edition of a field's text content.
|
|
90
101
|
* @see EditFieldAction
|
|
@@ -97,6 +108,12 @@ export declare enum DiagramActions {
|
|
|
97
108
|
* @public
|
|
98
109
|
*/
|
|
99
110
|
MoveNode = "move-node",
|
|
111
|
+
/**
|
|
112
|
+
* Action that corresponds to pasting diagram elements from the clipboard.
|
|
113
|
+
* @see PasteAction
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
Paste = "paste",
|
|
100
117
|
/**
|
|
101
118
|
* Action that corresponds to removing elements.
|
|
102
119
|
* @see RemoveAction
|
|
@@ -241,3 +258,18 @@ export declare class RemoveAction implements DiagramAction {
|
|
|
241
258
|
undo(): void;
|
|
242
259
|
redo(): void;
|
|
243
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Action which consists of pasting elements from an external source into a diagram.
|
|
263
|
+
*
|
|
264
|
+
* @private
|
|
265
|
+
*/
|
|
266
|
+
export declare class PasteAction implements DiagramAction {
|
|
267
|
+
canvas: Canvas;
|
|
268
|
+
nodes: DagaNode[];
|
|
269
|
+
connections: DagaConnection[];
|
|
270
|
+
coords?: Point;
|
|
271
|
+
constructor(canvas: Canvas, nodes: DagaNode[], connections: DagaConnection[], coords?: Point);
|
|
272
|
+
do(): void;
|
|
273
|
+
undo(): void;
|
|
274
|
+
redo(): void;
|
|
275
|
+
}
|
|
@@ -5,6 +5,7 @@ import { Canvas } from '../../interfaces/canvas';
|
|
|
5
5
|
import { DiagramEditor } from '../../interfaces/diagram-editor';
|
|
6
6
|
import { Point } from '../../util/canvas-util';
|
|
7
7
|
import { CursorStyle } from '../../util/style';
|
|
8
|
+
import { CollabEngine } from './collab/collab-engine';
|
|
8
9
|
import { ActionQueue, DiagramActions } from './diagram-action';
|
|
9
10
|
import { DiagramConfig } from './diagram-config';
|
|
10
11
|
import { DiagramConnection, DiagramConnectionType } from './diagram-connection';
|
|
@@ -12,7 +13,6 @@ import { DiagramElement } from './diagram-element';
|
|
|
12
13
|
import { DiagramModel } from './diagram-model';
|
|
13
14
|
import { DiagramPort } from './diagram-port';
|
|
14
15
|
import { ValueSet } from './diagram-property';
|
|
15
|
-
import { CollabEngine } from './collab/collab-engine';
|
|
16
16
|
/**
|
|
17
17
|
* Thickness of the invisible path around a connection used to make it easier to click on, in pixels.
|
|
18
18
|
* @private
|
|
@@ -59,6 +59,9 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
59
59
|
private priorityThresholds;
|
|
60
60
|
private mainUserHighlight?;
|
|
61
61
|
private userHighlight;
|
|
62
|
+
/**
|
|
63
|
+
* Elements selected by the user. Only nodes and connections should be selected.
|
|
64
|
+
*/
|
|
62
65
|
private userSelection;
|
|
63
66
|
private propertyEditorSelection?;
|
|
64
67
|
private propertyEditorValues?;
|
|
@@ -68,6 +71,7 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
68
71
|
*/
|
|
69
72
|
private unfinishedConnectionTracer?;
|
|
70
73
|
private inputFieldContainer?;
|
|
74
|
+
private contextMenuContainer?;
|
|
71
75
|
private draggingFrom;
|
|
72
76
|
private currentAction?;
|
|
73
77
|
viewInitialized$: Subject<void>;
|
|
@@ -87,8 +91,10 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
87
91
|
translateTo(x: number, y: number): void;
|
|
88
92
|
center(): void;
|
|
89
93
|
getClosestGridPoint(point: Point): Point;
|
|
94
|
+
getCoordinatesOnScreen(): [Point, Point];
|
|
90
95
|
private getEventHoldingCoordinates;
|
|
91
96
|
getPointerLocationRelativeToCanvas(event: MouseEvent): Point;
|
|
97
|
+
getPointerLocationRelativeToRoot(event: MouseEvent): Point;
|
|
92
98
|
getPointerLocationRelativeToBody(event: MouseEvent): Point;
|
|
93
99
|
getPointerLocationRelativeToScreen(event: MouseEvent): Point;
|
|
94
100
|
updateModelInView(): void;
|
|
@@ -97,11 +103,12 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
97
103
|
updatePortsInView(...ids: string[]): void;
|
|
98
104
|
updateConnectionsInView(...ids: string[]): void;
|
|
99
105
|
updateFieldsInView(...ids: string[]): void;
|
|
106
|
+
updateObjectsInView(...ids: string[]): void;
|
|
100
107
|
updateConnectionLabelsInView(connection: DiagramConnection): void;
|
|
101
108
|
updateConnectionMarkersInView(connection: DiagramConnection): void;
|
|
102
109
|
fitFieldRootInView(id: string): void;
|
|
103
110
|
fitNodeInView(id: string): void;
|
|
104
|
-
selectRoot(): d3.Selection<
|
|
111
|
+
selectRoot(): d3.Selection<SVGElement, unknown, null, unknown>;
|
|
105
112
|
selectCanvasView(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
106
113
|
selectCanvasElements(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
107
114
|
selectCanvasNodes(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
@@ -109,6 +116,7 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
109
116
|
selectCanvasPorts(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
110
117
|
selectCanvasConnections(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
111
118
|
selectCanvasFields(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
119
|
+
selectCanvasObjects(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
112
120
|
startConnection(port: DiagramPort): void;
|
|
113
121
|
finishConnection(port: DiagramPort): void;
|
|
114
122
|
dropConnection(): void;
|
|
@@ -122,6 +130,11 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
122
130
|
removeFromUserSelection(selection: DiagramElement): void;
|
|
123
131
|
toggleUserSelection(selection: DiagramElement): void;
|
|
124
132
|
clearUserSelection(): void;
|
|
133
|
+
deleteUserSelection(): void;
|
|
134
|
+
copyUserSelectionToClipboard(): void;
|
|
135
|
+
pasteUserSelectionFromClipboard(coords?: Point): void;
|
|
136
|
+
openContextMenu(event: MouseEvent): void;
|
|
137
|
+
closeContextMenu(): void;
|
|
125
138
|
cancelAllUserActions(): void;
|
|
126
139
|
canUserPerformAction(action: DiagramActions): boolean;
|
|
127
140
|
private createInputField;
|
|
@@ -2,6 +2,7 @@ import { Canvas } from '../../interfaces/canvas';
|
|
|
2
2
|
import { DiagramConnectionSet } from './diagram-connection';
|
|
3
3
|
import { DiagramFieldSet } from './diagram-field';
|
|
4
4
|
import { DiagramNodeSet } from './diagram-node';
|
|
5
|
+
import { DiagramObjectSet } from './diagram-object';
|
|
5
6
|
import { DiagramPortSet } from './diagram-port';
|
|
6
7
|
import { Property, ValueSet } from './diagram-property';
|
|
7
8
|
import { DiagramSectionSet } from './diagram-section';
|
|
@@ -46,6 +47,12 @@ export declare class DiagramModel {
|
|
|
46
47
|
* @public
|
|
47
48
|
*/
|
|
48
49
|
fields: DiagramFieldSet;
|
|
50
|
+
/**
|
|
51
|
+
* Objects of this model.
|
|
52
|
+
* @see DiagramObject
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
objects: DiagramObjectSet;
|
|
49
56
|
/**
|
|
50
57
|
* Identifier of this diagram. Set by the consumer of the diagram.
|
|
51
58
|
* @public
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Point } from '../../util/canvas-util';
|
|
2
|
+
import { DiagramElement, DiagramEntitySet } from './diagram-element';
|
|
3
|
+
import { DiagramModel } from './diagram-model';
|
|
4
|
+
/**
|
|
5
|
+
* A foreign object which is inserted with arbitrary html into a diagram.
|
|
6
|
+
* Diagram objects are not serialized with other diagram elements.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class DiagramObject extends DiagramElement {
|
|
10
|
+
/**
|
|
11
|
+
* Coordinates of this object.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
coords: Point;
|
|
15
|
+
/**
|
|
16
|
+
* Dimension of this object along the x axis.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
width: number;
|
|
20
|
+
/**
|
|
21
|
+
* Dimension of this object along the y axis.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
height: number;
|
|
25
|
+
priority: number;
|
|
26
|
+
html: string;
|
|
27
|
+
constructor(model: DiagramModel, coords: Point, width: number, height: number, priority: number, html: string, id: string);
|
|
28
|
+
select(): d3.Selection<SVGGElement, unknown, null, unknown> | undefined;
|
|
29
|
+
get removed(): boolean;
|
|
30
|
+
updateInView(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Change the coordinates of this object to the given coordinates.
|
|
33
|
+
* @public
|
|
34
|
+
* @param coords A point in the diagram.
|
|
35
|
+
*/
|
|
36
|
+
move(coords: Point): void;
|
|
37
|
+
getPriority(): number;
|
|
38
|
+
}
|
|
39
|
+
export declare class DiagramObjectSet extends DiagramEntitySet<DiagramObject> {
|
|
40
|
+
private model;
|
|
41
|
+
/**
|
|
42
|
+
* Instance a set of objects for the given model. This method is used internally.
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
constructor(model: DiagramModel);
|
|
46
|
+
/**
|
|
47
|
+
* Instance a new object and add it to this set.
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
new(coords: Point, width: number, height: number, priority: number, html: string, id: string): DiagramObject;
|
|
51
|
+
remove(id: string): void;
|
|
52
|
+
}
|
|
@@ -140,12 +140,23 @@ export interface Canvas {
|
|
|
140
140
|
* @param point A point.
|
|
141
141
|
*/
|
|
142
142
|
getClosestGridPoint(point: Point): Point;
|
|
143
|
+
/**
|
|
144
|
+
* Get the coordinates in the diagram of the points of the screen at the top left and the bottom right of the diagram view.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
getCoordinatesOnScreen(): [Point, Point];
|
|
143
148
|
/**
|
|
144
149
|
* Get the location of the pointer in the given event relative to the canvas.
|
|
145
150
|
* @private
|
|
146
151
|
* @param event A MouseEvent.
|
|
147
152
|
*/
|
|
148
153
|
getPointerLocationRelativeToCanvas(event: MouseEvent): Point;
|
|
154
|
+
/**
|
|
155
|
+
* Get the location of the pointer in the given event relative to the svg element.
|
|
156
|
+
* @private
|
|
157
|
+
* @param event A MouseEvent.
|
|
158
|
+
*/
|
|
159
|
+
getPointerLocationRelativeToRoot(event: MouseEvent): Point;
|
|
149
160
|
/**
|
|
150
161
|
* Get the location of the pointer in the given event relative to the body.
|
|
151
162
|
* @private
|
|
@@ -214,6 +225,11 @@ export interface Canvas {
|
|
|
214
225
|
* @public
|
|
215
226
|
*/
|
|
216
227
|
updateFieldsInView(...ids: string[]): void;
|
|
228
|
+
/**
|
|
229
|
+
* Update the view of the canvas to show the current state of the objects.
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
updateObjectsInView(...ids: string[]): void;
|
|
217
233
|
/**
|
|
218
234
|
* Fit the root of a diagram field to encompass the totality of the field.
|
|
219
235
|
* @param id The id of a diagram field
|
|
@@ -224,6 +240,11 @@ export interface Canvas {
|
|
|
224
240
|
* @param id The id of a node
|
|
225
241
|
*/
|
|
226
242
|
fitNodeInView(id: string): void;
|
|
243
|
+
/**
|
|
244
|
+
* Get the d3 Selection containing the svg root node of the canvas.
|
|
245
|
+
* @private
|
|
246
|
+
*/
|
|
247
|
+
selectRoot(): d3.Selection<SVGElement, unknown, null, unknown>;
|
|
227
248
|
/**
|
|
228
249
|
* Get the d3 Selection containing the view of all the elements in the canvas.
|
|
229
250
|
* @private
|
|
@@ -271,6 +292,31 @@ export interface Canvas {
|
|
|
271
292
|
* @private
|
|
272
293
|
*/
|
|
273
294
|
clearUserSelection(): void;
|
|
295
|
+
/**
|
|
296
|
+
* Removes all elements in the user selection from the canvas.
|
|
297
|
+
* @private
|
|
298
|
+
*/
|
|
299
|
+
deleteUserSelection(): void;
|
|
300
|
+
/**
|
|
301
|
+
* Copies all elements in the user selection to the clipboard.
|
|
302
|
+
* @private
|
|
303
|
+
*/
|
|
304
|
+
copyUserSelectionToClipboard(): void;
|
|
305
|
+
/**
|
|
306
|
+
* Pastes all elements in the clipboard to the model.
|
|
307
|
+
* @private
|
|
308
|
+
*/
|
|
309
|
+
pasteUserSelectionFromClipboard(coords?: Point): void;
|
|
310
|
+
/**
|
|
311
|
+
* Opens the context menu based on the given event.
|
|
312
|
+
* @private
|
|
313
|
+
*/
|
|
314
|
+
openContextMenu(event: MouseEvent): void;
|
|
315
|
+
/**
|
|
316
|
+
* Closes the context menu.
|
|
317
|
+
* @private
|
|
318
|
+
*/
|
|
319
|
+
closeContextMenu(): void;
|
|
274
320
|
/**
|
|
275
321
|
* Stops all unfinished user actions to ensure there are no unfinished actions before performing a different action.
|
|
276
322
|
* @public
|
package/lib/util/events.d.ts
CHANGED
|
@@ -6,15 +6,21 @@ export declare enum Events {
|
|
|
6
6
|
Blur = "blur",
|
|
7
7
|
Change = "change",
|
|
8
8
|
Click = "click",
|
|
9
|
+
ContextMenu = "contextmenu",
|
|
9
10
|
DoubleClick = "dblclick",
|
|
10
11
|
Focus = "focus",
|
|
11
12
|
FocusIn = "focusin",
|
|
12
13
|
FocusOut = "focusout",
|
|
13
14
|
Input = "input",
|
|
15
|
+
KeyDown = "keydown",
|
|
14
16
|
KeyUp = "keyup",
|
|
17
|
+
MouseDown = "mousedown",
|
|
15
18
|
MouseMove = "mousemove",
|
|
16
19
|
MouseOut = "mouseout",
|
|
17
20
|
MouseOver = "mouseover",
|
|
21
|
+
MouseUp = "mouseup",
|
|
22
|
+
TouchStart = "touchstart",
|
|
23
|
+
TouchEnd = "touchend",
|
|
18
24
|
Wheel = "wheel"
|
|
19
25
|
}
|
|
20
26
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metadev/daga",
|
|
3
3
|
"description": "Diagramming engine for editing models on the Web. Made by Metadev.",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"author": "Metadev (https://metadev.pro)",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"repository": "git+https://github.com/metadevpro/daga-tutorial.git",
|