@jylups/flowable-bpmn-js 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +282 -2
- package/assets/flowable-bpmn-js-touch.css +76 -0
- package/assets/flowable-bpmn-js.css +70 -0
- package/dist/assets/bpmn-font/css/bpmn-codes.css +110 -0
- package/dist/assets/bpmn-font/css/bpmn-embedded.css +168 -0
- package/dist/assets/bpmn-font/css/bpmn.css +166 -0
- package/dist/assets/bpmn-font/font/bpmn.eot +0 -0
- package/dist/assets/bpmn-font/font/bpmn.svg +228 -0
- package/dist/assets/bpmn-font/font/bpmn.ttf +0 -0
- package/dist/assets/bpmn-font/font/bpmn.woff +0 -0
- package/dist/assets/bpmn-font/font/bpmn.woff2 +0 -0
- package/dist/assets/bpmn-js-bpmnlint.css +263 -0
- package/dist/assets/bpmn-js.css +151 -0
- package/dist/assets/diagram-js.css +1325 -0
- package/dist/assets/flowable-bpmn-js-touch.css +76 -0
- package/dist/assets/flowable-bpmn-js.css +70 -0
- package/dist/assets/properties-panel.css +1905 -0
- package/dist/flowable-bpmn-modeler.development.js +128087 -0
- package/dist/flowable-bpmn-modeler.development.js.map +1 -0
- package/dist/flowable-bpmn-modeler.production.min.js +348 -0
- package/dist/flowable-bpmn-navigated-viewer.development.js +28092 -0
- package/dist/flowable-bpmn-navigated-viewer.development.js.map +1 -0
- package/dist/flowable-bpmn-navigated-viewer.production.min.js +2 -0
- package/dist/flowable-bpmn-viewer.development.js +26751 -0
- package/dist/flowable-bpmn-viewer.development.js.map +1 -0
- package/dist/flowable-bpmn-viewer.production.min.js +2 -0
- package/index.d.ts +107 -0
- package/index.js +32 -0
- package/lib/Modeler.js +68 -0
- package/lib/NavigatedViewer.js +30 -0
- package/lib/NewDiagram.js +69 -0
- package/lib/Theme.js +32 -0
- package/lib/Viewer.js +32 -0
- package/lib/distro/Modeler.js +5 -0
- package/lib/distro/NavigatedViewer.js +5 -0
- package/lib/distro/Viewer.js +5 -0
- package/lib/draw/TypedTaskRenderer.js +81 -0
- package/lib/draw/index.js +10 -0
- package/lib/features/touch/InputTracker.js +34 -0
- package/lib/features/touch/LICENSE +21 -0
- package/lib/features/touch/TouchContextPad.js +197 -0
- package/lib/features/touch/TouchInteraction.js +1276 -0
- package/lib/features/touch/TouchLabelEditing.js +60 -0
- package/lib/features/touch/index.js +40 -0
- package/lib/features/typed-tasks/ReplaceWithTypedTaskHandler.js +63 -0
- package/lib/features/typed-tasks/TypedTaskPaletteProvider.js +76 -0
- package/lib/features/typed-tasks/TypedTaskReplaceMenuProvider.js +71 -0
- package/lib/features/typed-tasks/TypedTasks.js +127 -0
- package/lib/features/typed-tasks/icons.js +99 -0
- package/lib/features/typed-tasks/index.js +17 -0
- package/lib/lint/FlowableLinting.js +23 -0
- package/lib/lint/index.js +44 -0
- package/lib/lint/module.js +15 -0
- package/lib/lint/rules/called-element.js +19 -0
- package/lib/lint/rules/service-task-implementation.js +81 -0
- package/lib/lint/rules/valid-durations.js +102 -0
- package/lib/lint/values.js +71 -0
- package/lib/xml/FlowableXML.js +50 -0
- package/lib/xml/index.js +6 -0
- package/package.json +80 -4
package/index.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import BpmnModeler from 'bpmn-js/lib/Modeler.js';
|
|
2
|
+
import BpmnNavigatedViewer from 'bpmn-js/lib/NavigatedViewer.js';
|
|
3
|
+
import BpmnViewer from 'bpmn-js/lib/Viewer.js';
|
|
4
|
+
|
|
5
|
+
import type { ModuleDeclaration } from 'didi';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A bpmn-js modeler for Flowable models, with the Flowable moddle
|
|
9
|
+
* descriptor, the Flowable modeling behaviors, and the bpmn.io properties
|
|
10
|
+
* panel with the Flowable properties provider.
|
|
11
|
+
*
|
|
12
|
+
* Give the properties panel a place with `propertiesPanel: { parent }`.
|
|
13
|
+
*/
|
|
14
|
+
export class Modeler<ServiceMap = null> extends BpmnModeler<ServiceMap> {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Opens a new Flowable process: an executable process with a start event.
|
|
18
|
+
*/
|
|
19
|
+
createDiagram(options?: NewDiagramOptions): ReturnType<BpmnModeler['importXML']>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type NewDiagramOptions = {
|
|
23
|
+
|
|
24
|
+
/** The process key; Process_ and a random suffix by default. */
|
|
25
|
+
processId?: string;
|
|
26
|
+
|
|
27
|
+
processName?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A bpmn-js viewer for Flowable models.
|
|
32
|
+
*/
|
|
33
|
+
export class Viewer<ServiceMap = null> extends BpmnViewer<ServiceMap> {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A bpmn-js viewer with zoom and scroll, for Flowable models.
|
|
37
|
+
*/
|
|
38
|
+
export class NavigatedViewer<ServiceMap = null> extends BpmnNavigatedViewer<ServiceMap> {}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Reads and writes Flowable models: Activiti namespace migration and unknown
|
|
42
|
+
* flowable:* elements on import, definitions for references by code or name,
|
|
43
|
+
* and the flowable prefix on save. Included in Modeler, Viewer and
|
|
44
|
+
* NavigatedViewer.
|
|
45
|
+
*/
|
|
46
|
+
export const FlowableXMLModule: ModuleDeclaration;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Draws the typed service tasks (mail, HTTP, shell, Camel, decision, case,
|
|
50
|
+
* send event, external worker) with their icons. Included in Modeler, Viewer
|
|
51
|
+
* and NavigatedViewer.
|
|
52
|
+
*/
|
|
53
|
+
export const FlowableDrawModule: ModuleDeclaration;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Touch editing for the modeler: tap, drag, pan, pinch zoom, double tap to
|
|
57
|
+
* edit labels, and creating and connecting from the palette and context pad.
|
|
58
|
+
* Optional: add it with `additionalModules`. It turns itself on only where
|
|
59
|
+
* `(pointer: coarse)` matches; `assets/flowable-bpmn-js-touch.css` makes the
|
|
60
|
+
* touch targets larger.
|
|
61
|
+
*/
|
|
62
|
+
export const TouchModule: ModuleDeclaration;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Lints the diagram with the Flowable rules while it is edited
|
|
66
|
+
* (bpmn-js-bpmnlint). Included in Modeler; `linting.active: false` hides the
|
|
67
|
+
* issues, `linting.bpmnlint` sets another linter configuration.
|
|
68
|
+
*/
|
|
69
|
+
export const FlowableLintModule: ModuleDeclaration;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The Flowable lint rules (bpmnlint rule factories) by name.
|
|
73
|
+
*/
|
|
74
|
+
export const FLOWABLE_RULES: Record<string, () => { check(node: any, reporter: any): void }>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A bpmnlint configuration with all Flowable rules as errors.
|
|
78
|
+
*/
|
|
79
|
+
export const flowableLintConfig: { rules: Record<string, string> };
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The `{ config, resolver }` that bpmn-js-bpmnlint takes, for a bpmnlint
|
|
83
|
+
* configuration that uses `flowable/<rule>` rules.
|
|
84
|
+
*/
|
|
85
|
+
export function createFlowableLinterConfig(config?: object): { config: object; resolver: object };
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The XML of a new Flowable process: an executable process with a start
|
|
89
|
+
* event, the Flowable namespace declared, and Flowable's target namespace.
|
|
90
|
+
*/
|
|
91
|
+
export function createNewDiagramXML(options?: NewDiagramOptions): string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The target namespace Flowable's modeler gives new processes.
|
|
95
|
+
*/
|
|
96
|
+
export const FLOWABLE_TARGET_NAMESPACE: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The default renderer colors as CSS custom properties with bpmn-js'
|
|
100
|
+
* defaults as fallbacks: --flowable-shape-fill, --flowable-shape-stroke and
|
|
101
|
+
* --flowable-label-color.
|
|
102
|
+
*/
|
|
103
|
+
export const THEME_COLORS: {
|
|
104
|
+
defaultFillColor: string;
|
|
105
|
+
defaultStrokeColor: string;
|
|
106
|
+
defaultLabelColor: string;
|
|
107
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jylups/flowable-bpmn-js
|
|
3
|
+
*
|
|
4
|
+
* A bpmn-js modeler and viewers for Flowable BPMN models, with the Flowable
|
|
5
|
+
* moddle descriptor, modeling behaviors and properties panel built in:
|
|
6
|
+
*
|
|
7
|
+
* import { Modeler } from '@jylups/flowable-bpmn-js';
|
|
8
|
+
*
|
|
9
|
+
* const modeler = new Modeler({
|
|
10
|
+
* container: '#canvas',
|
|
11
|
+
* propertiesPanel: { parent: '#properties' }
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* await modeler.importXML(xml);
|
|
15
|
+
*/
|
|
16
|
+
export { default as Modeler } from './lib/Modeler.js';
|
|
17
|
+
export { default as Viewer } from './lib/Viewer.js';
|
|
18
|
+
export { default as NavigatedViewer } from './lib/NavigatedViewer.js';
|
|
19
|
+
|
|
20
|
+
export { default as FlowableXMLModule } from './lib/xml/index.js';
|
|
21
|
+
|
|
22
|
+
export { FLOWABLE_TARGET_NAMESPACE, createNewDiagramXML } from './lib/NewDiagram.js';
|
|
23
|
+
export { THEME_COLORS } from './lib/Theme.js';
|
|
24
|
+
export { default as FlowableDrawModule } from './lib/draw/index.js';
|
|
25
|
+
export { default as TouchModule } from './lib/features/touch/index.js';
|
|
26
|
+
export { default as FlowableLintModule } from './lib/lint/module.js';
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
FLOWABLE_RULES,
|
|
30
|
+
createFlowableLinterConfig,
|
|
31
|
+
flowableLintConfig
|
|
32
|
+
} from './lib/lint/index.js';
|
package/lib/Modeler.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import BpmnModeler from 'bpmn-js/lib/Modeler';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BpmnPropertiesPanelModule,
|
|
5
|
+
BpmnPropertiesProviderModule
|
|
6
|
+
} from 'bpmn-js-properties-panel';
|
|
7
|
+
|
|
8
|
+
import { FlowablePropertiesProviderModule } from '@jylups/bpmn-js-properties-panel-flowable';
|
|
9
|
+
import { FlowableBehaviorsModule } from '@jylups/flowable-bpmn-js-behaviors';
|
|
10
|
+
import flowableDescriptor from '@jylups/flowable-bpmn-moddle';
|
|
11
|
+
|
|
12
|
+
import FlowableXMLModule from './xml/index.js';
|
|
13
|
+
import { withThemeColors } from './Theme.js';
|
|
14
|
+
import { createNewDiagramXML } from './NewDiagram.js';
|
|
15
|
+
import FlowableDrawModule from './draw/index.js';
|
|
16
|
+
import TypedTasksModule from './features/typed-tasks/index.js';
|
|
17
|
+
import FlowableLintModule from './lint/module.js';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A bpmn-js modeler for Flowable models, with the Flowable moddle
|
|
22
|
+
* descriptor, the Flowable modeling behaviors, the bpmn.io properties
|
|
23
|
+
* panel with the Flowable properties provider, palette and replace menu
|
|
24
|
+
* entries for the typed service tasks, and linting with the Flowable rules.
|
|
25
|
+
* Models are read and written as described in FlowableXML; createDiagram
|
|
26
|
+
* opens a new Flowable process, and colors follow the theme hooks in Theme.
|
|
27
|
+
*
|
|
28
|
+
* Give the properties panel a place with `propertiesPanel: { parent }`, or
|
|
29
|
+
* attach it later with `modeler.get('propertiesPanel').attachTo(parent)`.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} [options] - as for bpmn-js' Modeler
|
|
32
|
+
*/
|
|
33
|
+
export default class Modeler extends BpmnModeler {
|
|
34
|
+
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super(withThemeColors(options));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Opens a new Flowable process: an executable process with a start event
|
|
41
|
+
* (see createNewDiagramXML).
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} [options] - processId and processName
|
|
44
|
+
*/
|
|
45
|
+
createDiagram(options) {
|
|
46
|
+
return this.importXML(createNewDiagramXML(options));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Modeler.prototype._flowableModules = [
|
|
51
|
+
FlowableXMLModule,
|
|
52
|
+
FlowableDrawModule,
|
|
53
|
+
FlowableBehaviorsModule,
|
|
54
|
+
BpmnPropertiesPanelModule,
|
|
55
|
+
BpmnPropertiesProviderModule,
|
|
56
|
+
FlowablePropertiesProviderModule,
|
|
57
|
+
TypedTasksModule,
|
|
58
|
+
FlowableLintModule
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
Modeler.prototype._modules = [
|
|
62
|
+
...BpmnModeler.prototype._modules,
|
|
63
|
+
...Modeler.prototype._flowableModules
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
Modeler.prototype._moddleExtensions = {
|
|
67
|
+
flowable: flowableDescriptor
|
|
68
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import BpmnNavigatedViewer from 'bpmn-js/lib/NavigatedViewer';
|
|
2
|
+
|
|
3
|
+
import flowableDescriptor from '@jylups/flowable-bpmn-moddle';
|
|
4
|
+
|
|
5
|
+
import FlowableXMLModule from './xml/index.js';
|
|
6
|
+
import { withThemeColors } from './Theme.js';
|
|
7
|
+
import FlowableDrawModule from './draw/index.js';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A bpmn-js viewer with zoom and scroll, for Flowable models.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} [options] - as for bpmn-js' NavigatedViewer
|
|
14
|
+
*/
|
|
15
|
+
export default class NavigatedViewer extends BpmnNavigatedViewer {
|
|
16
|
+
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(withThemeColors(options));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
NavigatedViewer.prototype._modules = [
|
|
23
|
+
...BpmnNavigatedViewer.prototype._modules,
|
|
24
|
+
FlowableXMLModule,
|
|
25
|
+
FlowableDrawModule
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
NavigatedViewer.prototype._moddleExtensions = {
|
|
29
|
+
flowable: flowableDescriptor
|
|
30
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New Flowable process diagrams.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const ID_PATTERN = /^[A-Za-z_][\w.-]*$/;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The target namespace Flowable's own modeler gives new processes.
|
|
9
|
+
*/
|
|
10
|
+
export const FLOWABLE_TARGET_NAMESPACE = 'http://www.flowable.org/processdef';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The XML of a new process: one executable process with a start event, the
|
|
14
|
+
* Flowable namespace declared, and Flowable's default target namespace.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} [options]
|
|
17
|
+
* @param {string} [options.processId] - the process key; Process_ and a
|
|
18
|
+
* random suffix by default
|
|
19
|
+
* @param {string} [options.processName]
|
|
20
|
+
*
|
|
21
|
+
* @return {string}
|
|
22
|
+
*/
|
|
23
|
+
export function createNewDiagramXML(options = {}) {
|
|
24
|
+
const processId = options.processId || `Process_${ randomSuffix() }`;
|
|
25
|
+
const processName = options.processName;
|
|
26
|
+
|
|
27
|
+
if (!ID_PATTERN.test(processId)) {
|
|
28
|
+
throw new Error(`invalid process id <${ processId }>: use letters, digits, _, - and ., starting with a letter or _`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const name = processName ? ` name="${ escapeXML(processName) }"` : '';
|
|
32
|
+
|
|
33
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
34
|
+
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
|
35
|
+
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
|
|
36
|
+
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
|
|
37
|
+
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
|
|
38
|
+
xmlns:flowable="http://flowable.org/bpmn"
|
|
39
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
40
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
41
|
+
typeLanguage="http://www.w3.org/2001/XMLSchema"
|
|
42
|
+
expressionLanguage="http://www.w3.org/1999/XPath"
|
|
43
|
+
targetNamespace="${ FLOWABLE_TARGET_NAMESPACE }"
|
|
44
|
+
id="Definitions_${ randomSuffix() }">
|
|
45
|
+
<process id="${ processId }"${ name } isExecutable="true">
|
|
46
|
+
<startEvent id="StartEvent_1" />
|
|
47
|
+
</process>
|
|
48
|
+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
|
49
|
+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="${ processId }">
|
|
50
|
+
<bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1">
|
|
51
|
+
<dc:Bounds x="152" y="102" width="36" height="36" />
|
|
52
|
+
</bpmndi:BPMNShape>
|
|
53
|
+
</bpmndi:BPMNPlane>
|
|
54
|
+
</bpmndi:BPMNDiagram>
|
|
55
|
+
</definitions>
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function randomSuffix() {
|
|
60
|
+
return Math.random().toString(36).slice(2, 9);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function escapeXML(value) {
|
|
64
|
+
return String(value)
|
|
65
|
+
.replace(/&/g, '&')
|
|
66
|
+
.replace(/</g, '<')
|
|
67
|
+
.replace(/>/g, '>')
|
|
68
|
+
.replace(/"/g, '"');
|
|
69
|
+
}
|
package/lib/Theme.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme hooks: the renderers' default colors are CSS custom properties, so
|
|
3
|
+
* a page can restyle shapes and labels with CSS only, for example for a
|
|
4
|
+
* dark theme. Their fallbacks are bpmn-js' own defaults, so nothing changes
|
|
5
|
+
* when they aren't set, and SVG exports use the fallbacks.
|
|
6
|
+
*
|
|
7
|
+
* --flowable-shape-fill shape fill (white)
|
|
8
|
+
* --flowable-shape-stroke shape outline, connections and icons
|
|
9
|
+
* --flowable-label-color label text (the stroke color by default)
|
|
10
|
+
*
|
|
11
|
+
* Colors set on single elements (color picker, bioc:fill) still win. An app
|
|
12
|
+
* that passes its own `bpmnRenderer` colors keeps them.
|
|
13
|
+
*/
|
|
14
|
+
export const THEME_COLORS = {
|
|
15
|
+
defaultFillColor: 'var(--flowable-shape-fill, white)',
|
|
16
|
+
defaultStrokeColor: 'var(--flowable-shape-stroke, hsl(225, 10%, 15%))',
|
|
17
|
+
defaultLabelColor: 'var(--flowable-label-color, var(--flowable-shape-stroke, hsl(225, 10%, 15%)))'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Constructor options with the theme colors as `bpmnRenderer` defaults.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} [options]
|
|
24
|
+
*
|
|
25
|
+
* @return {Object}
|
|
26
|
+
*/
|
|
27
|
+
export function withThemeColors(options = {}) {
|
|
28
|
+
return {
|
|
29
|
+
...options,
|
|
30
|
+
bpmnRenderer: { ...THEME_COLORS, ...options.bpmnRenderer }
|
|
31
|
+
};
|
|
32
|
+
}
|
package/lib/Viewer.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import BpmnViewer from 'bpmn-js/lib/Viewer';
|
|
2
|
+
|
|
3
|
+
import flowableDescriptor from '@jylups/flowable-bpmn-moddle';
|
|
4
|
+
|
|
5
|
+
import FlowableXMLModule from './xml/index.js';
|
|
6
|
+
import { withThemeColors } from './Theme.js';
|
|
7
|
+
import FlowableDrawModule from './draw/index.js';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A bpmn-js viewer for Flowable models: the Flowable moddle descriptor is
|
|
12
|
+
* registered, and models are read and written as described in
|
|
13
|
+
* FlowableXML.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} [options] - as for bpmn-js' Viewer
|
|
16
|
+
*/
|
|
17
|
+
export default class Viewer extends BpmnViewer {
|
|
18
|
+
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(withThemeColors(options));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Viewer.prototype._modules = [
|
|
25
|
+
...BpmnViewer.prototype._modules,
|
|
26
|
+
FlowableXMLModule,
|
|
27
|
+
FlowableDrawModule
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
Viewer.prototype._moddleExtensions = {
|
|
31
|
+
flowable: flowableDescriptor
|
|
32
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import BaseRenderer from 'diagram-js/lib/draw/BaseRenderer';
|
|
2
|
+
|
|
3
|
+
import { getStrokeColor } from 'bpmn-js/lib/draw/BpmnRenderUtil';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
append as svgAppend,
|
|
7
|
+
attr as svgAttr,
|
|
8
|
+
classes as svgClasses,
|
|
9
|
+
create as svgCreate
|
|
10
|
+
} from 'tiny-svg';
|
|
11
|
+
|
|
12
|
+
import { ICONS, ICON_STYLE } from '../features/typed-tasks/icons.js';
|
|
13
|
+
import { getTypedTask } from '../features/typed-tasks/TypedTasks.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Above the BpmnRenderer, so typed service tasks are drawn here.
|
|
17
|
+
*/
|
|
18
|
+
const HIGH_PRIORITY = 1500;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Icon size and place, as bpmn-js places its task type icons.
|
|
22
|
+
*/
|
|
23
|
+
const ICON_SIZE = 18;
|
|
24
|
+
const ICON_OFFSET = 5;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Draws a typed service task as a task with its type's icon in the top left
|
|
29
|
+
* corner, instead of the service task gear.
|
|
30
|
+
*/
|
|
31
|
+
export default class TypedTaskRenderer extends BaseRenderer {
|
|
32
|
+
|
|
33
|
+
constructor(config, eventBus, bpmnRenderer) {
|
|
34
|
+
super(eventBus, HIGH_PRIORITY);
|
|
35
|
+
|
|
36
|
+
this._bpmnRenderer = bpmnRenderer;
|
|
37
|
+
this._defaultStrokeColor = config && config.defaultStrokeColor;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
canRender(element) {
|
|
41
|
+
return !element.labelTarget && !!getTypedTask(element);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
drawShape(parentGfx, element, attrs) {
|
|
45
|
+
const shape = this._bpmnRenderer.handlers['bpmn:Task'](parentGfx, element, attrs);
|
|
46
|
+
|
|
47
|
+
this._drawIcon(parentGfx, element, attrs);
|
|
48
|
+
|
|
49
|
+
return shape;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getShapePath(element) {
|
|
53
|
+
return this._bpmnRenderer.getShapePath(element);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_drawIcon(parentGfx, element, attrs = {}) {
|
|
57
|
+
const { type } = getTypedTask(element);
|
|
58
|
+
const scale = ICON_SIZE / 24;
|
|
59
|
+
|
|
60
|
+
const group = svgCreate('g');
|
|
61
|
+
|
|
62
|
+
svgClasses(group).add('flowable-task-icon');
|
|
63
|
+
svgAttr(group, {
|
|
64
|
+
'data-type': type,
|
|
65
|
+
transform: `translate(${ ICON_OFFSET }, ${ ICON_OFFSET }) scale(${ scale })`,
|
|
66
|
+
...ICON_STYLE,
|
|
67
|
+
stroke: getStrokeColor(element, this._defaultStrokeColor, attrs.stroke)
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
ICONS[type].forEach(([ tag, iconAttrs ]) => {
|
|
71
|
+
const node = svgCreate(tag);
|
|
72
|
+
|
|
73
|
+
svgAttr(node, iconAttrs);
|
|
74
|
+
svgAppend(group, node);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
svgAppend(parentGfx, group);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
TypedTaskRenderer.$inject = [ 'config.bpmnRenderer', 'eventBus', 'bpmnRenderer' ];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import TypedTaskRenderer from './TypedTaskRenderer.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Draws the typed service tasks with their icons; part of the modeler and
|
|
5
|
+
* the viewers.
|
|
6
|
+
*/
|
|
7
|
+
export default {
|
|
8
|
+
__init__: [ 'typedTaskRenderer' ],
|
|
9
|
+
typedTaskRenderer: [ 'type', TypedTaskRenderer ]
|
|
10
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which kind of pointer was pressed last. An iPad with a trackpad or a mouse
|
|
3
|
+
* still matches (pointer: coarse), so the touch module's replacements for the
|
|
4
|
+
* lasso, space and global connect tools would otherwise wait for a finger
|
|
5
|
+
* after a click. A pen counts as touch, since iOS sends touch events for it
|
|
6
|
+
* too.
|
|
7
|
+
*
|
|
8
|
+
* @param {EventTarget} [target] where presses are listened to, the document by default
|
|
9
|
+
*
|
|
10
|
+
* @return {{ isMouse: function(): boolean, destroy: function() }}
|
|
11
|
+
*/
|
|
12
|
+
export function createInputTracker(target) {
|
|
13
|
+
target = target || document;
|
|
14
|
+
|
|
15
|
+
var lastIsMouse = false;
|
|
16
|
+
|
|
17
|
+
function onPointerDown(event) {
|
|
18
|
+
lastIsMouse = event.pointerType === 'mouse';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
target.addEventListener('pointerdown', onPointerDown, true);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
|
|
25
|
+
/** Whether the last press came from a mouse or a trackpad. */
|
|
26
|
+
isMouse: function() {
|
|
27
|
+
return lastIsMouse;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
destroy: function() {
|
|
31
|
+
target.removeEventListener('pointerdown', onPointerDown, true);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michał Krasucki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|