@jylups/cmmn-js 0.0.0-stage → 0.21.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.
- package/.babelrc +3 -0
- package/CHANGELOG.md +119 -0
- package/LICENSE +23 -0
- package/README.md +107 -2
- package/dist/assets/cmmn-font/css/cmmn-codes.css +41 -0
- package/dist/assets/cmmn-font/css/cmmn-embedded.css +94 -0
- package/dist/assets/cmmn-font/css/cmmn.css +97 -0
- package/dist/assets/cmmn-font/font/cmmn.eot +0 -0
- package/dist/assets/cmmn-font/font/cmmn.svg +90 -0
- package/dist/assets/cmmn-font/font/cmmn.ttf +0 -0
- package/dist/assets/cmmn-font/font/cmmn.woff +0 -0
- package/dist/assets/cmmn-font/font/cmmn.woff2 +0 -0
- package/dist/assets/diagram-js.css +713 -0
- package/dist/cmmn-modeler.development.js +44817 -0
- package/dist/cmmn-modeler.production.min.js +2 -0
- package/dist/cmmn-navigated-viewer.development.js +18131 -0
- package/dist/cmmn-navigated-viewer.production.min.js +2 -0
- package/dist/cmmn-viewer.development.js +17599 -0
- package/dist/cmmn-viewer.production.min.js +2 -0
- package/index.js +1 -0
- package/lib/Modeler.js +222 -0
- package/lib/NavigatedViewer.js +28 -0
- package/lib/Viewer.js +489 -0
- package/lib/core/ItemRegistry.js +316 -0
- package/lib/core/index.js +7 -0
- package/lib/draw/CmmnRenderer.js +1235 -0
- package/lib/draw/PathMap.js +335 -0
- package/lib/draw/index.js +5 -0
- package/lib/features/auto-resize/CmmnAutoResizeProvider.js +57 -0
- package/lib/features/auto-resize/index.js +7 -0
- package/lib/features/context-pad/ContextPadProvider.js +240 -0
- package/lib/features/context-pad/index.js +11 -0
- package/lib/features/editor-actions/CmmnEditorActions.js +105 -0
- package/lib/features/editor-actions/index.js +10 -0
- package/lib/features/keyboard/CmmnKeyboardBindings.js +159 -0
- package/lib/features/keyboard/index.js +7 -0
- package/lib/features/label-editing/LabelEditingProvider.js +221 -0
- package/lib/features/label-editing/LabelUtil.js +95 -0
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +63 -0
- package/lib/features/label-editing/index.js +9 -0
- package/lib/features/modeling/CmmnFactory.js +166 -0
- package/lib/features/modeling/CmmnLayouter.js +49 -0
- package/lib/features/modeling/CmmnUpdater.js +511 -0
- package/lib/features/modeling/ElementFactory.js +215 -0
- package/lib/features/modeling/Modeling.js +185 -0
- package/lib/features/modeling/behavior/AttachCriterionBehavior.js +58 -0
- package/lib/features/modeling/behavior/CaseFileItemUpdater.js +324 -0
- package/lib/features/modeling/behavior/LabelBehavior.js +139 -0
- package/lib/features/modeling/behavior/PlanItemDefinitionUpdater.js +449 -0
- package/lib/features/modeling/behavior/PlanningTableUpdater.js +620 -0
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +320 -0
- package/lib/features/modeling/behavior/ReplaceElementBehavior.js +395 -0
- package/lib/features/modeling/behavior/ResizeCasePlanModelBehavior.js +108 -0
- package/lib/features/modeling/behavior/SentryUpdater.js +678 -0
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +28 -0
- package/lib/features/modeling/behavior/index.js +24 -0
- package/lib/features/modeling/cmd/AppendShapeHandler.js +52 -0
- package/lib/features/modeling/cmd/IdClaimHandler.js +38 -0
- package/lib/features/modeling/cmd/ReconnectConnectionHandler.js +57 -0
- package/lib/features/modeling/cmd/ReplaceShapeHandler.js +46 -0
- package/lib/features/modeling/cmd/UpdateControlsHandler.js +221 -0
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +240 -0
- package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +94 -0
- package/lib/features/modeling/index.js +20 -0
- package/lib/features/modeling/util/ModelingUtil.js +138 -0
- package/lib/features/modeling/util/PlanItemDefinitionUtil.js +183 -0
- package/lib/features/ordering/CmmnOrderingProvider.js +146 -0
- package/lib/features/ordering/index.js +4 -0
- package/lib/features/outline/Outline.js +47 -0
- package/lib/features/outline/index.js +6 -0
- package/lib/features/palette/PaletteProvider.js +171 -0
- package/lib/features/palette/index.js +12 -0
- package/lib/features/popup-menu/ReplaceMenuProvider.js +448 -0
- package/lib/features/popup-menu/index.js +4 -0
- package/lib/features/replace/CmmnReplace.js +355 -0
- package/lib/features/replace/ReplaceOptions.js +241 -0
- package/lib/features/replace/index.js +8 -0
- package/lib/features/replace-preview/CmmnReplacePreview.js +247 -0
- package/lib/features/replace-preview/index.js +7 -0
- package/lib/features/rules/CmmnRules.js +1040 -0
- package/lib/features/rules/index.js +7 -0
- package/lib/features/search/CmmnSearchProvider.js +129 -0
- package/lib/features/search/index.js +7 -0
- package/lib/features/snapping/CmmnConnectSnapping.js +110 -0
- package/lib/features/snapping/CmmnCreateMoveSnapping.js +148 -0
- package/lib/features/snapping/CmmnResizeSnapping.js +42 -0
- package/lib/features/snapping/CmmnSnappingUtil.js +76 -0
- package/lib/features/snapping/index.js +17 -0
- package/lib/import/CmmnImporter.js +251 -0
- package/lib/import/CmmnTreeWalker.js +410 -0
- package/lib/import/Importer.js +73 -0
- package/lib/import/Util.js +9 -0
- package/lib/import/index.js +3 -0
- package/lib/util/DiUtil.js +39 -0
- package/lib/util/LabelUtil.js +124 -0
- package/lib/util/ModelUtil.js +257 -0
- package/lib/util/PoweredByUtil.js +91 -0
- package/package.json +88 -4
- package/test/helper/index.js +231 -0
- package/test/util/KeyEvents.js +23 -0
- package/test/util/MockEvents.js +55 -0
- package/test/util/custom-rules/CustomRules.js +19 -0
- package/test/util/custom-rules/index.js +4 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A helper file that may be used in test cases for cmmn-js and extensions.
|
|
5
|
+
*
|
|
6
|
+
* Publishes the globals
|
|
7
|
+
*
|
|
8
|
+
* * bootstrapModeler(): bootstrap a modeler instance
|
|
9
|
+
* * bootstrapViewer(): bootstrap a viewer instance
|
|
10
|
+
* * inject(function(a, b) {}): inject the cmmn-js services in the given function
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
* In addition it provides the utilities
|
|
14
|
+
*
|
|
15
|
+
* * insertCSS(name, css): add a CSS file to be used in test cases
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* It is recommended to expose the helper through a per-project utility and
|
|
19
|
+
* and perform custom bootstrapping (CSS, ...) in that utility.
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* var TestHelper = module.exports = require('cmmn-js/test/helper');
|
|
23
|
+
*
|
|
24
|
+
* var fs = require('fs');
|
|
25
|
+
*
|
|
26
|
+
* // insert diagram.css
|
|
27
|
+
* TestHelper.insertCSS('diagram.css', fs.readFileSync('some-css.css', 'utf8'));
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var isFunction = require('min-dash').isFunction,
|
|
32
|
+
assign = require('min-dash').assign,
|
|
33
|
+
forEach = require('min-dash').forEach;
|
|
34
|
+
|
|
35
|
+
var TestContainer = require('mocha-test-container-support');
|
|
36
|
+
|
|
37
|
+
var Viewer = require('../../lib/Viewer'),
|
|
38
|
+
Modeler = require('../../lib/Modeler');
|
|
39
|
+
|
|
40
|
+
var OPTIONS, CMMN_JS;
|
|
41
|
+
|
|
42
|
+
function bootstrapCmmnJs(CmmnJs, diagram, options, locals) {
|
|
43
|
+
|
|
44
|
+
return function(done) {
|
|
45
|
+
var testContainer;
|
|
46
|
+
|
|
47
|
+
// Make sure the test container is an optional dependency and we fall back
|
|
48
|
+
// to an empty <div> if it does not exist.
|
|
49
|
+
//
|
|
50
|
+
// This is needed if other libraries rely on this helper for testing
|
|
51
|
+
// while not adding the mocha-test-container-support as a dependency.
|
|
52
|
+
try {
|
|
53
|
+
// 'this' is the current test context
|
|
54
|
+
testContainer = TestContainer.get(this);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
testContainer = document.createElement('div');
|
|
57
|
+
document.body.appendChild(testContainer);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
testContainer.classList.add('test-container');
|
|
61
|
+
|
|
62
|
+
var _options = options,
|
|
63
|
+
_locals = locals;
|
|
64
|
+
|
|
65
|
+
if (_locals === undefined && isFunction(_options)) {
|
|
66
|
+
_locals = _options;
|
|
67
|
+
_options = null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (isFunction(_options)) {
|
|
71
|
+
_options = _options();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (isFunction(_locals)) {
|
|
75
|
+
_locals = _locals();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_options = assign({ container: testContainer }, OPTIONS || {}, _options || {});
|
|
79
|
+
|
|
80
|
+
if (_locals) {
|
|
81
|
+
var mockModule = {};
|
|
82
|
+
|
|
83
|
+
forEach(_locals, function(v, k) {
|
|
84
|
+
mockModule[k] = ['value', v];
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
_options.modules = [].concat(_options.modules || [], [ mockModule ]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (_options.modules && !_options.modules.length) {
|
|
91
|
+
_options.modules = undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (CMMN_JS) {
|
|
95
|
+
CMMN_JS.destroy();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
CMMN_JS = new CmmnJs(_options);
|
|
99
|
+
|
|
100
|
+
CMMN_JS.importXML(diagram, done);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Bootstrap the Modeler given the specified options and a number of locals (i.e. services)
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
*
|
|
110
|
+
* describe(function() {
|
|
111
|
+
*
|
|
112
|
+
* var mockEvents;
|
|
113
|
+
*
|
|
114
|
+
* beforeEach(bootstrapModeler('some-xml', function() {
|
|
115
|
+
* mockEvents = new Events();
|
|
116
|
+
*
|
|
117
|
+
* return {
|
|
118
|
+
* events: mockEvents
|
|
119
|
+
* };
|
|
120
|
+
* }));
|
|
121
|
+
*
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* @param {String} xml document to display
|
|
125
|
+
* @param {Object} (options) optional options to be passed to the diagram upon instantiation
|
|
126
|
+
* @param {Object|Function} locals the local overrides to be used by the diagram or a function that produces them
|
|
127
|
+
* @return {Function} a function to be passed to beforeEach
|
|
128
|
+
*/
|
|
129
|
+
function bootstrapModeler(diagram, options, locals) {
|
|
130
|
+
return bootstrapCmmnJs(Modeler, diagram, options, locals);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Bootstrap the Viewer given the specified options and a number of locals (i.e. services)
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
*
|
|
138
|
+
* describe(function() {
|
|
139
|
+
*
|
|
140
|
+
* var mockEvents;
|
|
141
|
+
*
|
|
142
|
+
* beforeEach(bootstrapViewer('some-xml', function() {
|
|
143
|
+
* mockEvents = new Events();
|
|
144
|
+
*
|
|
145
|
+
* return {
|
|
146
|
+
* events: mockEvents
|
|
147
|
+
* };
|
|
148
|
+
* }));
|
|
149
|
+
*
|
|
150
|
+
* });
|
|
151
|
+
*
|
|
152
|
+
* @param {String} xml document to display
|
|
153
|
+
* @param {Object} (options) optional options to be passed to the diagram upon instantiation
|
|
154
|
+
* @param {Object|Function} locals the local overrides to be used by the diagram or a function that produces them
|
|
155
|
+
* @return {Function} a function to be passed to beforeEach
|
|
156
|
+
*/
|
|
157
|
+
function bootstrapViewer(diagram, options, locals) {
|
|
158
|
+
return bootstrapCmmnJs(Viewer, diagram, options, locals);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Injects services of an instantiated diagram into the argument.
|
|
164
|
+
*
|
|
165
|
+
* Use it in conjunction with {@link #bootstrapModeler} or {@link #bootstrapViewer}.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
*
|
|
169
|
+
* describe(function() {
|
|
170
|
+
*
|
|
171
|
+
* var mockEvents;
|
|
172
|
+
*
|
|
173
|
+
* beforeEach(bootstrapViewer(...));
|
|
174
|
+
*
|
|
175
|
+
* it('should provide mocked events', inject(function(events) {
|
|
176
|
+
* expect(events).to.eql(mockEvents);
|
|
177
|
+
* }));
|
|
178
|
+
*
|
|
179
|
+
* });
|
|
180
|
+
*
|
|
181
|
+
* @param {Function} fn the function to inject to
|
|
182
|
+
* @return {Function} a function that can be passed to it to carry out the injection
|
|
183
|
+
*/
|
|
184
|
+
function inject(fn) {
|
|
185
|
+
return function() {
|
|
186
|
+
|
|
187
|
+
if (!CMMN_JS) {
|
|
188
|
+
throw new Error('no bootstraped cmmn-js instance, ensure you created it via #boostrap(Modeler|Viewer)');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
CMMN_JS.invoke(fn);
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
module.exports.bootstrapModeler = (window || global).bootstrapModeler = bootstrapModeler;
|
|
197
|
+
module.exports.bootstrapViewer = (window || global).bootstrapViewer = bootstrapViewer;
|
|
198
|
+
module.exports.inject = (window || global).inject = inject;
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Returns the current active CmmnJs instance.
|
|
203
|
+
*
|
|
204
|
+
* @return {CmmnJs}
|
|
205
|
+
*/
|
|
206
|
+
module.exports.getCmmnJs = function() {
|
|
207
|
+
return CMMN_JS;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
function insertCSS(name, css) {
|
|
212
|
+
if (document.querySelector('[data-css-file="' + name + '"]')) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var head = document.head || document.getElementsByTagName('head')[0],
|
|
217
|
+
style = document.createElement('style');
|
|
218
|
+
|
|
219
|
+
style.setAttribute('data-css-file', name);
|
|
220
|
+
|
|
221
|
+
style.type = 'text/css';
|
|
222
|
+
if (style.styleSheet) {
|
|
223
|
+
style.styleSheet.cssText = css;
|
|
224
|
+
} else {
|
|
225
|
+
style.appendChild(document.createTextNode(css));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
head.appendChild(style);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
module.exports.insertCSS = insertCSS;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var isString = require('min-dash').isString;
|
|
2
|
+
var assign = require('min-dash').assign;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a fake key event for testing purposes.
|
|
6
|
+
*
|
|
7
|
+
* @param {String|Number} key the key or keyCode/charCode
|
|
8
|
+
* @param {Object} [attrs]
|
|
9
|
+
*
|
|
10
|
+
* @return {Event}
|
|
11
|
+
*/
|
|
12
|
+
function createKeyEvent(key, attrs) {
|
|
13
|
+
var event = document.createEvent('Events') || new document.defaultView.CustomEvent('keyEvent');
|
|
14
|
+
|
|
15
|
+
// init and mark as bubbles / cancelable
|
|
16
|
+
event.initEvent('keydown', false, true);
|
|
17
|
+
|
|
18
|
+
var keyAttrs = isString(key) ? { key: key } : { keyCode: key, which: key };
|
|
19
|
+
|
|
20
|
+
return assign(event, keyAttrs, attrs || {});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports.createKeyEvent = createKeyEvent;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var assign = require('min-dash').assign;
|
|
4
|
+
|
|
5
|
+
var TestHelper = require('../TestHelper');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create an event with global coordinates
|
|
10
|
+
* computed based on the loaded diagrams canvas position and the
|
|
11
|
+
* specified canvas local coordinates.
|
|
12
|
+
*
|
|
13
|
+
* @param {Point} point of the event local the canvas (closure)
|
|
14
|
+
* @param {Object} data
|
|
15
|
+
*
|
|
16
|
+
* @return {Event} event, scoped to the given canvas
|
|
17
|
+
*/
|
|
18
|
+
function createCanvasEvent(position, data) {
|
|
19
|
+
|
|
20
|
+
return TestHelper.getCmmnJs().invoke(function(canvas) {
|
|
21
|
+
|
|
22
|
+
var target = canvas._svg;
|
|
23
|
+
|
|
24
|
+
var clientRect = canvas._container.getBoundingClientRect();
|
|
25
|
+
|
|
26
|
+
var absolutePosition = {
|
|
27
|
+
x: position.x + clientRect.left,
|
|
28
|
+
y: position.y + clientRect.top
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return createEvent(target, absolutePosition, data);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports.createCanvasEvent = createCanvasEvent;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function createEvent(target, position, data) {
|
|
39
|
+
|
|
40
|
+
return TestHelper.getCmmnJs().invoke(function(eventBus) {
|
|
41
|
+
data = assign({
|
|
42
|
+
target: target,
|
|
43
|
+
x: position.x,
|
|
44
|
+
y: position.y,
|
|
45
|
+
clientX: position.x,
|
|
46
|
+
clientY: position.y,
|
|
47
|
+
offsetX: position.x,
|
|
48
|
+
offsetY: position.y
|
|
49
|
+
}, data || {});
|
|
50
|
+
|
|
51
|
+
return eventBus.createEvent(data);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports.createEvent = createEvent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inherits = require('inherits');
|
|
4
|
+
|
|
5
|
+
var RuleProvider = require('diagram-js/lib/features/rules/RuleProvider').default;
|
|
6
|
+
|
|
7
|
+
function CustomRules(eventBus) {
|
|
8
|
+
RuleProvider.call(this, eventBus);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
CustomRules.$inject = [ 'eventBus' ];
|
|
12
|
+
|
|
13
|
+
inherits(CustomRules, RuleProvider);
|
|
14
|
+
|
|
15
|
+
CustomRules.prototype.init = function() {
|
|
16
|
+
// placeholder
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = CustomRules;
|