@bpmnkit/canvas 0.0.28 → 0.0.29
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/dist/canvas.d.ts +126 -1
- package/dist/canvas.js +528 -30
- package/dist/css.d.ts +1 -1
- package/dist/css.js +83 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +3 -1
- package/dist/measure.d.ts +8 -0
- package/dist/measure.js +114 -0
- package/dist/overlays.d.ts +86 -0
- package/dist/overlays.js +140 -0
- package/dist/renderer.d.ts +71 -8
- package/dist/renderer.js +525 -249
- package/dist/scene.d.ts +51 -0
- package/dist/scene.js +140 -0
- package/dist/types.d.ts +94 -3
- package/package.json +2 -2
package/dist/canvas.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BpmnDefinitions } from "@bpmnkit/core";
|
|
2
|
-
import
|
|
2
|
+
import { OverlayManager } from "./overlays.js";
|
|
3
|
+
import type { CanvasEvents, CanvasOptions, ImportWarnings, PlaneInfo, RenderedEdge, RenderedShape, ScreenBox, Theme, Viewbox } from "./types.js";
|
|
3
4
|
/**
|
|
4
5
|
* BpmnCanvas — a high-performance, accessible BPMN 2.0 diagram viewer.
|
|
5
6
|
*
|
|
@@ -58,14 +59,35 @@ export declare class BpmnCanvas {
|
|
|
58
59
|
private readonly _labelsG;
|
|
59
60
|
private _gridPattern;
|
|
60
61
|
private _markerId;
|
|
62
|
+
private _breadcrumb;
|
|
61
63
|
private readonly _viewport;
|
|
62
64
|
private readonly _keyboard;
|
|
65
|
+
private readonly _overlays;
|
|
66
|
+
private readonly _scene;
|
|
63
67
|
private readonly _plugins;
|
|
64
68
|
private _shapes;
|
|
65
69
|
private _edges;
|
|
66
70
|
private _currentDefs;
|
|
67
71
|
private _theme;
|
|
68
72
|
private _fit;
|
|
73
|
+
private _layoutMissingDi;
|
|
74
|
+
/** Elements from the last load that had no diagram interchange. */
|
|
75
|
+
private _importWarnings;
|
|
76
|
+
/** The DI plane currently rendered. */
|
|
77
|
+
private _currentPlane;
|
|
78
|
+
/** Element ids (this document) that own a plane and can be drilled into. */
|
|
79
|
+
private _planeElementIds;
|
|
80
|
+
/** Breadcrumb path from the root plane to the current one. */
|
|
81
|
+
private _planeStack;
|
|
82
|
+
/** CSS classes applied via {@link addMarker}, keyed by element id. */
|
|
83
|
+
private _markers;
|
|
84
|
+
/** Element id currently under the pointer (for hover enter/leave events). */
|
|
85
|
+
private _hoverId;
|
|
86
|
+
/**
|
|
87
|
+
* Set once the user pans/zooms so a container resize preserves their
|
|
88
|
+
* viewport instead of force-fitting the diagram.
|
|
89
|
+
*/
|
|
90
|
+
private _userMovedViewport;
|
|
69
91
|
private _listeners;
|
|
70
92
|
constructor(options: CanvasOptions);
|
|
71
93
|
private _ro;
|
|
@@ -80,6 +102,25 @@ export declare class BpmnCanvas {
|
|
|
80
102
|
* Use this when you already have the parsed model from `@bpmnkit/core`.
|
|
81
103
|
*/
|
|
82
104
|
loadDefinitions(defs: BpmnDefinitions): void;
|
|
105
|
+
/**
|
|
106
|
+
* Returns the elements from the last {@link load}/{@link loadDefinitions}
|
|
107
|
+
* that had no diagram interchange (and so were auto-laid-out or skipped).
|
|
108
|
+
*/
|
|
109
|
+
getImportWarnings(): ImportWarnings;
|
|
110
|
+
/**
|
|
111
|
+
* Lists every DI plane in the current document (the primary plane plus any
|
|
112
|
+
* collapsed sub-processes that carry their own layout).
|
|
113
|
+
*/
|
|
114
|
+
getPlanes(): PlaneInfo[];
|
|
115
|
+
/**
|
|
116
|
+
* Shows the plane identified by a DI plane `bpmnElement` (a process/
|
|
117
|
+
* collaboration id or a collapsed sub-process id). Drilling into a
|
|
118
|
+
* sub-process extends the breadcrumb; navigating to an ancestor trims it.
|
|
119
|
+
* No-op if the id has no plane. Fires `plane:change`.
|
|
120
|
+
*/
|
|
121
|
+
showPlane(planeElementId: string): void;
|
|
122
|
+
/** Renders a specific plane into the (cleared) layers and refits. */
|
|
123
|
+
private _renderPlane;
|
|
83
124
|
/** Clears the canvas and fires `diagram:clear`. */
|
|
84
125
|
clear(): void;
|
|
85
126
|
/**
|
|
@@ -89,12 +130,75 @@ export declare class BpmnCanvas {
|
|
|
89
130
|
fitView(padding?: number): void;
|
|
90
131
|
/** Sets the color theme. Pass `"auto"` to follow the OS preference. */
|
|
91
132
|
setTheme(theme: Theme): void;
|
|
133
|
+
/**
|
|
134
|
+
* HTML overlays anchored to diagram elements (badges, tooltips, panels).
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* canvas.overlays.add("Task_1", {
|
|
138
|
+
* position: { top: -8, right: -8 },
|
|
139
|
+
* html: `<span class="badge">!</span>`,
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
get overlays(): OverlayManager;
|
|
144
|
+
/** Returns the rendered shape or edge for a BPMN id, or `undefined` (O(1)). */
|
|
145
|
+
getElement(id: string): RenderedShape | RenderedEdge | undefined;
|
|
146
|
+
/** Returns the `<g>` graphics element for a BPMN id, or `undefined` (O(1)). */
|
|
147
|
+
getGraphics(id: string): SVGGElement | undefined;
|
|
148
|
+
/** Iterates every rendered element (shapes and edges). */
|
|
149
|
+
forEachElement(fn: (el: RenderedShape | RenderedEdge) => void): void;
|
|
150
|
+
/**
|
|
151
|
+
* Re-renders a single element's `<g>` in place from the current model,
|
|
152
|
+
* preserving markers/selection classes — the incremental-update path used
|
|
153
|
+
* for cheap edits. No-op for an unknown id.
|
|
154
|
+
*/
|
|
155
|
+
updateElement(id: string): void;
|
|
92
156
|
/** Zooms in by 25% centred on the canvas. */
|
|
93
157
|
zoomIn(): void;
|
|
94
158
|
/** Zooms out by 25% centred on the canvas. */
|
|
95
159
|
zoomOut(): void;
|
|
96
160
|
/** Resets to 100% zoom, centred on the canvas. */
|
|
97
161
|
resetZoom(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Adjusts the zoom. Pass `"fit"` (or no argument) to fit the whole diagram;
|
|
164
|
+
* pass a number for an absolute scale, optionally keeping `center`
|
|
165
|
+
* (screen-space pixels relative to the host) fixed.
|
|
166
|
+
*/
|
|
167
|
+
zoom(scaleOrFit?: number | "fit", center?: {
|
|
168
|
+
x: number;
|
|
169
|
+
y: number;
|
|
170
|
+
}): void;
|
|
171
|
+
/** Returns the visible region in diagram coordinates plus the zoom scale. */
|
|
172
|
+
viewbox(): Viewbox;
|
|
173
|
+
/** Pans (without changing zoom) so the element with the given id is centred. */
|
|
174
|
+
scrollToElement(id: string): void;
|
|
175
|
+
/**
|
|
176
|
+
* Returns the element's bounding box in screen pixels relative to the host,
|
|
177
|
+
* or `null` if the element is not found.
|
|
178
|
+
*/
|
|
179
|
+
getAbsoluteBBox(id: string): ScreenBox | null;
|
|
180
|
+
/**
|
|
181
|
+
* Serializes the current diagram to a standalone SVG string with theme
|
|
182
|
+
* colours inlined, so it renders correctly outside the page.
|
|
183
|
+
* @param opts.bounds `"diagram"` (default) exports the whole diagram;
|
|
184
|
+
* `"viewport"` exports only the currently visible region.
|
|
185
|
+
*/
|
|
186
|
+
exportSvg(opts?: {
|
|
187
|
+
bounds?: "diagram" | "viewport";
|
|
188
|
+
}): string;
|
|
189
|
+
/**
|
|
190
|
+
* Rasterizes the current diagram to a PNG data URL at `scale`× the diagram
|
|
191
|
+
* size. Browser-only (requires `Image`/`<canvas>`).
|
|
192
|
+
*/
|
|
193
|
+
exportPng(scale?: number): Promise<string>;
|
|
194
|
+
/** Adds a CSS class to the element with the given BPMN id. No-op if not found. */
|
|
195
|
+
addMarker(id: string, cls: string): void;
|
|
196
|
+
/** Removes a CSS class from the element with the given BPMN id. */
|
|
197
|
+
removeMarker(id: string, cls: string): void;
|
|
198
|
+
/** Returns whether the element with the given id currently has the CSS class. */
|
|
199
|
+
hasMarker(id: string, cls: string): boolean;
|
|
200
|
+
/** Toggles a CSS class on the element with the given id. */
|
|
201
|
+
toggleMarker(id: string, cls: string): void;
|
|
98
202
|
/**
|
|
99
203
|
* Subscribes to a canvas event. Returns an unsubscribe function.
|
|
100
204
|
*
|
|
@@ -119,6 +223,27 @@ export declare class BpmnCanvas {
|
|
|
119
223
|
clearHighlights(): void;
|
|
120
224
|
/** Destroys the canvas, removing all DOM nodes and event listeners. */
|
|
121
225
|
destroy(): void;
|
|
226
|
+
/** Finds the SVG group for a shape or edge by BPMN id. */
|
|
227
|
+
private _findElement;
|
|
228
|
+
/** Design tokens to resolve from the live host for a self-contained export. */
|
|
229
|
+
private static readonly _EXPORT_TOKENS;
|
|
230
|
+
/** Stylesheet for the exported SVG: resolved theme tokens + the canvas CSS. */
|
|
231
|
+
private _exportStyles;
|
|
232
|
+
/** A human-readable label for a plane's `bpmnElement` (name, or a fallback). */
|
|
233
|
+
private _planeName;
|
|
234
|
+
/** Recursively finds a flow element by id across all processes/sub-processes. */
|
|
235
|
+
private _findFlowElementById;
|
|
236
|
+
/** Rebuilds the breadcrumb bar from the current plane stack. */
|
|
237
|
+
private _updateBreadcrumb;
|
|
238
|
+
/**
|
|
239
|
+
* Resolves the BPMN element id under a pointer/mouse event, or `null`.
|
|
240
|
+
* Prefers `elementFromPoint` (correct when native SVG hit-testing returns
|
|
241
|
+
* the root `<svg>` in flex/scroll containers) and falls back to the event
|
|
242
|
+
* target (for environments where `elementFromPoint` is unavailable).
|
|
243
|
+
*/
|
|
244
|
+
private _elementIdForEvent;
|
|
245
|
+
/** Diagram-coordinate bounds of a shape (from DI) or edge (waypoint bbox). */
|
|
246
|
+
private _diagramBounds;
|
|
122
247
|
private _applyTheme;
|
|
123
248
|
private _installPlugin;
|
|
124
249
|
private _emit;
|