@visuallyjs/browser-ui 1.2.4 → 1.2.6

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.
Files changed (61) hide show
  1. package/css/visuallyjs.css +34 -16
  2. package/js/visuallyjs.browser-ui.cjs.js +91 -59
  3. package/js/visuallyjs.browser-ui.esm.js +91 -59
  4. package/package.json +1 -1
  5. package/types/browser-ui/browser-util.d.ts +0 -7
  6. package/types/browser-ui/browser-visuallyjs-instance.d.ts +1 -0
  7. package/types/browser-ui/components/controls/controls-component.d.ts +8 -0
  8. package/types/browser-ui/components/index.d.ts +1 -0
  9. package/types/browser-ui/components/palette/auto-edge-connect.d.ts +74 -0
  10. package/types/browser-ui/components/palette/definitions.d.ts +50 -0
  11. package/types/browser-ui/components/palette/index.d.ts +3 -0
  12. package/types/browser-ui/components/palette/palette-options.d.ts +59 -2
  13. package/types/browser-ui/components/palette/palette.d.ts +25 -15
  14. package/types/browser-ui/components/palette/util.d.ts +21 -0
  15. package/types/browser-ui/components/rotate-manager.d.ts +27 -0
  16. package/types/browser-ui/constants.d.ts +5 -2
  17. package/types/browser-ui/css-constants.d.ts +28 -2
  18. package/types/browser-ui/definitions.d.ts +10 -2
  19. package/types/browser-ui/edge-handler-base.d.ts +20 -1
  20. package/types/browser-ui/edge-input-handler.d.ts +1 -18
  21. package/types/browser-ui/element-drag-handler-2.d.ts +4 -2
  22. package/types/browser-ui/event-manager.d.ts +7 -0
  23. package/types/browser-ui/index.d.ts +2 -1
  24. package/types/browser-ui/keyboard/index.d.ts +1 -0
  25. package/types/browser-ui/keyboard/keyboard-listener.d.ts +7 -0
  26. package/types/browser-ui/pan-zoom-options.d.ts +5 -0
  27. package/types/browser-ui/pan-zoom.d.ts +2 -1
  28. package/types/browser-ui/paper-renderer/paper.d.ts +1 -0
  29. package/types/browser-ui/positioning-and-sizing-utils.d.ts +5 -0
  30. package/types/browser-ui/shape-library/shape-library-definitions.d.ts +53 -12
  31. package/types/browser-ui/shape-library/shape-library.d.ts +15 -9
  32. package/types/browser-ui/surface-renderer/css-classes.d.ts +8 -0
  33. package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +46 -5
  34. package/types/browser-ui/surface-renderer/diagrams/diagram.d.ts +11 -1
  35. package/types/browser-ui/surface-renderer/diagrams/mediator.d.ts +7 -7
  36. package/types/browser-ui/surface-renderer/plugins/lasso/lasso.d.ts +1 -1
  37. package/types/browser-ui/surface-renderer/plugins/resizing-tools/resizing-tools-plugin.d.ts +4 -3
  38. package/types/browser-ui/surface-renderer/shape-palette-options.d.ts +31 -3
  39. package/types/browser-ui/surface-renderer/shape-palette.d.ts +1 -0
  40. package/types/browser-ui/surface-renderer/surface.d.ts +15 -1
  41. package/types/browser-ui/svg-util.d.ts +3 -1
  42. package/types/core/datasource.d.ts +1 -1
  43. package/types/core/geom.d.ts +6 -0
  44. package/types/core/io.d.ts +17 -3
  45. package/types/core/model/graph.d.ts +6 -2
  46. package/types/core/model/group-template.d.ts +4 -2
  47. package/types/core/params.d.ts +4 -4
  48. package/types/core/rtree/definitions.d.ts +5 -5
  49. package/types/core/rtree/rtree.d.ts +2 -2
  50. package/types/core/rtree/util.d.ts +2 -1
  51. package/types/core/toolkit.d.ts +7 -3
  52. package/types/test-support/test-support.d.ts +45 -1
  53. package/types/ui/common/anchor.d.ts +0 -4
  54. package/types/ui/common/overlay.d.ts +13 -1
  55. package/types/ui/core/constants.d.ts +24 -0
  56. package/types/ui/core/core.d.ts +40 -8
  57. package/types/ui/core/definitions.d.ts +12 -5
  58. package/types/ui/core/factory/anchor-record-factory.d.ts +6 -1
  59. package/types/ui/core/type-descriptors.d.ts +2 -2
  60. package/types/ui/core/view/group-options.d.ts +4 -0
  61. package/types/version.d.ts +1 -1
@@ -79,11 +79,12 @@ export declare class PanZoom {
79
79
  wheelCssFilterSpec: string;
80
80
  wheelFilter: (e: MouseEvent) => boolean;
81
81
  wheelCssFilter: (e: MouseEvent) => boolean;
82
- wheelZoomRequiresMetaKey: boolean;
82
+ wheelRequiresMetaKey: boolean;
83
83
  wheelDirection: number;
84
84
  wheelSensitivity: number;
85
85
  wheelPan: boolean;
86
86
  wheelPanAxis: PanAxis;
87
+ _shiftToSwitchPanZoom: boolean;
87
88
  background: PanZoomBackground;
88
89
  fixedLayer: FixedLayer;
89
90
  _mouseMove: Function;
@@ -62,5 +62,6 @@ export declare class Paper extends BrowserUI {
62
62
  zoomOut(canvasLoc?: PointXY): void;
63
63
  zoomIn(canvasLoc?: PointXY): void;
64
64
  getVisibleCanvasBounds(): RectangleXY;
65
+ $isConsideredCanvasEvent(e: MouseEvent): boolean;
65
66
  }
66
67
  export declare function createPaper(container: BrowserElement, options?: PaperOptions, modelOptions?: ModelOptions, data?: any): Paper;
@@ -14,6 +14,11 @@ export declare const ATTRIBUTE_TRANSFORM = "transform";
14
14
  */
15
15
  export declare function getElementSize(el: Element): Size;
16
16
  export declare function getPosition(el: BrowserElement, knownElementSize?: Size): PointXY;
17
+ /**
18
+ * If the given point p is not null and neither p.x nor p.y are NaN, returns p. Otherwise, returns a point with x and y both set to 0.
19
+ * @param p
20
+ */
21
+ export declare function nullSafePoint(p: PointXY): PointXY;
17
22
  export declare function setPosition(el: BrowserElement, p: PointXY): void;
18
23
  /**
19
24
  * Gets the position of an element relative to the some other SVG,
@@ -1,4 +1,4 @@
1
- import { Size, Group, Node, ObjectData, AbstractEntry, CustomTagOptions } from "../../core";
1
+ import { Size, Group, Node, ObjectData, AbstractEntry, CustomTagOptions, PointXY } from "../../core";
2
2
  import { BrowserElement } from "../util";
3
3
  import { IconDefinition } from "../icons";
4
4
  import { FontSpec } from "../definitions";
@@ -41,6 +41,10 @@ export interface ShapeType {
41
41
  * Label to use for the shape type when displayed in a palette
42
42
  */
43
43
  label?: string;
44
+ /**
45
+ * Optional label padding when labels are top/bottom to use for this shape type. The shape library will default to any labelPadding set on the shape set, or the system default.
46
+ */
47
+ labelPadding?: number;
44
48
  /**
45
49
  * Can be shown in a palette to give a user more information about a shape
46
50
  */
@@ -79,8 +83,7 @@ export interface ShapeType {
79
83
  */
80
84
  icon?: string;
81
85
  /**
82
- * A list of configurable properties exposed by this shape's template.
83
- * An inspector can read this array to automatically generate an editing UI.
86
+ * A list of configurable properties exposed by this shape's template. An inspector can read this array to automatically generate an editing UI.
84
87
  */
85
88
  properties?: Array<ShapePropertyDefinition>;
86
89
  /**
@@ -92,14 +95,19 @@ export interface ShapeType {
92
95
  */
93
96
  labelPosition?: LabelPosition;
94
97
  /**
95
- * optional name of the group to which the shape belongs.
98
+ * Optional name of the group to which the shape belongs. This is not the same concept as a "group" inside the data model: this is a grouping of shape types, used to organise them in the UI.
96
99
  */
97
100
  group?: string;
98
101
  /**
99
- * Optional blueprint for child vertices and edges to be created when this group is added.
100
- * Only relevant when objectType is Group.
102
+ * Optional blueprint for child vertices and edges to be created when this group is added. Only relevant when objectType is Group.
101
103
  */
102
104
  members?: GroupTemplate;
105
+ /**
106
+ * For groups, indicates that the group is locked and no edits can occur to the child vertices. This is intended for use with the `members` option, for groups that gather a set of elements together to form a more complex building block. As an example in the real world, consider a Binary Adder: it is a group of logic gates whose relationships are fixed.
107
+ */
108
+ locked?: boolean;
109
+ }
110
+ export interface RealisedShapeType extends ShapeType {
103
111
  }
104
112
  /**
105
113
  * Start placement for shape icon - in x axis this means the left; in y axis it means the top.
@@ -137,6 +145,10 @@ export interface ShapeSet {
137
145
  icons?: Array<IconDefinition>;
138
146
  defs?: Record<string, string>;
139
147
  children?: Array<ShapeSet>;
148
+ /**
149
+ * Optional label padding when labels are top/bottom to use as a default for all shapes. Individual shapes can set their own values. This defaults to 10 pixels.
150
+ */
151
+ labelPadding?: number;
140
152
  /**
141
153
  * A list of configurable properties exposed by shapes in this set.
142
154
  */
@@ -148,17 +160,18 @@ export interface ShapeSet {
148
160
  export interface RenderedShapeSet extends ShapeSet {
149
161
  children: Array<RenderedShapeSet>;
150
162
  parent?: string;
163
+ shapes: Array<RealisedShapeType>;
151
164
  }
152
165
  /**
153
166
  * Defines a library that acts as a factory for shapes.
154
167
  * @internal
155
168
  */
156
169
  export interface ShapeLibrary<T extends ObjectData> {
157
- $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): ShapeType;
158
- getShapeDefinition(type: string, set?: string): ShapeType;
170
+ $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): RealisedShapeType;
171
+ getShapeDefinition(type: string, set?: string): RealisedShapeType;
159
172
  renderCompiledShape(data: T, strokeWidth?: number): BrowserElement;
160
173
  renderShapeLabel(data: ObjectData, labelProperty: string, strokeWidth: string, label: string, fill: string, stroke: string, font: FontSpec): SVGTextElement;
161
- getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string): CustomTagOptions;
174
+ getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, labelPosition?: LabelPosition, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string): CustomTagOptions;
162
175
  getShapeSet(id: string): RenderedShapeSet;
163
176
  getShapeSets(): Array<RenderedShapeSet>;
164
177
  rootSet: RenderedShapeSet;
@@ -166,7 +179,7 @@ export interface ShapeLibrary<T extends ObjectData> {
166
179
  getSvgDefsElement(): SVGElement;
167
180
  parseDefs(): Array<Array<AbstractEntry>>;
168
181
  useMultilineLabels(): boolean;
169
- $applyMultilineLabel(el: Element, data: ObjectData, labelAttribute: string): void;
182
+ $applyMultilineLabel(el: Element, data: ObjectData, labelAttribute: string, labelPosition: LabelPosition): void;
170
183
  typeParameter: string;
171
184
  categoryParameter: string;
172
185
  defaultCategoryId: string;
@@ -176,7 +189,7 @@ export interface ShapeLibrary<T extends ObjectData> {
176
189
  * @param data The data associated with the element.
177
190
  * @param labelAttribute The attribute to use for the label.
178
191
  */
179
- refresh(el: BrowserElement, data: T, labelAttribute?: string): void;
192
+ refresh(el: BrowserElement, data: T, labelAttribute: string, labelPosition: LabelPosition): void;
180
193
  }
181
194
  /**
182
195
  * Defines a function that can take a vertex's data object and return a document fragment with it rendered.
@@ -209,6 +222,14 @@ export declare const TAG_SHAPE = "vjs-shape";
209
222
  * @context shape-library
210
223
  */
211
224
  export declare const CLASS_SHAPE_LABEL = "vjs-shape-label";
225
+ /**
226
+ * This class is assigned to svg rect elements serving as the background for shape labels. By default it is an empty rectangle with no fill, and is not visible in the UI. If you supply a `labelBackground` config, this element will use it.
227
+ * @group Nodes and Groups
228
+ * @category CSS Classes
229
+ * @cssClass
230
+ * @context shape-library
231
+ */
232
+ export declare const CLASS_SHAPE_LABEL_BG = "vjs-shape-label-bg";
212
233
  /**
213
234
  * This class is assigned to the parent SVG elements for shapes.
214
235
  * @group Nodes and Groups
@@ -250,9 +271,29 @@ export interface ShapePropertyDefinition {
250
271
  */
251
272
  description?: string;
252
273
  /**
253
- * For "number" types, optional min/max constraints.
274
+ * For "number" types, optional min constraints.
254
275
  */
255
276
  min?: number;
277
+ /**
278
+ * For "number" types, optional max constraints.
279
+ */
256
280
  max?: number;
281
+ /**
282
+ * Optional set of values to pick current value from
283
+ */
284
+ values?: Array<any>;
257
285
  }
258
286
  export type LabelPosition = "top" | "bottom" | "center";
287
+ /**
288
+ * Options for the label background on a shape.
289
+ * @group Diagrams
290
+ * @category Shapes
291
+ */
292
+ export interface LabelBackgroundOptions {
293
+ stroke?: string;
294
+ strokeWidth?: number;
295
+ fill?: string;
296
+ padding?: PointXY;
297
+ rx?: number;
298
+ opacity?: number;
299
+ }
@@ -1,4 +1,4 @@
1
- import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet, ShapeType, LabelPosition } from "./shape-library-definitions";
1
+ import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet, LabelPosition, RealisedShapeType, LabelBackgroundOptions } from "./shape-library-definitions";
2
2
  import { BrowserElement } from "../util";
3
3
  import { CustomTagOptions, Recado, AbstractEntry, ObjectData } from "../../core";
4
4
  import { IconDefinition } from "../icons";
@@ -122,6 +122,10 @@ export interface ShapeLibraryOptions {
122
122
  * Default position for labels (will be overridden by a shape that defines its own position. Defaults to "center"
123
123
  */
124
124
  labelPosition?: LabelPosition;
125
+ /**
126
+ * Options for label background. Use `true` for defaults, or supply your own values (which will be merged on top of the defaults)
127
+ */
128
+ labelBackground?: boolean | LabelBackgroundOptions;
125
129
  /**
126
130
  * Optional default for fill color. If not provided, fill is set to #FFFFFF.
127
131
  */
@@ -142,6 +146,8 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
142
146
  shapeSets: Map<string, RenderedShapeSet>;
143
147
  defaultCategoryId: string;
144
148
  private labelPosition;
149
+ private _showLabelBackgrounds;
150
+ private _labelBackgroundOptions;
145
151
  rootSet: RenderedShapeSet;
146
152
  iconContainerTemplate: string;
147
153
  iconContainerAst: Array<AbstractEntry>;
@@ -177,8 +183,9 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
177
183
  * @param el
178
184
  * @param data
179
185
  * @param labelAttribute
186
+ * @param labelPosition
180
187
  */
181
- refresh(el: BrowserElement, data: ObjectData, labelAttribute?: string): void;
188
+ refresh(el: BrowserElement, data: ObjectData, labelAttribute: string, labelPosition: LabelPosition): void;
182
189
  private _processShapeSets;
183
190
  getShapeSet(id: string): RenderedShapeSet;
184
191
  getShapeSets(): Array<RenderedShapeSet>;
@@ -187,12 +194,12 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
187
194
  * @param type
188
195
  * @param set
189
196
  */
190
- getShapeDefinition(type: string, set?: string): ShapeType;
197
+ getShapeDefinition(type: string, set?: string): RealisedShapeType;
191
198
  /**
192
199
  * Gets the definition for some data object, using the default type/category parameters, or specific ones that you supply. May return null.
193
200
  * @internal
194
201
  */
195
- $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): ShapeType;
202
+ $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): RealisedShapeType;
196
203
  /**
197
204
  * Gets the template for the given shape type in the given set. If no template is resolved then we return
198
205
  * DEFAULT_TEMPLATE (and log the issue to the console).
@@ -211,7 +218,6 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
211
218
  * @param el
212
219
  * @private
213
220
  */
214
- private _applyVectorEffect;
215
221
  /**
216
222
  * Render the given data with the appropriate template. A `fill` value is set on the resulting element, and the `vector-effect` attribute is set to 'non scaling stroke', ie. when the shape is scaled due to the element dimensions differing from the viewbox, the stroke does not change.
217
223
  * @param data
@@ -242,7 +248,7 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
242
248
  * Returns a tag definition that can be used in a Surface's `tags` declaration. Note that this method returns an object containing the tag's implementation, but not the name of the tag. You can call the tag whatever you like.
243
249
  * @internal
244
250
  */
245
- getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string, defaultOutlineWidth?: number): CustomTagOptions;
251
+ getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, labelPosition?: LabelPosition, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string, defaultOutlineWidth?: number): CustomTagOptions;
246
252
  /**
247
253
  * @internal
248
254
  */
@@ -256,14 +262,14 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
256
262
  */
257
263
  private _resolveIcon;
258
264
  /**
259
- * Converts text element labels to multiline tspans, if multilineLabels is set to true (which is
260
- * the default).
265
+ * Converts text element labels to multiline tspans, if multilineLabels is set to true (which is the default).
261
266
  * @param labelElement
262
267
  * @param data
263
268
  * @param labelAttribute
269
+ * @param labelPosition
264
270
  * @internal
265
271
  */
266
- $applyMultilineLabel(labelElement: SVGTextElement, data: ObjectData, labelAttribute: string): void;
272
+ $applyMultilineLabel(labelElement: SVGTextElement, data: ObjectData, labelAttribute: string, labelPosition: LabelPosition): void;
267
273
  /**
268
274
  * Check for any icons that were declared and render them.
269
275
  * @param el
@@ -54,6 +54,14 @@ export declare const CLASS_PALETTE_SET_TITLE = "vjs-shape-library-palette-set-ti
54
54
  * @category CSS Classes
55
55
  */
56
56
  export declare const CLASS_PALETTE_SET_SHAPES = "vjs-shape-library-palette-set-shapes";
57
+ /**
58
+ * Assigned to a group title element in the shape palette.
59
+ * @cssClass
60
+ * @context shapePalette
61
+ * @group Diagrams
62
+ * @category CSS Classes
63
+ */
64
+ export declare const CLASS_PALETTE_SET_SHAPE_GROUP_TITLE = "vjs-shape-library-palette-shape-group-title";
57
65
  /**
58
66
  * When in `tap` mode, this class is added to the lasso used to draw new vertices
59
67
  * @cssClass
@@ -1,16 +1,15 @@
1
- import { LabelPosition, ShapeSet } from "../../shape-library";
1
+ import { LabelBackgroundOptions, LabelPosition, ShapeSet } from "../../shape-library";
2
2
  import { Group, ObjectData, PointXY, Size, Vertex, Node, BeforeConnectInterceptor } from "../../../core";
3
3
  import { DiagramCell } from "./diagram-cell";
4
4
  import { GridOptions, UIExportOptions, UICoreDefaults, EdgeEventOptions, OverlaySpec, ConnectorSpec, NodeEventOptions, GroupMapping, NodeMapping, AnchorSpec, EdgePropertyMappings, MagnetizeOptions, PaintStyle, OverlayVisibility, EdgeDeleteConfirmationFunction } from "../../../ui";
5
5
  import { SurfaceSaveData } from "../definitions";
6
6
  import { BrowserElement } from "../../util";
7
- import { PaletteMode } from "../../components/palette/palette-options";
7
+ import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../../components/palette/palette-options";
8
8
  import { PanOptions, WheelOptions, ZoomOptions } from "../../pan-zoom-options";
9
9
  import { MiniviewPluginOptions, LassoPluginOptions, ResizingToolsModelUpdater, ResizingToolsHandlerFactory, DragGroupsPluginOptions, ResizingToolsResizeMethod, SnaplinesPluginOptions, PanButtonsPluginOptions, LineCrossingsPluginOptions } from "../plugins";
10
- import { EdgeSnapOptions } from "../../edge-handler-base";
10
+ import { EdgeSnapOptions, EdgeInputMethod } from "../../edge-handler-base";
11
11
  import { DiagramActionMediator } from "./mediator";
12
12
  import { OnVertexAddedCallback, FontSpec } from "../../definitions";
13
- import { EdgeInputMethod } from "../../edge-input-handler";
14
13
  import { PreparedShape } from "../shape-palette-options";
15
14
  /**
16
15
  * Options for the {@link Diagram.addLink method}
@@ -66,6 +65,14 @@ export interface DiagramOptions {
66
65
  * Defaults to true, meaning the user can edit the diagram.
67
66
  */
68
67
  editable?: boolean;
68
+ /**
69
+ * Whether or not to allow rotation of elements being dragged from the palette. Defaults to true.
70
+ */
71
+ allowRotation?: boolean;
72
+ /**
73
+ * The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
74
+ */
75
+ rotationSpeed?: number;
69
76
  edges?: {
70
77
  /**
71
78
  * Whether or not to disable drop targets on which an edge from some current source may not be dropped when drag starts. Defaults to true.
@@ -305,6 +312,10 @@ export interface DiagramOptions {
305
312
  * Default position for labels (will be overridden by a shape that defines its own position. Defaults to "center"
306
313
  */
307
314
  labelPosition?: LabelPosition;
315
+ /**
316
+ * Options for label background. Use `true` for defaults, or supply your own values (which will be merged on top of the defaults)
317
+ */
318
+ labelBackground?: boolean | LabelBackgroundOptions;
308
319
  /**
309
320
  * Optional event mappings for all cells.
310
321
  */
@@ -459,9 +470,14 @@ export interface DiagramPaletteOptions {
459
470
  */
460
471
  dragSize?: Size;
461
472
  /**
462
- * Indicates that when one or more vertices are selected, clicking on an entry in the palette will change the type of the selected vertices to that type. Defaults to true.
473
+ * When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
463
474
  */
464
475
  inspector?: boolean;
476
+ /**
477
+ * When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`.
478
+ * This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
479
+ */
480
+ updateTypeOnPaletteTap?: boolean;
465
481
  /**
466
482
  * Optional size to use for icons. Defaults to 150x100 pixels. If you provide this but not `dragSize` this size will also be used for an icon that is being dragged.
467
483
  */
@@ -495,6 +511,15 @@ export interface DiagramPaletteOptions {
495
511
  * Defaults to true: when in 'tap' mode and a new group/node has been drawn on the canvas, the UI is set back to pan mode.
496
512
  */
497
513
  autoExitDrawMode?: boolean;
514
+ /**
515
+ * If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
516
+ */
517
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter<BrowserElement>;
518
+ /**
519
+ * If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
520
+ * @advanced
521
+ */
522
+ connectToPortsOnEdgeDrop?: boolean;
498
523
  /**
499
524
  * When true (which is the default), a newly dropped shape will be set as the underlying model's selection.
500
525
  */
@@ -515,6 +540,22 @@ export interface DiagramPaletteOptions {
515
540
  * Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
516
541
  */
517
542
  preparedShapes?: Array<PreparedShape>;
543
+ /**
544
+ * Whether or not to allow rotation of elements being dragged. Defaults to true.
545
+ */
546
+ allowRotation?: boolean;
547
+ /**
548
+ * The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
549
+ */
550
+ rotationSpeed?: number;
551
+ /**
552
+ * 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.
553
+ */
554
+ autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
555
+ /**
556
+ * Whether or not to show groups in the palette. Defaults to true.
557
+ */
558
+ showGroups?: boolean;
518
559
  }
519
560
  /**
520
561
  * Save options for a Diagram
@@ -1,4 +1,4 @@
1
- import { ObjectData, PriorityQueue, SaveOptions, ModelOptions, Edge } from "../../../core";
1
+ import { Group, ObjectData, PriorityQueue, SaveOptions, ModelOptions, Edge } from "../../../core";
2
2
  import { PropertyTracker, ZoomToFitOptions, ZoomToFitIfNecessaryOptions } from "../../../ui";
3
3
  import { BrowserElement } from "../../util";
4
4
  import { BrowserUIModel } from "../../browser-ui";
@@ -204,6 +204,16 @@ export declare class Diagram {
204
204
  * @tags zoom
205
205
  */
206
206
  zoomToFitIfNecessary(params?: ZoomToFitIfNecessaryOptions): void;
207
+ /**
208
+ * Mark a group as "locked" : edges inside of it cannot be detached, removed or have their paths edited, edges cannot be established to child vertices.
209
+ * @param groupIdOrGroup
210
+ */
211
+ lockGroup(groupOrGroupId: string | Group): void;
212
+ /**
213
+ * Unlock a group
214
+ * @param groupOrGroupId
215
+ */
216
+ unlockGroup(groupOrGroupId: string | Group): void;
207
217
  }
208
218
  /**
209
219
  * Create a new DiagramPalette in the given container element, and attach it to the given Diagram.
@@ -1,4 +1,4 @@
1
- import { Group, Vertex, Node, ObjectData, Size } from "../../../core";
1
+ import { Group, Node, ObjectData, Size } from "../../../core";
2
2
  import { ShapeType } from "../../shape-library";
3
3
  import { BrowserElement } from "../../util";
4
4
  /**
@@ -13,42 +13,42 @@ export interface DiagramActionMediator {
13
13
  * @param shape
14
14
  * @param el
15
15
  */
16
- canClone?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
16
+ canClone?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
17
17
  /**
18
18
  * Returns whether or not the given vertex should be deletable in the UI. Defaults to true, meaning the delete icon will be present in the diagram tools when the vertex is selected.
19
19
  * @param v
20
20
  * @param shape
21
21
  * @param el
22
22
  */
23
- canDelete?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
23
+ canDelete?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
24
24
  /**
25
25
  * Returns whether or not the given vertex should be linkable via edge drag in the UI. Defaults to true, meaning the link icon will be present in the diagram tools when the vertex is selected.
26
26
  * @param v
27
27
  * @param shape
28
28
  * @param el
29
29
  */
30
- canLink?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
30
+ canLink?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
31
31
  /**
32
32
  * Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the resize handles will be present in the diagram tools when the vertex is selected.
33
33
  * @param v
34
34
  * @param shape
35
35
  * @param el
36
36
  */
37
- canResize?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
37
+ canResize?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
38
38
  /**
39
39
  * Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the rotate handle and leader will be present in the diagram tools when the vertex is selected.
40
40
  * @param v
41
41
  * @param shape
42
42
  * @param el
43
43
  */
44
- canRotate?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
44
+ canRotate?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
45
45
  /**
46
46
  * Returns whether or not the given vertex should be draggable in the UI. Defaults to true.
47
47
  * @param v
48
48
  * @param shape
49
49
  * @param el
50
50
  */
51
- canDrag?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
51
+ canDrag?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
52
52
  /**
53
53
  * Returns whether or not the given vertex should be droppable on the given target, which may either be another vertex (if `targetVertex` is set), or the diagram canvas (if `isOnCanvas` is set). This method will never be called with both `targetVertex` set an `isOnCanvas` true - it's one or the other.
54
54
  * @param v
@@ -53,7 +53,7 @@ export declare class Lasso {
53
53
  visibleOrigin: PointXY;
54
54
  size: Size;
55
55
  _generateLassoContent: (origin: PointXY, e: MouseEvent) => BrowserElement;
56
- el: HTMLElement;
56
+ el: BrowserElement;
57
57
  _extentTrackerEl: BrowserElement;
58
58
  masks: Record<string, HTMLElement>;
59
59
  origin: PointXY;
@@ -1,8 +1,8 @@
1
- import { ResizingToolsPluginOptions, ResizeHandler, ResizeDirection } from "./definitions";
2
- import { Grid, PointXY, Group, Node, ObjectData, VisuallyJsModel, Size, Vertex, VertexUpdatedReason } from "../../../../core";
1
+ import { ResizeDirection, ResizeHandler, ResizingToolsPluginOptions } from "./definitions";
2
+ import { Grid, Group, Node, ObjectData, PointXY, Size, Vertex, VertexUpdatedReason, VisuallyJsModel } from "../../../../core";
3
3
  import { Surface } from "../../surface";
4
4
  import { BrowserElement } from "../../../util";
5
- import { ViewportElement, GroupMapping, ViewportGroupElement, GroupContentAreaInfo, GroupResizeResult } from "../../../../ui";
5
+ import { GroupContentAreaInfo, GroupMapping, GroupResizeResult, ViewportElement, ViewportGroupElement } from "../../../../ui";
6
6
  import { BaseBrowserUIPlugin, BrowserUIPlugin } from "../../../plugins";
7
7
  import { ElasticGroupManager } from "../../elastic-group-manager";
8
8
  /**
@@ -108,6 +108,7 @@ export declare class ResizingToolsPlugin extends BaseBrowserUIPlugin implements
108
108
  destroy(): void;
109
109
  _handleDragHandlers: Record<string, ResizeHandler>;
110
110
  _borderDragHandlers: Record<string, ResizeHandler>;
111
+ $getRotationStopsArray(): Array<number>;
111
112
  initialise(surface: Surface, options: ResizingToolsPluginOptions): boolean;
112
113
  private _configureGroupParent;
113
114
  private _handleMouseDown;
@@ -1,7 +1,7 @@
1
1
  import { Group, ObjectData, Size, Node } from "../../core";
2
2
  import { ShapeLibrary } from "../shape-library";
3
3
  import { DataGeneratorFunction, OnVertexAddedCallback } from "../definitions";
4
- import { PaletteMode } from "../components";
4
+ import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../components";
5
5
  /**
6
6
  * Options for a shape palette.
7
7
  * @group Components
@@ -41,9 +41,13 @@ export interface ShapePaletteOptions<T extends ObjectData> {
41
41
  */
42
42
  selectAfterDrop?: boolean;
43
43
  /**
44
- * Indicates two things: first, when one or more vertices are selected, clicking on an entry in the palette will change the type of the selected vertices to that type. Secondly, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
44
+ * When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
45
45
  */
46
46
  inspector?: boolean;
47
+ /**
48
+ * When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`. This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
49
+ */
50
+ updateTypeOnPaletteTap?: boolean;
47
51
  /**
48
52
  * Stroke width to use for shapes in palette. Defaults to 1.
49
53
  */
@@ -95,12 +99,36 @@ export interface ShapePaletteOptions<T extends ObjectData> {
95
99
  * Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
96
100
  */
97
101
  preparedShapes?: Array<PreparedShape>;
102
+ /**
103
+ * If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
104
+ */
105
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter<T>;
106
+ /**`
107
+ * If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
108
+ * @advanced
109
+ */
110
+ connectToPortsOnEdgeDrop?: boolean;
111
+ /**
112
+ * Whether or not to allow rotation of elements being dragged. Defaults to true.
113
+ */
114
+ allowRotation?: boolean;
115
+ /**
116
+ * The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
117
+ */
118
+ rotationSpeed?: number;
119
+ /**
120
+ * Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
121
+ */
122
+ autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
123
+ /**
124
+ * Whether or not to show groups in the palette. Defaults to true.
125
+ */
126
+ showGroups?: boolean;
98
127
  }
99
128
  /**
100
129
  * Defines a wrapper around a shape with some `type` and `category` that adds properties (to be used to define the shape's appearance) and, optionally, the shape's initial size.
101
130
  * @group Components
102
131
  * @category Shape Palette
103
- * @internal
104
132
  */
105
133
  export interface PreparedShape {
106
134
  /**
@@ -18,6 +18,7 @@ export declare class ShapePalette<T extends ObjectData> {
18
18
  _$_templateEngine: BrowserUiRecado;
19
19
  _$_palette: Palette<ObjectData>;
20
20
  _$_userDataGenerator: DataGeneratorFunction<T>;
21
+ _$_showGroups: boolean;
21
22
  /**
22
23
  * @internal
23
24
  */
@@ -9,7 +9,6 @@ import { Base, Node, Group, Edge, Port, Vertex, ObjectData, VisuallyJsSelection,
9
9
  import { Connection, SupportsElementDragging, DragOptions, Overlay, ViewportBounds, UIExportOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions, ZoomToElementsOptions, ViewportNodeElement, ViewportElement, ViewportGroupElement, CenterContentOptions, AlignContentOptions, AlignContentToFaceOptions, CenterContentHorizontallyOptions, CenterContentVerticallyOptions, VertexDragFilter } from "../../ui";
10
10
  import { BrowserUI } from "../browser-visuallyjs-instance";
11
11
  import { BrowserElement } from "../util";
12
- import { EdgeInputMethod } from "../edge-input-handler";
13
12
  import { ModelEventCallback, SurfaceEvents, SurfaceMode, SurfaceSaveData, SurfaceVertexCloneOptions } from "./definitions";
14
13
  import { EdgePathEditor } from "../connector-editors";
15
14
  import { ConnectorEditorActivateParams } from "../connector-editor";
@@ -17,6 +16,7 @@ import { ElementDragHandler2, InternalDragGroupSpec } from "../element-drag-hand
17
16
  import { Background, DragGroupSpec, SupportsPathEditing, SupportsViewportManipulation, ZoomToExtentsOptions } from "../definitions";
18
17
  import { BrowserUIModel } from "../browser-ui";
19
18
  import { MiniviewPluginOptions } from "./plugins";
19
+ import { EdgeInputMethod } from "../edge-handler-base";
20
20
  /**
21
21
  * Provides a canvas on which nodes, groups and edges can be rendered, with support for pan/zoom, layouts and various plugins. This is not a class that API users should instantiate directly: for users of a library integration, a Surface will be created internally by the appropriate component; for users of vanilla VisuallyJs, a Surface is created either via the {@link createSurface} factory method, or via a `render` call on an instance of the {@link BrowserUIModel}.
22
22
  * @group Components
@@ -72,6 +72,14 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
72
72
  * @internal
73
73
  */
74
74
  $groupRemoved(deletion: GroupRemovedParams): ViewportGroupElement<BrowserElement>;
75
+ /**
76
+ * Returns whether or not the given event is considered for all practical reasons to have occurred on the surface canvas. Tests if the event target is the surface root or canvas element, or if the panZoom considers it to be a background element.
77
+ *
78
+ * This method is used when deciding to fire a canvas click event, and also by the lasso, to make the decision to switch to auto arm.
79
+ * @internal
80
+ * @param e
81
+ */
82
+ $isConsideredCanvasEvent(e: MouseEvent): boolean;
75
83
  /**
76
84
  * @internal
77
85
  */
@@ -271,6 +279,12 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
271
279
  * @param els Elements to remove from drag groups.
272
280
  */
273
281
  removeFromDragGroup(...els: Array<string | BrowserElement | Node | Group>): void;
282
+ /**
283
+ * Remove the given viewport element from a drag group it may be in. This method can be invoked after an element has been removed and it has no managed element tracked anymore, so internal invocations go through this method rather than the one above.
284
+ * @param vel
285
+ * @private
286
+ */
287
+ private _removeFromDragGroup;
274
288
  /**
275
289
  * Sets the active/passive state for the given element(s) in their respective drag groups (if any). You don't need to supply the drag group id, as elements can only be in one drag group anyway.
276
290
  * @param state true for active, false for passive.
@@ -1,6 +1,7 @@
1
1
  import { BrowserElement } from "./util";
2
2
  import { GradientSpec } from "../core";
3
3
  import { SvgConnector } from "./svg-element-connector";
4
+ import { LabelPosition } from "./shape-library";
4
5
  export type ElementAttributes = Record<string, string | number | object>;
5
6
  export declare function $attr(node: BrowserElement, attributes: ElementAttributes): void;
6
7
  export declare function $svgNode(name: string, attributes?: ElementAttributes, style?: Record<string, any>, clazz?: string): SVGElement;
@@ -22,6 +23,7 @@ export declare function $appendAtIndex(svg: SVGElement, path: SVGElement, idx: n
22
23
  * @param textElement
23
24
  * @param text
24
25
  * @param maxWidth
26
+ * @param textPosition Where the text is placed relative to its context. This has a bearing on how we adjust the `dy` attribute of the initial span.
25
27
  * @internal
26
28
  */
27
- export declare function convertToMultilineText(textElement: SVGTextElement, text: string, maxWidth: number): SVGTextElement;
29
+ export declare function convertToMultilineText(textElement: SVGTextElement, text: string, maxWidth: number, textPosition: LabelPosition): SVGTextElement;
@@ -38,7 +38,7 @@ export interface DataSource extends FilterableDataset {
38
38
  getPortType(port: ObjectData): string;
39
39
  getPortId(port: ObjectData): string;
40
40
  getDescendants(vertex: Group): Array<Node | Group>;
41
- getAncestors(vertex: Node | Group): Array<Group>;
41
+ getAncestors(vertex: Vertex): Array<Group>;
42
42
  isAncestor(focus: Node | Group, possibleAncestor: Group): boolean;
43
43
  isDescendantGroup(possibleDescendant: Group, ancestor: Group): boolean;
44
44
  getEdgeCount(): number;
@@ -310,6 +310,12 @@ export declare function clampAngle(angle: number): number;
310
310
  export interface RotatedRectangle extends RectangleXY {
311
311
  r?: number;
312
312
  }
313
+ /**
314
+ * Returns the four corner points of a rotated rectangle.
315
+ * @param rect The rotated rectangle.
316
+ * @returns An array of four PointXY objects representing the corners.
317
+ */
318
+ export declare function getRotatedCorners(rect: RotatedRectangle): PointXY[];
313
319
  /**
314
320
  * Determines if two rotated rectangles intersect using the Separating Axis Theorem (SAT).
315
321
  * @param r1 The first rotated rectangle.