@bpmn-nova/studio 0.3.9-preview → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/canvas.js +97 -25
- package/dist/config.js +13 -0
- package/dist/context-menu.js +41 -32
- package/dist/controller.js +45 -19
- package/dist/flow-tree.d.ts +4 -0
- package/dist/flow-tree.js +14 -0
- package/dist/index.d.ts +47 -2
- package/dist/index.js +1 -0
- package/dist/interactions.js +6 -1
- package/dist/modules/bpmn-model/index.d.ts +2 -1
- package/dist/modules/bpmn-model/index.js +12 -10
- package/dist/modules/core/gateway.js +16 -13
- package/dist/modules/core/index.d.ts +6 -4
- package/dist/modules/core/model.js +12 -7
- package/dist/modules/designer/index.d.ts +5 -1
- package/dist/modules/designer/index.js +36 -15
- package/dist/modules/export-svg/index.d.ts +12 -5
- package/dist/modules/export-svg/preview.js +34 -24
- package/dist/modules/export-svg/render.js +102 -50
- package/dist/modules/flow-tree/controller.js +364 -0
- package/dist/modules/flow-tree/index.d.ts +248 -0
- package/dist/modules/flow-tree/index.js +5 -0
- package/dist/modules/flow-tree/operations.js +484 -0
- package/dist/modules/flow-tree/sample.js +445 -0
- package/dist/modules/flow-tree/schema.js +588 -0
- package/dist/modules/flow-tree/validate.js +125 -0
- package/dist/modules/flow-tree-bpmn/compiler.js +547 -0
- package/dist/modules/flow-tree-bpmn/decompiler.js +524 -0
- package/dist/modules/flow-tree-bpmn/expression.js +135 -0
- package/dist/modules/flow-tree-bpmn/index.d.ts +53 -0
- package/dist/modules/flow-tree-bpmn/index.js +14 -0
- package/dist/modules/flow-tree-renderer/canvas.js +1003 -0
- package/dist/modules/flow-tree-renderer/export-svg.js +325 -0
- package/dist/modules/flow-tree-renderer/index.d.ts +143 -0
- package/dist/modules/flow-tree-renderer/index.js +3 -0
- package/dist/modules/flow-tree-renderer/shell.js +970 -0
- package/dist/modules/i18n/index.d.ts +647 -0
- package/dist/modules/i18n/index.js +247 -0
- package/dist/modules/i18n/locales/en-US.js +1222 -0
- package/dist/modules/i18n/locales/zh-CN.js +1204 -0
- package/dist/modules/icons/index.js +23 -0
- package/dist/modules/node-presentation/index.d.ts +3 -2
- package/dist/modules/node-presentation/index.js +14 -11
- package/dist/modules/palette/index.d.ts +6 -1
- package/dist/modules/palette/index.js +26 -8
- package/dist/modules/palette/panel.js +44 -6
- package/dist/modules/properties/index.d.ts +2 -1
- package/dist/modules/properties/index.js +2 -2
- package/dist/modules/properties-activiti/index.js +84 -59
- package/dist/modules/properties-bpmn/index.js +151 -128
- package/dist/modules/properties-core/index.d.ts +9 -3
- package/dist/modules/properties-core/index.js +16 -4
- package/dist/modules/properties-flow-tree/index.d.ts +56 -0
- package/dist/modules/properties-flow-tree/index.js +2 -0
- package/dist/modules/properties-flow-tree/panel.js +1136 -0
- package/dist/modules/properties-flow-tree/widgets.js +625 -0
- package/dist/modules/properties-flowable/index.js +55 -34
- package/dist/modules/properties-renderer/index.d.ts +5 -1
- package/dist/modules/properties-renderer/index.js +110 -42
- package/dist/modules/renderer-svg/index.d.ts +6 -2
- package/dist/modules/renderer-svg/index.js +113 -38
- package/dist/modules/runtime/index.d.ts +33 -5
- package/dist/modules/runtime/index.js +97 -73
- package/dist/modules/runtime/time.js +89 -4
- package/dist/modules/runtime/visits.js +6 -4
- package/dist/modules/theme/index.d.ts +5 -2
- package/dist/modules/theme/index.js +8 -4
- package/dist/modules/viewer/index.d.ts +28 -7
- package/dist/modules/viewer/index.js +223 -58
- package/dist/modules/viewer/runtime-content.js +26 -20
- package/dist/modules/viewer/runtime-trace.js +43 -25
- package/dist/modules/viewer/timeline.js +103 -36
- package/dist/shell.js +258 -75
- package/dist/sidebars.js +3 -1
- package/dist/styles.css +2371 -2
- package/llms-full.txt +586 -47
- package/llms.txt +6 -5
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@ BPMN Nova 的 Vanilla JavaScript / TypeScript 完整入口,提供流程设计
|
|
|
4
4
|
|
|
5
5
|
> **English summary:** The complete framework-neutral BPMN Nova package for process design, viewing, approval traces, themes, properties, and pure SVG export.
|
|
6
6
|
|
|
7
|
-
> 当前版本为 `0.
|
|
7
|
+
> 当前版本为 `0.4.1`。在生产接入前请验证目标 BPMN XML 与引擎扩展。
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
## 安装
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install @bpmn-nova/studio
|
|
14
|
+
npm install @bpmn-nova/studio
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
Vanilla JavaScript / TypeScript 项目选择本包;React 18+ 和 Vue 3.3+ 项目分别选择 `@bpmn-nova/react` 或 `@bpmn-nova/vue`。
|
package/dist/canvas.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from './modules/core/index.js';
|
|
14
14
|
import { DiagramRenderer, ZOOM_LIMITS } from './modules/renderer-svg/index.js';
|
|
15
15
|
import { hydrateIcons } from './modules/icons/index.js';
|
|
16
|
+
import { createI18n, resolveI18n } from './modules/i18n/index.js';
|
|
16
17
|
import { canCreateSequenceFlow } from './controller.js';
|
|
17
18
|
import { createDefaultContextMenuRegistry } from './context-menu.js';
|
|
18
19
|
import { CREATE_INTENT_MIME } from './interactions.js';
|
|
@@ -62,11 +63,25 @@ function viewportStateCenteredOn(bounds, viewportRect, zoom) {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export class BpmnCanvas {
|
|
65
|
-
constructor({ container, studio, rendererOptions = {}, nodeSubtitleResolver = rendererOptions.nodeSubtitleResolver, interactions = null, selectionToolbar = null, contextMenu = null, contextMenuRegistry = createDefaultContextMenuRegistry(), pointerMode = 'select', themeController = null, theme = null, onThemeChange = null } = {}) {
|
|
66
|
+
constructor({ container, studio, rendererOptions = {}, nodeSubtitleResolver = rendererOptions.nodeSubtitleResolver, interactions = null, selectionToolbar = null, contextMenu = null, contextMenuRegistry = createDefaultContextMenuRegistry(), pointerMode = 'select', themeController = null, theme = null, onThemeChange = null, i18n = null, locale, messages } = {}) {
|
|
66
67
|
if (!container) throw new Error('BpmnCanvas requires a container.');
|
|
67
68
|
if (!studio) throw new Error('BpmnCanvas requires a studio controller.');
|
|
68
69
|
this.container = container;
|
|
69
70
|
this.studio = studio;
|
|
71
|
+
const hasExplicitLocale = locale !== undefined || messages !== undefined;
|
|
72
|
+
if (i18n) {
|
|
73
|
+
this._ownsI18n = false;
|
|
74
|
+
this.i18n = resolveI18n(i18n);
|
|
75
|
+
} else if (hasExplicitLocale) {
|
|
76
|
+
this._ownsI18n = true;
|
|
77
|
+
this.i18n = createI18n({ locale, messages });
|
|
78
|
+
} else if (studio.i18n) {
|
|
79
|
+
this._ownsI18n = false;
|
|
80
|
+
this.i18n = resolveI18n(studio.i18n);
|
|
81
|
+
} else {
|
|
82
|
+
this._ownsI18n = true;
|
|
83
|
+
this.i18n = createI18n();
|
|
84
|
+
}
|
|
70
85
|
this.interactions = interactions;
|
|
71
86
|
this.selectionToolbarSlot = selectionToolbar;
|
|
72
87
|
this.contextMenuSlot = contextMenu;
|
|
@@ -78,6 +93,7 @@ export class BpmnCanvas {
|
|
|
78
93
|
const onViewportChange = rendererOptions.onViewportChange;
|
|
79
94
|
this.renderer = new DiagramRenderer(container, {
|
|
80
95
|
...rendererOptions,
|
|
96
|
+
i18n: this.i18n,
|
|
81
97
|
nodeSubtitleResolver,
|
|
82
98
|
themeController,
|
|
83
99
|
theme,
|
|
@@ -125,6 +141,7 @@ export class BpmnCanvas {
|
|
|
125
141
|
this._buildContextMenu();
|
|
126
142
|
this.renderer.setSelection(studio.selection);
|
|
127
143
|
this._offStudio = studio.subscribe((event) => this._onStudioEvent(event));
|
|
144
|
+
this._offI18n = this.i18n.subscribe(() => this._syncLocaleChrome());
|
|
128
145
|
this._onKeyDown = (event) => this._handleKeyDown(event);
|
|
129
146
|
this._onKeyUp = (event) => {
|
|
130
147
|
if (event.code === 'Space') this.renderer.setSpacePressed(false);
|
|
@@ -146,27 +163,33 @@ export class BpmnCanvas {
|
|
|
146
163
|
this._renderSelectionToolbar();
|
|
147
164
|
}
|
|
148
165
|
|
|
166
|
+
_pointerModeItems() {
|
|
167
|
+
return [
|
|
168
|
+
{ mode: 'select', iconId: 'ui.pointer', label: this.i18n.t('canvas.pointerModes.select'), title: this.i18n.t('canvas.pointerModes.selectTitle') },
|
|
169
|
+
{ mode: 'marquee', iconId: 'ui.marquee', label: this.i18n.t('canvas.pointerModes.marquee'), title: this.i18n.t('canvas.pointerModes.marqueeTitle') },
|
|
170
|
+
{ mode: 'pan', iconId: 'ui.hand', label: this.i18n.t('canvas.pointerModes.pan'), title: this.i18n.t('canvas.pointerModes.panTitle') },
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
|
|
149
174
|
_buildPointerToolbar() {
|
|
150
175
|
const toolbar = domNode('div', 'nova-pointer-toolbar');
|
|
151
176
|
toolbar.setAttribute('role', 'toolbar');
|
|
152
|
-
toolbar.setAttribute('aria-label', '
|
|
177
|
+
toolbar.setAttribute('aria-label', this.i18n.t('canvas.pointerToolbarAria'));
|
|
153
178
|
toolbar.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
154
179
|
this._pointerModeButtons = new Map();
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
{ mode: 'marquee', iconId: 'ui.marquee', label: '框选', title: '拖动空白区域框选节点' },
|
|
158
|
-
{ mode: 'pan', iconId: 'ui.hand', label: '拖动', title: '拖动画布' },
|
|
159
|
-
];
|
|
160
|
-
for (const item of items) {
|
|
180
|
+
this._pointerModeLabels = new Map();
|
|
181
|
+
for (const item of this._pointerModeItems()) {
|
|
161
182
|
const button = domNode('button', 'nova-pointer-mode');
|
|
162
183
|
button.type = 'button';
|
|
163
184
|
button.dataset.pointerMode = item.mode;
|
|
164
185
|
button.title = item.title;
|
|
165
186
|
button.setAttribute('aria-label', item.title);
|
|
166
|
-
|
|
187
|
+
const labelEl = domNode('span', '', item.label);
|
|
188
|
+
button.append(toolbarIcon(item.iconId), labelEl);
|
|
167
189
|
button.addEventListener('click', () => this.setPointerMode(item.mode));
|
|
168
190
|
toolbar.appendChild(button);
|
|
169
191
|
this._pointerModeButtons.set(item.mode, button);
|
|
192
|
+
this._pointerModeLabels.set(item.mode, labelEl);
|
|
170
193
|
}
|
|
171
194
|
this._pointerToolbar = toolbar;
|
|
172
195
|
this.container.appendChild(toolbar);
|
|
@@ -174,6 +197,32 @@ export class BpmnCanvas {
|
|
|
174
197
|
this.setPointerMode(this.pointerMode);
|
|
175
198
|
}
|
|
176
199
|
|
|
200
|
+
_syncLocaleChrome() {
|
|
201
|
+
if (this._pointerToolbar) {
|
|
202
|
+
this._pointerToolbar.setAttribute('aria-label', this.i18n.t('canvas.pointerToolbarAria'));
|
|
203
|
+
for (const item of this._pointerModeItems()) {
|
|
204
|
+
const button = this._pointerModeButtons?.get(item.mode);
|
|
205
|
+
const labelEl = this._pointerModeLabels?.get(item.mode);
|
|
206
|
+
if (button) {
|
|
207
|
+
button.title = item.title;
|
|
208
|
+
button.setAttribute('aria-label', item.title);
|
|
209
|
+
}
|
|
210
|
+
if (labelEl) labelEl.textContent = item.label;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (this._contextMenu) {
|
|
214
|
+
this._contextMenu.setAttribute('aria-label', this.i18n.t('contextMenu.ariaLabel'));
|
|
215
|
+
if (!this._contextMenu.hidden && this._contextMenuState) {
|
|
216
|
+
const { target, position, keyboard } = this._contextMenuState;
|
|
217
|
+
this._openContextMenu(target, position, keyboard);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (this._selectionToolbar) {
|
|
221
|
+
this._selectionToolbar.setAttribute('aria-label', this.i18n.t('canvas.selectionToolbarAria'));
|
|
222
|
+
this._renderSelectionToolbar();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
177
226
|
setPointerMode(mode) {
|
|
178
227
|
if (!['select', 'marquee', 'pan'].includes(mode)) return false;
|
|
179
228
|
this.pointerMode = mode;
|
|
@@ -193,7 +242,7 @@ export class BpmnCanvas {
|
|
|
193
242
|
this._contextMenu = domNode('div', 'nova-context-menu');
|
|
194
243
|
this._contextMenu.hidden = true;
|
|
195
244
|
this._contextMenu.setAttribute('role', 'menu');
|
|
196
|
-
this._contextMenu.setAttribute('aria-label', '
|
|
245
|
+
this._contextMenu.setAttribute('aria-label', this.i18n.t('contextMenu.ariaLabel'));
|
|
197
246
|
this._contextMenu.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
198
247
|
this._contextMenu.addEventListener('contextmenu', (event) => event.preventDefault());
|
|
199
248
|
this._contextMenu.addEventListener('keydown', (event) => this._handleContextMenuKeyDown(event));
|
|
@@ -262,7 +311,7 @@ export class BpmnCanvas {
|
|
|
262
311
|
this.closeContextMenu();
|
|
263
312
|
this._selectionToolbar?.querySelectorAll('details[open]').forEach((details) => { details.open = false; });
|
|
264
313
|
this.renderer.closeTransientOverlays?.();
|
|
265
|
-
const context = { studio: this.studio, canvas: this, target, selection: this.studio.selection, position };
|
|
314
|
+
const context = { studio: this.studio, canvas: this, i18n: this.i18n, target, selection: this.studio.selection, position };
|
|
266
315
|
const actions = this.contextMenuRegistry?.resolve?.(context) || [];
|
|
267
316
|
if (!actions.length) return false;
|
|
268
317
|
this._contextMenuState = { ...context, actions, keyboard };
|
|
@@ -288,9 +337,9 @@ export class BpmnCanvas {
|
|
|
288
337
|
|
|
289
338
|
_renderDefaultContextMenu(actions) {
|
|
290
339
|
const submenuGroups = {
|
|
291
|
-
align: { label: '
|
|
292
|
-
distribute: { label: '
|
|
293
|
-
pointer: { label: '
|
|
340
|
+
align: { label: this.i18n.t('contextMenu.groups.align'), iconId: 'ui.alignCenterHorizontal' },
|
|
341
|
+
distribute: { label: this.i18n.t('contextMenu.groups.distribute'), iconId: 'ui.distributeHorizontal' },
|
|
342
|
+
pointer: { label: this.i18n.t('contextMenu.groups.pointer'), iconId: 'ui.pointer' },
|
|
294
343
|
};
|
|
295
344
|
let previousGroup = null;
|
|
296
345
|
for (let index = 0; index < actions.length;) {
|
|
@@ -455,7 +504,7 @@ export class BpmnCanvas {
|
|
|
455
504
|
this._selectionToolbar = domNode('div', 'nova-selection-toolbar');
|
|
456
505
|
this._selectionToolbar.hidden = true;
|
|
457
506
|
this._selectionToolbar.setAttribute('role', 'toolbar');
|
|
458
|
-
this._selectionToolbar.setAttribute('aria-label', '
|
|
507
|
+
this._selectionToolbar.setAttribute('aria-label', this.i18n.t('canvas.selectionToolbarAria'));
|
|
459
508
|
this._selectionToolbar.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
460
509
|
this.container.appendChild(this._selectionToolbar);
|
|
461
510
|
}
|
|
@@ -495,6 +544,7 @@ export class BpmnCanvas {
|
|
|
495
544
|
container: this._selectionToolbar,
|
|
496
545
|
studio: this.studio,
|
|
497
546
|
canvas: this,
|
|
547
|
+
i18n: this.i18n,
|
|
498
548
|
selection: this.studio.selection,
|
|
499
549
|
elements: diagramNodes,
|
|
500
550
|
bounds,
|
|
@@ -542,23 +592,29 @@ export class BpmnCanvas {
|
|
|
542
592
|
};
|
|
543
593
|
const separator = () => domNode('span', 'nova-selection-separator');
|
|
544
594
|
const alignmentItems = [
|
|
545
|
-
['left', 'ui.alignLeft',
|
|
546
|
-
['
|
|
595
|
+
['left', 'ui.alignLeft', this.i18n.t('contextMenu.actions.alignLeft')],
|
|
596
|
+
['centerX', 'ui.alignCenterHorizontal', this.i18n.t('contextMenu.actions.alignCenterX')],
|
|
597
|
+
['right', 'ui.alignRight', this.i18n.t('contextMenu.actions.alignRight')],
|
|
598
|
+
['top', 'ui.alignTop', this.i18n.t('contextMenu.actions.alignTop')],
|
|
599
|
+
['centerY', 'ui.alignCenterVertical', this.i18n.t('contextMenu.actions.alignCenterY')],
|
|
600
|
+
['bottom', 'ui.alignBottom', this.i18n.t('contextMenu.actions.alignBottom')],
|
|
547
601
|
].map(([value, iconId, title]) => ({ id: `align-${value}`, iconId, title, action: () => actions.align(value) }));
|
|
548
602
|
const distributeItems = [
|
|
549
|
-
{ id: 'distribute-horizontal', iconId: 'ui.distributeHorizontal', title: '
|
|
550
|
-
{ id: 'distribute-vertical', iconId: 'ui.distributeVertical', title: '
|
|
603
|
+
{ id: 'distribute-horizontal', iconId: 'ui.distributeHorizontal', title: this.i18n.t('contextMenu.actions.distributeHorizontal'), action: () => actions.distribute('horizontal'), disabled: nodes.length < 3 },
|
|
604
|
+
{ id: 'distribute-vertical', iconId: 'ui.distributeVertical', title: this.i18n.t('contextMenu.actions.distributeVertical'), action: () => actions.distribute('vertical'), disabled: nodes.length < 3 },
|
|
551
605
|
];
|
|
606
|
+
const groupLabel = this.i18n.t('canvas.selectionActions.group');
|
|
607
|
+
const layoutLabel = this.i18n.t('canvas.selectionActions.layout');
|
|
552
608
|
this._selectionToolbar.append(
|
|
553
|
-
button('group', 'ui.layoutSelection',
|
|
609
|
+
button('group', 'ui.layoutSelection', groupLabel, actions.group, { label: groupLabel, disabled: this.studio.allowsNodeType?.('group') === false || !groupableNodes.length || groupableNodes.length !== diagramNodes.length }),
|
|
554
610
|
separator(),
|
|
555
|
-
menu('align', 'ui.alignCenterHorizontal', '
|
|
556
|
-
menu('distribute', 'ui.distributeHorizontal', '
|
|
611
|
+
menu('align', 'ui.alignCenterHorizontal', this.i18n.t('canvas.selectionActions.align'), alignmentItems, nodes.length < 2),
|
|
612
|
+
menu('distribute', 'ui.distributeHorizontal', this.i18n.t('canvas.selectionActions.distribute'), distributeItems, nodes.length < 3),
|
|
557
613
|
separator(),
|
|
558
|
-
button('layout', 'ui.layoutSelection',
|
|
559
|
-
button('reroute', 'ui.rerouteSelection', '
|
|
614
|
+
button('layout', 'ui.layoutSelection', layoutLabel, actions.layout, { label: layoutLabel, disabled: nodes.length < 2 }),
|
|
615
|
+
button('reroute', 'ui.rerouteSelection', this.i18n.t('canvas.selectionActions.reroute'), actions.reroute, { disabled: nodes.length < 1 }),
|
|
560
616
|
separator(),
|
|
561
|
-
button('fit', 'ui.fitSelection', '
|
|
617
|
+
button('fit', 'ui.fitSelection', this.i18n.t('canvas.selectionActions.fit'), actions.fit),
|
|
562
618
|
);
|
|
563
619
|
hydrateIcons(this._selectionToolbar, this.renderer.iconRegistry);
|
|
564
620
|
this._positionSelectionToolbar();
|
|
@@ -995,8 +1051,24 @@ export class BpmnCanvas {
|
|
|
995
1051
|
setTheme(theme) { return this.renderer.setTheme(theme); }
|
|
996
1052
|
setThemeMode(mode) { return this.renderer.setThemeMode(mode); }
|
|
997
1053
|
getThemeState() { return this.renderer.getThemeState(); }
|
|
1054
|
+
setLocale(locale, messages) {
|
|
1055
|
+
if (!this._ownsI18n) {
|
|
1056
|
+
this._offI18n?.();
|
|
1057
|
+
this.i18n = createI18n({ locale, messages });
|
|
1058
|
+
this._ownsI18n = true;
|
|
1059
|
+
this._offI18n = this.i18n.subscribe(() => this._syncLocaleChrome());
|
|
1060
|
+
this.renderer.setLocale(locale, messages);
|
|
1061
|
+
this._syncLocaleChrome();
|
|
1062
|
+
} else {
|
|
1063
|
+
this.i18n.setLocale(locale, messages);
|
|
1064
|
+
}
|
|
1065
|
+
return this.getLocale();
|
|
1066
|
+
}
|
|
1067
|
+
getLocale() { return this.i18n.getState(); }
|
|
998
1068
|
destroy() {
|
|
999
1069
|
this._offStudio?.();
|
|
1070
|
+
this._offI18n?.();
|
|
1071
|
+
this._offI18n = null;
|
|
1000
1072
|
this.container.removeEventListener('keydown', this._onKeyDown);
|
|
1001
1073
|
this.container.removeEventListener('keyup', this._onKeyUp);
|
|
1002
1074
|
this.container.removeEventListener('dragover', this._onDragOver);
|
package/dist/config.js
CHANGED
|
@@ -239,6 +239,8 @@ function applyLegacyConfig(target, legacy) {
|
|
|
239
239
|
timeline: ['viewer', 'timeline'],
|
|
240
240
|
runtimeDetails: ['viewer', 'runtimeDetails'],
|
|
241
241
|
runtimeTraceOptions: ['viewer', 'runtimeTraceOptions'],
|
|
242
|
+
formatRuntimeTime: ['viewer', 'formatRuntimeTime'],
|
|
243
|
+
runtimeTimeFormat: ['viewer', 'runtimeTimeFormat'],
|
|
242
244
|
})) {
|
|
243
245
|
if (hasOwn(legacy, key) && legacy[key] !== undefined) assignPath(target, path[0], path[1], legacy[key]);
|
|
244
246
|
}
|
|
@@ -289,12 +291,23 @@ export function normalizeStudioConfig(config, { fallback = null, legacy = null }
|
|
|
289
291
|
const timeline = optionalObject(viewerInput.timeline, 'config.viewer.timeline');
|
|
290
292
|
const runtimeDetails = optionalObject(viewerInput.runtimeDetails, 'config.viewer.runtimeDetails');
|
|
291
293
|
const runtimeTraceOptions = optionalObject(viewerInput.runtimeTraceOptions, 'config.viewer.runtimeTraceOptions');
|
|
294
|
+
const formatRuntimeTime = viewerInput.formatRuntimeTime === undefined || viewerInput.formatRuntimeTime === null
|
|
295
|
+
? undefined
|
|
296
|
+
: viewerInput.formatRuntimeTime;
|
|
297
|
+
if (formatRuntimeTime !== undefined && typeof formatRuntimeTime !== 'function') {
|
|
298
|
+
throw new TypeError('config.viewer.formatRuntimeTime must be a function.');
|
|
299
|
+
}
|
|
300
|
+
const runtimeTimeFormat = viewerInput.runtimeTimeFormat === undefined || viewerInput.runtimeTimeFormat === null
|
|
301
|
+
? undefined
|
|
302
|
+
: optionalObject(viewerInput.runtimeTimeFormat, 'config.viewer.runtimeTimeFormat');
|
|
292
303
|
const viewer = {
|
|
293
304
|
responsive,
|
|
294
305
|
...(projectionOptions ? { projectionOptions } : {}),
|
|
295
306
|
...(timeline ? { timeline } : {}),
|
|
296
307
|
...(runtimeDetails ? { runtimeDetails } : {}),
|
|
297
308
|
...(runtimeTraceOptions ? { runtimeTraceOptions } : {}),
|
|
309
|
+
...(formatRuntimeTime ? { formatRuntimeTime } : {}),
|
|
310
|
+
...(runtimeTimeFormat ? { runtimeTimeFormat } : {}),
|
|
298
311
|
};
|
|
299
312
|
const exportOptions = merged.export === undefined || merged.export === null
|
|
300
313
|
? undefined
|
package/dist/context-menu.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
getNode,
|
|
5
5
|
isEmbeddedSubProcess,
|
|
6
6
|
} from './modules/core/index.js';
|
|
7
|
+
import { resolveI18n } from './modules/i18n/index.js';
|
|
7
8
|
import { selectedDiagramNodes, selectedGroupableNodes, selectedLayoutNodes } from './selection-layout.js';
|
|
8
9
|
|
|
9
10
|
function insert(actions, action) {
|
|
@@ -36,18 +37,24 @@ function action(config) {
|
|
|
36
37
|
|
|
37
38
|
const flowKinds = new Set(['event', 'boundary', 'task', 'container', 'gateway']);
|
|
38
39
|
|
|
39
|
-
function
|
|
40
|
+
function contextI18n(context) {
|
|
41
|
+
return resolveI18n(context?.i18n || context?.studio?.i18n || context);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function canvasActions(context) {
|
|
45
|
+
const i18n = contextI18n(context);
|
|
40
46
|
return [
|
|
41
|
-
action({ id: 'canvas.fit', label: '
|
|
42
|
-
action({ id: 'canvas.beautify', label: '
|
|
43
|
-
action({ id: 'canvas.reroute', label: '
|
|
44
|
-
action({ id: 'pointer.select', label: '
|
|
45
|
-
action({ id: 'pointer.marquee', label: '
|
|
46
|
-
action({ id: 'pointer.pan', label: '
|
|
47
|
+
action({ id: 'canvas.fit', label: i18n.t('contextMenu.actions.canvasFit'), iconId: 'ui.fitView', execute: ({ canvas }) => canvas.fitView(72) }),
|
|
48
|
+
action({ id: 'canvas.beautify', label: i18n.t('contextMenu.actions.canvasBeautify'), iconId: 'ui.magic', execute: ({ studio }) => studio.commands.beautify() }),
|
|
49
|
+
action({ id: 'canvas.reroute', label: i18n.t('contextMenu.actions.canvasReroute'), iconId: 'ui.rerouteSelection', execute: ({ studio }) => studio.commands.rerouteEdges() }),
|
|
50
|
+
action({ id: 'pointer.select', label: i18n.t('contextMenu.actions.pointerSelect'), iconId: 'ui.pointer', group: 'pointer', execute: ({ canvas }) => canvas.setPointerMode('select') }),
|
|
51
|
+
action({ id: 'pointer.marquee', label: i18n.t('contextMenu.actions.pointerMarquee'), iconId: 'ui.marquee', group: 'pointer', execute: ({ canvas }) => canvas.setPointerMode('marquee') }),
|
|
52
|
+
action({ id: 'pointer.pan', label: i18n.t('contextMenu.actions.pointerPan'), iconId: 'ui.hand', group: 'pointer', execute: ({ canvas }) => canvas.setPointerMode('pan') }),
|
|
47
53
|
];
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
function nodeActions(context) {
|
|
57
|
+
const i18n = contextI18n(context);
|
|
51
58
|
const node = getNode(context.studio.model, context.target.id);
|
|
52
59
|
if (!node) return [];
|
|
53
60
|
const definition = NODE_DEFINITIONS[node.type] || NODE_DEFINITIONS.generic;
|
|
@@ -55,62 +62,64 @@ function nodeActions(context) {
|
|
|
55
62
|
const actions = [];
|
|
56
63
|
if (canOutgoing) {
|
|
57
64
|
actions.push(
|
|
58
|
-
action({ id: 'node.quickAdd', label: '
|
|
59
|
-
action({ id: 'node.connect', label: '
|
|
65
|
+
action({ id: 'node.quickAdd', label: i18n.t('contextMenu.actions.nodeQuickAdd'), iconId: 'ui.add', execute: ({ canvas, target }) => canvas.openQuickAdd(target.id) }),
|
|
66
|
+
action({ id: 'node.connect', label: i18n.t('contextMenu.actions.nodeConnect'), iconId: 'ui.connect', execute: ({ canvas, target }) => canvas.startConnect(target.id) }),
|
|
60
67
|
);
|
|
61
68
|
}
|
|
62
69
|
if (isEmbeddedSubProcess(node)) {
|
|
63
|
-
actions.push(action({ id: 'node.enterScope', label: '
|
|
70
|
+
actions.push(action({ id: 'node.enterScope', label: i18n.t('contextMenu.actions.nodeEnterScope'), iconId: 'ui.enterScope', group: 'navigation', execute: ({ studio, target }) => studio.enterScope(target.id) }));
|
|
64
71
|
}
|
|
65
72
|
if (definition.kind === 'group') {
|
|
66
|
-
actions.push(action({ id: 'node.ungroup', label: '
|
|
73
|
+
actions.push(action({ id: 'node.ungroup', label: i18n.t('contextMenu.actions.nodeUngroup'), iconId: 'ui.layoutSelection', execute: ({ studio, target }) => studio.commands.ungroup(target.id) }));
|
|
67
74
|
return actions;
|
|
68
75
|
}
|
|
69
|
-
actions.push(action({ id: 'selection.delete', label: '
|
|
76
|
+
actions.push(action({ id: 'selection.delete', label: i18n.t('contextMenu.actions.nodeDelete'), iconId: 'ui.delete', group: 'danger', danger: true, execute: ({ studio, target }) => studio.commands.remove(target) }));
|
|
70
77
|
return actions;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
function edgeActions(context) {
|
|
81
|
+
const i18n = contextI18n(context);
|
|
74
82
|
const edge = getEdge(context.studio.model, context.target.id);
|
|
75
83
|
if (!edge) return [];
|
|
76
84
|
return [
|
|
77
|
-
action({ id: 'edge.rename', label: '
|
|
78
|
-
action({ id: 'edge.resetRoute', label: '
|
|
79
|
-
action({ id: 'edge.locateSource', label: '
|
|
80
|
-
action({ id: 'edge.locateTarget', label: '
|
|
81
|
-
action({ id: 'selection.delete', label: '
|
|
85
|
+
action({ id: 'edge.rename', label: i18n.t('contextMenu.actions.edgeRename'), iconId: 'ui.edit', execute: ({ canvas, target }) => canvas.editEdgeName(target.id) }),
|
|
86
|
+
action({ id: 'edge.resetRoute', label: i18n.t('contextMenu.actions.edgeResetRoute'), iconId: 'ui.rerouteSelection', disabled: !edge.waypoints?.length, execute: ({ studio, target }) => studio.commands.resetEdgeRoute(target.id) }),
|
|
87
|
+
action({ id: 'edge.locateSource', label: i18n.t('contextMenu.actions.edgeLocateSource'), iconId: 'ui.locateSource', group: 'navigation', execute: ({ studio }) => studio.select({ kind: 'node', id: edge.source }) }),
|
|
88
|
+
action({ id: 'edge.locateTarget', label: i18n.t('contextMenu.actions.edgeLocateTarget'), iconId: 'ui.locateTarget', group: 'navigation', execute: ({ studio }) => studio.select({ kind: 'node', id: edge.target }) }),
|
|
89
|
+
action({ id: 'selection.delete', label: i18n.t('contextMenu.actions.edgeDelete'), iconId: 'ui.delete', group: 'danger', danger: true, execute: ({ studio, target }) => studio.commands.remove(target) }),
|
|
82
90
|
];
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
const alignments = [
|
|
86
|
-
['left', '
|
|
87
|
-
['centerX', '
|
|
88
|
-
['right', '
|
|
89
|
-
['top', '
|
|
90
|
-
['centerY', '
|
|
91
|
-
['bottom', '
|
|
94
|
+
['left', 'contextMenu.actions.alignLeft', 'ui.alignLeft'],
|
|
95
|
+
['centerX', 'contextMenu.actions.alignCenterX', 'ui.alignCenterHorizontal'],
|
|
96
|
+
['right', 'contextMenu.actions.alignRight', 'ui.alignRight'],
|
|
97
|
+
['top', 'contextMenu.actions.alignTop', 'ui.alignTop'],
|
|
98
|
+
['centerY', 'contextMenu.actions.alignCenterY', 'ui.alignCenterVertical'],
|
|
99
|
+
['bottom', 'contextMenu.actions.alignBottom', 'ui.alignBottom'],
|
|
92
100
|
];
|
|
93
101
|
|
|
94
102
|
function multiActions(context) {
|
|
103
|
+
const i18n = contextI18n(context);
|
|
95
104
|
const nodes = selectedLayoutNodes(context.studio.model, context.selection, context.studio.activeScopeId);
|
|
96
105
|
const diagramNodes = selectedDiagramNodes(context.studio.model, context.selection, context.studio.activeScopeId);
|
|
97
106
|
const groupableNodes = selectedGroupableNodes(context.studio.model, context.selection, context.studio.activeScopeId);
|
|
98
|
-
const actions = alignments.map(([alignment,
|
|
107
|
+
const actions = alignments.map(([alignment, labelKey, iconId]) => action({
|
|
99
108
|
id: `selection.align.${alignment}`,
|
|
100
|
-
label,
|
|
109
|
+
label: i18n.t(labelKey),
|
|
101
110
|
iconId,
|
|
102
111
|
group: 'align',
|
|
103
112
|
disabled: nodes.length < 2,
|
|
104
113
|
execute: ({ studio }) => studio.arrangeSelection({ type: 'align', alignment }),
|
|
105
114
|
}));
|
|
106
115
|
actions.push(
|
|
107
|
-
action({ id: 'selection.group', label: '
|
|
108
|
-
action({ id: 'selection.distribute.horizontal', label: '
|
|
109
|
-
action({ id: 'selection.distribute.vertical', label: '
|
|
110
|
-
action({ id: 'selection.layout', label: '
|
|
111
|
-
action({ id: 'selection.reroute', label: '
|
|
112
|
-
action({ id: 'selection.fit', label: '
|
|
113
|
-
action({ id: 'selection.delete', label: '
|
|
116
|
+
action({ id: 'selection.group', label: i18n.t('contextMenu.actions.selectionGroup'), iconId: 'ui.layoutSelection', group: 'layout', disabled: context.studio.allowsNodeType?.('group') === false || !groupableNodes.length || groupableNodes.length !== diagramNodes.length, execute: ({ studio }) => studio.commands.groupSelection() }),
|
|
117
|
+
action({ id: 'selection.distribute.horizontal', label: i18n.t('contextMenu.actions.distributeHorizontal'), iconId: 'ui.distributeHorizontal', group: 'distribute', disabled: nodes.length < 3, execute: ({ studio }) => studio.arrangeSelection({ type: 'distribute', axis: 'horizontal' }) }),
|
|
118
|
+
action({ id: 'selection.distribute.vertical', label: i18n.t('contextMenu.actions.distributeVertical'), iconId: 'ui.distributeVertical', group: 'distribute', disabled: nodes.length < 3, execute: ({ studio }) => studio.arrangeSelection({ type: 'distribute', axis: 'vertical' }) }),
|
|
119
|
+
action({ id: 'selection.layout', label: i18n.t('contextMenu.actions.selectionLayout'), iconId: 'ui.layoutSelection', group: 'layout', disabled: nodes.length < 2, execute: ({ studio }) => studio.arrangeSelection({ type: 'layout' }) }),
|
|
120
|
+
action({ id: 'selection.reroute', label: i18n.t('contextMenu.actions.selectionReroute'), iconId: 'ui.rerouteSelection', group: 'layout', disabled: nodes.length < 1, execute: ({ studio }) => studio.arrangeSelection({ type: 'reroute' }) }),
|
|
121
|
+
action({ id: 'selection.fit', label: i18n.t('contextMenu.actions.selectionFit'), iconId: 'ui.fitSelection', group: 'layout', disabled: nodes.length < 1, execute: ({ canvas }) => canvas.fitSelection() }),
|
|
122
|
+
action({ id: 'selection.delete', label: i18n.t('contextMenu.actions.selectionDelete'), iconId: 'ui.delete', group: 'danger', danger: true, execute: ({ studio, selection }) => studio.commands.remove(selection) }),
|
|
114
123
|
);
|
|
115
124
|
return actions;
|
|
116
125
|
}
|
package/dist/controller.js
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
validateParallelGateway,
|
|
28
28
|
} from './modules/core/index.js';
|
|
29
29
|
import { exportBpmn, importBpmn } from './modules/bpmn-model/index.js';
|
|
30
|
+
import { createI18n, resolveI18n } from './modules/i18n/index.js';
|
|
30
31
|
import {
|
|
31
32
|
applySelectionArrangement,
|
|
32
33
|
mergeSelectionRefs,
|
|
@@ -96,6 +97,9 @@ export class BpmnStudioController {
|
|
|
96
97
|
allowedNodeTypes,
|
|
97
98
|
allowedEdgeTypes,
|
|
98
99
|
config,
|
|
100
|
+
i18n = null,
|
|
101
|
+
locale,
|
|
102
|
+
messages,
|
|
99
103
|
} = options;
|
|
100
104
|
if (!model) throw new Error('BpmnStudioController requires a model.');
|
|
101
105
|
const legacy = {};
|
|
@@ -103,6 +107,8 @@ export class BpmnStudioController {
|
|
|
103
107
|
if (Object.prototype.hasOwnProperty.call(options, 'allowedNodeTypes')) legacy.allowedNodeTypes = allowedNodeTypes;
|
|
104
108
|
if (Object.prototype.hasOwnProperty.call(options, 'allowedEdgeTypes')) legacy.allowedEdgeTypes = allowedEdgeTypes;
|
|
105
109
|
const normalizedConfig = normalizeStudioConfig(config, { legacy });
|
|
110
|
+
this._ownsI18n = !i18n;
|
|
111
|
+
this.i18n = i18n ? resolveI18n(i18n) : createI18n({ locale, messages });
|
|
106
112
|
this._allowedNodeTypes = normalizeAllowedNodeTypes(normalizedConfig.modeling.allowedNodeTypes);
|
|
107
113
|
this._allowedEdgeTypes = normalizeAllowedEdgeTypes(normalizedConfig.modeling.allowedEdgeTypes);
|
|
108
114
|
this._nodeLimits = normalizedConfig.modeling.nodeLimits || null;
|
|
@@ -150,10 +156,22 @@ export class BpmnStudioController {
|
|
|
150
156
|
redo: () => this.redo(),
|
|
151
157
|
});
|
|
152
158
|
for (const extension of extensions) this.registerExtension(extension);
|
|
159
|
+
this._offI18n = this.i18n.subscribe((state) => {
|
|
160
|
+
this._emit('localeChanged', { locale: state.locale, resolvedLocale: state.resolvedLocale });
|
|
161
|
+
});
|
|
153
162
|
}
|
|
154
163
|
|
|
155
164
|
get model() { return this._model; }
|
|
156
165
|
|
|
166
|
+
setLocale(locale, messages) {
|
|
167
|
+
this.i18n.setLocale(locale, messages);
|
|
168
|
+
return this.getLocale();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
getLocale() {
|
|
172
|
+
return this.i18n.getState();
|
|
173
|
+
}
|
|
174
|
+
|
|
157
175
|
allowsNodeType(nodeType) {
|
|
158
176
|
return Boolean(NODE_DEFINITIONS[nodeType])
|
|
159
177
|
&& nodeType !== 'generic'
|
|
@@ -191,7 +209,11 @@ export class BpmnStudioController {
|
|
|
191
209
|
nodeLimitReason(nodeType, count = 1) {
|
|
192
210
|
const limit = this._nodeLimits?.[nodeType];
|
|
193
211
|
if (!limit || this._countNodesOfType(nodeType) + count <= limit.max) return null;
|
|
194
|
-
return
|
|
212
|
+
return this.i18n.t('modeling.nodeLimitExceeded', {
|
|
213
|
+
max: limit.max,
|
|
214
|
+
label: this.i18n.elementTypeLabel(nodeType, NODE_DEFINITIONS[nodeType]?.label),
|
|
215
|
+
nodeType,
|
|
216
|
+
});
|
|
195
217
|
}
|
|
196
218
|
|
|
197
219
|
_assertAllowedModel(model) {
|
|
@@ -236,6 +258,7 @@ export class BpmnStudioController {
|
|
|
236
258
|
: null,
|
|
237
259
|
activeScopeId: this.activeScopeId,
|
|
238
260
|
scopePath: getScopePath(this._model, this.activeScopeId),
|
|
261
|
+
locale: this.i18n.locale,
|
|
239
262
|
};
|
|
240
263
|
}
|
|
241
264
|
|
|
@@ -322,8 +345,8 @@ export class BpmnStudioController {
|
|
|
322
345
|
scopeId: this.activeScopeId,
|
|
323
346
|
width: Math.max(CONTAINMENT_LIMITS.groupMinWidth, bounds.width + padding * 2),
|
|
324
347
|
height: Math.max(CONTAINMENT_LIMITS.groupMinHeight, bounds.height + padding * 2),
|
|
325
|
-
properties: { categoryValue: '
|
|
326
|
-
});
|
|
348
|
+
properties: { categoryValue: this.i18n.t('modeling.defaultGroupCategory') },
|
|
349
|
+
}, { i18n: this.i18n });
|
|
327
350
|
const firstIndex = Math.min(...groupable.map((node) => this._model.nodes.indexOf(node)));
|
|
328
351
|
this._model.nodes.splice(Math.max(0, firstIndex), 0, group);
|
|
329
352
|
});
|
|
@@ -430,7 +453,7 @@ export class BpmnStudioController {
|
|
|
430
453
|
if (nodeType === 'participant') {
|
|
431
454
|
mergedPreset.properties = { ...(mergedPreset.properties || {}), processRef: mergedPreset.properties?.processRef || this._model.id };
|
|
432
455
|
}
|
|
433
|
-
node = createNode(nodeType, position.x, position.y, { ...mergedPreset, scopeId: this.activeScopeId });
|
|
456
|
+
node = createNode(nodeType, position.x, position.y, { ...mergedPreset, scopeId: this.activeScopeId }, { i18n: this.i18n });
|
|
434
457
|
this._model.nodes.push(node);
|
|
435
458
|
if (nodeType === 'lane') {
|
|
436
459
|
const participant = resolveContainment(this._model).getParticipantAt({
|
|
@@ -472,7 +495,7 @@ export class BpmnStudioController {
|
|
|
472
495
|
this._commit('create-template', () => {
|
|
473
496
|
for (const spec of nodeSpecs) {
|
|
474
497
|
const offset = spec.offset || { x: 0, y: 0 };
|
|
475
|
-
const node = createNode(spec.nodeType, Math.round(point.x + (offset.x || 0)), Math.round(point.y + (offset.y || 0)), { ...mergeNodePreset(spec.preset), scopeId: this.activeScopeId });
|
|
498
|
+
const node = createNode(spec.nodeType, Math.round(point.x + (offset.x || 0)), Math.round(point.y + (offset.y || 0)), { ...mergeNodePreset(spec.preset), scopeId: this.activeScopeId }, { i18n: this.i18n });
|
|
476
499
|
byKey.set(spec.key, node);
|
|
477
500
|
result.nodes.push(node);
|
|
478
501
|
this._model.nodes.push(node);
|
|
@@ -646,7 +669,7 @@ export class BpmnStudioController {
|
|
|
646
669
|
if (!node || !def || !this.canChangeNodeType(id, type) || node.type === type) return false;
|
|
647
670
|
if (isEmbeddedSubProcess(node) && !isEmbeddedSubProcess(type) && hasScopeChildren(this._model, id)) return false;
|
|
648
671
|
this._commit('change-node-type', () => {
|
|
649
|
-
const next = createNode(type, node.x, node.y, { id: node.id, name: node.name });
|
|
672
|
+
const next = createNode(type, node.x, node.y, { id: node.id, name: node.name }, { i18n: this.i18n });
|
|
650
673
|
Object.assign(node, { type, bpmnType: def.bpmnType, width: def.width, height: def.height, originalLocalName: def.localName });
|
|
651
674
|
node.isExpanded = isEmbeddedSubProcess(type) ? false : undefined;
|
|
652
675
|
node.properties = { ...next.properties, ...node.properties };
|
|
@@ -672,9 +695,9 @@ export class BpmnStudioController {
|
|
|
672
695
|
: source.y + source.height / 2 - def.height / 2 + (outgoingCount ? outgoingCount * (def.height + spacing.nodeGap) : 0);
|
|
673
696
|
let node;
|
|
674
697
|
this._commit('quick-add', () => {
|
|
675
|
-
node = createNode(type, Math.round(x), Math.round(y), { ...mergeNodePreset(preset), scopeId: elementScopeId(this._model, source) });
|
|
698
|
+
node = createNode(type, Math.round(x), Math.round(y), { ...mergeNodePreset(preset), scopeId: elementScopeId(this._model, source) }, { i18n: this.i18n });
|
|
676
699
|
this._model.nodes.push(node);
|
|
677
|
-
this._model.edges.push(createEdge(sourceId, node.id, { name: NODE_DEFINITIONS[source.type]?.kind === 'gateway' ?
|
|
700
|
+
this._model.edges.push(createEdge(sourceId, node.id, { name: NODE_DEFINITIONS[source.type]?.kind === 'gateway' ? this.i18n.t('modeling.branchName', { index: outgoingCount + 1 }) : '', scopeId: elementScopeId(this._model, source) }));
|
|
678
701
|
});
|
|
679
702
|
this.select({ kind: 'node', id: node.id });
|
|
680
703
|
return node;
|
|
@@ -741,30 +764,31 @@ export class BpmnStudioController {
|
|
|
741
764
|
return true;
|
|
742
765
|
}
|
|
743
766
|
exportXml(engine) { return exportBpmn(this._model, engine); }
|
|
744
|
-
importXml(xml, engine) { const model = importBpmn(xml, engine); this.setModel(model); return model; }
|
|
767
|
+
importXml(xml, engine) { const model = importBpmn(xml, engine, { i18n: this.i18n }); this.setModel(model); return model; }
|
|
745
768
|
|
|
746
769
|
validate() {
|
|
770
|
+
const i18n = this.i18n;
|
|
747
771
|
const issues = [];
|
|
748
772
|
const starts = this._model.nodes.filter((node) => NODE_DEFINITIONS[node.type]?.eventStage === 'start');
|
|
749
773
|
const ends = this._model.nodes.filter((node) => NODE_DEFINITIONS[node.type]?.eventStage === 'end');
|
|
750
|
-
if (!starts.length) issues.push({ level: 'error', message: '
|
|
751
|
-
if (!ends.length) issues.push({ level: 'warning', message: '
|
|
774
|
+
if (!starts.length) issues.push({ level: 'error', message: i18n.t('validation.missingStartEvent') });
|
|
775
|
+
if (!ends.length) issues.push({ level: 'warning', message: i18n.t('validation.missingEndEvent') });
|
|
752
776
|
const scopeIssues = getScopeIntegrityIssues(this._model);
|
|
753
777
|
const invalidScopeEdges = new Set(scopeIssues.filter((issue) => issue.kind === 'edge').map((issue) => issue.id));
|
|
754
778
|
for (const issue of scopeIssues.filter((item) => item.kind === 'node')) {
|
|
755
|
-
issues.push({ level: 'error', elementId: issue.id, message: '
|
|
779
|
+
issues.push({ level: 'error', elementId: issue.id, message: i18n.t('validation.invalidSubProcessScope') });
|
|
756
780
|
}
|
|
757
781
|
for (const edge of this._model.edges) {
|
|
758
|
-
if (!getNode(this._model, edge.source) || !getNode(this._model, edge.target)) issues.push({ level: 'error', elementId: edge.id, message: '
|
|
759
|
-
else if (invalidScopeEdges.has(edge.id)) issues.push({ level: 'error', elementId: edge.id, message: '
|
|
760
|
-
if ((edge.type || 'sequenceFlow') === 'sequenceFlow' && edge.source === edge.target) issues.push({ level: 'error', elementId: edge.id, message: '
|
|
782
|
+
if (!getNode(this._model, edge.source) || !getNode(this._model, edge.target)) issues.push({ level: 'error', elementId: edge.id, message: i18n.t('validation.edgeMissingNode') });
|
|
783
|
+
else if (invalidScopeEdges.has(edge.id)) issues.push({ level: 'error', elementId: edge.id, message: i18n.t('validation.edgeCrossScope') });
|
|
784
|
+
if ((edge.type || 'sequenceFlow') === 'sequenceFlow' && edge.source === edge.target) issues.push({ level: 'error', elementId: edge.id, message: i18n.t('validation.sequenceFlowSelfLoop') });
|
|
761
785
|
}
|
|
762
786
|
for (const node of this._model.nodes) {
|
|
763
787
|
const definition = NODE_DEFINITIONS[node.type] || NODE_DEFINITIONS.generic;
|
|
764
|
-
if (node.type === 'serviceTask' && !node.properties?.implementation) issues.push({ level: 'warning', elementId: node.id, message:
|
|
765
|
-
if (node.type === 'userTask' && !node.properties?.assignee && !node.properties?.candidateUsers && !node.properties?.candidateGroups) issues.push({ level: 'warning', elementId: node.id, message:
|
|
766
|
-
if (definition.kind === 'boundary' && !node.properties?.attachedToRef) issues.push({ level: 'warning', elementId: node.id, message:
|
|
767
|
-
for (const message of validateParallelGateway(this._model, node)) issues.push({ level: 'warning', elementId: node.id, message:
|
|
788
|
+
if (node.type === 'serviceTask' && !node.properties?.implementation) issues.push({ level: 'warning', elementId: node.id, message: i18n.t('validation.serviceTaskMissingImpl', { name: node.name }) });
|
|
789
|
+
if (node.type === 'userTask' && !node.properties?.assignee && !node.properties?.candidateUsers && !node.properties?.candidateGroups) issues.push({ level: 'warning', elementId: node.id, message: i18n.t('validation.userTaskMissingAssignee', { name: node.name }) });
|
|
790
|
+
if (definition.kind === 'boundary' && !node.properties?.attachedToRef) issues.push({ level: 'warning', elementId: node.id, message: i18n.t('validation.boundaryMissingTarget', { name: node.name }) });
|
|
791
|
+
for (const message of validateParallelGateway(this._model, node, { i18n })) issues.push({ level: 'warning', elementId: node.id, message: i18n.t('validation.nodeIssue', { name: node.name, message }) });
|
|
768
792
|
}
|
|
769
793
|
return issues;
|
|
770
794
|
}
|
|
@@ -810,6 +834,8 @@ export class BpmnStudioController {
|
|
|
810
834
|
}
|
|
811
835
|
|
|
812
836
|
destroy() {
|
|
837
|
+
this._offI18n?.();
|
|
838
|
+
this._offI18n = null;
|
|
813
839
|
for (const cleanup of this._extensions.values()) cleanup?.();
|
|
814
840
|
this._extensions.clear();
|
|
815
841
|
this._listeners.clear();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createFlowTreeController as createRawFlowTreeController } from './modules/flow-tree/index.js';
|
|
2
|
+
import { createFlowTreeBpmnCompiler } from './modules/flow-tree-bpmn/index.js';
|
|
3
|
+
|
|
4
|
+
export * from './modules/flow-tree/index.js';
|
|
5
|
+
export * from './modules/flow-tree-bpmn/index.js';
|
|
6
|
+
export * from './modules/properties-flow-tree/index.js';
|
|
7
|
+
export * from './modules/flow-tree-renderer/index.js';
|
|
8
|
+
|
|
9
|
+
export function createFlowTreeController(options = {}) {
|
|
10
|
+
return createRawFlowTreeController({
|
|
11
|
+
...options,
|
|
12
|
+
compiler: options.compiler !== undefined ? options.compiler : createFlowTreeBpmnCompiler(),
|
|
13
|
+
});
|
|
14
|
+
}
|