@metadev/daga 5.0.5 → 5.1.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.
@@ -1,4 +1,4 @@
1
- import { Point } from '../../util/canvas-util';
1
+ import { AnchorPoint, Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { CollabTimestamp, CollabTimestampSet } from '../collab/primitives';
4
4
  export declare const DAGA_FILE_VERSION = 1;
@@ -18,9 +18,9 @@ export interface DagaModel {
18
18
  typeVersion: number;
19
19
  createdAt: Date;
20
20
  updatedAt: Date;
21
- updatedDaysAgo?: string;
22
21
  nodes: DagaNode[];
23
22
  connections: DagaConnection[];
23
+ objects?: DagaObject[];
24
24
  data: {
25
25
  [key: string]: unknown;
26
26
  };
@@ -35,6 +35,7 @@ export interface DagaNode {
35
35
  children?: DagaNode[];
36
36
  sections?: DagaSection[];
37
37
  ports?: DagaPort[];
38
+ decorators?: DagaDecorator[];
38
39
  label: string;
39
40
  coords: Point;
40
41
  width: number;
@@ -59,6 +60,7 @@ export interface DagaNode {
59
60
  export interface DagaSection {
60
61
  id: string;
61
62
  ports?: DagaPort[];
63
+ decorators?: DagaDecorator[];
62
64
  label: string;
63
65
  indexXInNode: number;
64
66
  indexYInNode: number;
@@ -115,3 +117,28 @@ export interface DagaConnection {
115
117
  dataTimestamps: CollabTimestampSet;
116
118
  };
117
119
  }
120
+ export interface DagaObject {
121
+ id: string;
122
+ coords: Point;
123
+ width: number;
124
+ height: number;
125
+ priority: number;
126
+ svg: string;
127
+ collabMeta?: {
128
+ removed: boolean;
129
+ selfRemoved: boolean;
130
+ };
131
+ }
132
+ export interface DagaDecorator {
133
+ id: string;
134
+ coords: Point;
135
+ width: number;
136
+ height: number;
137
+ priority: number;
138
+ anchorPoints: [AnchorPoint, AnchorPoint];
139
+ svg: string;
140
+ collabMeta?: {
141
+ removed: boolean;
142
+ selfRemoved: boolean;
143
+ };
144
+ }
@@ -33,7 +33,8 @@ export declare class DiagramZoomEvent extends DiagramEvent {
33
33
  /**
34
34
  * Create a diagram zoom event.
35
35
  *
36
- * @param coords .
36
+ * @param coords Coordinates to which the user panned. Calling the method `canvas.translateTo()` with these coordinates after this event should cause no changes.
37
+ * @param zoom Zoom level to which the user zoomed. Calling the method `canvas.zoomTo()` with this zoom level after this event should cause no changes.
37
38
  */
38
39
  constructor(coords: Point, zoom: number);
39
40
  }
@@ -3,12 +3,12 @@ import { LineShape, LineStyle } from '../../util/line';
3
3
  import { Side } from '../../util/svg-util';
4
4
  import { ConnectionTypeConfig, FieldConfig } from '../config/diagram-config';
5
5
  import { ConnectionLook, ConnectionLookConfig, MarkerImageLook, MarkerImageLookConfig } from '../config/diagram-look-config';
6
+ import { PropertySet } from '../property/property';
7
+ import { ValueSet } from '../property/value';
6
8
  import { DiagramElement, DiagramElementSet } from './diagram-element';
7
9
  import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
8
10
  import { DiagramModel } from './diagram-model';
9
11
  import { DiagramPort } from './diagram-port';
10
- import { PropertySet } from '../property/property';
11
- import { ValueSet } from '../property/value';
12
12
  /**
13
13
  * Default values of the parameters of a diagram connection.
14
14
  * @private
@@ -18,7 +18,6 @@ export declare const DIAGRAM_CONNECTION_TYPE_DEFAULTS: {
18
18
  name: string;
19
19
  label: null;
20
20
  look: {
21
- lookType: string;
22
21
  color: string;
23
22
  thickness: number;
24
23
  shape: LineShape;
@@ -4,7 +4,7 @@ import { DiagramModel } from './diagram-model';
4
4
  import { DiagramNode } from './diagram-node';
5
5
  import { DiagramSection } from './diagram-section';
6
6
  /**
7
- * A foreign object which is inserted with arbitrary html into a diagram.
7
+ * A foreign object which is inserted with arbitrary SVG code into a diagram.
8
8
  * Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
9
9
  * Diagram decorators are not serialized with other diagram elements.
10
10
  * @public
@@ -34,7 +34,7 @@ export declare class DiagramDecorator extends DiagramElement {
34
34
  */
35
35
  height: number;
36
36
  priority: number;
37
- html: string;
37
+ svg: string;
38
38
  /**
39
39
  * Horizontal anchor point for this decorator. Determines how the decorator behaves when its root element is resized.
40
40
  * @public
@@ -45,7 +45,7 @@ export declare class DiagramDecorator extends DiagramElement {
45
45
  * @public
46
46
  */
47
47
  anchorPointY: AnchorPoint;
48
- constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, width: number, height: number, priority: number, html: string, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint);
48
+ constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, width: number, height: number, priority: number, svg: string, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint);
49
49
  get removed(): boolean;
50
50
  updateInView(): void;
51
51
  raise(): void;
@@ -71,10 +71,10 @@ export declare class DiagramDecoratorSet extends DiagramElementSet<DiagramDecora
71
71
  * @param width The dimension of the decorator along the x axis.
72
72
  * @param height The dimension of the decorator along the y axis.
73
73
  * @param priority The priority of the decorator. Used when filtering by priority.
74
- * @param html The html contents of the decorator.
74
+ * @param svg The SVG contents of the decorator.
75
75
  * @param id The id of the decorator. Cannot be an empty string.
76
76
  * @returns The instanced decorator.
77
77
  */
78
- new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, width: number, height: number, priority: number, html: string, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint): DiagramDecorator;
78
+ new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, width: number, height: number, priority: number, svg: string, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint): DiagramDecorator;
79
79
  remove(id: string): void;
80
80
  }
@@ -2,6 +2,7 @@ import { Point } from '../../util/canvas-util';
2
2
  import { HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
3
3
  import { CollabTimestamp } from '../collab/primitives';
4
4
  import { FieldConfig } from '../config/diagram-config';
5
+ import { FieldLook, FieldLookConfig } from '../config/diagram-look-config';
5
6
  import { DiagramElement, DiagramElementSet } from './diagram-element';
6
7
  import { DiagramModel } from './diagram-model';
7
8
  /**
@@ -11,19 +12,21 @@ import { DiagramModel } from './diagram-model';
11
12
  */
12
13
  export declare const DIAGRAM_FIELD_DEFAULTS: {
13
14
  editable: boolean;
14
- fontSize: number;
15
15
  margin: number;
16
16
  padding: number;
17
- fontFamily: string;
18
- color: string;
19
- selectedColor: string;
20
- backgroundColor: string;
21
17
  horizontalAlign: HorizontalAlign;
22
18
  verticalAlign: VerticalAlign;
23
19
  orientation: Side;
24
20
  multiline: boolean;
25
21
  fit: boolean;
26
22
  shrink: boolean;
23
+ look: {
24
+ fillColor: string;
25
+ fontColor: string;
26
+ fontFamily: string;
27
+ fontSize: number;
28
+ fontWeight: number;
29
+ };
27
30
  };
28
31
  export interface LabeledElement {
29
32
  label?: DiagramField;
@@ -56,26 +59,6 @@ export declare class DiagramField extends DiagramElement {
56
59
  * @public
57
60
  */
58
61
  height: number;
59
- /**
60
- * Font size of this field.
61
- * @public
62
- */
63
- fontSize: number;
64
- /**
65
- * Font family of this field. `null` for the default one.
66
- * @public
67
- */
68
- fontFamily: string | null;
69
- /**
70
- * Font color of this field.
71
- * @public
72
- */
73
- color: string;
74
- /**
75
- * Font color of this field when selected.
76
- * @public
77
- */
78
- selectedColor: string;
79
62
  /**
80
63
  * Horizontal alignment of the text of this field.
81
64
  * @public
@@ -128,7 +111,16 @@ export declare class DiagramField extends DiagramElement {
128
111
  * @public
129
112
  */
130
113
  shrink: boolean;
131
- constructor(model: DiagramModel, rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, width: number, height: number, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, multiline: boolean, text: string, editable: boolean, fit: boolean, shrink: boolean);
114
+ private defaultLook;
115
+ private selectedLook;
116
+ private highlightedLook;
117
+ private selectedAndHighlightedLook;
118
+ /**
119
+ * Current look of this field.
120
+ * @private
121
+ */
122
+ get look(): FieldLook;
123
+ constructor(model: DiagramModel, rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, multiline: boolean, look: FieldLookConfig, text: string, editable: boolean, fit: boolean, shrink: boolean);
132
124
  get removed(): boolean;
133
125
  updateInView(): void;
134
126
  raise(): void;
@@ -151,7 +143,7 @@ export declare class DiagramFieldSet extends DiagramElementSet<DiagramField> {
151
143
  * 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.
152
144
  * @private
153
145
  */
154
- new(rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, multiline: boolean, text: string, editable: boolean, fit: boolean, shrink: boolean): DiagramField;
146
+ new(rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, multiline: boolean, look: FieldLookConfig, text: string, editable: boolean, fit: boolean, shrink: boolean): DiagramField;
155
147
  remove(id: string): void;
156
148
  }
157
149
  export declare const getBottomMargin: (config?: FieldConfig | null) => number;
@@ -1,7 +1,7 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { CollabTimestamp } from '../collab/primitives';
4
- import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig, ResizableMode } from '../config/diagram-config';
4
+ import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig } from '../config/diagram-config';
5
5
  import { ImageLook, ImageLookConfig, ShapedLook, ShapedLookConfig, StretchableImageLook, StretchableImageLookConfig } from '../config/diagram-look-config';
6
6
  import { PropertySet } from '../property/property';
7
7
  import { ValueSet } from '../property/value';
@@ -12,6 +12,7 @@ import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
12
12
  import { DiagramField, LabeledElement } from './diagram-field';
13
13
  import { DiagramModel } from './diagram-model';
14
14
  import { DiagramPort } from './diagram-port';
15
+ import { DiagramResizer } from './diagram-resizer';
15
16
  import { DiagramSection, DiagramSectionGeometry, DiagramSectionGrid } from './diagram-section';
16
17
  /**
17
18
  * Default values of the look of a diagram node.
@@ -75,8 +76,9 @@ export declare class DiagramNodeType implements DiagramEntity {
75
76
  defaultHeight: number;
76
77
  minWidth: number;
77
78
  minHeight: number;
78
- resizableX: boolean | ResizableMode;
79
- resizableY: boolean | ResizableMode;
79
+ resizerX: DiagramResizer;
80
+ resizerY: DiagramResizer;
81
+ resizerXY: DiagramResizer;
80
82
  snapToGridOffset: [number, number, number, number];
81
83
  bottomPadding: number;
82
84
  leftPadding: number;
@@ -182,7 +184,7 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
182
184
  private _highlightedLook?;
183
185
  private _selectedAndHighlightedLook?;
184
186
  /**
185
- * Current look of this port.
187
+ * Current look of this node.
186
188
  * @private
187
189
  */
188
190
  get look(): NodeLook;
@@ -207,6 +209,21 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
207
209
  updateInView(): void;
208
210
  raise(): void;
209
211
  getPriority(): number;
212
+ /**
213
+ * Returns the horizontal resizer of this node.
214
+ * @public
215
+ */
216
+ getResizerX(): DiagramResizer;
217
+ /**
218
+ * Returns the vertical resizer of this node.
219
+ * @public
220
+ */
221
+ getResizerY(): DiagramResizer;
222
+ /**
223
+ * Returns the diagonal resizer of this node.
224
+ * @public
225
+ */
226
+ getResizerXY(): DiagramResizer;
210
227
  /**
211
228
  * Returns whether this node can be resized horizontally.
212
229
  * @public
@@ -217,6 +234,11 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
217
234
  * @public
218
235
  */
219
236
  getResizableY(): boolean;
237
+ /**
238
+ * Returns whether this node can be resized diagonally.
239
+ * @public
240
+ */
241
+ getResizableXY(): boolean;
220
242
  /**
221
243
  * Get the port of this node which is closest to the given coordinates.
222
244
  * @param coords A point in the diagram.
@@ -2,7 +2,7 @@ import { Point } from '../../util/canvas-util';
2
2
  import { DiagramElement, DiagramElementSet } from './diagram-element';
3
3
  import { DiagramModel } from './diagram-model';
4
4
  /**
5
- * A foreign object which is inserted with arbitrary html into a diagram.
5
+ * A foreign object which is inserted with arbitrary SVG code into a diagram.
6
6
  * Diagram objects are not serialized with other diagram elements.
7
7
  * @public
8
8
  */
@@ -23,8 +23,8 @@ export declare class DiagramObject extends DiagramElement {
23
23
  */
24
24
  height: number;
25
25
  priority: number;
26
- html: string;
27
- constructor(model: DiagramModel, coords: Point, width: number, height: number, priority: number, html: string, id: string);
26
+ svg: string;
27
+ constructor(model: DiagramModel, coords: Point, width: number, height: number, priority: number, svg: string, id: string);
28
28
  get removed(): boolean;
29
29
  updateInView(): void;
30
30
  raise(): void;
@@ -50,10 +50,10 @@ export declare class DiagramObjectSet extends DiagramElementSet<DiagramObject> {
50
50
  * @param width The dimension of the object along the x axis.
51
51
  * @param height The dimension of the object along the y axis.
52
52
  * @param priority The priority of the object. Used when filtering by priority.
53
- * @param html The html contents of the object.
53
+ * @param svg The SVG contents of the object.
54
54
  * @param id The id of the object. Cannot be an empty string.
55
55
  * @returns The instanced object.
56
56
  */
57
- new(coords: Point, width: number, height: number, priority: number, html: string, id: string): DiagramObject;
57
+ new(coords: Point, width: number, height: number, priority: number, svg: string, id: string): DiagramObject;
58
58
  remove(id: string): void;
59
59
  }
@@ -0,0 +1,32 @@
1
+ import { ResizableMode, ResizerConfig } from '../config/diagram-config';
2
+ import { ResizerLook } from '../config/diagram-look-config';
3
+ import { DiagramNode } from './diagram-node';
4
+ import { DiagramSection } from './diagram-section';
5
+ /**
6
+ * Default values of the parameters of a diagram field.
7
+ * @private
8
+ * @see ResizerConfig
9
+ */
10
+ export declare const DIAGRAM_RESIZER_DEFAULTS: ResizerConfig;
11
+ /**
12
+ * Holds the data for the resizers of a type of node or section.
13
+ * @public
14
+ * @see DiagramNode
15
+ * @see DiagramSection
16
+ */
17
+ export declare class DiagramResizer {
18
+ mode: ResizableMode;
19
+ thickness: number;
20
+ outerMargin: number;
21
+ defaultLook: ResizerLook;
22
+ selectedLook: ResizerLook;
23
+ highlightedLook: ResizerLook;
24
+ selectedAndHighlightedLook: ResizerLook;
25
+ constructor(options: boolean | ResizableMode | ResizerConfig);
26
+ /**
27
+ * Current look of this resizer.
28
+ * @private
29
+ */
30
+ getLook(rootElement?: DiagramNode | DiagramSection): ResizerLook;
31
+ }
32
+ export declare const DIAGRAM_DEFAULT_RESIZER: DiagramResizer;
@@ -1,6 +1,6 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
- import { FieldConfig, PortConfig, ResizableMode, SectionConfig, SectionGridConfig } from '../config/diagram-config';
3
+ import { FieldConfig, PortConfig, SectionConfig, SectionGridConfig } from '../config/diagram-config';
4
4
  import { ImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from '../config/diagram-look-config';
5
5
  import { DiagramConnection } from './diagram-connection';
6
6
  import { DiagramDecorator } from './diagram-decorator';
@@ -9,6 +9,7 @@ import { DiagramField, LabeledElement } from './diagram-field';
9
9
  import { DiagramModel } from './diagram-model';
10
10
  import { DiagramNode, NodeLook } from './diagram-node';
11
11
  import { DiagramPort } from './diagram-port';
12
+ import { DiagramResizer } from './diagram-resizer';
12
13
  /**
13
14
  * Default value of the default width of a diagram section.
14
15
  * @private
@@ -61,8 +62,9 @@ export declare class DiagramSectionType {
61
62
  highlightedLook: NodeLook;
62
63
  selectedAndHighlightedLook: NodeLook;
63
64
  priority: number;
64
- resizableX: boolean | ResizableMode | undefined;
65
- resizableY: boolean | ResizableMode | undefined;
65
+ resizerX: DiagramResizer | undefined;
66
+ resizerY: DiagramResizer | undefined;
67
+ resizerXY: DiagramResizer | undefined;
66
68
  constructor(options: SectionConfig);
67
69
  }
68
70
  /**
@@ -156,6 +158,21 @@ export declare class DiagramSection extends DiagramElement implements LabeledEle
156
158
  getMinWidth(): number;
157
159
  getMinHeight(): number;
158
160
  getPriority(): number;
161
+ /**
162
+ * Returns the horizontal resizer of this section.
163
+ * @public
164
+ */
165
+ getResizerX(): DiagramResizer;
166
+ /**
167
+ * Returns the vertical resizer of this section.
168
+ * @public
169
+ */
170
+ getResizerY(): DiagramResizer;
171
+ /**
172
+ * Returns the diagonal resizer of this section.
173
+ * @public
174
+ */
175
+ getResizerXY(): DiagramResizer;
159
176
  /**
160
177
  * Returns whether this section can be resized horizontally.
161
178
  * If the section has a specific resizableX setting, it uses that.
@@ -170,6 +187,13 @@ export declare class DiagramSection extends DiagramElement implements LabeledEle
170
187
  * @public
171
188
  */
172
189
  getResizableY(): boolean;
190
+ /**
191
+ * Returns whether this section can be resized diagonally.
192
+ * If the section has a specific resizableXY setting, it uses that.
193
+ * Otherwise, it inherits from the parent node's resizableXY setting.
194
+ * @public
195
+ */
196
+ getResizableXY(): boolean;
173
197
  /**
174
198
  * Get the port of this section which is closest to the given coordinates.
175
199
  * @param coords A point in the diagram.
@@ -3,15 +3,15 @@ import { DiagramContextMenu } from '../diagram/canvas/diagram-context-menu';
3
3
  import { DiagramUserHighlight } from '../diagram/canvas/diagram-user-highlight';
4
4
  import { DiagramUserSelection } from '../diagram/canvas/diagram-user-selection';
5
5
  import { CollabEngine } from '../diagram/collab/collab-engine';
6
- import { ActionStack, DiagramAction, DiagramActionMethod, DiagramActions } from '../diagram/diagram-action';
6
+ import { BackgroundConfig, GridConfig } from '../diagram/config/diagram-canvas-config';
7
7
  import { UserActionConfig } from '../diagram/config/diagram-config';
8
+ import { ActionStack, DiagramAction, DiagramActionMethod, DiagramActions } from '../diagram/diagram-action';
8
9
  import { DiagramEvent } from '../diagram/diagram-event';
9
10
  import { DiagramConnectionType } from '../diagram/model/diagram-connection';
10
11
  import { DiagramModel } from '../diagram/model/diagram-model';
11
12
  import { DiagramValidator } from '../errors/diagram-validator';
12
13
  import { Point } from '../util/canvas-util';
13
14
  import { DiagramEditor } from './diagram-editor';
14
- import { GridStyle } from '../diagram/config/diagram-canvas-config';
15
15
  /**
16
16
  * Represents a specific replica or view of the model.
17
17
  * Provides the functionality for the visual representation of the elements of a model.
@@ -54,35 +54,15 @@ export interface Canvas {
54
54
  */
55
55
  readonly collabEngine: CollabEngine;
56
56
  /**
57
- * Background color of the diagram.
58
- * @public
59
- */
60
- backgroundColor: string;
61
- /**
62
- * Style of the grid elements of the diagram.
63
- * @public
64
- */
65
- gridStyle: GridStyle;
66
- /**
67
- * Distance between the grid points of the diagram in diagram units.
68
- * @public
69
- */
70
- gridSize: number;
71
- /**
72
- * Size of the grid points of the diagram relative to the distance between grid points in diagram units.
73
- * @public
74
- */
75
- gridThickness: number;
76
- /**
77
- * Color of the grid elements of the diagram.
57
+ * Background config of the diagram.
78
58
  * @public
79
59
  */
80
- gridColor: string;
60
+ backgroundConfig: BackgroundConfig;
81
61
  /**
82
- * If true, elements moved by the user should be placed on the closest grid point rather than the exact point where they were placed.
62
+ * Grid config of the diagram.
83
63
  * @public
84
64
  */
85
- snapToGrid: boolean;
65
+ gridConfig: GridConfig;
86
66
  /**
87
67
  * The factor by which the zoom level increases or decreases when the user users buttons or keys to zoom in or out. Should be above 1.
88
68
  * @public
@@ -7,7 +7,9 @@ export declare enum CursorStyle {
7
7
  Grabbing = "grabbing",
8
8
  Move = "move",
9
9
  NoDrop = "no-drop",
10
+ NESWResize = "nesw-resize",
10
11
  NSResize = "ns-resize",
12
+ NWSEResize = "nwse-resize",
11
13
  NotAllowed = "not-allowed",
12
14
  ZoomIn = "zoom-in",
13
15
  ZoomOut = "zoom-out"