@metadev/daga 1.4.1 → 1.4.2
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 +18 -1
- package/assets/styles/_property-editor.scss +225 -157
- package/assets/styles/daga.scss +149 -156
- package/fesm2022/metadev-daga.mjs +1537 -592
- package/fesm2022/metadev-daga.mjs.map +1 -1
- package/index.d.ts +5 -3
- package/lib/daga.module.d.ts +4 -5
- package/lib/diagram-editor/diagram/collab/collab-action.d.ts +90 -0
- package/lib/diagram-editor/diagram/collab/collab-client.d.ts +57 -0
- package/lib/diagram-editor/diagram/collab/collab-engine.d.ts +46 -0
- package/lib/diagram-editor/diagram/collab/message-types.d.ts +97 -0
- package/lib/diagram-editor/diagram/collab/primitives.d.ts +15 -0
- package/lib/diagram-editor/diagram/converters/daga-model.d.ts +3 -0
- package/lib/diagram-editor/diagram/diagram-action.d.ts +27 -19
- package/lib/diagram-editor/diagram/diagram-canvas.d.ts +3 -1
- package/lib/diagram-editor/diagram/diagram-connection.d.ts +35 -3
- package/lib/diagram-editor/diagram/diagram-element.d.ts +7 -2
- package/lib/diagram-editor/diagram/diagram-field.d.ts +13 -2
- package/lib/diagram-editor/diagram/diagram-model.d.ts +6 -0
- package/lib/diagram-editor/diagram/diagram-node.d.ts +67 -3
- package/lib/diagram-editor/diagram/diagram-port.d.ts +28 -2
- package/lib/diagram-editor/diagram/diagram-property.d.ts +143 -19
- package/lib/diagram-editor/diagram/diagram-section.d.ts +40 -3
- package/lib/interfaces/canvas.d.ts +7 -0
- package/lib/property-editor/autocomplete/autocomplete.component.d.ts +39 -0
- package/lib/{object-editor → property-editor/object-editor}/object-editor.component.d.ts +5 -6
- package/lib/property-editor/option-list-editor/option-list-editor.component.d.ts +29 -0
- package/lib/{text-list-editor → property-editor/text-list-editor}/text-list-editor.component.d.ts +2 -2
- package/lib/{text-map-editor → property-editor/text-map-editor}/text-map-editor.component.d.ts +2 -2
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { CollapseButtonComponent } from './lib/collapse-button/collapse-button.c
|
|
|
2
2
|
export { DagaModule } from './lib/daga.module';
|
|
3
3
|
export { DiagramButtonsComponent } from './lib/diagram-buttons/diagram-buttons.component';
|
|
4
4
|
export { DiagramEditorComponent } from './lib/diagram-editor/diagram-editor.component';
|
|
5
|
+
export { CollabClient } from './lib/diagram-editor/diagram/collab/collab-client';
|
|
6
|
+
export { CollabTimestamp as LogicalTimestamp } from './lib/diagram-editor/diagram/collab/primitives';
|
|
5
7
|
export { DagaExporter } from './lib/diagram-editor/diagram/converters/daga-exporter';
|
|
6
8
|
export { DagaImporter } from './lib/diagram-editor/diagram/converters/daga-importer';
|
|
7
9
|
export { DagaModel } from './lib/diagram-editor/diagram/converters/daga-model';
|
|
@@ -35,13 +37,13 @@ export { DiagramButtons } from './lib/interfaces/diagram-buttons';
|
|
|
35
37
|
export { DiagramEditor } from './lib/interfaces/diagram-editor';
|
|
36
38
|
export { Palette } from './lib/interfaces/palette';
|
|
37
39
|
export { PropertyEditor } from './lib/interfaces/property-editor';
|
|
38
|
-
export { ObjectEditorComponent } from './lib/object-editor/object-editor.component';
|
|
39
40
|
export { PaletteComponent } from './lib/palette/palette.component';
|
|
41
|
+
export { ObjectEditorComponent } from './lib/property-editor/object-editor/object-editor.component';
|
|
40
42
|
export { PropertyEditorComponent } from './lib/property-editor/property-editor.component';
|
|
43
|
+
export { TextListEditorComponent } from './lib/property-editor/text-list-editor/text-list-editor.component';
|
|
44
|
+
export { TextMapEditorComponent } from './lib/property-editor/text-map-editor/text-map-editor.component';
|
|
41
45
|
export { CanvasProviderService } from './lib/services/canvas-provider.service';
|
|
42
46
|
export { DagaConfigurationService } from './lib/services/daga-configuration.service';
|
|
43
|
-
export { TextListEditorComponent } from './lib/text-list-editor/text-list-editor.component';
|
|
44
|
-
export { TextMapEditorComponent } from './lib/text-map-editor/text-map-editor.component';
|
|
45
47
|
export { Line, Point, Rectangle } from './lib/util/canvas-util';
|
|
46
48
|
export { LineShape, LineStyle } from './lib/util/line';
|
|
47
49
|
export { ClosedShape } from './lib/util/shape';
|
package/lib/daga.module.d.ts
CHANGED
|
@@ -4,16 +4,15 @@ import * as i2 from "./diagram-buttons/diagram-buttons.component";
|
|
|
4
4
|
import * as i3 from "./diagram/diagram.component";
|
|
5
5
|
import * as i4 from "./diagram-editor/diagram-editor.component";
|
|
6
6
|
import * as i5 from "./errors/errors.component";
|
|
7
|
-
import * as i6 from "./object-editor/object-editor.component";
|
|
7
|
+
import * as i6 from "./property-editor/object-editor/object-editor.component";
|
|
8
8
|
import * as i7 from "./palette/palette.component";
|
|
9
|
-
import * as i8 from "./text-list-editor/text-list-editor.component";
|
|
10
|
-
import * as i9 from "./text-map-editor/text-map-editor.component";
|
|
9
|
+
import * as i8 from "./property-editor/text-list-editor/text-list-editor.component";
|
|
10
|
+
import * as i9 from "./property-editor/text-map-editor/text-map-editor.component";
|
|
11
11
|
import * as i10 from "./property-editor/property-editor.component";
|
|
12
12
|
import * as i11 from "@angular/common";
|
|
13
13
|
import * as i12 from "@angular/forms";
|
|
14
|
-
import * as i13 from "@metadev/lux";
|
|
15
14
|
export declare class DagaModule {
|
|
16
15
|
static ɵfac: i0.ɵɵFactoryDeclaration<DagaModule, never>;
|
|
17
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<DagaModule, never, [typeof i1.CollapseButtonComponent, typeof i2.DiagramButtonsComponent, typeof i3.DiagramComponent, typeof i4.DiagramEditorComponent, typeof i5.ErrorsComponent, typeof i6.ObjectEditorComponent, typeof i7.PaletteComponent, typeof i8.TextListEditorComponent, typeof i9.TextMapEditorComponent, typeof i10.PropertyEditorComponent, typeof i11.CommonModule, typeof i12.FormsModule
|
|
16
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<DagaModule, never, [typeof i1.CollapseButtonComponent, typeof i2.DiagramButtonsComponent, typeof i3.DiagramComponent, typeof i4.DiagramEditorComponent, typeof i5.ErrorsComponent, typeof i6.ObjectEditorComponent, typeof i7.PaletteComponent, typeof i8.TextListEditorComponent, typeof i9.TextMapEditorComponent, typeof i10.PropertyEditorComponent, typeof i11.CommonModule, typeof i12.FormsModule], [typeof i3.DiagramComponent, typeof i4.DiagramEditorComponent]>;
|
|
18
17
|
static ɵinj: i0.ɵɵInjectorDeclaration<DagaModule>;
|
|
19
18
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Canvas } from '../../../interfaces/canvas';
|
|
2
|
+
import { Point } from '../../../util/canvas-util';
|
|
3
|
+
import { CollabTimestamp } from './primitives';
|
|
4
|
+
/**
|
|
5
|
+
* An action taken by a local or remote user.
|
|
6
|
+
*
|
|
7
|
+
* The action can performed on its creator's device, serialized
|
|
8
|
+
* and deserialized to reach remote users' devices, and performed
|
|
9
|
+
* on remote users' devices.
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export interface CollabAction {
|
|
13
|
+
/**
|
|
14
|
+
* Performs this action on the diagram.
|
|
15
|
+
*
|
|
16
|
+
* Note: Local Actions should call `canvas.collabEngine.doCollaboratively(collabAction)`, **not** this method directly.
|
|
17
|
+
*
|
|
18
|
+
* CollabAction `do()` methods must follow the rules of operation-based CRDT messages:
|
|
19
|
+
* If two users concurrently create CollabActions (possibly of different types) on the same diagram, then performing the actions on a future diagram state _in either order_ must result in the same diagram state.
|
|
20
|
+
*/
|
|
21
|
+
do(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Serializes this action, converting it to a JSON form.
|
|
24
|
+
*
|
|
25
|
+
* To deserialize, use the *static* deserialize method on the same class.
|
|
26
|
+
*/
|
|
27
|
+
serialize(): CollabActionSerialized;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
export type CollabActionSerialized = AddNodeSerialized | MoveNodeSerialized;
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
export type AddNodeSerialized = {
|
|
37
|
+
type: 'add';
|
|
38
|
+
id: string;
|
|
39
|
+
nodeTypeId: string;
|
|
40
|
+
coords: Point;
|
|
41
|
+
label?: string;
|
|
42
|
+
values?: {
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Collaborative action which consists of adding a node.
|
|
48
|
+
* @see AddNodeAction
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
export declare class AddNodeCollabAction implements CollabAction {
|
|
52
|
+
canvas: Canvas;
|
|
53
|
+
id: string;
|
|
54
|
+
nodeTypeId: string;
|
|
55
|
+
coords: Point;
|
|
56
|
+
label?: string;
|
|
57
|
+
values?: {
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
constructor(canvas: Canvas, id: string, nodeTypeId: string, coords: Point, label?: string, values?: {
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
});
|
|
63
|
+
do(): void;
|
|
64
|
+
serialize(): AddNodeSerialized;
|
|
65
|
+
static deserialize(canvas: Canvas, serialized: AddNodeSerialized): AddNodeCollabAction;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
export type MoveNodeSerialized = {
|
|
71
|
+
type: 'move';
|
|
72
|
+
nodeId: string;
|
|
73
|
+
to: Point;
|
|
74
|
+
timestamp: CollabTimestamp;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Collaborative action which consists of moving a node.
|
|
78
|
+
* @see MoveNodeAction
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
export declare class MoveNodeCollabAction implements CollabAction {
|
|
82
|
+
readonly canvas: Canvas;
|
|
83
|
+
readonly nodeId: string;
|
|
84
|
+
readonly to: Point;
|
|
85
|
+
readonly timestamp: CollabTimestamp;
|
|
86
|
+
constructor(canvas: Canvas, nodeId: string, to: Point, timestamp: CollabTimestamp);
|
|
87
|
+
do(): void;
|
|
88
|
+
serialize(): MoveNodeSerialized;
|
|
89
|
+
static deserialize(canvas: Canvas, serialized: MoveNodeSerialized): MoveNodeCollabAction;
|
|
90
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Canvas } from '../../../interfaces/canvas';
|
|
2
|
+
/**
|
|
3
|
+
* The client that communicates with the daga-server over WebSockets.
|
|
4
|
+
*
|
|
5
|
+
* Use this to create and join rooms.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class CollabClient {
|
|
9
|
+
/**
|
|
10
|
+
* The WebSocket URL of the daga-server.
|
|
11
|
+
*/
|
|
12
|
+
readonly dagaServer: string;
|
|
13
|
+
readonly userId: string;
|
|
14
|
+
readonly clientId: string;
|
|
15
|
+
private readonly ws;
|
|
16
|
+
private sendQueue;
|
|
17
|
+
/**
|
|
18
|
+
* Joined sessions by locator.
|
|
19
|
+
*/
|
|
20
|
+
private sessions;
|
|
21
|
+
/**
|
|
22
|
+
* Created but unacked sessions by refId.
|
|
23
|
+
*/
|
|
24
|
+
private pendingSessions;
|
|
25
|
+
constructor(dagaServer: string, userId: string);
|
|
26
|
+
private onOpen;
|
|
27
|
+
private onMessage;
|
|
28
|
+
private onClose;
|
|
29
|
+
private onError;
|
|
30
|
+
/**
|
|
31
|
+
* Internal send method. Use instead of calling ws.send directly.
|
|
32
|
+
*/
|
|
33
|
+
private send;
|
|
34
|
+
/**
|
|
35
|
+
* Internal receive method. Use instead of handling ws receive events directly.
|
|
36
|
+
*/
|
|
37
|
+
private receive;
|
|
38
|
+
/**
|
|
39
|
+
* Creates and joins a room. The given canvas becomes collaborative, starting
|
|
40
|
+
* with its current model.
|
|
41
|
+
*
|
|
42
|
+
* Returns a Promise that resolves with the new room's locator once joined.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
createAndJoinRoom(canvas: Canvas): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Joins the room with the given locator. The given canvas becomes collaborative,
|
|
48
|
+
* **replacing** its current model with the room's model.
|
|
49
|
+
*
|
|
50
|
+
* Returns a Promise that resolves once the room has been joined and loaded into
|
|
51
|
+
* the canvas. You should hide or lock the canvas until it resolves, since any
|
|
52
|
+
* user inputs before then will be overwritten.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
joinRoom(canvas: Canvas, locator: string): Promise<void>;
|
|
56
|
+
private startSyncing;
|
|
57
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Canvas } from '../../../interfaces/canvas';
|
|
2
|
+
import { CollabAction, CollabActionSerialized } from './collab-action';
|
|
3
|
+
import { CollabTimestamp } from './primitives';
|
|
4
|
+
/**
|
|
5
|
+
* A collaboration engine, which manages collaboration for a diagram.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
export declare class CollabEngine {
|
|
9
|
+
/**
|
|
10
|
+
* Canvas that this collaboration engine belongs to.
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
readonly canvas: Canvas;
|
|
14
|
+
/**
|
|
15
|
+
* The local replica ID.
|
|
16
|
+
*/
|
|
17
|
+
readonly replicaId: string;
|
|
18
|
+
/**
|
|
19
|
+
* Event handler for when we request to send a message to the server.
|
|
20
|
+
*/
|
|
21
|
+
onSend?: (message: CollabActionSerialized) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Whether we have joined (or are joining) a room on the server.
|
|
24
|
+
*/
|
|
25
|
+
isInRoom: boolean;
|
|
26
|
+
constructor(canvas: Canvas);
|
|
27
|
+
/**
|
|
28
|
+
* Returns a fresh timestamp, suitable for use by new CollabActions.
|
|
29
|
+
*/
|
|
30
|
+
freshTimestamp(): CollabTimestamp;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a fresh unique ID, suitable for use by new CollabActions.
|
|
33
|
+
*/
|
|
34
|
+
freshId(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Performs the action - immediately locally, and eventually for remote collaborators.
|
|
37
|
+
*/
|
|
38
|
+
doCollaboratively(action: CollabAction): void;
|
|
39
|
+
/**
|
|
40
|
+
* Processes a message received from the server.
|
|
41
|
+
*
|
|
42
|
+
* The message is assumed to be non-redundant (in particular, not one of
|
|
43
|
+
* our own messages) and delivered after all prior messages on the server.
|
|
44
|
+
*/
|
|
45
|
+
receive(message: CollabActionSerialized): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message types for communicating with the daga server.
|
|
3
|
+
*
|
|
4
|
+
* Duplicated between https://github.com/metadevpro/daga-server/blob/dev/types.ts and
|
|
5
|
+
* https://github.com/metadevpro/daga/blob/dev/libs/daga/src/lib/diagram-editor/diagram/collab/message-types.ts
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Stand-in for the DagaModel type on the server.
|
|
9
|
+
*/
|
|
10
|
+
export interface DagaModelStub {
|
|
11
|
+
}
|
|
12
|
+
export interface RoomInfo {
|
|
13
|
+
locator: string;
|
|
14
|
+
ownerId: string;
|
|
15
|
+
initialModel: DagaModelStub;
|
|
16
|
+
messages: AddMessage[];
|
|
17
|
+
}
|
|
18
|
+
export interface UserInfo {
|
|
19
|
+
id: string;
|
|
20
|
+
username: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ClientInfo {
|
|
23
|
+
key: string;
|
|
24
|
+
connection: unknown;
|
|
25
|
+
user: UserInfo;
|
|
26
|
+
ts: string;
|
|
27
|
+
}
|
|
28
|
+
export interface IMessage {
|
|
29
|
+
ts: string;
|
|
30
|
+
}
|
|
31
|
+
export type Message = HeloMessage | ByeMessage | CreateMessage | CreateAckMessage | EnrollMessage | EnrollAckMessage | DeleteMessage | AddMessage | ErrorMessage | OkMessage;
|
|
32
|
+
export interface HeloMessage extends IMessage {
|
|
33
|
+
type: 'HELO';
|
|
34
|
+
clientId: string;
|
|
35
|
+
userId: string;
|
|
36
|
+
token?: string;
|
|
37
|
+
/** version of the protocol */
|
|
38
|
+
version: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ByeMessage extends IMessage {
|
|
41
|
+
type: 'BYE';
|
|
42
|
+
clientId: string;
|
|
43
|
+
userId: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CreateMessage extends IMessage {
|
|
46
|
+
type: 'CREA';
|
|
47
|
+
clientId: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
/** Correlation id for the client */
|
|
50
|
+
refId: string;
|
|
51
|
+
initialModel: DagaModelStub;
|
|
52
|
+
}
|
|
53
|
+
export interface CreateAckMessage extends IMessage {
|
|
54
|
+
type: 'CACK';
|
|
55
|
+
clientId: string;
|
|
56
|
+
userId: string;
|
|
57
|
+
/** Correlation id for the client */
|
|
58
|
+
refId: string;
|
|
59
|
+
locator: string;
|
|
60
|
+
}
|
|
61
|
+
export interface EnrollMessage extends IMessage {
|
|
62
|
+
type: 'ENRO';
|
|
63
|
+
clientId: string;
|
|
64
|
+
userId: string;
|
|
65
|
+
locator: string;
|
|
66
|
+
}
|
|
67
|
+
export interface EnrollAckMessage extends IMessage {
|
|
68
|
+
type: 'EACK';
|
|
69
|
+
locator: string;
|
|
70
|
+
initialModel: DagaModelStub;
|
|
71
|
+
}
|
|
72
|
+
export interface DeleteMessage extends IMessage {
|
|
73
|
+
type: 'DLTE';
|
|
74
|
+
clientId: string;
|
|
75
|
+
userId: string;
|
|
76
|
+
locator: string;
|
|
77
|
+
}
|
|
78
|
+
export interface AddMessage extends IMessage {
|
|
79
|
+
type: 'ADD';
|
|
80
|
+
clientId: string;
|
|
81
|
+
userId: string;
|
|
82
|
+
locator: string;
|
|
83
|
+
payload: unknown;
|
|
84
|
+
}
|
|
85
|
+
export interface ErrorMessage extends IMessage {
|
|
86
|
+
type: 'ERR';
|
|
87
|
+
clientId: string;
|
|
88
|
+
userId: string;
|
|
89
|
+
locator: string;
|
|
90
|
+
status: number;
|
|
91
|
+
description: string;
|
|
92
|
+
}
|
|
93
|
+
export interface OkMessage extends IMessage {
|
|
94
|
+
type: 'OK';
|
|
95
|
+
clientId: string;
|
|
96
|
+
userId: string;
|
|
97
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A timestamp used to break ties during collaborative editing.
|
|
3
|
+
* If multiple users edit a property at the same time, the edit with the last timestamp "wins".
|
|
4
|
+
*
|
|
5
|
+
* Specifically, `CollabTimestamp` is a [Lamport timestamp](https://en.wikipedia.org/wiki/Lamport_timestamp),
|
|
6
|
+
* consisting of a logical clock and a tiebreaker (`replicaId`, a UUID that is created fresh for each diagram).
|
|
7
|
+
*/
|
|
8
|
+
export type CollabTimestamp = [clock: number, replicaId: string];
|
|
9
|
+
/**
|
|
10
|
+
* Returns whether the incoming timestamp wins over the existing timestamp.
|
|
11
|
+
*
|
|
12
|
+
* In the DiagramModel, timestamps that have never been set are left undefined;
|
|
13
|
+
* `timestampWins` treats that as an "initial timestamp" that loses to all LogicalTimestamps.
|
|
14
|
+
*/
|
|
15
|
+
export declare function timestampWins(incoming: CollabTimestamp, existing: CollabTimestamp | undefined): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Point } from '../../../util/canvas-util';
|
|
2
2
|
import { Side } from '../../../util/svg-util';
|
|
3
|
+
import { CollabTimestamp } from '../collab/primitives';
|
|
3
4
|
export declare const DAGA_FILE_VERSION = 1;
|
|
4
5
|
/**
|
|
5
6
|
* Representation of a diagram model in a serialized format.
|
|
@@ -18,6 +19,7 @@ export interface DagaModel {
|
|
|
18
19
|
createdAt: Date;
|
|
19
20
|
updatedAt: Date;
|
|
20
21
|
updatedDaysAgo?: string;
|
|
22
|
+
logicalClock?: number;
|
|
21
23
|
nodes: {
|
|
22
24
|
id: string;
|
|
23
25
|
type: string;
|
|
@@ -44,6 +46,7 @@ export interface DagaModel {
|
|
|
44
46
|
}[];
|
|
45
47
|
label: string;
|
|
46
48
|
coords: Point;
|
|
49
|
+
coordsTimestamp?: CollabTimestamp;
|
|
47
50
|
width: number;
|
|
48
51
|
height: number;
|
|
49
52
|
data: {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Canvas } from '../../interfaces/canvas';
|
|
2
2
|
import { Point } from '../../util/canvas-util';
|
|
3
3
|
import { Side } from '../../util/svg-util';
|
|
4
|
-
import {
|
|
5
|
-
import { DiagramField } from './diagram-field';
|
|
4
|
+
import { DiagramConnectionType } from './diagram-connection';
|
|
6
5
|
import { DiagramModel } from './diagram-model';
|
|
7
|
-
import {
|
|
8
|
-
import { DiagramPort } from './diagram-port';
|
|
6
|
+
import { DiagramNodeType } from './diagram-node';
|
|
9
7
|
import { ValueSet } from './diagram-property';
|
|
10
|
-
import { DiagramSection } from './diagram-section';
|
|
11
8
|
/**
|
|
12
9
|
* A queue of recent actions taken by the user that can be undone and redone.
|
|
13
10
|
* @private
|
|
@@ -56,7 +53,21 @@ export declare class ActionQueue {
|
|
|
56
53
|
* @private
|
|
57
54
|
*/
|
|
58
55
|
export interface DiagramAction {
|
|
56
|
+
/**
|
|
57
|
+
* Perform this action on the diagram for the first time.
|
|
58
|
+
* Performing the same action with the same parameters on a diagram with the same state should always result in the same changes to the state of the diagram.
|
|
59
|
+
*/
|
|
60
|
+
do(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Undo the changes in the diagram caused by this action.
|
|
63
|
+
* After having called `do()` followed by `undo()`, calling `redo()` followed by `undo()` any number of times should always result in no net changes to the state of the diagram.
|
|
64
|
+
*/
|
|
59
65
|
undo(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Redo the changes in the diagram caused by this action.
|
|
68
|
+
* After having called `do()`, calling `undo()` followed by `redo()` any number of times should always result in no net changes to the state of the diagram.
|
|
69
|
+
* `redo()` is usually equivalent to `do()`, but not always.
|
|
70
|
+
*/
|
|
60
71
|
redo(): void;
|
|
61
72
|
}
|
|
62
73
|
/**
|
|
@@ -132,16 +143,11 @@ export declare class AddNodeAction implements DiagramAction {
|
|
|
132
143
|
values?: {
|
|
133
144
|
[key: string]: unknown;
|
|
134
145
|
};
|
|
135
|
-
id
|
|
136
|
-
sectionIds?: (string | undefined)[];
|
|
137
|
-
sectionPortIds?: (string | undefined)[][];
|
|
138
|
-
sectionPortLabelIds?: (string | undefined)[][];
|
|
139
|
-
portIds?: (string | undefined)[];
|
|
140
|
-
portLabelIds?: (string | undefined)[];
|
|
141
|
-
labelId?: string | undefined;
|
|
146
|
+
id: string;
|
|
142
147
|
constructor(canvas: Canvas, type: DiagramNodeType, coords: Point, label?: string, values?: {
|
|
143
148
|
[key: string]: unknown;
|
|
144
|
-
}
|
|
149
|
+
});
|
|
150
|
+
do(): void;
|
|
145
151
|
undo(): void;
|
|
146
152
|
redo(): void;
|
|
147
153
|
}
|
|
@@ -156,6 +162,7 @@ export declare class MoveNodeAction implements DiagramAction {
|
|
|
156
162
|
from: Point;
|
|
157
163
|
to: Point;
|
|
158
164
|
constructor(canvas: Canvas, nodeId: string, from: Point, to: Point);
|
|
165
|
+
do(): void;
|
|
159
166
|
undo(): void;
|
|
160
167
|
redo(): void;
|
|
161
168
|
}
|
|
@@ -171,6 +178,7 @@ export declare class StretchNodeAction implements DiagramAction {
|
|
|
171
178
|
from: number;
|
|
172
179
|
to: number;
|
|
173
180
|
constructor(canvas: Canvas, nodeId: string, direction: Side, from: number, to: number);
|
|
181
|
+
do(): void;
|
|
174
182
|
undo(): void;
|
|
175
183
|
redo(): void;
|
|
176
184
|
}
|
|
@@ -186,6 +194,7 @@ export declare class StretchSectionAction implements DiagramAction {
|
|
|
186
194
|
from: number;
|
|
187
195
|
to: number;
|
|
188
196
|
constructor(canvas: Canvas, sectionId: string, direction: Side, from: number, to: number);
|
|
197
|
+
do(): void;
|
|
189
198
|
undo(): void;
|
|
190
199
|
redo(): void;
|
|
191
200
|
}
|
|
@@ -201,6 +210,7 @@ export declare class AddConnectionAction implements DiagramAction {
|
|
|
201
210
|
endId: string;
|
|
202
211
|
id?: string;
|
|
203
212
|
constructor(canvas: Canvas, type: DiagramConnectionType, startId: string, endId: string, id?: string);
|
|
213
|
+
do(): void;
|
|
204
214
|
undo(): void;
|
|
205
215
|
redo(): void;
|
|
206
216
|
}
|
|
@@ -215,6 +225,7 @@ export declare class EditFieldAction implements DiagramAction {
|
|
|
215
225
|
from: string;
|
|
216
226
|
to: string;
|
|
217
227
|
constructor(canvas: Canvas, fieldId: string, from: string, to: string);
|
|
228
|
+
do(): void;
|
|
218
229
|
undo(): void;
|
|
219
230
|
redo(): void;
|
|
220
231
|
}
|
|
@@ -238,6 +249,7 @@ export declare class UpdateValuesAction implements DiagramAction {
|
|
|
238
249
|
[key: string]: unknown;
|
|
239
250
|
});
|
|
240
251
|
getValueSet(): ValueSet | undefined;
|
|
252
|
+
do(): void;
|
|
241
253
|
undo(): void;
|
|
242
254
|
redo(): void;
|
|
243
255
|
}
|
|
@@ -247,17 +259,13 @@ export declare class UpdateValuesAction implements DiagramAction {
|
|
|
247
259
|
*/
|
|
248
260
|
export declare class RemoveAction implements DiagramAction {
|
|
249
261
|
model: DiagramModel;
|
|
250
|
-
nodes: DiagramNode[];
|
|
251
262
|
nodeIds: string[];
|
|
252
|
-
sections: DiagramSection[];
|
|
253
263
|
sectionIds: string[];
|
|
254
|
-
ports: DiagramPort[];
|
|
255
264
|
portIds: string[];
|
|
256
|
-
connections: DiagramConnection[];
|
|
257
265
|
connectionIds: string[];
|
|
258
|
-
fields: DiagramField[];
|
|
259
266
|
fieldIds: string[];
|
|
260
|
-
constructor(model: DiagramModel,
|
|
267
|
+
constructor(model: DiagramModel, nodeIds: string[], sectionIds: string[], portIds: string[], connectionIds: string[], fieldIds: string[]);
|
|
268
|
+
do(): void;
|
|
261
269
|
undo(): void;
|
|
262
270
|
redo(): void;
|
|
263
271
|
}
|
|
@@ -4,6 +4,7 @@ import { DiagramValidator } from '../../errors/diagram-validator';
|
|
|
4
4
|
import { Canvas } from '../../interfaces/canvas';
|
|
5
5
|
import { DiagramEditor } from '../../interfaces/diagram-editor';
|
|
6
6
|
import { Point } from '../../util/canvas-util';
|
|
7
|
+
import { CursorStyle } from '../../util/style';
|
|
7
8
|
import { ActionQueue, DiagramActions } from './diagram-action';
|
|
8
9
|
import { DiagramConfig } from './diagram-config';
|
|
9
10
|
import { DiagramConnection, DiagramConnectionType } from './diagram-connection';
|
|
@@ -11,7 +12,7 @@ import { DiagramElement } from './diagram-element';
|
|
|
11
12
|
import { DiagramModel } from './diagram-model';
|
|
12
13
|
import { DiagramPort } from './diagram-port';
|
|
13
14
|
import { ValueSet } from './diagram-property';
|
|
14
|
-
import {
|
|
15
|
+
import { CollabEngine } from './collab/collab-engine';
|
|
15
16
|
/**
|
|
16
17
|
* Thickness of the invisible path around a connection used to make it easier to click on, in pixels.
|
|
17
18
|
* @private
|
|
@@ -49,6 +50,7 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
49
50
|
[key in DiagramActions]?: boolean;
|
|
50
51
|
};
|
|
51
52
|
actionQueue: ActionQueue;
|
|
53
|
+
collabEngine: CollabEngine;
|
|
52
54
|
private static canvasCount;
|
|
53
55
|
private backgroundPatternId;
|
|
54
56
|
private zoomBehavior;
|
|
@@ -133,17 +133,49 @@ export declare class DiagramConnection extends DiagramElement {
|
|
|
133
133
|
set name(name: string);
|
|
134
134
|
constructor(model: DiagramModel, type: DiagramConnectionType, start?: DiagramPort, end?: DiagramPort, id?: string);
|
|
135
135
|
updateInView(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
|
|
138
|
+
* Add or remove this connection from the list of outgoing connections of ports correspondingly.
|
|
139
|
+
* @public
|
|
140
|
+
* @param start A port.
|
|
141
|
+
*/
|
|
136
142
|
setStart(start?: DiagramPort): void;
|
|
143
|
+
/**
|
|
144
|
+
* Set the end of this connection to the given port or reset this connection's ending port if `undefined`.
|
|
145
|
+
* Add or remove this connection from the list of incoming connections of ports correspondingly.
|
|
146
|
+
* @public
|
|
147
|
+
* @param end A port.
|
|
148
|
+
*/
|
|
137
149
|
setEnd(end?: DiagramPort): void;
|
|
150
|
+
/**
|
|
151
|
+
* Reassign the start and end ports of this connection to ports with less distance between them that have the same root element.
|
|
152
|
+
* If no ports with less distance between them are found, do nothing.
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
138
155
|
tighten(): void;
|
|
139
156
|
getPriority(): number;
|
|
140
157
|
}
|
|
141
158
|
export declare class DiagramConnectionSet extends DiagramEntitySet<DiagramConnection> {
|
|
142
159
|
private model;
|
|
160
|
+
/**
|
|
161
|
+
* Set of the possible types of connection that the connections of this set can have.
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
143
164
|
types: DiagramEntitySet<DiagramConnectionType>;
|
|
165
|
+
/**
|
|
166
|
+
* Instance a set of connections for the given model. This method is used internally.
|
|
167
|
+
* @private
|
|
168
|
+
*/
|
|
144
169
|
constructor(model: DiagramModel);
|
|
145
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Instance a new connection and add it to this set.
|
|
172
|
+
* @public
|
|
173
|
+
* @param type The type of the connection given as either the type itself or the id of the type.
|
|
174
|
+
* @param start The start port of the connection.
|
|
175
|
+
* @param end The end port of the connection.
|
|
176
|
+
* @param id The id of the connection. Should be left undefined unless a specific id is required.
|
|
177
|
+
* @returns The instanced connection.
|
|
178
|
+
*/
|
|
179
|
+
new(type: DiagramConnectionType | string, start?: DiagramPort, end?: DiagramPort, id?: string | undefined): DiagramConnection;
|
|
146
180
|
remove(id: string): void;
|
|
147
|
-
filter(type?: string, threshold?: number): DiagramConnection[];
|
|
148
|
-
find(type?: string, threshold?: number): DiagramConnection | undefined;
|
|
149
181
|
}
|
|
@@ -41,6 +41,11 @@ export declare abstract class DiagramElement implements DiagramEntity {
|
|
|
41
41
|
* @private
|
|
42
42
|
*/
|
|
43
43
|
selected: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether this diagram element has been removed.
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
removed: boolean;
|
|
44
49
|
constructor(model: DiagramModel, id: string);
|
|
45
50
|
/**
|
|
46
51
|
* Get the priority of this element to calculate whether it should be filtered out in the view or not.
|
|
@@ -112,13 +117,13 @@ export declare class DiagramEntitySet<E extends DiagramEntity> implements Iterab
|
|
|
112
117
|
* @public
|
|
113
118
|
* @returns An array containing the entities of this set that meet the given criteria.
|
|
114
119
|
*/
|
|
115
|
-
filter(): E[];
|
|
120
|
+
filter(predicate: (value: E, index: number, array: E[]) => unknown): E[];
|
|
116
121
|
/**
|
|
117
122
|
* Gets an entity of this set matching specific criteria.
|
|
118
123
|
* @public
|
|
119
124
|
* @returns An entity of this set.
|
|
120
125
|
*/
|
|
121
|
-
find(): E | undefined;
|
|
126
|
+
find(predicate: (value: E, index: number, array: E[]) => unknown): E | undefined;
|
|
122
127
|
/**
|
|
123
128
|
* Gets an entity from this set.
|
|
124
129
|
* @public
|
|
@@ -105,14 +105,25 @@ export declare class DiagramField extends DiagramElement {
|
|
|
105
105
|
constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | DiagramPort | undefined, coords: Point, width: number, height: number, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, text: string, editable: boolean, fit: boolean, id?: string);
|
|
106
106
|
select(): d3.Selection<SVGGElement, unknown, null, unknown> | undefined;
|
|
107
107
|
updateInView(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Change the coordinates of this field to the given coordinates.
|
|
110
|
+
* @public
|
|
111
|
+
* @param coords A point in the diagram.
|
|
112
|
+
*/
|
|
108
113
|
move(coords: Point): void;
|
|
109
114
|
getPriority(): number;
|
|
110
115
|
}
|
|
111
116
|
export declare class DiagramFieldSet extends DiagramEntitySet<DiagramField> {
|
|
112
117
|
private model;
|
|
118
|
+
/**
|
|
119
|
+
* Instance a set of fields for the given model. This method is used internally.
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
113
122
|
constructor(model: DiagramModel);
|
|
123
|
+
/**
|
|
124
|
+
* Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
114
127
|
new(rootElement: DiagramNode | DiagramSection | DiagramPort | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, text: string, editable: boolean, fit: boolean, id?: string | undefined): DiagramField;
|
|
115
128
|
remove(id: string): void;
|
|
116
|
-
filter(threshold?: number): DiagramField[];
|
|
117
|
-
find(threshold?: number): DiagramField | undefined;
|
|
118
129
|
}
|
|
@@ -7,6 +7,7 @@ import { Property, ValueSet } from './diagram-property';
|
|
|
7
7
|
import { DiagramSectionSet } from './diagram-section';
|
|
8
8
|
/**
|
|
9
9
|
* Stores the data of a diagram.
|
|
10
|
+
* Represents the state of the diagram.
|
|
10
11
|
* @public
|
|
11
12
|
*/
|
|
12
13
|
export declare class DiagramModel {
|
|
@@ -80,6 +81,11 @@ export declare class DiagramModel {
|
|
|
80
81
|
* @public
|
|
81
82
|
*/
|
|
82
83
|
valueSet: ValueSet;
|
|
84
|
+
/**
|
|
85
|
+
* The last-seen logical clock value, used to generate CollabTimestamps.
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
logicalClock: number;
|
|
83
89
|
constructor(canvas: Canvas | undefined, id: string | undefined, name: string, description: string | undefined, type: string, properties?: Property[]);
|
|
84
90
|
/**
|
|
85
91
|
* Deletes everything in this diagram.
|