orcasvn-react-diagrams 0.2.11 → 0.2.13
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 +27 -0
- package/README.md +15 -7
- package/ai/api-contract.json +90 -1
- package/ai/invariants.json +6 -2
- package/ai/manifest.json +1 -1
- package/dist/cjs/examples.js +916 -331
- package/dist/cjs/index.js +406 -97
- package/dist/cjs/types/api/createDiagramEditor.d.ts +3 -1
- package/dist/cjs/types/api/types.d.ts +64 -0
- package/dist/cjs/types/displaybox/demos/LinkPortCreationDemoTab.d.ts +3 -0
- package/dist/cjs/types/displaybox/demos/deletionEventsDemo.d.ts +2 -0
- package/dist/cjs/types/displaybox/demos/focusElementDemo.d.ts +4 -0
- package/dist/cjs/types/displaybox/demos/linkLabelsDemo.d.ts +4 -0
- package/dist/cjs/types/displaybox/types.d.ts +3 -0
- package/dist/cjs/types/displaybox/useDemoEditor.d.ts +3 -2
- package/dist/cjs/types/engine/DiagramEngine.d.ts +11 -1
- package/dist/cjs/types/engine/TextLayoutService.d.ts +1 -0
- package/dist/cjs/types/examples/index.d.ts +1 -1
- package/dist/cjs/types/renderer/konva/KonvaInteraction.d.ts +10 -1
- package/dist/esm/examples.js +916 -331
- package/dist/esm/examples.js.map +1 -1
- package/dist/esm/index.js +406 -97
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api/createDiagramEditor.d.ts +3 -1
- package/dist/esm/types/api/types.d.ts +64 -0
- package/dist/esm/types/displaybox/demos/LinkPortCreationDemoTab.d.ts +3 -0
- package/dist/esm/types/displaybox/demos/deletionEventsDemo.d.ts +2 -0
- package/dist/esm/types/displaybox/demos/focusElementDemo.d.ts +4 -0
- package/dist/esm/types/displaybox/demos/linkLabelsDemo.d.ts +4 -0
- package/dist/esm/types/displaybox/types.d.ts +3 -0
- package/dist/esm/types/displaybox/useDemoEditor.d.ts +3 -2
- package/dist/esm/types/engine/DiagramEngine.d.ts +11 -1
- package/dist/esm/types/engine/TextLayoutService.d.ts +1 -0
- package/dist/esm/types/examples/index.d.ts +1 -1
- package/dist/esm/types/renderer/konva/KonvaInteraction.d.ts +10 -1
- package/dist/examples.d.ts +55 -1
- package/dist/index.d.ts +67 -1
- package/docs/API_CONTRACT.md +88 -1
- package/docs/ARCHITECTURE.md +9 -7
- package/docs/CAPABILITIES.md +5 -0
- package/docs/COMMANDS_EVENTS.md +16 -6
- package/docs/DOCUMENTATION_WORKFLOW.md +5 -1
- package/docs/INTEGRATION_PLAYBOOK.md +8 -0
- package/docs/PORTING_CHECKLIST.md +4 -1
- package/docs/STATE_INVARIANTS.md +3 -0
- package/package.json +1 -1
- package/src/displaybox/demos/DeletionEventsDemoTab.tsx +167 -9
- package/src/displaybox/demos/LinkPortCreationDemoTab.tsx +98 -0
- package/src/displaybox/demos/deletionEventsDemo.ts +2 -2
- package/src/displaybox/demos/focusElementDemo.ts +91 -0
- package/src/displaybox/demos/index.tsx +124 -221
- package/src/displaybox/demos/linkLabelsDemo.ts +164 -0
- package/src/displaybox/demos/linkPortCreationDemo.ts +7 -7
- package/src/displaybox/types.ts +21 -11
- package/src/examples/index.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiagramEngineHandle, Point, DiagramState, ElementShapeHoverControlActivationEvent, ElementShapeHoverControlInteractionEvent, ElementShapeHoverControls, EngineChangeEvent, EngineSelectionEvent, LinkColorPoolPolicy, LinkRouteRefreshPolicy, ViewportFitOptions } from './types';
|
|
1
|
+
import { DiagramEngineHandle, Point, DiagramState, ElementShapeHoverControlActivationEvent, ElementShapeHoverControlInteractionEvent, ElementShapeHoverControls, EngineChangeEvent, EngineSelectionEvent, LinkTargetPortCreationHandler, LinkColorPoolPolicy, LinkRouteRefreshPolicy, FocusElementOptions, ViewportFitOptions } from './types';
|
|
2
2
|
import { type BuiltInShapeKind } from '../shapes';
|
|
3
3
|
export type SimpleShape = {
|
|
4
4
|
id: string;
|
|
@@ -16,6 +16,7 @@ export type DiagramEditorConfig = {
|
|
|
16
16
|
elementShapeHoverControls?: ElementShapeHoverControls;
|
|
17
17
|
onElementShapeHoverControlInteraction?: (event: ElementShapeHoverControlInteractionEvent) => void;
|
|
18
18
|
onElementShapeHoverControlActivated?: (event: ElementShapeHoverControlActivationEvent) => void;
|
|
19
|
+
onCreateLinkTargetPort?: LinkTargetPortCreationHandler;
|
|
19
20
|
onChange?: (event: EngineChangeEvent) => void;
|
|
20
21
|
onSelection?: (event: EngineSelectionEvent) => void;
|
|
21
22
|
linkRouteRefreshPolicy?: LinkRouteRefreshPolicy;
|
|
@@ -40,6 +41,7 @@ export type DiagramEditorHandle = DiagramEngineHandle & {
|
|
|
40
41
|
completeLinkToElement: (targetElementId: string, pointer: Point) => void;
|
|
41
42
|
cancelLink: () => void;
|
|
42
43
|
zoomToFitElements: (options?: ViewportFitOptions) => void;
|
|
44
|
+
focusElement: (elementId: string, options?: FocusElementOptions) => void;
|
|
43
45
|
exportImage: (options?: DiagramImageExportOptions) => string;
|
|
44
46
|
resize: (width: number, height: number) => void;
|
|
45
47
|
setElementShapeHoverControls: (controls?: ElementShapeHoverControls) => void;
|
|
@@ -24,6 +24,9 @@ export type ViewportFitOptions = {
|
|
|
24
24
|
minZoom?: number;
|
|
25
25
|
maxZoom?: number;
|
|
26
26
|
};
|
|
27
|
+
export type FocusElementOptions = {
|
|
28
|
+
zoom?: number;
|
|
29
|
+
};
|
|
27
30
|
export type MoveConstraint = 'free' | 'inside' | 'border';
|
|
28
31
|
export type TextInteractionPolicy = {
|
|
29
32
|
movable?: boolean;
|
|
@@ -297,6 +300,20 @@ export type PortData = {
|
|
|
297
300
|
rotationPivot?: Point;
|
|
298
301
|
currentAnchorId?: string;
|
|
299
302
|
};
|
|
303
|
+
export type LinkTargetPortCreationPhase = 'preview' | 'commit';
|
|
304
|
+
export type LinkTargetPortDraft = Omit<PortData, 'id' | 'elementId'>;
|
|
305
|
+
export type LinkTargetPortCreationContext = {
|
|
306
|
+
phase: LinkTargetPortCreationPhase;
|
|
307
|
+
pointer: Point;
|
|
308
|
+
sourcePortId: string;
|
|
309
|
+
sourceElementId: string;
|
|
310
|
+
targetElementId: string;
|
|
311
|
+
sourcePort: PortData;
|
|
312
|
+
targetElement: ElementData;
|
|
313
|
+
defaultPort: LinkTargetPortDraft;
|
|
314
|
+
};
|
|
315
|
+
export type LinkTargetPortCreationResult = Partial<LinkTargetPortDraft> | void;
|
|
316
|
+
export type LinkTargetPortCreationHandler = (context: LinkTargetPortCreationContext) => LinkTargetPortCreationResult;
|
|
300
317
|
export type ShapeDrawContext = {
|
|
301
318
|
ctx: CanvasRenderingContext2D;
|
|
302
319
|
model: ElementData | PortData;
|
|
@@ -380,6 +397,11 @@ export type ElementPointerEvent = {
|
|
|
380
397
|
pointer: EnginePointerInfo;
|
|
381
398
|
isMulti: boolean;
|
|
382
399
|
};
|
|
400
|
+
export type ElementDoubleClickEvent = {
|
|
401
|
+
elementId: string;
|
|
402
|
+
pointer: EnginePointerInfo;
|
|
403
|
+
isMulti: boolean;
|
|
404
|
+
};
|
|
383
405
|
export type ElementMovedEvent = {
|
|
384
406
|
elementId: string;
|
|
385
407
|
oldWorld: Point;
|
|
@@ -404,18 +426,55 @@ export type GridLayoutChangedEvent = {
|
|
|
404
426
|
beforeGridTemplate?: ElementLayoutGridRowTemplate[];
|
|
405
427
|
afterGridTemplate: ElementLayoutGridRowTemplate[];
|
|
406
428
|
};
|
|
429
|
+
export type DeletionTrigger = 'direct' | 'selection' | 'cascade';
|
|
430
|
+
export type DeletionRootRef = {
|
|
431
|
+
entity: 'element' | 'port' | 'link' | 'text';
|
|
432
|
+
id: string;
|
|
433
|
+
};
|
|
434
|
+
export type ElementDeletingEvent = {
|
|
435
|
+
elementId: string;
|
|
436
|
+
trigger: DeletionTrigger;
|
|
437
|
+
root: DeletionRootRef;
|
|
438
|
+
cancel: () => void;
|
|
439
|
+
cancelled: boolean;
|
|
440
|
+
};
|
|
407
441
|
export type ElementDeletedEvent = {
|
|
408
442
|
elementId: string;
|
|
409
443
|
};
|
|
444
|
+
export type PortDeletingEvent = {
|
|
445
|
+
portId: string;
|
|
446
|
+
elementId: string;
|
|
447
|
+
trigger: DeletionTrigger;
|
|
448
|
+
root: DeletionRootRef;
|
|
449
|
+
cancel: () => void;
|
|
450
|
+
cancelled: boolean;
|
|
451
|
+
};
|
|
410
452
|
export type PortDeletedEvent = {
|
|
411
453
|
portId: string;
|
|
412
454
|
elementId: string;
|
|
413
455
|
};
|
|
456
|
+
export type LinkDeletingEvent = {
|
|
457
|
+
linkId: string;
|
|
458
|
+
sourcePortId: string;
|
|
459
|
+
targetPortId: string;
|
|
460
|
+
trigger: DeletionTrigger;
|
|
461
|
+
root: DeletionRootRef;
|
|
462
|
+
cancel: () => void;
|
|
463
|
+
cancelled: boolean;
|
|
464
|
+
};
|
|
414
465
|
export type LinkDeletedEvent = {
|
|
415
466
|
linkId: string;
|
|
416
467
|
sourcePortId: string;
|
|
417
468
|
targetPortId: string;
|
|
418
469
|
};
|
|
470
|
+
export type TextDeletingEvent = {
|
|
471
|
+
textId: string;
|
|
472
|
+
ownerId?: string | null;
|
|
473
|
+
trigger: DeletionTrigger;
|
|
474
|
+
root: DeletionRootRef;
|
|
475
|
+
cancel: () => void;
|
|
476
|
+
cancelled: boolean;
|
|
477
|
+
};
|
|
419
478
|
export type TextDeletedEvent = {
|
|
420
479
|
textId: string;
|
|
421
480
|
ownerId?: string | null;
|
|
@@ -469,13 +528,18 @@ export type EngineEventMap = {
|
|
|
469
528
|
portMoved: PortMovedEvent;
|
|
470
529
|
portSelected: PortSelectedEvent;
|
|
471
530
|
elementClick: ElementPointerEvent;
|
|
531
|
+
elementDoubleClick: ElementDoubleClickEvent;
|
|
472
532
|
elementDragged: ElementDropEvent;
|
|
473
533
|
elementMoved: ElementMovedEvent;
|
|
474
534
|
elementResized: ElementResizedEvent;
|
|
475
535
|
gridLayoutChanged: GridLayoutChangedEvent;
|
|
536
|
+
elementDeleting: ElementDeletingEvent;
|
|
476
537
|
elementDeleted: ElementDeletedEvent;
|
|
538
|
+
portDeleting: PortDeletingEvent;
|
|
477
539
|
portDeleted: PortDeletedEvent;
|
|
540
|
+
linkDeleting: LinkDeletingEvent;
|
|
478
541
|
linkDeleted: LinkDeletedEvent;
|
|
542
|
+
textDeleting: TextDeletingEvent;
|
|
479
543
|
textDeleted: TextDeletedEvent;
|
|
480
544
|
textUpdated: TextUpdatedEvent;
|
|
481
545
|
elementSelected: ElementSelectedEvent;
|
|
@@ -25,11 +25,14 @@ export type DemoConfig = {
|
|
|
25
25
|
stageStyle?: CSSProperties;
|
|
26
26
|
actions: DemoAction[];
|
|
27
27
|
};
|
|
28
|
+
export type DemoMenuGroup = 'basics' | 'layoutText' | 'shapes' | 'portsAnchors' | 'linksRouting' | 'eventsIntegration';
|
|
28
29
|
export type DemoDefinition = {
|
|
29
30
|
id: string;
|
|
30
31
|
title: string;
|
|
31
32
|
description: string;
|
|
32
33
|
Component: React.ComponentType;
|
|
34
|
+
menuGroup: DemoMenuGroup;
|
|
35
|
+
menuOrder: number;
|
|
33
36
|
};
|
|
34
37
|
export type ToolboxItem = {
|
|
35
38
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { DiagramEditorHandle, DiagramState, ElementShapeHoverControlActivationEvent, ElementShapeHoverControlInteractionEvent, ElementShapeHoverControls, LinkColorPoolPolicy, LinkRouteRefreshPolicy, SimpleShape } from '../api';
|
|
2
|
+
import type { DiagramEditorHandle, DiagramState, ElementShapeHoverControlActivationEvent, ElementShapeHoverControlInteractionEvent, ElementShapeHoverControls, LinkColorPoolPolicy, LinkTargetPortCreationHandler, LinkRouteRefreshPolicy, SimpleShape } from '../api';
|
|
3
3
|
import type { RouterStrategy } from '../strategies/RouterStrategy';
|
|
4
4
|
import type { ViewportSnapshot } from './types';
|
|
5
5
|
type DemoEditorConfig = {
|
|
@@ -13,8 +13,9 @@ type DemoEditorConfig = {
|
|
|
13
13
|
elementShapeHoverControls?: ElementShapeHoverControls;
|
|
14
14
|
onElementShapeHoverControlInteraction?: (event: ElementShapeHoverControlInteractionEvent) => void;
|
|
15
15
|
onElementShapeHoverControlActivated?: (event: ElementShapeHoverControlActivationEvent) => void;
|
|
16
|
+
onCreateLinkTargetPort?: LinkTargetPortCreationHandler;
|
|
16
17
|
};
|
|
17
|
-
declare const useDemoEditor: ({ createState, elementShapes, portShapes, router, snapDefault, linkRouteRefreshPolicy, linkColorPoolPolicy, elementShapeHoverControls, onElementShapeHoverControlInteraction, onElementShapeHoverControlActivated, }: DemoEditorConfig) => {
|
|
18
|
+
declare const useDemoEditor: ({ createState, elementShapes, portShapes, router, snapDefault, linkRouteRefreshPolicy, linkColorPoolPolicy, elementShapeHoverControls, onElementShapeHoverControlInteraction, onElementShapeHoverControlActivated, onCreateLinkTargetPort, }: DemoEditorConfig) => {
|
|
18
19
|
containerRef: import("react").MutableRefObject<HTMLDivElement | null>;
|
|
19
20
|
editorRef: import("react").MutableRefObject<DiagramEditorHandle | null>;
|
|
20
21
|
diagramState: DiagramState | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiagramEngineHandle, DiagramState, ElementData, EngineEventMap, ElementDropEvent, EnginePointerInfo, LinkData, LinkColorPoolPolicy, ElementLinkConnectingEvent, LinkRoutingMode, LinkRouteRefreshPolicy, OverlayShapeConfig, OverlayShapeHandle, Point, PortData, RerouteLinksOptions, TextData, PortMouseEvent } from '../api/types';
|
|
1
|
+
import { DiagramEngineHandle, DiagramState, ElementData, EngineEventMap, ElementDropEvent, EnginePointerInfo, LinkData, LinkColorPoolPolicy, ElementLinkConnectingEvent, LinkRoutingMode, LinkRouteRefreshPolicy, LinkTargetPortDraft, OverlayShapeConfig, OverlayShapeHandle, Point, PortData, RerouteLinksOptions, TextData, PortMouseEvent } from '../api/types';
|
|
2
2
|
import { Renderer } from '../renderer/Renderer';
|
|
3
3
|
import RenderScheduler from '../renderer/RenderScheduler';
|
|
4
4
|
import { RouterStrategy } from '../strategies/RouterStrategy';
|
|
@@ -61,6 +61,7 @@ export default class DiagramEngine {
|
|
|
61
61
|
setElementLayout(id: string, layout: ElementData['layout']): void;
|
|
62
62
|
removeElement(id: string): void;
|
|
63
63
|
addPortToElement(elementId: string, port: PortData): void;
|
|
64
|
+
normalizePortDraftForElement(elementId: string, draft: LinkTargetPortDraft): LinkTargetPortDraft | null;
|
|
64
65
|
movePortTo(id: string, x: number, y: number): void;
|
|
65
66
|
removePort(id: string): void;
|
|
66
67
|
addLink(link: LinkData): void;
|
|
@@ -119,6 +120,7 @@ export default class DiagramEngine {
|
|
|
119
120
|
emitPortMouseDown(event: PortMouseEvent): void;
|
|
120
121
|
emitPortMouseUp(event: PortMouseEvent): void;
|
|
121
122
|
emitElementClick(elementId: string, pointer: EnginePointerInfo, isMulti: boolean): void;
|
|
123
|
+
emitElementDoubleClick(elementId: string, pointer: EnginePointerInfo, isMulti: boolean): void;
|
|
122
124
|
emitElementLinkStarted(event: {
|
|
123
125
|
sourcePortId: string;
|
|
124
126
|
sourceElementId: string;
|
|
@@ -171,6 +173,14 @@ export default class DiagramEngine {
|
|
|
171
173
|
private refreshLinksForRenderCycle;
|
|
172
174
|
private normalizePortsForHostPolicies;
|
|
173
175
|
private computeRemovalDiff;
|
|
176
|
+
private resolveDeletionRoot;
|
|
177
|
+
private applyRemovalCommand;
|
|
178
|
+
private planRemoval;
|
|
179
|
+
private emitDeletionLifecycleEvents;
|
|
180
|
+
private emitElementDeleting;
|
|
181
|
+
private emitPortDeleting;
|
|
182
|
+
private emitLinkDeleting;
|
|
183
|
+
private emitTextDeleting;
|
|
174
184
|
private emitEntityDeletionEvents;
|
|
175
185
|
}
|
|
176
186
|
export declare const createDiagramEngine: (config: DiagramEngineConfig) => DiagramEngineHandle;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { demoTabs, baseElementShapes, basePortShapes, customGalleryShapes, defaultGhostSize, defaultSvgPath, defaultSvgPathSize, externalToolboxItems, } from '../displaybox/demos';
|
|
2
|
-
export type { DemoAction, DemoActionHelpers, DemoConfig, DemoDefinition, ToolboxItem, DiagramCounts, ViewportSnapshot, DisplayBoxMetrics, } from '../displaybox/types';
|
|
2
|
+
export type { DemoAction, DemoActionHelpers, DemoConfig, DemoDefinition, DemoMenuGroup, ToolboxItem, DiagramCounts, ViewportSnapshot, DisplayBoxMetrics, } from '../displaybox/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementShapeHoverControlActivationEvent, ElementShapeHoverControlInteractionEvent, ElementShapeHoverControls, Point, PortData } from '../../api/types';
|
|
1
|
+
import { ElementShapeHoverControlActivationEvent, ElementShapeHoverControlInteractionEvent, ElementShapeHoverControls, LinkTargetPortCreationHandler, Point, PortData } from '../../api/types';
|
|
2
2
|
import DiagramEngine from '../../engine/DiagramEngine';
|
|
3
3
|
import KonvaHitTester from './KonvaHitTester';
|
|
4
4
|
import { KonvaStageLike, ShapeHoverControlRenderConfig } from './KonvaRenderer';
|
|
@@ -11,6 +11,7 @@ export type InteractionConfig = {
|
|
|
11
11
|
shapeHoverControls?: ElementShapeHoverControls;
|
|
12
12
|
onShapeHoverControlInteracted?: (event: ElementShapeHoverControlInteractionEvent) => void;
|
|
13
13
|
onShapeHoverControlActivated?: (event: ElementShapeHoverControlActivationEvent) => void;
|
|
14
|
+
onCreateLinkTargetPort?: LinkTargetPortCreationHandler;
|
|
14
15
|
renderer?: {
|
|
15
16
|
renderResizeHandles: (elementId: string, position: Point, size: {
|
|
16
17
|
width: number;
|
|
@@ -55,6 +56,7 @@ export default class KonvaInteraction {
|
|
|
55
56
|
private shapeHoverControls?;
|
|
56
57
|
private onShapeHoverControlInteracted?;
|
|
57
58
|
private onShapeHoverControlActivated?;
|
|
59
|
+
private onCreateLinkTargetPort?;
|
|
58
60
|
private linkDragContext;
|
|
59
61
|
private programmaticLinkSession;
|
|
60
62
|
private bound;
|
|
@@ -142,6 +144,13 @@ export default class KonvaInteraction {
|
|
|
142
144
|
private tryCreateLinkToElement;
|
|
143
145
|
private createPortForLink;
|
|
144
146
|
private createPlaceholderPort;
|
|
147
|
+
private resolveLinkTargetPortDraft;
|
|
148
|
+
private buildDefaultLinkTargetPortDraft;
|
|
149
|
+
private mergeLinkTargetPortDraft;
|
|
150
|
+
private resolveLinkSourcePort;
|
|
151
|
+
private clonePortData;
|
|
152
|
+
private cloneLinkTargetPortDraft;
|
|
153
|
+
private cloneElementData;
|
|
145
154
|
private getElementById;
|
|
146
155
|
private getPortById;
|
|
147
156
|
private getTextById;
|
package/dist/examples.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ type ViewportFitOptions = {
|
|
|
26
26
|
minZoom?: number;
|
|
27
27
|
maxZoom?: number;
|
|
28
28
|
};
|
|
29
|
+
type FocusElementOptions = {
|
|
30
|
+
zoom?: number;
|
|
31
|
+
};
|
|
29
32
|
type MoveConstraint = 'free' | 'inside' | 'border';
|
|
30
33
|
type TextInteractionPolicy = {
|
|
31
34
|
movable?: boolean;
|
|
@@ -353,6 +356,11 @@ type ElementPointerEvent = {
|
|
|
353
356
|
pointer: EnginePointerInfo;
|
|
354
357
|
isMulti: boolean;
|
|
355
358
|
};
|
|
359
|
+
type ElementDoubleClickEvent = {
|
|
360
|
+
elementId: string;
|
|
361
|
+
pointer: EnginePointerInfo;
|
|
362
|
+
isMulti: boolean;
|
|
363
|
+
};
|
|
356
364
|
type ElementMovedEvent = {
|
|
357
365
|
elementId: string;
|
|
358
366
|
oldWorld: Point;
|
|
@@ -377,18 +385,55 @@ type GridLayoutChangedEvent = {
|
|
|
377
385
|
beforeGridTemplate?: ElementLayoutGridRowTemplate[];
|
|
378
386
|
afterGridTemplate: ElementLayoutGridRowTemplate[];
|
|
379
387
|
};
|
|
388
|
+
type DeletionTrigger = 'direct' | 'selection' | 'cascade';
|
|
389
|
+
type DeletionRootRef = {
|
|
390
|
+
entity: 'element' | 'port' | 'link' | 'text';
|
|
391
|
+
id: string;
|
|
392
|
+
};
|
|
393
|
+
type ElementDeletingEvent = {
|
|
394
|
+
elementId: string;
|
|
395
|
+
trigger: DeletionTrigger;
|
|
396
|
+
root: DeletionRootRef;
|
|
397
|
+
cancel: () => void;
|
|
398
|
+
cancelled: boolean;
|
|
399
|
+
};
|
|
380
400
|
type ElementDeletedEvent = {
|
|
381
401
|
elementId: string;
|
|
382
402
|
};
|
|
403
|
+
type PortDeletingEvent = {
|
|
404
|
+
portId: string;
|
|
405
|
+
elementId: string;
|
|
406
|
+
trigger: DeletionTrigger;
|
|
407
|
+
root: DeletionRootRef;
|
|
408
|
+
cancel: () => void;
|
|
409
|
+
cancelled: boolean;
|
|
410
|
+
};
|
|
383
411
|
type PortDeletedEvent = {
|
|
384
412
|
portId: string;
|
|
385
413
|
elementId: string;
|
|
386
414
|
};
|
|
415
|
+
type LinkDeletingEvent = {
|
|
416
|
+
linkId: string;
|
|
417
|
+
sourcePortId: string;
|
|
418
|
+
targetPortId: string;
|
|
419
|
+
trigger: DeletionTrigger;
|
|
420
|
+
root: DeletionRootRef;
|
|
421
|
+
cancel: () => void;
|
|
422
|
+
cancelled: boolean;
|
|
423
|
+
};
|
|
387
424
|
type LinkDeletedEvent = {
|
|
388
425
|
linkId: string;
|
|
389
426
|
sourcePortId: string;
|
|
390
427
|
targetPortId: string;
|
|
391
428
|
};
|
|
429
|
+
type TextDeletingEvent = {
|
|
430
|
+
textId: string;
|
|
431
|
+
ownerId?: string | null;
|
|
432
|
+
trigger: DeletionTrigger;
|
|
433
|
+
root: DeletionRootRef;
|
|
434
|
+
cancel: () => void;
|
|
435
|
+
cancelled: boolean;
|
|
436
|
+
};
|
|
392
437
|
type TextDeletedEvent = {
|
|
393
438
|
textId: string;
|
|
394
439
|
ownerId?: string | null;
|
|
@@ -442,13 +487,18 @@ type EngineEventMap = {
|
|
|
442
487
|
portMoved: PortMovedEvent;
|
|
443
488
|
portSelected: PortSelectedEvent;
|
|
444
489
|
elementClick: ElementPointerEvent;
|
|
490
|
+
elementDoubleClick: ElementDoubleClickEvent;
|
|
445
491
|
elementDragged: ElementDropEvent;
|
|
446
492
|
elementMoved: ElementMovedEvent;
|
|
447
493
|
elementResized: ElementResizedEvent;
|
|
448
494
|
gridLayoutChanged: GridLayoutChangedEvent;
|
|
495
|
+
elementDeleting: ElementDeletingEvent;
|
|
449
496
|
elementDeleted: ElementDeletedEvent;
|
|
497
|
+
portDeleting: PortDeletingEvent;
|
|
450
498
|
portDeleted: PortDeletedEvent;
|
|
499
|
+
linkDeleting: LinkDeletingEvent;
|
|
451
500
|
linkDeleted: LinkDeletedEvent;
|
|
501
|
+
textDeleting: TextDeletingEvent;
|
|
452
502
|
textDeleted: TextDeletedEvent;
|
|
453
503
|
textUpdated: TextUpdatedEvent;
|
|
454
504
|
elementSelected: ElementSelectedEvent;
|
|
@@ -569,6 +619,7 @@ type DiagramEditorHandle = DiagramEngineHandle & {
|
|
|
569
619
|
completeLinkToElement: (targetElementId: string, pointer: Point) => void;
|
|
570
620
|
cancelLink: () => void;
|
|
571
621
|
zoomToFitElements: (options?: ViewportFitOptions) => void;
|
|
622
|
+
focusElement: (elementId: string, options?: FocusElementOptions) => void;
|
|
572
623
|
exportImage: (options?: DiagramImageExportOptions) => string;
|
|
573
624
|
resize: (width: number, height: number) => void;
|
|
574
625
|
setElementShapeHoverControls: (controls?: ElementShapeHoverControls) => void;
|
|
@@ -599,11 +650,14 @@ type DemoConfig = {
|
|
|
599
650
|
stageStyle?: CSSProperties;
|
|
600
651
|
actions: DemoAction[];
|
|
601
652
|
};
|
|
653
|
+
type DemoMenuGroup = 'basics' | 'layoutText' | 'shapes' | 'portsAnchors' | 'linksRouting' | 'eventsIntegration';
|
|
602
654
|
type DemoDefinition = {
|
|
603
655
|
id: string;
|
|
604
656
|
title: string;
|
|
605
657
|
description: string;
|
|
606
658
|
Component: React.ComponentType;
|
|
659
|
+
menuGroup: DemoMenuGroup;
|
|
660
|
+
menuOrder: number;
|
|
607
661
|
};
|
|
608
662
|
type ToolboxItem = {
|
|
609
663
|
id: string;
|
|
@@ -650,4 +704,4 @@ declare const defaultSvgPathSize: {
|
|
|
650
704
|
|
|
651
705
|
declare const demoTabs: DemoDefinition[];
|
|
652
706
|
|
|
653
|
-
export { type DemoAction, type DemoActionHelpers, type DemoConfig, type DemoDefinition, type DiagramCounts, type DisplayBoxMetrics, type ToolboxItem, type ViewportSnapshot, baseElementShapes, basePortShapes, customGalleryShapes, defaultGhostSize, defaultSvgPath, defaultSvgPathSize, demoTabs, externalToolboxItems };
|
|
707
|
+
export { type DemoAction, type DemoActionHelpers, type DemoConfig, type DemoDefinition, type DemoMenuGroup, type DiagramCounts, type DisplayBoxMetrics, type ToolboxItem, type ViewportSnapshot, baseElementShapes, basePortShapes, customGalleryShapes, defaultGhostSize, defaultSvgPath, defaultSvgPathSize, demoTabs, externalToolboxItems };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ type ViewportFitOptions = {
|
|
|
24
24
|
minZoom?: number;
|
|
25
25
|
maxZoom?: number;
|
|
26
26
|
};
|
|
27
|
+
type FocusElementOptions = {
|
|
28
|
+
zoom?: number;
|
|
29
|
+
};
|
|
27
30
|
type MoveConstraint = 'free' | 'inside' | 'border';
|
|
28
31
|
type TextInteractionPolicy = {
|
|
29
32
|
movable?: boolean;
|
|
@@ -297,6 +300,20 @@ type PortData = {
|
|
|
297
300
|
rotationPivot?: Point;
|
|
298
301
|
currentAnchorId?: string;
|
|
299
302
|
};
|
|
303
|
+
type LinkTargetPortCreationPhase = 'preview' | 'commit';
|
|
304
|
+
type LinkTargetPortDraft = Omit<PortData, 'id' | 'elementId'>;
|
|
305
|
+
type LinkTargetPortCreationContext = {
|
|
306
|
+
phase: LinkTargetPortCreationPhase;
|
|
307
|
+
pointer: Point;
|
|
308
|
+
sourcePortId: string;
|
|
309
|
+
sourceElementId: string;
|
|
310
|
+
targetElementId: string;
|
|
311
|
+
sourcePort: PortData;
|
|
312
|
+
targetElement: ElementData;
|
|
313
|
+
defaultPort: LinkTargetPortDraft;
|
|
314
|
+
};
|
|
315
|
+
type LinkTargetPortCreationResult = Partial<LinkTargetPortDraft> | void;
|
|
316
|
+
type LinkTargetPortCreationHandler = (context: LinkTargetPortCreationContext) => LinkTargetPortCreationResult;
|
|
300
317
|
type ShapeDrawContext = {
|
|
301
318
|
ctx: CanvasRenderingContext2D;
|
|
302
319
|
model: ElementData | PortData;
|
|
@@ -380,6 +397,11 @@ type ElementPointerEvent = {
|
|
|
380
397
|
pointer: EnginePointerInfo;
|
|
381
398
|
isMulti: boolean;
|
|
382
399
|
};
|
|
400
|
+
type ElementDoubleClickEvent = {
|
|
401
|
+
elementId: string;
|
|
402
|
+
pointer: EnginePointerInfo;
|
|
403
|
+
isMulti: boolean;
|
|
404
|
+
};
|
|
383
405
|
type ElementMovedEvent = {
|
|
384
406
|
elementId: string;
|
|
385
407
|
oldWorld: Point;
|
|
@@ -404,18 +426,55 @@ type GridLayoutChangedEvent = {
|
|
|
404
426
|
beforeGridTemplate?: ElementLayoutGridRowTemplate[];
|
|
405
427
|
afterGridTemplate: ElementLayoutGridRowTemplate[];
|
|
406
428
|
};
|
|
429
|
+
type DeletionTrigger = 'direct' | 'selection' | 'cascade';
|
|
430
|
+
type DeletionRootRef = {
|
|
431
|
+
entity: 'element' | 'port' | 'link' | 'text';
|
|
432
|
+
id: string;
|
|
433
|
+
};
|
|
434
|
+
type ElementDeletingEvent = {
|
|
435
|
+
elementId: string;
|
|
436
|
+
trigger: DeletionTrigger;
|
|
437
|
+
root: DeletionRootRef;
|
|
438
|
+
cancel: () => void;
|
|
439
|
+
cancelled: boolean;
|
|
440
|
+
};
|
|
407
441
|
type ElementDeletedEvent = {
|
|
408
442
|
elementId: string;
|
|
409
443
|
};
|
|
444
|
+
type PortDeletingEvent = {
|
|
445
|
+
portId: string;
|
|
446
|
+
elementId: string;
|
|
447
|
+
trigger: DeletionTrigger;
|
|
448
|
+
root: DeletionRootRef;
|
|
449
|
+
cancel: () => void;
|
|
450
|
+
cancelled: boolean;
|
|
451
|
+
};
|
|
410
452
|
type PortDeletedEvent = {
|
|
411
453
|
portId: string;
|
|
412
454
|
elementId: string;
|
|
413
455
|
};
|
|
456
|
+
type LinkDeletingEvent = {
|
|
457
|
+
linkId: string;
|
|
458
|
+
sourcePortId: string;
|
|
459
|
+
targetPortId: string;
|
|
460
|
+
trigger: DeletionTrigger;
|
|
461
|
+
root: DeletionRootRef;
|
|
462
|
+
cancel: () => void;
|
|
463
|
+
cancelled: boolean;
|
|
464
|
+
};
|
|
414
465
|
type LinkDeletedEvent = {
|
|
415
466
|
linkId: string;
|
|
416
467
|
sourcePortId: string;
|
|
417
468
|
targetPortId: string;
|
|
418
469
|
};
|
|
470
|
+
type TextDeletingEvent = {
|
|
471
|
+
textId: string;
|
|
472
|
+
ownerId?: string | null;
|
|
473
|
+
trigger: DeletionTrigger;
|
|
474
|
+
root: DeletionRootRef;
|
|
475
|
+
cancel: () => void;
|
|
476
|
+
cancelled: boolean;
|
|
477
|
+
};
|
|
419
478
|
type TextDeletedEvent = {
|
|
420
479
|
textId: string;
|
|
421
480
|
ownerId?: string | null;
|
|
@@ -469,13 +528,18 @@ type EngineEventMap = {
|
|
|
469
528
|
portMoved: PortMovedEvent;
|
|
470
529
|
portSelected: PortSelectedEvent;
|
|
471
530
|
elementClick: ElementPointerEvent;
|
|
531
|
+
elementDoubleClick: ElementDoubleClickEvent;
|
|
472
532
|
elementDragged: ElementDropEvent;
|
|
473
533
|
elementMoved: ElementMovedEvent;
|
|
474
534
|
elementResized: ElementResizedEvent;
|
|
475
535
|
gridLayoutChanged: GridLayoutChangedEvent;
|
|
536
|
+
elementDeleting: ElementDeletingEvent;
|
|
476
537
|
elementDeleted: ElementDeletedEvent;
|
|
538
|
+
portDeleting: PortDeletingEvent;
|
|
477
539
|
portDeleted: PortDeletedEvent;
|
|
540
|
+
linkDeleting: LinkDeletingEvent;
|
|
478
541
|
linkDeleted: LinkDeletedEvent;
|
|
542
|
+
textDeleting: TextDeletingEvent;
|
|
479
543
|
textDeleted: TextDeletedEvent;
|
|
480
544
|
textUpdated: TextUpdatedEvent;
|
|
481
545
|
elementSelected: ElementSelectedEvent;
|
|
@@ -818,6 +882,7 @@ type DiagramEditorConfig = {
|
|
|
818
882
|
elementShapeHoverControls?: ElementShapeHoverControls;
|
|
819
883
|
onElementShapeHoverControlInteraction?: (event: ElementShapeHoverControlInteractionEvent) => void;
|
|
820
884
|
onElementShapeHoverControlActivated?: (event: ElementShapeHoverControlActivationEvent) => void;
|
|
885
|
+
onCreateLinkTargetPort?: LinkTargetPortCreationHandler;
|
|
821
886
|
onChange?: (event: EngineChangeEvent) => void;
|
|
822
887
|
onSelection?: (event: EngineSelectionEvent) => void;
|
|
823
888
|
linkRouteRefreshPolicy?: LinkRouteRefreshPolicy;
|
|
@@ -842,6 +907,7 @@ type DiagramEditorHandle = DiagramEngineHandle & {
|
|
|
842
907
|
completeLinkToElement: (targetElementId: string, pointer: Point) => void;
|
|
843
908
|
cancelLink: () => void;
|
|
844
909
|
zoomToFitElements: (options?: ViewportFitOptions) => void;
|
|
910
|
+
focusElement: (elementId: string, options?: FocusElementOptions) => void;
|
|
845
911
|
exportImage: (options?: DiagramImageExportOptions) => string;
|
|
846
912
|
resize: (width: number, height: number) => void;
|
|
847
913
|
setElementShapeHoverControls: (controls?: ElementShapeHoverControls) => void;
|
|
@@ -849,4 +915,4 @@ type DiagramEditorHandle = DiagramEngineHandle & {
|
|
|
849
915
|
};
|
|
850
916
|
declare const createDiagramEditor: (config: DiagramEditorConfig) => DiagramEditorHandle;
|
|
851
917
|
|
|
852
|
-
export { type AnchorReference, type BorderSide$1 as BorderSide, type ClientRectLike, type DiagramContainer, type DiagramEditorConfig, type DiagramEditorHandle, type DiagramEngineHandle, type DiagramImageExportOptions, type DiagramPatch, type DiagramState, type EdgeHoverControl, type ElementChildInteractionPolicy, type ElementData, type ElementDeletedEvent, type ElementDropEvent, type ElementLayout, type ElementLayoutAlign, type ElementLayoutAutoResizeMode, type ElementLayoutChildFitCrossAxis, type ElementLayoutChildFitMainAxis, type ElementLayoutGridRowTemplate, type ElementLayoutLabelReservedSpace, type ElementLayoutLabelReservedSpaceMode, type ElementLayoutLabelReservedSpacePlacement, type ElementLayoutMode, type ElementLinkConnectingEvent, type ElementLinkEndedEvent, type ElementLinkStartedEvent, type ElementMovedEvent, type ElementPointerEvent, type ElementPortMovementPolicy, type ElementResizedEvent, type ElementSelectedEvent, type ElementShapeControlDragEvent, type ElementShapeControlEventType, type ElementShapeHoverControlActivationEvent, type ElementShapeHoverControlInteractionEvent, type ElementShapeHoverControls, EllipseMidPoint, type EngineChangeEvent, type EngineConfigEvent, type EngineEventMap, type EnginePointerInfo, type EngineSelectionEvent, type GridLayoutChangedEvent, type GridLayoutChangedReason, type GridRowSnapshot, type HostAnchorPreset, type HoverControlIcon, type LinkColorPoolPolicy, type LinkData, type LinkDeletedEvent, type LinkRouteRefreshMode, type LinkRouteRefreshPolicy, type LinkRoutingMode, type MoveConstraint, type OverlayShapeConfig, type OverlayShapeHandle, type PaperClickEvent, type Point, type PortAnchor, type PortAnchorConstraint, type PortBorderTransformContext, type PortBorderTransformResult, type PortData, type PortDeletedEvent, type PortLinkAttachMode, type PortMouseEvent, type PortMovedEvent, type PortPositionLimits, type PortSelectedEvent, type PositionAxisLimit, type Rect, type RerouteLinksOptions, type ResolvePortAnchorsOptions, type ShapeControlDefinition, type ShapeControlTargetKind, type ShapeControlVisibilityTrigger, type ShapeDrawContext, type ShapeEdgeTarget, type ShapeEllipseMidPointTarget, type ShapeHoverGeometry, type ShapeVertexTarget, type SimpleShape, type Size, type TextData, type TextDeletedEvent, type TextInteractionPolicy, type TextLayout, type TextLayoutBoundsMode, type TextLayoutOverflowMode, type TextLayoutWrapMode, type TextSelectedEvent, type TextUpdatedEvent, type VertexHoverControl, type ViewportFitOptions, createDiagramEditor, createDiagramEngine };
|
|
918
|
+
export { type AnchorReference, type BorderSide$1 as BorderSide, type ClientRectLike, type DeletionRootRef, type DeletionTrigger, type DiagramContainer, type DiagramEditorConfig, type DiagramEditorHandle, type DiagramEngineHandle, type DiagramImageExportOptions, type DiagramPatch, type DiagramState, type EdgeHoverControl, type ElementChildInteractionPolicy, type ElementData, type ElementDeletedEvent, type ElementDeletingEvent, type ElementDoubleClickEvent, type ElementDropEvent, type ElementLayout, type ElementLayoutAlign, type ElementLayoutAutoResizeMode, type ElementLayoutChildFitCrossAxis, type ElementLayoutChildFitMainAxis, type ElementLayoutGridRowTemplate, type ElementLayoutLabelReservedSpace, type ElementLayoutLabelReservedSpaceMode, type ElementLayoutLabelReservedSpacePlacement, type ElementLayoutMode, type ElementLinkConnectingEvent, type ElementLinkEndedEvent, type ElementLinkStartedEvent, type ElementMovedEvent, type ElementPointerEvent, type ElementPortMovementPolicy, type ElementResizedEvent, type ElementSelectedEvent, type ElementShapeControlDragEvent, type ElementShapeControlEventType, type ElementShapeHoverControlActivationEvent, type ElementShapeHoverControlInteractionEvent, type ElementShapeHoverControls, EllipseMidPoint, type EngineChangeEvent, type EngineConfigEvent, type EngineEventMap, type EnginePointerInfo, type EngineSelectionEvent, type FocusElementOptions, type GridLayoutChangedEvent, type GridLayoutChangedReason, type GridRowSnapshot, type HostAnchorPreset, type HoverControlIcon, type LinkColorPoolPolicy, type LinkData, type LinkDeletedEvent, type LinkDeletingEvent, type LinkRouteRefreshMode, type LinkRouteRefreshPolicy, type LinkRoutingMode, type LinkTargetPortCreationContext, type LinkTargetPortCreationHandler, type LinkTargetPortCreationPhase, type LinkTargetPortCreationResult, type LinkTargetPortDraft, type MoveConstraint, type OverlayShapeConfig, type OverlayShapeHandle, type PaperClickEvent, type Point, type PortAnchor, type PortAnchorConstraint, type PortBorderTransformContext, type PortBorderTransformResult, type PortData, type PortDeletedEvent, type PortDeletingEvent, type PortLinkAttachMode, type PortMouseEvent, type PortMovedEvent, type PortPositionLimits, type PortSelectedEvent, type PositionAxisLimit, type Rect, type RerouteLinksOptions, type ResolvePortAnchorsOptions, type ShapeControlDefinition, type ShapeControlTargetKind, type ShapeControlVisibilityTrigger, type ShapeDrawContext, type ShapeEdgeTarget, type ShapeEllipseMidPointTarget, type ShapeHoverGeometry, type ShapeVertexTarget, type SimpleShape, type Size, type TextData, type TextDeletedEvent, type TextDeletingEvent, type TextInteractionPolicy, type TextLayout, type TextLayoutBoundsMode, type TextLayoutOverflowMode, type TextLayoutWrapMode, type TextSelectedEvent, type TextUpdatedEvent, type VertexHoverControl, type ViewportFitOptions, createDiagramEditor, createDiagramEngine };
|