@bpmnkit/editor 0.0.8

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.
@@ -0,0 +1,588 @@
1
+ import { applyResize } from "./geometry.js";
2
+ // ── Helpers ───────────────────────────────────────────────────────────────────
3
+ const DRAG_THRESHOLD = 4; // screen pixels
4
+ function screenDist(ax, ay, bx, by) {
5
+ return Math.hypot(ax - bx, ay - by);
6
+ }
7
+ /**
8
+ * Discriminated-union state machine for the BPMN editor.
9
+ * Receives pointer + keyboard events from the editor and notifies the editor
10
+ * via injected `Callbacks`.
11
+ */
12
+ export class EditorStateMachine {
13
+ _cb;
14
+ _mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
15
+ constructor(_cb) {
16
+ this._cb = _cb;
17
+ }
18
+ get mode() {
19
+ return this._mode;
20
+ }
21
+ setMode(mode) {
22
+ this._mode = mode;
23
+ }
24
+ // ── Pointer down ─────────────────────────────────────────────────
25
+ onPointerDown(e, diag, hit) {
26
+ const mode = this._mode;
27
+ // Create mode: place shape and revert to select
28
+ if (mode.mode === "create") {
29
+ this._cb.commitCreate(mode.elementType, diag);
30
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
31
+ this._cb.setTool("select");
32
+ return;
33
+ }
34
+ // Space mode: lock viewport and begin drag
35
+ if (mode.mode === "space") {
36
+ this._cb.lockViewport(true);
37
+ this._mode = {
38
+ mode: "space",
39
+ sub: { name: "dragging", origin: diag, last: diag, axis: null },
40
+ };
41
+ return;
42
+ }
43
+ // Pan mode: viewport handles this
44
+ if (mode.mode === "pan")
45
+ return;
46
+ // If already in connecting mode (entered from contextual toolbar), a click commits or cancels
47
+ if (mode.sub.name === "connecting") {
48
+ this._cb.lockViewport(false);
49
+ if (hit.type === "shape" && hit.id !== mode.sub.sourceId) {
50
+ this._cb.commitConnect(mode.sub.sourceId, hit.id);
51
+ }
52
+ else {
53
+ this._cb.cancelConnect();
54
+ }
55
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
56
+ return;
57
+ }
58
+ // In label-editing mode: clicking elsewhere commits label (via blur) — do nothing here
59
+ if (mode.sub.name === "editing-label")
60
+ return;
61
+ switch (hit.type) {
62
+ case "handle": {
63
+ if (!this._cb.isResizable(hit.shapeId))
64
+ break;
65
+ const shapes = this._cb.getShapes();
66
+ const shape = shapes.find((s) => s.id === hit.shapeId);
67
+ if (!shape)
68
+ return;
69
+ this._cb.lockViewport(true);
70
+ this._mode = {
71
+ mode: "select",
72
+ sub: {
73
+ name: "pointing-handle",
74
+ origin: diag,
75
+ id: hit.shapeId,
76
+ handle: hit.handle,
77
+ screenX: e.clientX,
78
+ screenY: e.clientY,
79
+ },
80
+ };
81
+ break;
82
+ }
83
+ case "port": {
84
+ this._cb.lockViewport(true);
85
+ this._mode = {
86
+ mode: "select",
87
+ sub: {
88
+ name: "pointing-port",
89
+ origin: diag,
90
+ sourceId: hit.shapeId,
91
+ port: hit.port,
92
+ screenX: e.clientX,
93
+ screenY: e.clientY,
94
+ },
95
+ };
96
+ break;
97
+ }
98
+ case "shape": {
99
+ const selectedIds = this._cb.getSelectedIds();
100
+ if (e.shiftKey) {
101
+ const newIds = selectedIds.includes(hit.id)
102
+ ? selectedIds.filter((id) => id !== hit.id)
103
+ : [...selectedIds, hit.id];
104
+ this._cb.setSelection(newIds);
105
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: hit.id } };
106
+ }
107
+ else {
108
+ if (!selectedIds.includes(hit.id)) {
109
+ this._cb.setSelection([hit.id]);
110
+ }
111
+ this._mode = {
112
+ mode: "select",
113
+ sub: {
114
+ name: "pointing-shape",
115
+ origin: diag,
116
+ id: hit.id,
117
+ screenX: e.clientX,
118
+ screenY: e.clientY,
119
+ },
120
+ };
121
+ }
122
+ break;
123
+ }
124
+ case "edge": {
125
+ this._cb.setEdgeSelected(hit.id);
126
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
127
+ break;
128
+ }
129
+ case "edge-segment": {
130
+ this._cb.lockViewport(true);
131
+ this._mode = {
132
+ mode: "select",
133
+ sub: {
134
+ name: "pointing-edge-segment",
135
+ edgeId: hit.id,
136
+ segIdx: hit.segIdx,
137
+ isHoriz: hit.isHoriz,
138
+ projPt: hit.projPt,
139
+ origin: diag,
140
+ screenX: e.clientX,
141
+ screenY: e.clientY,
142
+ },
143
+ };
144
+ break;
145
+ }
146
+ case "edge-waypoint": {
147
+ this._cb.lockViewport(true);
148
+ this._mode = {
149
+ mode: "select",
150
+ sub: {
151
+ name: "pointing-edge-waypoint",
152
+ edgeId: hit.id,
153
+ wpIdx: hit.wpIdx,
154
+ pt: hit.pt,
155
+ screenX: e.clientX,
156
+ screenY: e.clientY,
157
+ },
158
+ };
159
+ break;
160
+ }
161
+ case "edge-endpoint": {
162
+ this._cb.lockViewport(true);
163
+ this._mode = {
164
+ mode: "select",
165
+ sub: {
166
+ name: "pointing-edge-endpoint",
167
+ edgeId: hit.edgeId,
168
+ isStart: hit.isStart,
169
+ origin: diag,
170
+ screenX: e.clientX,
171
+ screenY: e.clientY,
172
+ },
173
+ };
174
+ break;
175
+ }
176
+ case "canvas": {
177
+ if (e.shiftKey) {
178
+ this._cb.lockViewport(true);
179
+ this._mode = {
180
+ mode: "select",
181
+ sub: { name: "rubber-band", origin: diag, current: diag },
182
+ };
183
+ }
184
+ else {
185
+ this._mode = {
186
+ mode: "select",
187
+ sub: {
188
+ name: "pointing-canvas",
189
+ origin: diag,
190
+ screenX: e.clientX,
191
+ screenY: e.clientY,
192
+ },
193
+ };
194
+ }
195
+ break;
196
+ }
197
+ }
198
+ }
199
+ // ── Pointer move ─────────────────────────────────────────────────
200
+ onPointerMove(e, diag, hit) {
201
+ const mode = this._mode;
202
+ // Space mode drag
203
+ if (mode.mode === "space" && mode.sub.name === "dragging") {
204
+ const sub = mode.sub;
205
+ const absDx = Math.abs(diag.x - sub.origin.x);
206
+ const absDy = Math.abs(diag.y - sub.origin.y);
207
+ let axis = sub.axis;
208
+ if (axis === null && (absDx > 4 || absDy > 4)) {
209
+ axis = absDx >= absDy ? "h" : "v";
210
+ }
211
+ this._mode = { mode: "space", sub: { ...sub, last: diag, axis } };
212
+ this._cb.previewSpace(sub.origin, diag, axis);
213
+ return;
214
+ }
215
+ if (mode.mode !== "select") {
216
+ if (mode.mode === "create") {
217
+ // Ghost create: update overlay (editor reads state.mode to update ghost)
218
+ }
219
+ return;
220
+ }
221
+ const sub = mode.sub;
222
+ switch (sub.name) {
223
+ case "idle": {
224
+ const hoveredId = hit.type === "shape" ? hit.id : null;
225
+ if (hoveredId !== sub.hoveredId) {
226
+ this._cb.setHovered(hoveredId);
227
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId } };
228
+ }
229
+ if (hit.type === "edge-segment") {
230
+ this._cb.showEdgeHoverDot(hit.projPt);
231
+ this._cb.showEdgeWaypointBalls(hit.id);
232
+ }
233
+ else if (hit.type === "edge-waypoint") {
234
+ this._cb.hideEdgeHoverDot();
235
+ this._cb.showEdgeWaypointBalls(hit.id);
236
+ }
237
+ else {
238
+ this._cb.hideEdgeHoverDot();
239
+ this._cb.hideEdgeWaypointBalls();
240
+ }
241
+ break;
242
+ }
243
+ case "pointing-shape": {
244
+ const dist = screenDist(e.clientX, e.clientY, sub.screenX, sub.screenY);
245
+ if (dist > DRAG_THRESHOLD) {
246
+ this._cb.lockViewport(true);
247
+ this._mode = {
248
+ mode: "select",
249
+ sub: { name: "translating", origin: sub.origin, last: diag },
250
+ };
251
+ const dx = diag.x - sub.origin.x;
252
+ const dy = diag.y - sub.origin.y;
253
+ this._cb.previewTranslate(dx, dy);
254
+ }
255
+ break;
256
+ }
257
+ case "translating": {
258
+ const dx = diag.x - sub.origin.x;
259
+ const dy = diag.y - sub.origin.y;
260
+ this._mode = { mode: "select", sub: { ...sub, last: diag } };
261
+ this._cb.previewTranslate(dx, dy);
262
+ break;
263
+ }
264
+ case "pointing-handle": {
265
+ const dist = screenDist(e.clientX, e.clientY, sub.screenX, sub.screenY);
266
+ if (dist > DRAG_THRESHOLD) {
267
+ const shapes = this._cb.getShapes();
268
+ const shape = shapes.find((s) => s.id === sub.id);
269
+ if (!shape)
270
+ break;
271
+ const newBounds = applyResize(shape.shape.bounds, sub.handle, diag.x, diag.y);
272
+ this._mode = {
273
+ mode: "select",
274
+ sub: {
275
+ name: "resizing",
276
+ id: sub.id,
277
+ handle: sub.handle,
278
+ original: shape.shape.bounds,
279
+ current: diag,
280
+ },
281
+ };
282
+ this._cb.previewResize(newBounds);
283
+ }
284
+ break;
285
+ }
286
+ case "resizing": {
287
+ const newBounds = applyResize(sub.original, sub.handle, diag.x, diag.y);
288
+ this._mode = { mode: "select", sub: { ...sub, current: diag } };
289
+ this._cb.previewResize(newBounds);
290
+ break;
291
+ }
292
+ case "pointing-port": {
293
+ const dist = screenDist(e.clientX, e.clientY, sub.screenX, sub.screenY);
294
+ if (dist > DRAG_THRESHOLD) {
295
+ this._mode = {
296
+ mode: "select",
297
+ sub: { name: "connecting", sourceId: sub.sourceId, ghostEnd: diag },
298
+ };
299
+ this._cb.previewConnect(diag);
300
+ }
301
+ break;
302
+ }
303
+ case "connecting": {
304
+ this._mode = { mode: "select", sub: { ...sub, ghostEnd: diag } };
305
+ this._cb.previewConnect(diag);
306
+ break;
307
+ }
308
+ case "pointing-edge-endpoint": {
309
+ const dist = screenDist(e.clientX, e.clientY, sub.screenX, sub.screenY);
310
+ if (dist > DRAG_THRESHOLD) {
311
+ this._mode = {
312
+ mode: "select",
313
+ sub: {
314
+ name: "dragging-edge-endpoint",
315
+ edgeId: sub.edgeId,
316
+ isStart: sub.isStart,
317
+ origin: sub.origin,
318
+ },
319
+ };
320
+ this._cb.previewEndpointMove(sub.edgeId, sub.isStart, diag);
321
+ }
322
+ break;
323
+ }
324
+ case "dragging-edge-endpoint": {
325
+ this._cb.previewEndpointMove(sub.edgeId, sub.isStart, diag);
326
+ break;
327
+ }
328
+ case "pointing-edge-segment": {
329
+ const dist = screenDist(e.clientX, e.clientY, sub.screenX, sub.screenY);
330
+ if (dist > DRAG_THRESHOLD) {
331
+ this._mode = {
332
+ mode: "select",
333
+ sub: {
334
+ name: "dragging-edge-waypoint-new",
335
+ edgeId: sub.edgeId,
336
+ segIdx: sub.segIdx,
337
+ origin: sub.origin,
338
+ },
339
+ };
340
+ this._cb.previewWaypointInsert(sub.edgeId, sub.segIdx, diag);
341
+ }
342
+ break;
343
+ }
344
+ case "dragging-edge-waypoint-new": {
345
+ this._cb.previewWaypointInsert(sub.edgeId, sub.segIdx, diag);
346
+ break;
347
+ }
348
+ case "pointing-edge-waypoint": {
349
+ const dist = screenDist(e.clientX, e.clientY, sub.screenX, sub.screenY);
350
+ if (dist > DRAG_THRESHOLD) {
351
+ this._mode = {
352
+ mode: "select",
353
+ sub: {
354
+ name: "dragging-edge-waypoint",
355
+ edgeId: sub.edgeId,
356
+ wpIdx: sub.wpIdx,
357
+ origin: sub.pt,
358
+ },
359
+ };
360
+ this._cb.previewWaypointMove(sub.edgeId, sub.wpIdx, diag);
361
+ }
362
+ break;
363
+ }
364
+ case "dragging-edge-waypoint": {
365
+ this._cb.previewWaypointMove(sub.edgeId, sub.wpIdx, diag);
366
+ break;
367
+ }
368
+ case "rubber-band": {
369
+ this._mode = { mode: "select", sub: { ...sub, current: diag } };
370
+ this._cb.previewRubberBand(sub.origin, diag);
371
+ break;
372
+ }
373
+ case "pointing-canvas": {
374
+ // Transition to rubber-band when drag threshold exceeded (no Shift required)
375
+ const dist = screenDist(e.clientX, e.clientY, sub.screenX, sub.screenY);
376
+ if (dist > DRAG_THRESHOLD) {
377
+ this._cb.lockViewport(true);
378
+ this._mode = {
379
+ mode: "select",
380
+ sub: { name: "rubber-band", origin: sub.origin, current: diag },
381
+ };
382
+ this._cb.previewRubberBand(sub.origin, diag);
383
+ }
384
+ break;
385
+ }
386
+ default:
387
+ break;
388
+ }
389
+ }
390
+ // ── Pointer up ────────────────────────────────────────────────────
391
+ onPointerUp(_e, diag, hit) {
392
+ const mode = this._mode;
393
+ // Space mode commit
394
+ if (mode.mode === "space") {
395
+ if (mode.sub.name === "dragging") {
396
+ this._cb.lockViewport(false);
397
+ this._cb.commitSpace(mode.sub.origin, diag, mode.sub.axis);
398
+ this._mode = { mode: "space", sub: { name: "idle" } };
399
+ }
400
+ return;
401
+ }
402
+ if (mode.mode !== "select")
403
+ return;
404
+ const sub = mode.sub;
405
+ switch (sub.name) {
406
+ case "pointing-shape": {
407
+ this._cb.setSelection([sub.id]);
408
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: sub.id } };
409
+ break;
410
+ }
411
+ case "translating": {
412
+ const dx = diag.x - sub.origin.x;
413
+ const dy = diag.y - sub.origin.y;
414
+ this._cb.lockViewport(false);
415
+ this._cb.commitTranslate(dx, dy);
416
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
417
+ break;
418
+ }
419
+ case "pointing-handle": {
420
+ this._cb.lockViewport(false);
421
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
422
+ break;
423
+ }
424
+ case "resizing": {
425
+ const newBounds = applyResize(sub.original, sub.handle, diag.x, diag.y);
426
+ this._cb.lockViewport(false);
427
+ this._cb.commitResize(sub.id, newBounds);
428
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
429
+ break;
430
+ }
431
+ case "pointing-port": {
432
+ this._cb.lockViewport(false);
433
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
434
+ break;
435
+ }
436
+ case "connecting": {
437
+ this._cb.lockViewport(false);
438
+ if (hit.type === "shape" && hit.id !== sub.sourceId) {
439
+ this._cb.commitConnect(sub.sourceId, hit.id);
440
+ }
441
+ else {
442
+ this._cb.cancelConnect();
443
+ }
444
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
445
+ break;
446
+ }
447
+ case "rubber-band": {
448
+ this._cb.lockViewport(false);
449
+ this._cb.cancelRubberBand();
450
+ const minX = Math.min(sub.origin.x, sub.current.x);
451
+ const maxX = Math.max(sub.origin.x, sub.current.x);
452
+ const minY = Math.min(sub.origin.y, sub.current.y);
453
+ const maxY = Math.max(sub.origin.y, sub.current.y);
454
+ const shapes = this._cb.getShapes();
455
+ const ids = shapes
456
+ .filter((s) => {
457
+ const b = s.shape.bounds;
458
+ return b.x + b.width > minX && b.x < maxX && b.y + b.height > minY && b.y < maxY;
459
+ })
460
+ .map((s) => s.id);
461
+ this._cb.setSelection(ids);
462
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
463
+ break;
464
+ }
465
+ case "pointing-edge-endpoint": {
466
+ this._cb.lockViewport(false);
467
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
468
+ break;
469
+ }
470
+ case "dragging-edge-endpoint": {
471
+ this._cb.lockViewport(false);
472
+ this._cb.commitEndpointMove(sub.edgeId, sub.isStart, diag);
473
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
474
+ break;
475
+ }
476
+ case "pointing-edge-segment": {
477
+ this._cb.lockViewport(false);
478
+ // Tap without drag: select the edge
479
+ this._cb.setEdgeSelected(sub.edgeId);
480
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
481
+ break;
482
+ }
483
+ case "dragging-edge-waypoint-new": {
484
+ this._cb.lockViewport(false);
485
+ this._cb.commitWaypointInsert(sub.edgeId, sub.segIdx, diag);
486
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
487
+ break;
488
+ }
489
+ case "pointing-edge-waypoint": {
490
+ this._cb.lockViewport(false);
491
+ this._cb.setEdgeSelected(sub.edgeId);
492
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
493
+ break;
494
+ }
495
+ case "dragging-edge-waypoint": {
496
+ this._cb.lockViewport(false);
497
+ this._cb.commitWaypointMove(sub.edgeId, sub.wpIdx, diag);
498
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
499
+ break;
500
+ }
501
+ case "pointing-canvas": {
502
+ if (!this._cb.viewportDidPan()) {
503
+ this._cb.setSelection([]);
504
+ }
505
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
506
+ break;
507
+ }
508
+ default:
509
+ break;
510
+ }
511
+ }
512
+ // ── Double-click ──────────────────────────────────────────────────
513
+ onDblClick(_e, _diag, hit) {
514
+ if (hit.type === "shape") {
515
+ this._mode = { mode: "select", sub: { name: "editing-label", id: hit.id } };
516
+ this._cb.startLabelEdit(hit.id);
517
+ }
518
+ }
519
+ // ── Key down ──────────────────────────────────────────────────────
520
+ onKeyDown(e) {
521
+ const mode = this._mode;
522
+ if (mode.mode === "create" && e.key === "Escape") {
523
+ e.preventDefault();
524
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
525
+ this._cb.setTool("select");
526
+ return;
527
+ }
528
+ if (mode.mode === "space" && e.key === "Escape") {
529
+ e.preventDefault();
530
+ if (mode.sub.name === "dragging") {
531
+ this._cb.lockViewport(false);
532
+ this._cb.cancelSpace();
533
+ }
534
+ this._mode = { mode: "space", sub: { name: "idle" } };
535
+ return;
536
+ }
537
+ if (mode.mode !== "select")
538
+ return;
539
+ const sub = mode.sub;
540
+ if (e.key === "Escape") {
541
+ e.preventDefault();
542
+ // Cancel in-progress operations
543
+ if (sub.name === "translating") {
544
+ this._cb.cancelTranslate();
545
+ this._cb.lockViewport(false);
546
+ }
547
+ else if (sub.name === "rubber-band" ||
548
+ sub.name === "pointing-handle" ||
549
+ sub.name === "resizing" ||
550
+ sub.name === "connecting" ||
551
+ sub.name === "pointing-port") {
552
+ this._cb.lockViewport(false);
553
+ }
554
+ else if (sub.name === "pointing-edge-endpoint" || sub.name === "dragging-edge-endpoint") {
555
+ this._cb.lockViewport(false);
556
+ this._cb.cancelEndpointMove();
557
+ }
558
+ else if (sub.name === "pointing-edge-segment" || sub.name === "pointing-edge-waypoint") {
559
+ this._cb.lockViewport(false);
560
+ }
561
+ else if (sub.name === "dragging-edge-waypoint-new") {
562
+ this._cb.lockViewport(false);
563
+ this._cb.cancelWaypointInsert();
564
+ }
565
+ else if (sub.name === "dragging-edge-waypoint") {
566
+ this._cb.lockViewport(false);
567
+ this._cb.cancelWaypointMove();
568
+ }
569
+ this._cb.setSelection([]);
570
+ this._mode = { mode: "select", sub: { name: "idle", hoveredId: null } };
571
+ return;
572
+ }
573
+ if (e.key === "Delete" || e.key === "Backspace") {
574
+ // Don't delete while label-editing
575
+ if (sub.name === "editing-label")
576
+ return;
577
+ e.preventDefault();
578
+ const ids = this._cb.getSelectedIds();
579
+ const edgeId = this._cb.getSelectedEdgeId();
580
+ const allIds = edgeId ? [...ids, edgeId] : ids;
581
+ if (allIds.length > 0) {
582
+ this._cb.executeDelete(allIds);
583
+ }
584
+ return;
585
+ }
586
+ }
587
+ }
588
+ //# sourceMappingURL=state-machine.js.map
@@ -0,0 +1,61 @@
1
+ import type { CanvasEvents, CanvasOptions } from "@bpmnkit/canvas";
2
+ import type { BpmnDefinitions } from "@bpmnkit/core";
3
+ export type CreateShapeType = "startEvent" | "messageStartEvent" | "timerStartEvent" | "conditionalStartEvent" | "signalStartEvent" | "endEvent" | "messageEndEvent" | "escalationEndEvent" | "errorEndEvent" | "compensationEndEvent" | "signalEndEvent" | "terminateEndEvent" | "intermediateThrowEvent" | "intermediateCatchEvent" | "messageCatchEvent" | "messageThrowEvent" | "timerCatchEvent" | "escalationThrowEvent" | "conditionalCatchEvent" | "linkCatchEvent" | "linkThrowEvent" | "compensationThrowEvent" | "signalCatchEvent" | "signalThrowEvent" | "task" | "serviceTask" | "userTask" | "scriptTask" | "sendTask" | "receiveTask" | "businessRuleTask" | "manualTask" | "callActivity" | "subProcess" | "adHocSubProcess" | "transaction" | "exclusiveGateway" | "parallelGateway" | "inclusiveGateway" | "eventBasedGateway" | "complexGateway" | "textAnnotation";
4
+ /** Element types that support resize handles. */
5
+ export declare const RESIZABLE_TYPES: ReadonlySet<string>;
6
+ export type Tool = "select" | "pan" | "space" | `create:${CreateShapeType}`;
7
+ export type HandleDir = "nw" | "n" | "ne" | "e" | "se" | "s" | "sw" | "w";
8
+ export type PortDir = "top" | "right" | "bottom" | "left";
9
+ export type EditorOptions = CanvasOptions & {
10
+ /**
11
+ * When true, the editor reads the initial theme from
12
+ * `localStorage.getItem("bpmnkit-theme")` and persists theme changes back to
13
+ * localStorage automatically. The stored key is `"bpmnkit-theme"`.
14
+ */
15
+ persistTheme?: boolean;
16
+ };
17
+ export interface EditorEvents extends CanvasEvents {
18
+ "diagram:change": (defs: BpmnDefinitions) => void;
19
+ "editor:select": (ids: string[]) => void;
20
+ "editor:tool": (tool: Tool) => void;
21
+ "editor:drag": (dragging: boolean) => void;
22
+ }
23
+ /** Label position options for events and gateways (external labels). */
24
+ export type LabelPosition = "bottom" | "top" | "left" | "right" | "bottom-left" | "bottom-right" | "top-left" | "top-right";
25
+ export type HitResult = {
26
+ type: "canvas";
27
+ } | {
28
+ type: "shape";
29
+ id: string;
30
+ } | {
31
+ type: "handle";
32
+ shapeId: string;
33
+ handle: HandleDir;
34
+ } | {
35
+ type: "port";
36
+ shapeId: string;
37
+ port: PortDir;
38
+ } | {
39
+ type: "edge";
40
+ id: string;
41
+ } | {
42
+ type: "edge-endpoint";
43
+ edgeId: string;
44
+ isStart: boolean;
45
+ } | {
46
+ type: "edge-segment";
47
+ id: string;
48
+ segIdx: number;
49
+ isHoriz: boolean;
50
+ projPt: DiagPoint;
51
+ } | {
52
+ type: "edge-waypoint";
53
+ id: string;
54
+ wpIdx: number;
55
+ pt: DiagPoint;
56
+ };
57
+ export interface DiagPoint {
58
+ x: number;
59
+ y: number;
60
+ }
61
+ //# sourceMappingURL=types.d.ts.map
package/dist/types.js ADDED
@@ -0,0 +1,17 @@
1
+ /** Element types that support resize handles. */
2
+ export const RESIZABLE_TYPES = new Set([
3
+ "task",
4
+ "serviceTask",
5
+ "userTask",
6
+ "scriptTask",
7
+ "sendTask",
8
+ "receiveTask",
9
+ "businessRuleTask",
10
+ "manualTask",
11
+ "callActivity",
12
+ "subProcess",
13
+ "adHocSubProcess",
14
+ "transaction",
15
+ "textAnnotation",
16
+ ]);
17
+ //# sourceMappingURL=types.js.map