bpmn-js 11.4.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/bpmn-modeler.development.js +5348 -5378
  2. package/dist/bpmn-modeler.production.min.js +17 -18
  3. package/dist/bpmn-navigated-viewer.development.js +838 -599
  4. package/dist/bpmn-navigated-viewer.production.min.js +3 -5
  5. package/dist/bpmn-viewer.development.js +808 -593
  6. package/dist/bpmn-viewer.production.min.js +4 -6
  7. package/lib/BaseModeler.d.ts +5 -0
  8. package/lib/BaseModeler.js +16 -18
  9. package/lib/BaseViewer.d.ts +366 -0
  10. package/lib/BaseViewer.js +147 -109
  11. package/lib/Modeler.d.ts +15 -0
  12. package/lib/Modeler.js +6 -27
  13. package/lib/NavigatedViewer.d.ts +3 -0
  14. package/lib/NavigatedViewer.js +5 -2
  15. package/lib/Viewer.d.ts +3 -0
  16. package/lib/Viewer.js +2 -8
  17. package/lib/features/align-elements/dist/align-bottom-tool.svg +1 -0
  18. package/lib/features/align-elements/dist/align-horizontal-center-tool.svg +1 -0
  19. package/lib/features/align-elements/dist/align-left-tool.svg +1 -0
  20. package/lib/features/align-elements/dist/align-right-tool.svg +1 -0
  21. package/lib/features/align-elements/dist/align-tool.svg +1 -0
  22. package/lib/features/align-elements/dist/align-top-tool.svg +1 -0
  23. package/lib/features/align-elements/dist/align-vertical-center-tool.svg +1 -0
  24. package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +11 -3
  25. package/lib/features/replace/BpmnReplace.js +3 -12
  26. package/lib/features/replace-preview/BpmnReplacePreview.js +1 -1
  27. package/package.json +13 -11
  28. package/lib/features/create-append-anything/AppendContextPadProvider.js +0 -77
  29. package/lib/features/create-append-anything/AppendMenuProvider.js +0 -187
  30. package/lib/features/create-append-anything/AppendRules.js +0 -83
  31. package/lib/features/create-append-anything/CreateAppendEditorActions.js +0 -58
  32. package/lib/features/create-append-anything/CreateAppendKeyboardBindings.js +0 -90
  33. package/lib/features/create-append-anything/CreateMenuProvider.js +0 -114
  34. package/lib/features/create-append-anything/CreatePaletteProvider.js +0 -72
  35. package/lib/features/create-append-anything/index.js +0 -37
  36. package/lib/features/create-append-anything/util/OptionsUtil.js +0 -617
  37. package/lib/icons/Icons.js +0 -11
  38. package/lib/icons/dist/append.svg +0 -1
  39. package/lib/icons/dist/connect-context-pad.svg +0 -1
  40. package/lib/icons/dist/connect-palette.svg +0 -1
  41. package/lib/icons/resources/append.svg +0 -3
  42. package/lib/icons/resources/create.svg +0 -3
  43. /package/lib/{icons → features/palette}/dist/create.svg +0 -0
@@ -85,8 +85,7 @@ export default function BpmnReplace(
85
85
  moddleCopy,
86
86
  modeling,
87
87
  replace,
88
- rules,
89
- selection
88
+ rules
90
89
  ) {
91
90
 
92
91
  /**
@@ -284,14 +283,7 @@ export default function BpmnReplace(
284
283
  newElement.x = element.x + (element.width - newElement.width) / 2;
285
284
  }
286
285
 
287
-
288
- newElement = replace.replaceElement(element, newElement, hints);
289
-
290
- if (hints.select !== false) {
291
- selection.select(newElement);
292
- }
293
-
294
- return newElement;
286
+ return replace.replaceElement(element, newElement, hints);
295
287
  }
296
288
 
297
289
  this.replaceElement = replaceElement;
@@ -303,8 +295,7 @@ BpmnReplace.$inject = [
303
295
  'moddleCopy',
304
296
  'modeling',
305
297
  'replace',
306
- 'rules',
307
- 'selection'
298
+ 'rules'
308
299
  ];
309
300
 
310
301
 
@@ -2,7 +2,7 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
2
2
 
3
3
  import inherits from 'inherits-browser';
4
4
 
5
- import cssEscape from 'css.escape';
5
+ import { escapeCSS as cssEscape } from 'diagram-js/lib/util/EscapeUtil';
6
6
 
7
7
  import {
8
8
  assign,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "11.4.1",
3
+ "version": "12.0.0",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -9,10 +9,11 @@
9
9
  "test/util",
10
10
  "test/helper",
11
11
  "test/matchers",
12
- "!.eslintrc"
12
+ "!.eslintrc",
13
+ "!lib/**/*.spec.ts"
13
14
  ],
14
15
  "scripts": {
15
- "all": "run-s lint test distro test:distro",
16
+ "all": "run-s lint test test:types distro test:distro",
16
17
  "lint": "eslint .",
17
18
  "format": "run-s format:markdown 'lint -- --fix'",
18
19
  "format:markdown": "remark . -qo",
@@ -24,6 +25,7 @@
24
25
  "distro": "node tasks/build-distro.js",
25
26
  "collect-translations": "cross-env COLLECT_TRANSLATIONS=1 npm test",
26
27
  "test:distro": "node tasks/test-distro.js",
28
+ "test:types": "tsc",
27
29
  "postversion": "run-s distro test:distro",
28
30
  "prepare": "run-s distro"
29
31
  },
@@ -56,11 +58,11 @@
56
58
  ],
57
59
  "devDependencies": {
58
60
  "@babel/core": "^7.20.2",
59
- "@rollup/plugin-commonjs": "^23.0.2",
60
- "@rollup/plugin-json": "^5.0.1",
61
+ "@rollup/plugin-commonjs": "^24.0.1",
62
+ "@rollup/plugin-json": "^6.0.0",
61
63
  "@rollup/plugin-node-resolve": "^15.0.1",
62
- "@rollup/plugin-replace": "^5.0.1",
63
- "@rollup/plugin-terser": "^0.1.0",
64
+ "@rollup/plugin-replace": "^5.0.2",
65
+ "@rollup/plugin-terser": "^0.4.0",
64
66
  "babel-loader": "^9.1.0",
65
67
  "babel-plugin-istanbul": "^6.1.1",
66
68
  "bpmn-font": "^0.12.0",
@@ -92,16 +94,16 @@
92
94
  "puppeteer": "^19.4.1",
93
95
  "remark-cli": "^11.0.0",
94
96
  "remark-preset-bpmn-io": "^0.2.1",
95
- "rollup": "^2.79.1",
96
- "rollup-plugin-license": "^2.9.1",
97
+ "rollup": "^3.19.1",
98
+ "rollup-plugin-license": "^3.0.0",
97
99
  "sinon": "^15.0.0",
98
100
  "sinon-chai": "^3.7.0",
101
+ "typescript": "^5.0.0",
99
102
  "webpack": "^5.74.0"
100
103
  },
101
104
  "dependencies": {
102
105
  "bpmn-moddle": "^8.0.0",
103
- "css.escape": "^1.5.1",
104
- "diagram-js": "^11.9.1",
106
+ "diagram-js": "^11.12.0",
105
107
  "diagram-js-direct-editing": "^2.0.0",
106
108
  "ids": "^1.0.0",
107
109
  "inherits-browser": "^0.1.0",
@@ -1,77 +0,0 @@
1
- import {
2
- assign
3
- } from 'min-dash';
4
-
5
- import {
6
- appendIcon
7
- } from '../../icons/Icons';
8
-
9
- var LOW_PRIORITY = 900;
10
-
11
- /**
12
- * A provider for align elements context pad button
13
- */
14
- export default function AppendContextPadProvider(contextPad, popupMenu, translate, canvas) {
15
- contextPad.registerProvider(LOW_PRIORITY, this);
16
-
17
- this._contextPad = contextPad;
18
- this._popupMenu = popupMenu;
19
- this._translate = translate;
20
- this._canvas = canvas;
21
- }
22
-
23
- AppendContextPadProvider.$inject = [
24
- 'contextPad',
25
- 'popupMenu',
26
- 'translate',
27
- 'canvas'
28
- ];
29
-
30
- AppendContextPadProvider.prototype.getContextPadEntries = function(element) {
31
- const popupMenu = this._popupMenu;
32
- const translate = this._translate;
33
- const getAppendMenuPosition = this._getAppendMenuPosition.bind(this);
34
-
35
- if (!popupMenu.isEmpty(element, 'bpmn-append')) {
36
-
37
- // append menu entry
38
- return {
39
- 'append': {
40
- group: 'model',
41
- imageUrl: appendIcon,
42
- title: translate('Append element'),
43
- action: {
44
- click: function(event, element) {
45
-
46
- var position = assign(getAppendMenuPosition(element), {
47
- cursor: { x: event.x, y: event.y }
48
- });
49
-
50
- popupMenu.open(element, 'bpmn-append', position, {
51
- title: translate('Append element'),
52
- width: 300,
53
- search: true
54
- });
55
- }
56
- }
57
- }
58
- };
59
- }
60
- };
61
-
62
- AppendContextPadProvider.prototype._getAppendMenuPosition = function(element) {
63
- const contextPad = this._contextPad;
64
-
65
- const X_OFFSET = 5;
66
-
67
- const pad = contextPad.getPad(element).html;
68
-
69
- const padRect = pad.getBoundingClientRect();
70
-
71
- const pos = {
72
- x: padRect.right + X_OFFSET,
73
- y: padRect.top
74
- };
75
-
76
- return pos;
77
- };
@@ -1,187 +0,0 @@
1
- import { isUndefined } from 'min-dash';
2
- import { CREATE_OPTIONS } from './util/OptionsUtil';
3
-
4
- /**
5
- * This module is an append menu provider for the popup menu.
6
- */
7
- export default function AppendMenuProvider(
8
- elementFactory,
9
- popupMenu,
10
- create,
11
- autoPlace,
12
- rules,
13
- mouse,
14
- translate
15
- ) {
16
- this._elementFactory = elementFactory;
17
- this._popupMenu = popupMenu;
18
- this._create = create;
19
- this._autoPlace = autoPlace;
20
- this._rules = rules;
21
- this._create = create;
22
- this._mouse = mouse;
23
- this._translate = translate;
24
-
25
- this.register();
26
- }
27
-
28
- AppendMenuProvider.$inject = [
29
- 'elementFactory',
30
- 'popupMenu',
31
- 'create',
32
- 'autoPlace',
33
- 'rules',
34
- 'mouse',
35
- 'translate'
36
- ];
37
-
38
- /**
39
- * Register append menu provider in the popup menu
40
- */
41
- AppendMenuProvider.prototype.register = function() {
42
- this._popupMenu.registerProvider('bpmn-append', this);
43
- };
44
-
45
- /**
46
- * Get all entries from createOptions for the given element.
47
- *
48
- * @param {djs.model.Base} element
49
- *
50
- * @return {Array<Object>} a list of menu entry items
51
- */
52
- AppendMenuProvider.prototype.getPopupMenuEntries = function(element) {
53
- const rules = this._rules;
54
- const translate = this._translate;
55
-
56
- const entries = {};
57
-
58
- if (!rules.allowed('shape.append', { element: element })) {
59
- return [];
60
- }
61
-
62
- // filter out elements with no incoming connections
63
- const appendOptions = this._filterEntries(CREATE_OPTIONS);
64
-
65
- // map options to menu entries
66
- appendOptions.forEach(option => {
67
- const {
68
- actionName,
69
- className,
70
- label,
71
- target,
72
- description,
73
- group,
74
- search,
75
- rank
76
- } = option;
77
-
78
- entries[`append-${actionName}`] = {
79
- label: label && translate(label),
80
- className,
81
- description,
82
- group: group && {
83
- ...group,
84
- name: translate(group.name)
85
- },
86
- search,
87
- rank,
88
- action: this._createEntryAction(element, target)
89
- };
90
- });
91
-
92
- return entries;
93
- };
94
-
95
- /**
96
- * Filter out entries from the options.
97
- *
98
- * @param {Array<Object>} entries
99
- *
100
- * @return {Array<Object>} filtered entries
101
- */
102
- AppendMenuProvider.prototype._filterEntries = function(entries) {
103
- return entries.filter(option => {
104
-
105
- const target = option.target;
106
- const {
107
- type,
108
- eventDefinitionType
109
- } = target;
110
-
111
- if ([
112
- 'bpmn:StartEvent',
113
- 'bpmn:Participant'
114
- ].includes(type)) {
115
- return false;
116
- }
117
-
118
- if (type === 'bpmn:BoundaryEvent' && isUndefined(eventDefinitionType)) {
119
- return false;
120
- }
121
-
122
- return true;
123
- });
124
- };
125
-
126
- /**
127
- * Create an action for a given target.
128
- *
129
- * @param {djs.model.Base} element
130
- * @param {Object} target
131
- *
132
- * @return {Object}
133
- */
134
- AppendMenuProvider.prototype._createEntryAction = function(element, target) {
135
- const elementFactory = this._elementFactory;
136
- const autoPlace = this._autoPlace;
137
- const create = this._create;
138
- const mouse = this._mouse;
139
-
140
-
141
- const autoPlaceElement = () => {
142
- const newElement = elementFactory.create('shape', target);
143
- autoPlace.append(element, newElement);
144
- };
145
-
146
- const manualPlaceElement = (event) => {
147
- const newElement = elementFactory.create('shape', target);
148
-
149
- if (event instanceof KeyboardEvent) {
150
- event = mouse.getLastMoveEvent();
151
- }
152
-
153
- return create.start(event, newElement, {
154
- source: element
155
- });
156
- };
157
-
158
- return {
159
- click: this._canAutoPlaceElement(target) ? autoPlaceElement : manualPlaceElement,
160
- dragstart: manualPlaceElement
161
- };
162
- };
163
-
164
- /**
165
- * Check if the element should be auto placed.
166
- *
167
- * @param {Object} target
168
- *
169
- * @return {Boolean}
170
- */
171
- AppendMenuProvider.prototype._canAutoPlaceElement = (target) => {
172
- const { type } = target;
173
-
174
- if (type === 'bpmn:BoundaryEvent') {
175
- return false;
176
- }
177
-
178
- if (type === 'bpmn:SubProcess' && target.triggeredByEvent) {
179
- return false;
180
- }
181
-
182
- if (type === 'bpmn:IntermediateCatchEvent' && target.eventDefinitionType === 'bpmn:LinkEventDefinition') {
183
- return false;
184
- }
185
-
186
- return true;
187
- };
@@ -1,83 +0,0 @@
1
- import {
2
- find,
3
- } from 'min-dash';
4
-
5
- import inherits from 'inherits-browser';
6
-
7
- import {
8
- is,
9
- isAny,
10
- getBusinessObject
11
- } from '../../util/ModelUtil';
12
-
13
- import {
14
- isLabel
15
- } from '../../util/LabelUtil';
16
-
17
- import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
18
-
19
-
20
- /**
21
- * Append anything modeling rules
22
- */
23
- export default function AppendRules(eventBus) {
24
- RuleProvider.call(this, eventBus);
25
- }
26
-
27
- inherits(AppendRules, RuleProvider);
28
-
29
- AppendRules.$inject = [
30
- 'eventBus'
31
- ];
32
-
33
- AppendRules.prototype.init = function() {
34
- this.addRule('shape.append', function(context) {
35
-
36
- var source = context.element;
37
-
38
- const businessObject = getBusinessObject(source);
39
-
40
- if (isLabel(source)) {
41
- return false;
42
- }
43
-
44
- if (isAny(source, [
45
- 'bpmn:EndEvent',
46
- 'bpmn:Group',
47
- 'bpmn:TextAnnotation',
48
- 'bpmn:Lane',
49
- 'bpmn:Participant',
50
- 'bpmn:DataStoreReference',
51
- 'bpmn:DataObjectReference'
52
- ])) {
53
- return false;
54
- }
55
-
56
- if (isConnection(source)) {
57
- return false;
58
- }
59
-
60
- if (is(source, 'bpmn:IntermediateThrowEvent') && hasEventDefinition(source, 'bpmn:LinkEventDefinition')) {
61
- return false;
62
- }
63
-
64
- if (is(source, 'bpmn:SubProcess') && businessObject.triggeredByEvent) {
65
- return false;
66
- }
67
- });
68
-
69
- };
70
-
71
-
72
- // helpers //////////////
73
- function hasEventDefinition(element, eventDefinition) {
74
- var bo = getBusinessObject(element);
75
-
76
- return !!find(bo.eventDefinitions || [], function(definition) {
77
- return is(definition, eventDefinition);
78
- });
79
- }
80
-
81
- function isConnection(element) {
82
- return element.waypoints;
83
- }
@@ -1,58 +0,0 @@
1
- import { assign } from 'min-dash';
2
-
3
- /**
4
- * Registers and executes BPMN specific editor actions.
5
- *
6
- * @param {Injector} injector
7
- */
8
- export default function CreateAppendEditorActions(injector) {
9
- this._injector = injector;
10
-
11
- this.registerActions();
12
- }
13
-
14
- CreateAppendEditorActions.$inject = [
15
- 'injector'
16
- ];
17
-
18
- /**
19
- * Register actions.
20
- *
21
- * @param {Injector} injector
22
- */
23
- CreateAppendEditorActions.prototype.registerActions = function() {
24
- var editorActions = this._injector.get('editorActions', false);
25
- var selection = this._injector.get('selection', false);
26
- var contextPad = this._injector.get('contextPad', false);
27
- var palette = this._injector.get('palette', false);
28
- var popupMenu = this._injector.get('popupMenu', false);
29
-
30
- const actions = {};
31
-
32
- // append
33
- if (selection && contextPad && palette && popupMenu && palette) {
34
- assign(actions, {
35
- 'appendElement': function(event) {
36
- const selected = selection && selection.get();
37
-
38
- if (selected.length == 1 && !popupMenu.isEmpty(selected[0], 'bpmn-append')) {
39
- contextPad.triggerEntry('append', 'click', event);
40
- } else {
41
- palette.triggerEntry('create', 'click', event);
42
- }
43
- }
44
- });
45
- }
46
-
47
- // create
48
- if (palette) {
49
- assign(actions, {
50
- 'createElement': function(event) {
51
- palette.triggerEntry('create', 'click', event);
52
- } }
53
- );
54
- }
55
-
56
- editorActions && editorActions.register(actions);
57
-
58
- };
@@ -1,90 +0,0 @@
1
- import inherits from 'inherits-browser';
2
-
3
- import KeyboardBindings from 'diagram-js/lib/features/keyboard/KeyboardBindings';
4
-
5
-
6
- /**
7
- * BPMN 2.0 specific keyboard bindings.
8
- *
9
- * @param {Injector} injector
10
- */
11
- export default function CreateAppendKeyboardBindings(injector) {
12
-
13
- this._injector = injector;
14
- this._keyboard = this._injector.get('keyboard', false);
15
- this._editorActions = this._injector.get('editorActions', false);
16
-
17
- if (this._keyboard) {
18
- this._injector.invoke(KeyboardBindings, this);
19
- }
20
- }
21
-
22
- inherits(CreateAppendKeyboardBindings, KeyboardBindings);
23
-
24
- CreateAppendKeyboardBindings.$inject = [
25
- 'injector'
26
- ];
27
-
28
-
29
- /**
30
- * Register available keyboard bindings.
31
- *
32
- * @param {Keyboard} keyboard
33
- * @param {EditorActions} editorActions
34
- */
35
- CreateAppendKeyboardBindings.prototype.registerBindings = function() {
36
-
37
- var keyboard = this._keyboard;
38
- var editorActions = this._editorActions;
39
-
40
- // inherit default bindings
41
- KeyboardBindings.prototype.registerBindings.call(this, keyboard, editorActions);
42
-
43
- /**
44
- * Add keyboard binding if respective editor action
45
- * is registered.
46
- *
47
- * @param {string} action name
48
- * @param {Function} fn that implements the key binding
49
- */
50
- function addListener(action, fn) {
51
-
52
- if (editorActions && editorActions.isRegistered(action)) {
53
- keyboard && keyboard.addListener(fn);
54
- }
55
- }
56
-
57
- // activate append/create element
58
- // A
59
- addListener('appendElement', function(context) {
60
-
61
- var event = context.keyEvent;
62
-
63
- if (keyboard && keyboard.hasModifier(event)) {
64
- return;
65
- }
66
-
67
- if (keyboard && keyboard.isKey([ 'a', 'A' ], event)) {
68
-
69
- editorActions && editorActions.trigger('appendElement', event);
70
- return true;
71
- }
72
- });
73
-
74
- // N
75
- addListener('createElement', function(context) {
76
-
77
- var event = context.keyEvent;
78
-
79
- if (keyboard && keyboard.hasModifier(event)) {
80
- return;
81
- }
82
-
83
- if (keyboard && keyboard.isKey([ 'n', 'N' ], event)) {
84
- editorActions && editorActions.trigger('createElement', event);
85
-
86
- return true;
87
- }
88
- });
89
-
90
- };