├── .github
└── workflows
│ └── CI.yml
├── .gitignore
├── README.md
├── bpmn-properties
├── README.md
├── karma.conf.js
├── package.json
└── test
│ ├── TestHelper.js
│ └── spec
│ ├── BpmnPropertiesSpec.js
│ └── diagram.bpmn
├── bundling
├── README.md
├── package.json
├── resources
│ ├── pizza-collaboration.bpmn
│ └── screenshot.png
├── src
│ ├── app.js
│ └── index.html
├── webpack.config.js
└── webpack.es5.config.js
├── colors
├── README.md
├── index.html
├── resources
│ └── pizza-collaboration.bpmn
└── screenshot.png
├── commenting
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ ├── pizza-collaboration-annotated.bpmn
│ └── pizza-collaboration.bpmn
├── src
│ ├── app.js
│ ├── font
│ │ ├── LICENSE.txt
│ │ ├── bpmn-js-comments.eot
│ │ ├── bpmn-js-comments.svg
│ │ ├── bpmn-js-comments.ttf
│ │ ├── bpmn-js-comments.woff
│ │ └── config.json
│ ├── index.html
│ └── style.css
└── webpack.config.js
├── custom-bower-bundle
└── README.md
├── custom-bundle
├── README.md
├── index.html
├── package.json
├── rollup.config.js
└── src
│ ├── custom-viewer.js
│ └── features
│ └── logging
│ ├── InteractionLogger.js
│ └── index.js
├── custom-elements
├── README.md
└── docs
│ ├── screenshot-custom-editor-controls.png
│ ├── screenshot-custom-elements.png
│ ├── screenshot-custom-rendering.png
│ └── screenshot-model-extension.png
├── custom-meta-model
├── README.md
├── package.json
├── resources
│ ├── qa.json
│ ├── sample.bpmn
│ └── screenshot.png
├── src
│ ├── app.js
│ └── index.html
└── webpack.config.js
├── custom-modeling-rules
├── README.md
├── karma.conf.js
├── lib
│ └── custom-rules
│ │ ├── CustomRules.js
│ │ └── index.js
├── package.json
└── test
│ ├── TestHelper.js
│ └── spec
│ ├── CustomRulesSpec.js
│ └── diagram.bpmn
├── deep-linking
├── README.md
├── package.json
├── resources
│ ├── nested-subprocesses.bpmn
│ └── screenshot.png
├── src
│ ├── app.js
│ └── index.html
└── webpack.config.js
├── embedding
├── .gitignore
├── README.md
├── docs
│ └── screenshot.png
├── package-lock.json
├── package.json
├── src
│ ├── app.js
│ ├── diagrams
│ │ ├── first.bpmn
│ │ ├── overview.bpmn
│ │ └── second.bpmn
│ ├── index.html
│ └── style.css
└── webpack.config.js
├── eslint.config.mjs
├── i18n
├── README.md
├── package.json
├── resources
│ ├── newDiagram.bpmn
│ └── screenshot.png
├── src
│ ├── app.js
│ ├── customTranslate
│ │ ├── customTranslate.js
│ │ └── translations.js
│ └── index.html
└── webpack.config.js
├── interaction
├── README.md
└── index.html
├── lerna.json
├── minimap
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ └── pizza-collaboration.bpmn
├── src
│ ├── app.js
│ ├── index.html
│ └── style.css
└── webpack.config.js
├── modeler
├── .gitignore
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ └── newDiagram.bpmn
├── src
│ ├── app.js
│ ├── index.html
│ └── style.css
└── webpack.config.js
├── modeling-api
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ ├── diagram.bpmn
│ └── editingElements.bpmn
├── src
│ ├── app.js
│ ├── index.html
│ ├── snippets
│ │ ├── businessObjects.js
│ │ ├── collaborations.js
│ │ ├── connectingShapes.js
│ │ ├── creatingShapes.js
│ │ ├── editingElements.js
│ │ ├── index.js
│ │ └── introduction.js
│ └── style.css
└── webpack.config.js
├── overlays
├── README.md
├── docs
│ ├── qr-code.gif
│ └── qr-code.png
├── package.json
├── resources
│ └── qr-code.bpmn
├── src
│ ├── app.js
│ └── index.html
└── webpack.config.js
├── package-lock.json
├── package.json
├── pre-packaged
└── README.md
├── properties-panel-async-extension
├── README.md
├── docs
│ └── screencapture.gif
├── package.json
├── resources
│ └── newDiagram.bpmn
├── server.js
├── src
│ ├── app.js
│ ├── descriptors
│ │ └── magic.json
│ ├── index.html
│ ├── provider
│ │ └── magic
│ │ │ ├── MagicPropertiesProvider.js
│ │ │ ├── index.js
│ │ │ └── parts
│ │ │ └── SpellProps.js
│ └── style.less
└── webpack.config.js
├── properties-panel-extension
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ └── newDiagram.bpmn
├── src
│ ├── app.js
│ ├── descriptors
│ │ └── magic.json
│ ├── index.html
│ ├── provider
│ │ └── magic
│ │ │ ├── MagicPropertiesProvider.js
│ │ │ ├── index.js
│ │ │ └── parts
│ │ │ └── SpellProps.js
│ └── style.less
└── webpack.config.js
├── properties-panel-list-extension
├── .gitignore
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ └── newDiagram.bpmn
├── src
│ ├── app.js
│ ├── descriptors
│ │ └── magic.json
│ ├── index.html
│ ├── provider
│ │ └── magic
│ │ │ ├── MagicPropertiesProvider.js
│ │ │ ├── index.js
│ │ │ ├── parts
│ │ │ ├── ExtensionList.js
│ │ │ ├── ExtensionProps.js
│ │ │ ├── ParameterProps.js
│ │ │ └── ParametersProps.js
│ │ │ └── util.js
│ └── style.less
└── webpack.config.js
├── properties-panel
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ └── newDiagram.bpmn
├── src
│ ├── app.js
│ ├── index.html
│ └── style.less
└── webpack.config.js
├── renovate.json
├── simple-bower
└── README.md
├── simple-commonjs
└── README.md
├── starter
├── README.md
├── diagram.bpmn
├── modeler.html
├── viewer.html
└── viewer.png
├── theming
├── README.md
├── docs
│ └── screenshot.png
├── index.html
├── package.json
├── resources
│ ├── kitchen-sink.bpmn
│ └── pizza-collaboration.bpmn
├── rollup.config.js
└── src
│ └── custom-viewer.js
├── transaction-boundaries
├── README.md
├── docs
│ └── screenshot.png
├── package.json
├── resources
│ └── transaction-boundaries.bpmn
├── src
│ ├── app.js
│ ├── index.html
│ └── style.css
└── webpack.config.js
├── types
├── README.md
├── package.json
├── src
│ ├── app.js
│ └── app.ts
└── tsconfig.json
└── url-viewer
├── README.md
├── index.html
└── resources
├── pizza-collaboration.bpmn
└── screenshot.png
/.github/workflows/CI.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on: [ push, pull_request ]
3 | jobs:
4 | Build:
5 |
6 | strategy:
7 | matrix:
8 | os: [ ubuntu-latest ]
9 | node-version: [ 20 ]
10 | runs-on: ${{ matrix.os }}
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v4
14 | - name: Use Node.js
15 | uses: actions/setup-node@v4
16 | with:
17 | node-version: ${{ matrix.node-version }}
18 | cache: 'npm'
19 | - name: Install dependencies
20 | run: npm ci
21 | - name: Project setup
22 | uses: bpmn-io/actions/setup@latest
23 | - name: Build examples
24 | run: npm run build
25 | - name: Lint examples
26 | run: npm run lint
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | public/
3 | dist/
4 | .idea
5 | *.iml
6 | .DS_Store
7 | npm-debug.log
--------------------------------------------------------------------------------
/bpmn-properties/README.md:
--------------------------------------------------------------------------------
1 | # bpmn properties
2 |
3 | This example shows how to use [bpmn-js](https://github.com/bpmn-io/bpmn-js) to access BPMN properties behind certain diagram elements.
4 |
5 |
6 | ## About
7 |
8 | Each diagram element stores a reference to the underlying BPMN element via the `businessObject` property. The business object is the actual element that gets imported from BPMN 2.0 XML and serialized during export. Use the business object to read and write BPMN specific properties.
9 |
10 |
11 | #### Reading BPMN Properties
12 |
13 | To read BPMN properties, obtain a reference to a diagram elements business object.
14 |
15 | ```javascript
16 | var elementRegistry = bpmnJS.get('elementRegistry');
17 |
18 | var sequenceFlowElement = elementRegistry.get('SequenceFlow_1'),
19 | sequenceFlow = sequenceFlowElement.businessObject;
20 |
21 | sequenceFlow.name; // 'YES'
22 | sequenceFlow.conditionExpression; // ModdleElement { $type: 'bpmn:FormalExpression', ... }
23 | ```
24 |
25 |
26 | #### Writing BPMN properties
27 |
28 | To write a BPMN property, simply set it on the business object.
29 |
30 | > Check out the [`bpmn.json` meta-model descriptor](https://github.com/bpmn-io/bpmn-moddle/blob/main/resources/bpmn/json/bpmn.json) to learn about BPMN types, their properties and relationships.
31 |
32 | ```javascript
33 | var moddle = bpmnJS.get('moddle');
34 |
35 | // create a BPMN element that can be serialized to XML during export
36 | var newCondition = moddle.create('bpmn:FormalExpression', {
37 | body: '${ value > 100 }'
38 | });
39 |
40 | // write property, no undo support
41 | sequenceFlow.conditionExpression = newCondition;
42 | ```
43 |
44 | In order to get undo/redo support you need to dispatch the property update through our modeling stack:
45 |
46 | ```javascript
47 | var modeling = bpmnJS.get('modeling');
48 |
49 | modeling.updateProperties(sequenceFlowElement, {
50 | conditionExpression: newCondition
51 | });
52 | ```
53 |
54 | > Implement your own [`CommandHandler`](https://github.com/bpmn-io/diagram-js/blob/main/lib/command/CommandHandler.js) to perform more advanced atomic updates.
55 |
56 | Both ways will eventually serialize the condition to XML.
57 |
58 | To learn more, check out [an example diagram](./test/spec/diagram.bpmn) and the accompanying [test cases](./test/spec/BpmnPropertiesSpec.js).
59 |
60 |
61 | ## Building
62 |
63 | One time installation of all dependencies via [npm](https://npmjs.org):
64 |
65 | ```
66 | npm install
67 | ```
68 |
69 |
70 | Execute the test suite to spin up the example in your browser:
71 |
72 | ```
73 | npm run dev
74 | ```
75 |
76 | Go to [localhost:9876/debug.html](http://localhost:9876/debug.html) to inspect the example in your Browser.
77 |
78 |
79 | ## License
80 |
81 | MIT
--------------------------------------------------------------------------------
/bpmn-properties/karma.conf.js:
--------------------------------------------------------------------------------
1 | // use puppeteer provided Chrome for testing
2 | process.env.CHROME_BIN = require('puppeteer').executablePath();
3 |
4 | // configures browsers to run test against
5 | // any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'Safari' ]
6 | const browsers = (process.env.TEST_BROWSERS || 'ChromeHeadless').split(',');
7 |
8 | module.exports = function(karma) {
9 | karma.set({
10 |
11 | frameworks: [
12 | 'webpack',
13 | 'mocha',
14 | 'chai'
15 | ],
16 |
17 | files: [
18 | 'test/spec/**/*Spec.js'
19 | ],
20 |
21 | reporters: [ 'dots' ],
22 |
23 | preprocessors: {
24 | 'test/spec/**/*Spec.js': [ 'webpack' ]
25 | },
26 |
27 | browsers,
28 |
29 | singleRun: true,
30 | autoWatch: false,
31 |
32 | webpack: {
33 | mode: 'development',
34 | module: {
35 | rules: [
36 | {
37 | test: /\.css|\.bpmn$/,
38 | type: 'asset/source'
39 | }
40 | ]
41 | },
42 | devtool: 'eval-source-map'
43 | }
44 | });
45 | };
46 |
--------------------------------------------------------------------------------
/bpmn-properties/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-bpmn-properties",
3 | "version": "0.0.0",
4 | "description": "An example how to read and write custom BPMN 2.0 extensions",
5 | "scripts": {
6 | "all": "run-s test",
7 | "dev": "npm test -- --auto-watch --no-single-run",
8 | "test": "karma start"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
13 | },
14 | "keywords": [
15 | "bpmnjs-example"
16 | ],
17 | "author": {
18 | "name": "Nico Rehwaldt",
19 | "url": "https://github.com/nikku"
20 | },
21 | "contributors": [
22 | {
23 | "name": "bpmn.io contributors",
24 | "url": "https://github.com/bpmn-io"
25 | }
26 | ],
27 | "license": "MIT",
28 | "devDependencies": {
29 | "chai": "^4.5.0",
30 | "karma": "^6.4.4",
31 | "karma-browserify": "^8.0.0",
32 | "karma-chai": "^0.1.0",
33 | "karma-chrome-launcher": "^3.2.0",
34 | "karma-firefox-launcher": "^2.1.3",
35 | "karma-mocha": "^2.0.0",
36 | "karma-webpack": "^5.0.1",
37 | "mocha": "^10.8.2",
38 | "mocha-test-container-support": "^0.2.0",
39 | "npm-run-all2": "^8.0.0",
40 | "puppeteer": "^24.0.0",
41 | "webpack": "^5.97.1"
42 | },
43 | "dependencies": {
44 | "bpmn-js": "^18.6.2"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/bpmn-properties/test/TestHelper.js:
--------------------------------------------------------------------------------
1 | export * from 'bpmn-js/test/helper';
2 |
3 | import {
4 | insertCSS
5 | } from 'bpmn-js/test/helper';
6 |
7 | insertCSS('diagram-js.css', require('bpmn-js/dist/assets/diagram-js.css'));
8 | insertCSS('bpmn-embedded.css', require('bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'));
9 |
10 | insertCSS('diagram-js-testing.css',
11 | '.test-container .result { height: 500px; }' + '.test-container > div'
12 | );
--------------------------------------------------------------------------------
/bpmn-properties/test/spec/BpmnPropertiesSpec.js:
--------------------------------------------------------------------------------
1 | import {
2 | bootstrapModeler,
3 | inject
4 | } from '../TestHelper';
5 |
6 | import coreModule from 'bpmn-js/lib/core';
7 | import modelingModule from 'bpmn-js/lib/features/modeling';
8 |
9 |
10 | describe('bpmn properties', function() {
11 |
12 | var testModules = [
13 | coreModule,
14 | modelingModule
15 | ];
16 |
17 |
18 | var diagramXML = require('./diagram.bpmn');
19 |
20 | beforeEach(bootstrapModeler(diagramXML, {
21 | modules: testModules
22 | }));
23 |
24 |
25 | describe('read properties', function() {
26 |
27 | it('should read name', inject(function(elementRegistry) {
28 |
29 | // given
30 | var sequenceFlowElement = elementRegistry.get('SequenceFlow_1'),
31 | sequenceFlow = sequenceFlowElement.businessObject;
32 |
33 | // when
34 | var name = sequenceFlow.name;
35 |
36 | // then
37 | expect(name).to.eql('FOO > BAR?');
38 | }));
39 |
40 |
41 | it('should read conditionExpression', inject(function(elementRegistry) {
42 |
43 | // given
44 | var sequenceFlowElement = elementRegistry.get('SequenceFlow_1'),
45 | sequenceFlow = sequenceFlowElement.businessObject;
46 |
47 | // when
48 | var condition = sequenceFlow.conditionExpression;
49 |
50 | // then
51 | expect(condition.body).to.eql('${foo > bar}');
52 | }));
53 |
54 | });
55 |
56 |
57 | describe('write properties', function() {
58 |
59 | it('should write conditionExpression', inject(
60 | function(elementRegistry, moddle, modeling) {
61 |
62 | // given
63 | var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
64 | sequenceFlow = sequenceFlowElement.businessObject;
65 |
66 | var newCondition = moddle.create('bpmn:FormalExpression', {
67 | body: '${ value > 100 }'
68 | });
69 |
70 | // assume
71 | expect(sequenceFlow.conditionExpression).not.to.exist;
72 |
73 | // when
74 | modeling.updateProperties(sequenceFlowElement, {
75 | conditionExpression: newCondition
76 | });
77 |
78 | // then
79 | expect(sequenceFlow.conditionExpression).to.equal(newCondition);
80 | }
81 | ));
82 |
83 |
84 | it('should undo write conditionExpression', inject(
85 | function(elementRegistry, moddle, modeling, commandStack) {
86 |
87 | // given
88 | var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
89 | sequenceFlow = sequenceFlowElement.businessObject;
90 |
91 | var newCondition = moddle.create('bpmn:FormalExpression', {
92 | body: '${ value > 100 }'
93 | });
94 |
95 | modeling.updateProperties(sequenceFlowElement, {
96 | conditionExpression: newCondition
97 | });
98 |
99 |
100 | // when
101 | commandStack.undo();
102 |
103 | // then
104 | expect(sequenceFlow.conditionExpression).not.to.exist;
105 | }
106 | ));
107 |
108 | });
109 |
110 | });
111 |
--------------------------------------------------------------------------------
/bpmn-properties/test/spec/diagram.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SequenceFlow_1
6 |
7 |
8 | SequenceFlow_1
9 | SequenceFlow_2
10 |
11 |
12 | bar}]]>
13 |
14 |
15 | SequenceFlow_2
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/bundling/README.md:
--------------------------------------------------------------------------------
1 |
2 | # bpmn-js bundling example
3 |
4 | This example showcases how add and bundle [bpmn-js](https://github.com/bpmn-io/bpmn-js)
5 | along with a node-style web application using [Webpack](https://webpack.js.org).
6 |
7 |
8 | ## About
9 |
10 | This example uses bpmn-js to embed the [pizza collaboration](http://demo.bpmn.io/s/pizza-collaboration) diagram into a web application.
11 |
12 | 
13 |
14 |
15 | ## Usage Summary
16 |
17 | Install bpmn-js via [npm](http://npmjs.org)
18 |
19 | ```
20 | npm install --save bpmn-js
21 | ```
22 |
23 | Use it in your application
24 |
25 | ```javascript
26 | import BpmnViewer from 'bpmn-js';
27 |
28 | var viewer = new BpmnViewer({
29 | container: '#canvas'
30 | });
31 |
32 |
33 | viewer.importXML(pizzaDiagram).then(function(result) {
34 |
35 | const { warnings } = result;
36 |
37 | console.log('success !', warnings);
38 |
39 | viewer.get('canvas').zoom('fit-viewport');
40 | }).catch(function(err) {
41 |
42 | const { warnings, message } = err;
43 |
44 | console.log('something went wrong:', warnings, message);
45 | });
46 | ```
47 |
48 | Bundle the `src/app.js` file for the browser with Webpack:
49 |
50 | ```
51 | webpack ./src/app.js -o public/app.bundled.js --mode development
52 | ```
53 |
54 | To learn about more bundling options, checkout the [webpack-cli documentation](https://webpack.js.org/api/cli/).
55 |
56 | __Note:__ You may use another ES module aware bundler such as [Rollup](https://rollupjs.org), too.
57 | Browserify may also be used but must be properly configured via a global babelify transform.
58 |
59 | ### Bundling to ES5
60 |
61 | If your application needs to support old browsers, you need to transpile the code to ES5.
62 | This can be achieved via
63 |
64 | ```
65 | npm run build:es5
66 | ```
67 |
68 | After the operation finishes, run
69 |
70 | ```
71 | npm run open
72 | ```
73 |
74 | to open the application in the browser.
75 |
76 | Inspect [webpack.es5.config.js](webpack.es5.config.js) to check how webpack can be configured to transpile your application with [babel](https://babeljs.io/).
77 |
78 | ## Building the Example
79 |
80 | Install the project dependencies via
81 |
82 | ```
83 | npm install
84 | ```
85 |
86 | To create the sample distribution in the `public` folder run
87 |
88 | ```
89 | npm run all
90 | ```
91 |
92 |
93 | ## License
94 |
95 | MIT
96 |
--------------------------------------------------------------------------------
/bundling/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bundling",
3 | "version": "0.0.0",
4 | "description": "An example how to bundle an app using bpmn-js for the browser",
5 | "scripts": {
6 | "all": "run-s build build:es5",
7 | "build": "webpack",
8 | "build:es5": "webpack --config webpack.es5.config.js",
9 | "build:watch": "webpack -w",
10 | "open": "open-cli ./public/index.html",
11 | "dev": "run-p bundle:watch open"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
16 | },
17 | "keywords": [
18 | "bpmnjs-example"
19 | ],
20 | "author": {
21 | "name": "Nico Rehwaldt",
22 | "url": "https://github.com/nikku"
23 | },
24 | "contributors": [
25 | {
26 | "name": "bpmn.io contributors",
27 | "url": "https://github.com/bpmn-io"
28 | }
29 | ],
30 | "license": "MIT",
31 | "devDependencies": {
32 | "@babel/core": "^7.26.0",
33 | "@babel/preset-env": "^7.26.0",
34 | "babel-loader": "^10.0.0",
35 | "copy-webpack-plugin": "^13.0.0",
36 | "npm-run-all2": "^8.0.0",
37 | "open-cli": "^8.0.0",
38 | "webpack": "^5.97.1",
39 | "webpack-cli": "^6.0.1"
40 | },
41 | "dependencies": {
42 | "bpmn-js": "^18.6.2"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/bundling/resources/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/bundling/resources/screenshot.png
--------------------------------------------------------------------------------
/bundling/src/app.js:
--------------------------------------------------------------------------------
1 | // we use stringify to inline an example XML document
2 | import pizzaDiagram from '../resources/pizza-collaboration.bpmn';
3 |
4 |
5 | // make sure you added bpmn-js to your your project
6 | // dependencies via npm install --save bpmn-js
7 | import BpmnViewer from 'bpmn-js';
8 |
9 | var viewer = new BpmnViewer({
10 | container: '#canvas'
11 | });
12 |
13 |
14 | viewer.importXML(pizzaDiagram).then(function(result) {
15 |
16 | const { warnings } = result;
17 |
18 | console.log('success !', warnings);
19 |
20 | viewer.get('canvas').zoom('fit-viewport');
21 | }).catch(function(err) {
22 |
23 | const { warnings, message } = err;
24 |
25 | console.log('something went wrong:', warnings, message);
26 | });
27 |
--------------------------------------------------------------------------------
/bundling/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
22 |
23 | npm/browserify example - bpmn-js-examples
24 |
25 |
26 |
27 | Pizza Collaboration Viewer
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/bundling/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | const path = require('path');
4 |
5 | module.exports = {
6 | mode: 'development',
7 | entry: './src/app.js',
8 | output: {
9 | path: path.resolve(__dirname, 'public'),
10 | filename: 'app.js'
11 | },
12 | module: {
13 | rules: [
14 | {
15 | test: /\.bpmn$/,
16 | type: 'asset/source'
17 | }
18 | ]
19 | },
20 | plugins: [
21 | new CopyWebpackPlugin({
22 | patterns: [
23 | { from: 'src/index.html', to: '.' }
24 | ]
25 | })
26 | ]
27 | };
--------------------------------------------------------------------------------
/bundling/webpack.es5.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | const path = require('path');
4 |
5 | module.exports = {
6 | mode: 'development',
7 | entry: './src/app.js',
8 | output: {
9 | path: path.resolve(__dirname, 'public'),
10 | filename: 'app.js'
11 | },
12 | module: {
13 | rules: [
14 | {
15 | test: /\.bpmn$/,
16 | type: 'asset/source'
17 | },
18 | {
19 | test: /\.m?js$/,
20 | exclude: /(node_modules)/,
21 | use: {
22 | loader: 'babel-loader',
23 | options: {
24 | presets: [ '@babel/preset-env' ]
25 | }
26 | }
27 | }
28 | ]
29 | },
30 | plugins: [
31 | new CopyWebpackPlugin({
32 | patterns: [
33 | { from: 'src/index.html', to: '.' }
34 | ]
35 | })
36 | ]
37 | };
--------------------------------------------------------------------------------
/colors/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
24 |
25 |
28 |
29 | bpmn-js colors example - bpmn-js-examples
30 |
31 |
32 |
33 | bpmn-js Colors
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/colors/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/colors/screenshot.png
--------------------------------------------------------------------------------
/commenting/README.md:
--------------------------------------------------------------------------------
1 | # A simple discussion app
2 |
3 | [bpmn-js](https://github.com/bpmn-io/bpmn-js) is the BPMN 2.0 diagram modeling and rendering toolkit that powers [bpmn.io](http://bpmn.io).
4 |
5 | This example showcases how to build a simple discussion app based on [bpmn-js](https://github.com/bpmn-io/bpmn-js) and the [bpmn-js-embedded-comments](https://github.com/bpmn-io/bpmn-js-embedded-comments) extension.
6 |
7 |
8 | ## About
9 |
10 | This example uses bpmn-js to embed the [pizza collaboration](http://demo.bpmn.io/s/pizza-collaboration) diagram into a web application and add the ability to put comments on individual tasks.
11 |
12 | 
13 |
14 | The comments are added to an elements `` tag and may be downloaded along with the element.
15 |
16 |
17 | ## Building
18 |
19 | One time installation of all dependencies via [npm](https://npmjs.org):
20 |
21 | ```
22 | npm install
23 | ```
24 |
25 |
26 | Building the app into the `public` directory and opening it in a browser:
27 |
28 | ```
29 | npm run dev
30 | ```
31 |
32 |
33 | ## License
34 |
35 | MIT
--------------------------------------------------------------------------------
/commenting/docs/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/commenting/docs/screenshot.png
--------------------------------------------------------------------------------
/commenting/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-commenting",
3 | "version": "0.0.0",
4 | "description": "A simple commenting app based on bpmn-js",
5 | "scripts": {
6 | "all": "webpack",
7 | "dev": "webpack-dev-server"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
12 | },
13 | "keywords": [
14 | "bpmnjs-example"
15 | ],
16 | "author": {
17 | "name": "Nico Rehwaldt",
18 | "url": "https://github.com/nikku"
19 | },
20 | "contributors": [
21 | {
22 | "name": "bpmn.io contributors",
23 | "url": "https://github.com/bpmn-io"
24 | }
25 | ],
26 | "license": "MIT",
27 | "devDependencies": {
28 | "css-loader": "^7.1.2",
29 | "style-loader": "^4.0.0",
30 | "webpack": "^5.97.1",
31 | "webpack-cli": "^6.0.1",
32 | "webpack-dev-server": "^5.2.0"
33 | },
34 | "dependencies": {
35 | "bpmn-js": "^18.6.2",
36 | "bpmn-js-embedded-comments": "^0.7.0",
37 | "diagram-js": "^15.1.0",
38 | "jquery": "^3.3.1"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/commenting/src/font/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Font license info
2 |
3 |
4 | ## Entypo
5 |
6 | Copyright (C) 2012 by Daniel Bruce
7 |
8 | Author: Daniel Bruce
9 | License: SIL (http://scripts.sil.org/OFL)
10 | Homepage: http://www.entypo.com
11 |
12 |
13 |
--------------------------------------------------------------------------------
/commenting/src/font/bpmn-js-comments.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/commenting/src/font/bpmn-js-comments.eot
--------------------------------------------------------------------------------
/commenting/src/font/bpmn-js-comments.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/commenting/src/font/bpmn-js-comments.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/commenting/src/font/bpmn-js-comments.ttf
--------------------------------------------------------------------------------
/commenting/src/font/bpmn-js-comments.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/commenting/src/font/bpmn-js-comments.woff
--------------------------------------------------------------------------------
/commenting/src/font/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-comments",
3 | "css_prefix_text": "icon-",
4 | "css_use_suffix": false,
5 | "hinting": true,
6 | "units_per_em": 1000,
7 | "ascent": 850,
8 | "glyphs": [
9 | {
10 | "uid": "c709da589c923ba3c2ad48d9fc563e93",
11 | "css": "delete",
12 | "code": 59394,
13 | "src": "entypo"
14 | },
15 | {
16 | "uid": "16890362e811b4cb8de36282b071fe30",
17 | "css": "comment",
18 | "code": 59392,
19 | "src": "entypo"
20 | }
21 | ]
22 | }
--------------------------------------------------------------------------------
/commenting/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
59 |
60 |
64 |
65 | BPMN 2.0 comments
66 |
67 |
68 |
69 |
72 |
73 |
74 |
75 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/commenting/src/style.css:
--------------------------------------------------------------------------------
1 | body, html {
2 | font-family: sans-serif;
3 | }
4 |
5 | .comments-overlay {
6 | background: #52B415;
7 | font-size: 12px;
8 |
9 | color: white;
10 | display: none;
11 | padding: 5px;
12 | }
13 |
14 | .selected .comments-overlay,
15 | .comments-overlay.with-comments {
16 | display: block;
17 | }
18 |
19 | .comments-overlay .edit {
20 | margin: 2px 0 0 0;
21 | padding-top: 2px;
22 | }
23 |
24 | .comments-overlay .edit textarea {
25 | border: none;
26 | margin: 0;
27 | }
28 |
29 | .comments-overlay .icon-comment:hover {
30 | color: #EEE;
31 | }
32 |
33 | .comments-overlay .comment {
34 | border-top-color: white;
35 | }
36 |
37 |
38 | .comments-overlay .icon-comment {
39 | margin-right: 2px;
40 | }
41 |
42 | .comments-overlay .icon-delete {
43 | color: white;
44 | float: right;
45 | }
46 |
47 |
48 | /** fonts **/
49 |
50 | @font-face {
51 | font-family: 'bpmn-js-comments';
52 | src: url('font/bpmn-js-comments.eot?23532594');
53 | src: url('font/bpmn-js-comments.eot?23532594#iefix') format('embedded-opentype'),
54 | url('font/bpmn-js-comments.woff?23532594') format('woff'),
55 | url('font/bpmn-js-comments.ttf?23532594') format('truetype'),
56 | url('font/bpmn-js-comments.svg?23532594#bpmn-js-comments') format('svg');
57 | font-weight: normal;
58 | font-style: normal;
59 | }
60 |
61 | [class^="icon-"]:before,
62 | [class*=" icon-"]:before {
63 | font-family: "bpmn-js-comments";
64 | font-style: normal;
65 | font-weight: normal;
66 | speak: none;
67 |
68 | display: inline-block;
69 | text-decoration: inherit;
70 | width: 1em;
71 | text-align: center;
72 |
73 | font-variant: normal;
74 | text-transform: none;
75 |
76 | line-height: 1em;
77 | }
78 |
79 | .icon-comment:before { content: '\e800'; }
80 | .icon-delete:before { content: '\e802'; }
--------------------------------------------------------------------------------
/commenting/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | module.exports = {
4 | entry: {
5 | bundle: [ './src/app.js' ]
6 | },
7 | output: {
8 | path: __dirname + '/public',
9 | filename: 'app.js'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.css$/,
15 | use: [
16 | 'style-loader',
17 | 'css-loader',
18 | ]
19 | },
20 | {
21 | test: /\.bpmn$/,
22 | use: 'raw-loader'
23 | }
24 | ]
25 | },
26 | plugins: [
27 | new CopyWebpackPlugin({
28 | patterns: [
29 | { from: 'src/index.html', to: '.' },
30 | { from: 'src/font/**/*', to: 'font' }
31 | ]
32 | })
33 | ],
34 | mode: 'development',
35 | devtool: 'source-map'
36 | };
37 |
--------------------------------------------------------------------------------
/custom-bower-bundle/README.md:
--------------------------------------------------------------------------------
1 | > Removed as of `bpmn-js@0.27.0`.
2 |
3 | Checkout [custom bundle example](../custom-bundle) for alternative.
--------------------------------------------------------------------------------
/custom-bundle/README.md:
--------------------------------------------------------------------------------
1 | # custom-bundle example
2 |
3 | How to role a customized, pre-packaged version of [bpmn-js](https://github.com/bpmn-io/bpmn-js).
4 |
5 | __Note:__ This is an __advanced__ topic.
6 |
7 | ## About
8 |
9 | This example extends the [bpmn-js](https://github.com/bpmn-io/bpmn-js) viewer via custom modules and shows how [Rollup](https://rollupjs.org) can be used to generate a UMD bundle of that custom viewer.
10 |
11 |
12 | ## In a Nutshell
13 |
14 | Create a sub-class of `Viewer` or `Modeler`, depending on which variant you
15 | would like to extend:
16 |
17 | ```javascript
18 | import inherits from 'inherits';
19 |
20 | import Viewer from 'bpmn-js/lib/Viewer';
21 |
22 | import ZoomScrollModule from 'diagram-js/lib/navigation/zoomscroll';
23 | import MoveCanvasModule from 'diagram-js/lib/navigation/movecanvas';
24 |
25 | import CustomLoggingModule from './features/logging';
26 |
27 |
28 | /**
29 | * A viewer that includes mouse navigation and other goodies.
30 | *
31 | * @param {Object} options
32 | */
33 | function CustomViewer(options) {
34 | Viewer.call(this, options);
35 | }
36 |
37 | inherits(CustomViewer, Viewer);
38 |
39 | module.exports = CustomViewer;
40 | ```
41 |
42 | Add additional modules to your custom bpmn-js prototype:
43 |
44 | ```javascript
45 |
46 | CustomViewer.prototype._customModules = [
47 | ZoomScrollModule,
48 | MoveCanvasModule,
49 | CustomLoggingModule
50 | ];
51 |
52 | CustomViewer.prototype._modules = [].concat(
53 | Viewer.prototype._modules,
54 | CustomViewer.prototype._customModules
55 | );
56 | ```
57 |
58 | Package the file as UMD for the browser, using a module bundler such as [Rollup](https://rollupjs.org/), [Browserify](https://browserify.org) or Webpack.
59 |
60 | We're using rollup to bundle the files based on [this configuration](./rollup.config.js):
61 |
62 | ```
63 | rollup -c
64 | ```
65 |
66 | Include the bundle in your webpage, as you would include our [pre-package distributions](../pre-packaged):
67 |
68 | ```html
69 |
70 |
77 | ```
78 |
79 |
80 | ## Build this Example
81 |
82 | ```
83 | npm install
84 | npm run all
85 | ```
86 |
87 |
88 | ## License
89 |
90 | MIT
91 |
--------------------------------------------------------------------------------
/custom-bundle/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hello World
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
40 |
41 |
42 |
43 |
44 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/custom-bundle/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "custom-bundle",
3 | "version": "0.0.0",
4 | "description": "Bundle a custom version of bpmn-js",
5 | "scripts": {
6 | "all": "run-s build",
7 | "dev": "run-s build open",
8 | "build": "rollup -c --bundleConfigAsCjs",
9 | "open": "open-cli ./index.html"
10 | },
11 | "dependencies": {
12 | "bpmn-js": "^18.6.2",
13 | "diagram-js": "^15.1.0",
14 | "inherits-browser": "^0.1.0"
15 | },
16 | "devDependencies": {
17 | "@rollup/plugin-commonjs": "^28.0.2",
18 | "@rollup/plugin-json": "^6.1.0",
19 | "@rollup/plugin-node-resolve": "^16.0.0",
20 | "npm-run-all2": "^8.0.0",
21 | "open-cli": "^8.0.0",
22 | "rollup": "^4.30.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/custom-bundle/rollup.config.js:
--------------------------------------------------------------------------------
1 | import commonjs from '@rollup/plugin-commonjs';
2 | import json from '@rollup/plugin-json';
3 | import nodeResolve from '@rollup/plugin-node-resolve';
4 |
5 | export default {
6 | input: 'src/custom-viewer.js',
7 | output: {
8 | file: 'dist/custom-viewer.bundled.js',
9 | name: 'CustomBpmnJS',
10 | format: 'umd'
11 | },
12 | plugins: [
13 | nodeResolve({
14 | browser: true
15 | }),
16 | commonjs(),
17 | json()
18 | ]
19 | };
--------------------------------------------------------------------------------
/custom-bundle/src/custom-viewer.js:
--------------------------------------------------------------------------------
1 | import inherits from 'inherits-browser';
2 |
3 | import Viewer from 'bpmn-js/lib/Viewer';
4 |
5 | import ZoomScrollModule from 'diagram-js/lib/navigation/zoomscroll';
6 | import MoveCanvasModule from 'diagram-js/lib/navigation/movecanvas';
7 |
8 | import CustomLoggingModule from './features/logging';
9 |
10 |
11 | /**
12 | * A viewer that includes mouse navigation and other goodies.
13 | *
14 | * @param {Object} options
15 | */
16 | export default function CustomViewer(options) {
17 | Viewer.call(this, options);
18 | }
19 |
20 | inherits(CustomViewer, Viewer);
21 |
22 | CustomViewer.prototype._customModules = [
23 | ZoomScrollModule,
24 | MoveCanvasModule,
25 | CustomLoggingModule
26 | ];
27 |
28 | CustomViewer.prototype._modules = [].concat(
29 | Viewer.prototype._modules,
30 | CustomViewer.prototype._customModules
31 | );
--------------------------------------------------------------------------------
/custom-bundle/src/features/logging/InteractionLogger.js:
--------------------------------------------------------------------------------
1 | var HIGH_PRIORITY = 1500;
2 |
3 |
4 | export default function InteractionLogger(eventBus) {
5 |
6 | // we log user clicks
7 | eventBus.on('element.click', HIGH_PRIORITY, function(evt) {
8 | console.log('user clicked', evt.element);
9 | });
10 |
11 | }
12 |
13 | InteractionLogger.$inject = [ 'eventBus' ];
--------------------------------------------------------------------------------
/custom-bundle/src/features/logging/index.js:
--------------------------------------------------------------------------------
1 | import InteractionLogger from './InteractionLogger';
2 |
3 | export default {
4 | __init__: [ 'interactionLogger' ],
5 | interactionLogger: [ 'type', InteractionLogger ]
6 | };
--------------------------------------------------------------------------------
/custom-elements/docs/screenshot-custom-editor-controls.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/custom-elements/docs/screenshot-custom-editor-controls.png
--------------------------------------------------------------------------------
/custom-elements/docs/screenshot-custom-elements.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/custom-elements/docs/screenshot-custom-elements.png
--------------------------------------------------------------------------------
/custom-elements/docs/screenshot-custom-rendering.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/custom-elements/docs/screenshot-custom-rendering.png
--------------------------------------------------------------------------------
/custom-elements/docs/screenshot-model-extension.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/custom-elements/docs/screenshot-model-extension.png
--------------------------------------------------------------------------------
/custom-meta-model/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "custom-meta-model",
3 | "version": "0.0.0",
4 | "description": "An bpmn-js modeler extended with a custom meta-model",
5 | "scripts": {
6 | "all": "webpack",
7 | "dev": "webpack-dev-server"
8 | },
9 | "keywords": [
10 | "bpmnjs-example"
11 | ],
12 | "author": {
13 | "name": "Nico Rehwaldt",
14 | "url": "https://github.com/nikku"
15 | },
16 | "contributors": [
17 | {
18 | "name": "bpmn.io contributors",
19 | "url": "https://github.com/bpmn-io"
20 | }
21 | ],
22 | "license": "MIT",
23 | "devDependencies": {
24 | "css-loader": "^7.1.2",
25 | "style-loader": "^4.0.0",
26 | "webpack": "^5.97.1",
27 | "webpack-cli": "^6.0.1",
28 | "webpack-dev-server": "^5.2.0"
29 | },
30 | "dependencies": {
31 | "bpmn-js": "^18.6.2",
32 | "diagram-js": "^15.1.0",
33 | "jquery": "^3.3.1"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/custom-meta-model/resources/qa.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "QualityAssurance",
3 | "uri": "http://some-company/schema/bpmn/qa",
4 | "prefix": "qa",
5 | "xml": {
6 | "tagAlias": "lowerCase"
7 | },
8 | "types": [
9 | {
10 | "name": "AnalyzedNode",
11 | "extends": [
12 | "bpmn:FlowNode"
13 | ],
14 | "properties": [
15 | {
16 | "name": "suitable",
17 | "isAttr": true,
18 | "type": "Float"
19 | }
20 | ]
21 | },
22 | {
23 | "name": "AnalysisDetails",
24 | "superClass": [ "Element" ],
25 | "properties": [
26 | {
27 | "name": "lastChecked",
28 | "isAttr": true,
29 | "type": "String"
30 | },
31 | {
32 | "name": "nextCheck",
33 | "isAttr": true,
34 | "type": "String"
35 | },
36 | {
37 | "name": "comments",
38 | "isMany": true,
39 | "type": "Comment"
40 | }
41 | ]
42 | },
43 | {
44 | "name": "Comment",
45 | "properties": [
46 | {
47 | "name": "author",
48 | "isAttr": true,
49 | "type": "String"
50 | },
51 | {
52 | "name": "text",
53 | "isBody": true,
54 | "type": "String"
55 | }
56 | ]
57 | }
58 | ],
59 | "emumerations": [],
60 | "associations": []
61 | }
62 |
--------------------------------------------------------------------------------
/custom-meta-model/resources/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/custom-meta-model/resources/screenshot.png
--------------------------------------------------------------------------------
/custom-meta-model/src/app.js:
--------------------------------------------------------------------------------
1 | import 'bpmn-js/dist/assets/diagram-js.css';
2 | import 'bpmn-js/dist/assets/bpmn-js.css';
3 |
4 | import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
5 |
6 | import BpmnViewer from 'bpmn-js';
7 |
8 | import sampleProcess from '../resources/sample.bpmn';
9 |
10 | import qaPackage from '../resources/qa';
11 |
12 | var viewer = new BpmnViewer({
13 | container: '#canvas',
14 | moddleExtensions: {
15 | qa: qaPackage
16 | }
17 | });
18 |
19 | viewer.importXML(sampleProcess);
20 |
21 | function getExtension(element, type) {
22 | if (!element.extensionElements) {
23 | return null;
24 | }
25 |
26 | return element.extensionElements.values.filter(function(e) {
27 | return e.$instanceOf(type);
28 | })[0];
29 | }
30 |
31 | viewer.on('element.click', function(event) {
32 | var element = event.element,
33 | moddle = viewer.get('moddle'),
34 |
35 | // the underlaying BPMN 2.0 element
36 | businessObject = element.businessObject,
37 | analysis,
38 | score,
39 | message;
40 |
41 | // do not allow on root element
42 | if (!element.parent) {
43 | return;
44 | }
45 |
46 | // we can access extension attribute properties
47 | score = businessObject.suitable;
48 |
49 | analysis = getExtension(businessObject, 'qa:AnalysisDetails');
50 |
51 | // right click
52 | if (event.originalEvent.ctrlKey) {
53 | var result = parseFloat(window.prompt('assign a new suitability score to ' + businessObject.id), 10);
54 |
55 | if (isNaN(result)) {
56 | return;
57 | }
58 |
59 | businessObject.suitable = result;
60 |
61 | if (!analysis) {
62 | analysis = moddle.create('qa:AnalysisDetails');
63 | businessObject.extensionElements = businessObject.extensionElements || moddle.create('bpmn:ExtensionElements');
64 | businessObject.extensionElements.get('values').push(analysis);
65 | }
66 |
67 | analysis.lastChecked = new Date().toString();
68 | } else {
69 |
70 | if (isNaN(score)) {
71 | message = 'No suitability score yet, CTRL+Click to assign one';
72 | } else {
73 | message = 'Diagram element has a suitability score of ' + score;
74 | }
75 |
76 | if (analysis) {
77 | message += '\n Last analyzed at ' + analysis.lastChecked;
78 | }
79 |
80 | window.alert(message);
81 | }
82 | });
83 |
84 |
85 | document.querySelector('#export-to-console').addEventListener('click', async function(e) {
86 |
87 | try {
88 |
89 | const { xml } = await viewer.saveXML({ format: true });
90 |
91 | console.log(xml);
92 | } catch (err) {
93 | console.error(err);
94 | }
95 |
96 | e.preventDefault();
97 | });
98 |
--------------------------------------------------------------------------------
/custom-meta-model/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | custom-meta-model example
4 |
5 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/custom-meta-model/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | module.exports = {
4 | entry: {
5 | bundle: [ './src/app.js' ]
6 | },
7 | output: {
8 | path: __dirname + '/public',
9 | filename: 'app.js'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.css$/,
15 | use: [
16 | 'style-loader',
17 | 'css-loader',
18 | ]
19 | },
20 | {
21 | test: /\.bpmn$/,
22 | use: 'raw-loader'
23 | }
24 | ]
25 | },
26 | plugins: [
27 | new CopyWebpackPlugin({
28 | patterns: [
29 | { from: 'src/index.html', to: '.' }
30 | ]
31 | })
32 | ],
33 | mode: 'development',
34 | devtool: 'source-map'
35 | };
36 |
--------------------------------------------------------------------------------
/custom-modeling-rules/README.md:
--------------------------------------------------------------------------------
1 | # Custom Modeling Rules
2 |
3 | This example shows how to implement custom modeling rules in [bpmn-js](https://github.com/bpmn-io/bpmn-js).
4 |
5 |
6 | ## About
7 |
8 | This example extends the [bpmn-js](https://github.com/bpmn-io/bpmn-js) modeler with custom modeling rules.
9 |
10 | The rules are added via a [custom rules provider](https://github.com/bpmn-io/bpmn-js-examples/blob/main/custom-modeling-rules/lib/custom-rules/CustomRules.js). The provider hooks into the rule evaluation for `shape.create` and restricts it to elements annotated with a `vendor:allowDrop` extension attribute.
11 |
12 | ```javascript
13 | this.addRule('shape.create', function(context) {
14 |
15 | var shape = context.shape,
16 | target = context.parent;
17 |
18 | var shapeBo = shape.businessObject,
19 | targetBo = target.businessObject;
20 |
21 | var allowDrop = targetBo.get('vendor:allowDrop');
22 |
23 | if (!allowDrop || !shapeBo.$instanceOf(allowDrop)) {
24 | return false;
25 | }
26 | });
27 | ```
28 |
29 | Using these custom rules users are able to insert tasks on the following sequence flow:
30 |
31 | ```xml
32 |
33 | ```
34 |
35 | They would not be able to insert anything if the `allowDrop` annotation is missing:
36 |
37 | ```xml
38 |
39 | ```
40 |
41 | To learn more, check out [an example diagram](https://github.com/bpmn-io/bpmn-js-examples/blob/main/custom-modeling-rules/test/spec/diagram.bpmn) and the accompanying [test cases](https://github.com/bpmn-io/bpmn-js-examples/blob/custom-rules/custom-modeling-rules/test/spec/CustomRulesSpec.js).
42 |
43 |
44 | ## Building
45 |
46 | One time installation of all dependencies via [npm](https://npmjs.org):
47 |
48 | ```
49 | npm install
50 | ```
51 |
52 |
53 | Execute the test suite to spin up the example in your browser:
54 |
55 | ```
56 | npm run dev
57 | ```
58 |
59 | Go to [localhost:9876/debug.html](http://localhost:9876/debug.html) to inspect the example in your Browser.
60 |
61 |
62 | ## License
63 |
64 | MIT
--------------------------------------------------------------------------------
/custom-modeling-rules/karma.conf.js:
--------------------------------------------------------------------------------
1 | // use puppeteer provided Chrome for testing
2 | process.env.CHROME_BIN = require('puppeteer').executablePath();
3 |
4 | // configures browsers to run test against
5 | // any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'Safari' ]
6 | const browsers = (process.env.TEST_BROWSERS || 'ChromeHeadless').split(',');
7 |
8 | module.exports = function(karma) {
9 | karma.set({
10 |
11 | frameworks: [
12 | 'webpack',
13 | 'mocha',
14 | 'chai'
15 | ],
16 |
17 | files: [
18 | 'test/spec/**/*Spec.js'
19 | ],
20 |
21 | reporters: [ 'dots' ],
22 |
23 | preprocessors: {
24 | 'test/spec/**/*Spec.js': [ 'webpack' ]
25 | },
26 |
27 | browsers: browsers,
28 |
29 | singleRun: true,
30 | autoWatch: false,
31 |
32 | webpack: {
33 | mode: 'development',
34 | module: {
35 | rules: [
36 | {
37 | test: /\.css|\.bpmn$/,
38 | type: 'asset/source'
39 | }
40 | ]
41 | },
42 | devtool: 'eval-source-map'
43 | }
44 | });
45 | };
46 |
--------------------------------------------------------------------------------
/custom-modeling-rules/lib/custom-rules/CustomRules.js:
--------------------------------------------------------------------------------
1 | import inherits from 'inherits-browser';
2 |
3 | import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider';
4 |
5 |
6 | /**
7 | * A custom rule provider that decides what elements can be
8 | * dropped where based on a `vendor:allowDrop` BPMN extension.
9 | *
10 | * See {@link BpmnRules} for the default implementation
11 | * of BPMN 2.0 modeling rules provided by bpmn-js.
12 | *
13 | * @param {EventBus} eventBus
14 | */
15 | export default function CustomRules(eventBus) {
16 | RuleProvider.call(this, eventBus);
17 | }
18 |
19 | inherits(CustomRules, RuleProvider);
20 |
21 | CustomRules.$inject = [ 'eventBus' ];
22 |
23 |
24 | CustomRules.prototype.init = function() {
25 |
26 | // there exist a number of modeling actions
27 | // that are identified by a unique ID. We
28 | // can hook into each one of them and make sure
29 | // they are only allowed if we say so
30 | this.addRule('shape.create', function(context) {
31 |
32 | var shape = context.shape,
33 | target = context.target;
34 |
35 | // we check for a custom vendor:allowDrop attribute
36 | // to be present on the BPMN 2.0 xml of the target
37 | // node
38 | //
39 | // we could practically check for other things too,
40 | // such as incoming / outgoing connections, element
41 | // types, ...
42 | var shapeBo = shape.businessObject,
43 | targetBo = target.businessObject;
44 |
45 | var allowDrop = targetBo.get('vendor:allowDrop');
46 |
47 | if (!allowDrop || !shapeBo.$instanceOf(allowDrop)) {
48 | return false;
49 | }
50 |
51 | // not returning anything means other rule
52 | // providers can still do their work
53 | //
54 | // this allows us to reuse the existing BPMN rules
55 | });
56 | };
--------------------------------------------------------------------------------
/custom-modeling-rules/lib/custom-rules/index.js:
--------------------------------------------------------------------------------
1 | import CustomRules from './CustomRules';
2 |
3 | export default {
4 | __init__: [ 'customRules' ],
5 | customRules: [ 'type', CustomRules ]
6 | };
--------------------------------------------------------------------------------
/custom-modeling-rules/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-custom-modeling-rules",
3 | "version": "0.0.0",
4 | "description": "An example how to read and write custom BPMN 2.0 extensions",
5 | "scripts": {
6 | "all": "npm test",
7 | "dev": "npm test -- --auto-watch --no-single-run",
8 | "test": "karma start"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
13 | },
14 | "keywords": [
15 | "bpmnjs-example"
16 | ],
17 | "author": {
18 | "name": "Nico Rehwaldt",
19 | "url": "https://github.com/nikku"
20 | },
21 | "contributors": [
22 | {
23 | "name": "bpmn.io contributors",
24 | "url": "https://github.com/bpmn-io"
25 | }
26 | ],
27 | "license": "MIT",
28 | "devDependencies": {
29 | "chai": "^4.5.0",
30 | "karma": "^6.4.4",
31 | "karma-chai": "^0.1.0",
32 | "karma-chrome-launcher": "^3.2.0",
33 | "karma-firefox-launcher": "^2.1.3",
34 | "karma-mocha": "^2.0.0",
35 | "karma-webpack": "^5.0.1",
36 | "mocha": "^10.8.2",
37 | "mocha-test-container-support": "^0.2.0",
38 | "puppeteer": "^24.0.0",
39 | "webpack": "^5.97.1"
40 | },
41 | "dependencies": {
42 | "bpmn-js": "^18.6.2",
43 | "diagram-js": "^15.1.0",
44 | "inherits-browser": "^0.1.0"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/custom-modeling-rules/test/TestHelper.js:
--------------------------------------------------------------------------------
1 | export * from 'bpmn-js/test/helper';
2 |
3 | import {
4 | insertCSS
5 | } from 'bpmn-js/test/helper';
6 |
7 | insertCSS('diagram-js.css', require('bpmn-js/dist/assets/diagram-js.css'));
8 | insertCSS('bpmn-embedded.css', require('bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'));
9 |
10 | insertCSS('diagram-js-testing.css',
11 | '.test-container .result { height: 500px; }' + '.test-container > div'
12 | );
--------------------------------------------------------------------------------
/custom-modeling-rules/test/spec/CustomRulesSpec.js:
--------------------------------------------------------------------------------
1 | import {
2 | bootstrapModeler,
3 | inject
4 | } from '../TestHelper';
5 |
6 | import coreModule from 'bpmn-js/lib/core';
7 | import bpmnPaletteModule from 'bpmn-js/lib/features/palette';
8 | import modelingModule from 'bpmn-js/lib/features/modeling';
9 |
10 | import customRulesModule from '../../lib/custom-rules';
11 |
12 |
13 | describe('custom-rules', function() {
14 |
15 | var testModules = [
16 |
17 | // prepend our custom rules to hook into the
18 | // rule evaluation before the default rules
19 | // get applied
20 | customRulesModule,
21 |
22 | // add default interaction features
23 | coreModule,
24 | modelingModule,
25 | bpmnPaletteModule
26 | ];
27 |
28 |
29 | var diagramXML = require('./diagram.bpmn');
30 |
31 | beforeEach(bootstrapModeler(diagramXML, {
32 | modules: testModules
33 | }));
34 |
35 |
36 | describe('shape.create', function() {
37 |
38 | it('should reject per default', inject(
39 | function(rules, elementRegistry, elementFactory) {
40 |
41 | // given
42 | var newEventShape = elementFactory.create('shape', { type: 'bpmn:StartEvent' });
43 | var targetElement = elementRegistry.get('Process_1');
44 |
45 | // when
46 | var canCreate = rules.allowed('shape.create', {
47 | shape: newEventShape,
48 | target: targetElement
49 | });
50 |
51 | // then
52 | expect(canCreate).to.be.false;
53 | }
54 | ));
55 |
56 |
57 | it('should reject drop non bpmn:Task on special flow', inject(
58 | function(rules, elementRegistry, elementFactory) {
59 |
60 | // given
61 | var newEventShape = elementFactory.create('shape', { type: 'bpmn:StartEvent' });
62 | var specialFlowElement = elementRegistry.get('SequenceFlow_1');
63 |
64 | // when
65 | var canCreate = rules.allowed('shape.create', {
66 | shape: newEventShape,
67 | target: specialFlowElement
68 | });
69 |
70 | // then
71 | expect(canCreate).to.be.false;
72 | }
73 | ));
74 |
75 |
76 | it('should allow drop bpmn:Task on special flow', inject(
77 | function(rules, elementRegistry, elementFactory) {
78 |
79 | // given
80 | var newTaskShape = elementFactory.create('shape', { type: 'bpmn:Task' });
81 | var specialFlowElement = elementRegistry.get('SequenceFlow_1');
82 |
83 | // when
84 | var canCreate = rules.allowed('shape.create', {
85 | shape: newTaskShape,
86 | target: specialFlowElement
87 | });
88 |
89 | // then
90 | expect(canCreate).to.be.true;
91 | }
92 | ));
93 |
94 | });
95 |
96 | });
97 |
--------------------------------------------------------------------------------
/custom-modeling-rules/test/spec/diagram.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SequenceFlow_1
6 |
7 |
8 | SequenceFlow_1
9 | SequenceFlow_2
10 |
11 |
12 |
13 | SequenceFlow_2
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/deep-linking/README.md:
--------------------------------------------------------------------------------
1 | # bpmn-js deep-linking example
2 |
3 | This example shows how to use the [rootElements API](https://github.com/bpmn-io/diagram-js/blob/main/lib/core/Canvas.js) of [bpmn-js](https://github.com/bpmn-io/bpmn-js) to switch between different diagram layers.
4 |
5 | 
6 |
7 | ## About
8 |
9 | The example loads a process diagram with nested subprocesses and changes the browser location changing drilling into.
10 | Opening the generated link will take you to the selected subprocess view directly.
11 |
12 |
13 | ## Usage summary
14 |
15 | Access the [`Canvas`](https://github.com/bpmn-io/diagram-js/blob/main/lib/core/Canvas.js) service via `bpmnViewer.get('canvas')` and set root elements by id using the `Canvas#setRootElement` method. For collapsed subprocesses, the root element is suffixed with `_plane`.
16 |
17 | ```javascript
18 | var canvas = bpmnViewer.get('canvas');
19 |
20 | // switch to a collapsed subprocess
21 | canvas.setRootElement('collapsedProcess_plane');
22 | ```
23 |
24 | ## Setting up bpmn-js
25 |
26 | Grab [bpmn-js](https://github.com/bpmn-io/bpmn-js) [pre-packaged](../pre-packaged) or [via npm](../bundling):
27 |
28 | To use `canvas` and other services provided by bpmn-js instantiate bpmn-js (this time the viewer) via
29 |
30 | ```javascript
31 | var bpmnViewer = new BpmnViewer({
32 | container: '#canvas',
33 | width: '100%',
34 | height: '100%'
35 | });
36 | ```
37 |
38 | Import a BPMN 2.0 diagram and add the overlays in the `done` callback:
39 |
40 | ```javascript
41 | await bpmnViewer.importXML(diagramXML);
42 |
43 | // retrieve services and work with them
44 | bpmnViewer.get('canvas').setRootElement('...');
45 | ```
46 |
47 |
48 | ## Building the Project
49 |
50 | Initialize the project dependencies via
51 |
52 | ```
53 | npm install
54 | ```
55 |
56 | To create the sample distribution in the `dist` folder run
57 |
58 | ```
59 | npm run all
60 | ```
61 |
62 | To bootstrap a development setup that spawns a small webserver and rebuilds your app on changes run
63 |
64 | ```
65 | npm run dev
66 | ```
67 |
68 |
69 | ## License
70 |
71 | MIT
72 |
--------------------------------------------------------------------------------
/deep-linking/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-deep-linking",
3 | "version": "0.0.0",
4 | "description": "An example how to bundle an app using bpmn-js for the browser",
5 | "scripts": {
6 | "all": "run-s build",
7 | "build": "webpack --mode=production",
8 | "dev": "webpack-dev-server --static=public --open",
9 | "start": "npm run dev"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
14 | },
15 | "keywords": [
16 | "bpmnjs-example"
17 | ],
18 | "contributors": [
19 | {
20 | "name": "bpmn.io contributors",
21 | "url": "https://github.com/bpmn-io"
22 | }
23 | ],
24 | "license": "MIT",
25 | "devDependencies": {
26 | "css-loader": "^7.1.2",
27 | "npm-run-all2": "^8.0.0",
28 | "raw-loader": "^4.0.0",
29 | "style-loader": "^4.0.0",
30 | "webpack": "^5.97.1",
31 | "webpack-cli": "^6.0.1"
32 | },
33 | "dependencies": {
34 | "bpmn-js": "^18.6.2",
35 | "webpack-dev-server": "^5.2.0"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/deep-linking/resources/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/deep-linking/resources/screenshot.png
--------------------------------------------------------------------------------
/deep-linking/src/app.js:
--------------------------------------------------------------------------------
1 | import 'bpmn-js/dist/assets/diagram-js.css';
2 | import 'bpmn-js/dist/assets/bpmn-js.css';
3 |
4 | import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
5 |
6 | // we use stringify to inline an example XML document
7 | import nestedDiagram from '../resources/nested-subprocesses.bpmn';
8 |
9 | // make sure you added bpmn-js to your your project
10 | // dependencies via npm install --save bpmn-js
11 | import BpmnViewer from 'bpmn-js';
12 |
13 | var viewer = new BpmnViewer({
14 | container: '#canvas'
15 | });
16 |
17 | var canvas = viewer.get('canvas');
18 | var eventBus = viewer.get('eventBus');
19 |
20 | var search = new URLSearchParams(window.location.search);
21 | var browserNavigationInProgress;
22 |
23 | // update the URL and browser history when switching to another root element
24 | eventBus.on('root.set', function(event) {
25 |
26 | // location is already updated through the browser history API
27 | if (browserNavigationInProgress) {
28 | return;
29 | }
30 |
31 | var rootElement = event.element;
32 |
33 | search.set('rootElement', rootElement.id);
34 | window.history.pushState({ element: rootElement.id }, null, 'index.html?' + search.toString());
35 | });
36 |
37 | // listen to browser navigation and change the root element accordingly
38 | window.addEventListener('popstate', (event) => {
39 | var rootElement = event.state && event.state.element;
40 |
41 | if (!rootElement) {
42 | return;
43 | }
44 |
45 | browserNavigationInProgress = true;
46 | canvas.setRootElement(canvas.findRoot(rootElement));
47 | browserNavigationInProgress = false;
48 | });
49 |
50 | // import the diagram and set the root element from the search params
51 | browserNavigationInProgress = !!search.get('rootElement');
52 | viewer.importXML(nestedDiagram).then(function() {
53 | var root = search.get('rootElement');
54 | if (root) {
55 | canvas.setRootElement(canvas.findRoot(root));
56 | }
57 |
58 | browserNavigationInProgress = false;
59 | });
60 |
--------------------------------------------------------------------------------
/deep-linking/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
14 |
15 | Deep linking example - bpmn-js
16 |
17 |
18 |
19 | Deep Linking Example
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/deep-linking/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | const path = require('path');
4 |
5 | module.exports = {
6 | mode: 'development',
7 | entry: './src/app.js',
8 | output: {
9 | path: path.resolve(__dirname, 'public'),
10 | filename: 'app.js'
11 | },
12 | module: {
13 | rules: [
14 | {
15 | test: /\.css$/,
16 | use: [
17 | 'style-loader',
18 | 'css-loader',
19 | ]
20 | },
21 | {
22 | test: /\.bpmn$/,
23 | use: {
24 | loader: 'raw-loader'
25 | }
26 | }
27 | ]
28 | },
29 | plugins: [
30 | new CopyWebpackPlugin({
31 | patterns: [
32 | { from: 'src/index.html', to: '.' }
33 | ]
34 | })
35 | ]
36 | };
--------------------------------------------------------------------------------
/embedding/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | public/
--------------------------------------------------------------------------------
/embedding/README.md:
--------------------------------------------------------------------------------
1 | # bpmn-js embedding example
2 |
3 | This example shows how different versions of the toolkit can be embedded easily into a HTML page.
4 |
5 | > [!NOTE]
6 | > Starting with [bpmn-js@18](https://github.com/bpmn-io/bpmn-js/blob/develop/CHANGELOG.md#1800) diagram containers are focusable elements that play nicely with others.
7 |
8 | ## About
9 |
10 | This example embedds different variants of the BPMN toolkit into a larger website. You can see how each instance of modeler only captures keyboard shortcuts when it's focused and doesn't interfer with other (native or custom) elements.
11 |
12 | 
13 |
14 | ## Building
15 |
16 | You need a [NodeJS](http://nodejs.org) development stack with [npm](https://npmjs.org) installed to build the project.
17 |
18 | To install all project dependencies execute
19 |
20 | ```
21 | npm install
22 | ```
23 |
24 | Spawn the demo by executing
25 |
26 | ```
27 | npm start
28 | ```
29 |
30 | Both tasks generate the distribution ready client-side modeler application into the `public` folder.
31 |
--------------------------------------------------------------------------------
/embedding/docs/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/embedding/docs/screenshot.png
--------------------------------------------------------------------------------
/embedding/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-implicit-keyboard-bind",
3 | "version": "0.0.0",
4 | "description": "Demo of implicit keyboard binding in bpmn-js",
5 | "scripts": {
6 | "all": "run-s build",
7 | "build": "webpack --mode production",
8 | "dev": "webpack-dev-server --static=public --open",
9 | "start": "run-s dev"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
14 | },
15 | "keywords": [
16 | "bpmnjs-example"
17 | ],
18 | "author": {
19 | "name": "Jarek Danielak",
20 | "url": "https://github.com/jarekdanielak"
21 | },
22 | "contributors": [
23 | {
24 | "name": "bpmn.io contributors",
25 | "url": "https://github.com/bpmn-io"
26 | }
27 | ],
28 | "license": "MIT",
29 | "devDependencies": {
30 | "copy-webpack-plugin": "^13.0.0",
31 | "css-loader": "^7.1.2",
32 | "npm-run-all2": "^8.0.0",
33 | "raw-loader": "^4.0.0",
34 | "style-loader": "^4.0.0",
35 | "webpack": "^5.97.1",
36 | "webpack-cli": "^6.0.1",
37 | "webpack-dev-server": "^5.2.0"
38 | },
39 | "dependencies": {
40 | "bpmn-js": "^18.6.2",
41 | "diagram-js": "^15.2.3",
42 | "jquery": "^3.3.1"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/embedding/src/app.js:
--------------------------------------------------------------------------------
1 | import 'bpmn-js/dist/assets/diagram-js.css';
2 | import 'bpmn-js/dist/assets/bpmn-js.css';
3 |
4 | import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
5 |
6 | import './style.css';
7 |
8 | import BpmnModeler from 'bpmn-js/lib/Modeler';
9 | import BpmnViewer from 'bpmn-js/lib/Viewer';
10 | import BpmnNavigatedViewer from 'bpmn-js/lib/NavigatedViewer';
11 |
12 | import Clipboard from 'diagram-js/lib/features/clipboard/Clipboard';
13 |
14 | const editorMap = {
15 | 'editor': BpmnModeler,
16 | 'viewer': BpmnViewer,
17 | 'navigated-viewer': BpmnNavigatedViewer
18 | };
19 |
20 | const sharedClipboard = {
21 | 'clipboard': [ 'value', new Clipboard() ]
22 | };
23 |
24 | const additionalModulesMap = {
25 | 'first-modeler': [
26 | sharedClipboard
27 | ],
28 | 'second-modeler': [
29 | sharedClipboard
30 | ]
31 | };
32 |
33 | const modelers = new Map();
34 |
35 | function createModeler(viewerType, config, id) {
36 |
37 | const BpmnJS = editorMap[viewerType] || BpmnModeler;
38 |
39 | const additionalModules = additionalModulesMap[id] || [];
40 |
41 | return new BpmnJS({
42 | ...config,
43 | additionalModules
44 | });
45 | }
46 |
47 | async function openDiagram(element) {
48 |
49 | const diagramURL = element.dataset.diagram;
50 | const viewerType = element.dataset.editor;
51 | const id = element.id || '__default';
52 |
53 | const modeler = createModeler(viewerType, { container: element }, id);
54 |
55 | modelers.set(element, modeler);
56 |
57 | const diagramXML = await fetch(diagramURL).then(response => response.text());
58 |
59 | await modeler.importXML(diagramXML);
60 | }
61 |
62 | const elements = document.querySelectorAll('[data-diagram]');
63 |
64 | for (const element of elements) {
65 | openDiagram(element).catch(err => console.error);
66 | }
67 |
--------------------------------------------------------------------------------
/embedding/src/diagrams/first.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/embedding/src/diagrams/overview.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/embedding/src/diagrams/second.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/embedding/src/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | box-sizing: border-box;
3 | }
4 |
5 | body, html {
6 | padding: 0;
7 | margin: 0;
8 | }
9 |
10 | figure {
11 | margin: 30px 0;
12 | }
13 |
14 | figcaption {
15 | margin-top: .85em;
16 | text-align: center;
17 | }
18 |
19 | :focus {
20 | outline-color: cornflowerblue;
21 | }
22 |
23 | .container {
24 | width: 80%;
25 | max-width: 1200px;
26 | height: 100%;
27 | margin: 0 auto;
28 | }
29 |
30 | .diagram-grid {
31 | display: flex;
32 | flex-direction: row;
33 | }
34 |
35 | .diagram-grid:not(.single) {
36 | margin-left: -30px;
37 | margin-right: -30px;
38 | }
39 |
40 | .canvas {
41 | height: 400px;
42 | width: 100%;
43 | border-radius: 5px;
44 | border: solid 3px #eee;
45 | }
46 |
47 | .diagram-grid > * {
48 | flex: 1;
49 | }
50 |
51 | .diagram-grid > * + * {
52 | margin-left: 2em;
53 | }
54 |
55 | hr {
56 | margin: 30px 0;
57 | }
--------------------------------------------------------------------------------
/embedding/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | module.exports = {
4 | entry: {
5 | bundle: [ './src/app.js' ]
6 | },
7 | output: {
8 | path: __dirname + '/public',
9 | filename: 'app.js'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.css$/,
15 | use: [
16 | 'style-loader',
17 | 'css-loader',
18 | ]
19 | },
20 | {
21 | test: /\.bpmn$/,
22 | use: 'raw-loader'
23 | }
24 | ]
25 | },
26 | plugins: [
27 | new CopyWebpackPlugin({
28 | patterns: [
29 | { from: 'src/index.html', to: '.' },
30 | { context: 'src', from: 'diagrams/*.bpmn', to: '.' }
31 | ]
32 | })
33 | ],
34 | mode: 'development',
35 | devtool: 'source-map'
36 | };
37 |
--------------------------------------------------------------------------------
/eslint.config.mjs:
--------------------------------------------------------------------------------
1 | import bpmnIoPlugin from 'eslint-plugin-bpmn-io';
2 |
3 | export default [
4 | {
5 | ignores: [ '**/public', '**/dist' ],
6 | },
7 | ...bpmnIoPlugin.configs.browser,
8 | ...bpmnIoPlugin.configs.node.map(config => {
9 | return {
10 | ...config,
11 | files: [
12 | '**/*.config.js',
13 | '**/*.conf.js',
14 | '**/server.js',
15 | '**/test/**/*.js',
16 | ]
17 | };
18 | }),
19 | ...bpmnIoPlugin.configs.mocha.map(config => {
20 | return {
21 | ...config,
22 | files: [
23 | '**/test/**/*.js',
24 | ]
25 | };
26 | }),
27 | {
28 | files: [ '**/*.js', '**/*.mjs' ],
29 | }
30 | ];
--------------------------------------------------------------------------------
/i18n/README.md:
--------------------------------------------------------------------------------
1 | # bpmn-js i18n Example
2 |
3 | This example shows how to translate the strings displayed in [bpmn-js](https://github.com/bpmn-io/bpmn-js) to another language or domain.
4 |
5 | 
6 |
7 | ## Usage Summary
8 |
9 | The custom translation function is provided as an additional module when [bpmn-js](https://github.com/bpmn-io/bpmn-js) is instantiated. The default translation implementation is thereby overwritten.
10 |
11 | ```javascript
12 | var customTranslate = {
13 | translate: [ 'value', require('./custom-translate/custom-translate') ]
14 | };
15 |
16 | var modeler = new BpmnModeler({
17 | // ...
18 | additionalModules: [
19 | customTranslate
20 | ]
21 | });
22 | ```
23 |
24 | You can use your own implementation for translation. The function has two arguments (a template string and an optional object with replacements) and must return the translated string. The example provides two main functionalities: translating and replacing template strings.
25 |
26 | Translating a string:
27 |
28 | ```javascript
29 | var translations = {
30 | 'Append': 'Anhängen'
31 | };
32 |
33 | //...
34 |
35 | translate('Append'); // Returns 'Anhängen'
36 | ```
37 |
38 | Translating a template string:
39 |
40 | ```javascript
41 | var translations = {
42 | 'Append {element}': '{element} anhängen'
43 | };
44 |
45 | //...
46 |
47 | translate('Append {element}', {element: 'Gateway'}); // Returns 'Gateway anhängen'
48 | ```
49 |
50 | A list of all available template strings of [bpmn-js](https://github.com/bpmn-io/bpmn-js) as well as existing translations can be found in the [bpmn-js-i18n repository](https://github.com/bpmn-io/bpmn-js-i18n).
51 |
52 |
53 | ## Run the Example
54 |
55 | You need a [NodeJS](http://nodejs.org) development stack with [npm](https://npmjs.org) installed to build the project.
56 |
57 | To install all project dependencies execute
58 |
59 | ```sh
60 | npm install
61 | ```
62 |
63 | To start the example execute
64 |
65 | ```sh
66 | npm start
67 | ```
68 |
69 | To build the example into the `public` folder execute
70 |
71 | ```sh
72 | npm run all
73 | ```
74 |
--------------------------------------------------------------------------------
/i18n/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-i18n",
3 | "version": "0.0.0",
4 | "description": "Simple i18n with bpmn-js",
5 | "scripts": {
6 | "all": "run-s build",
7 | "build": "webpack --mode production",
8 | "dev": "webpack-dev-server --static=public --open",
9 | "start": "run-s dev"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
14 | },
15 | "keywords": [
16 | "bpmnjs-example"
17 | ],
18 | "author": {
19 | "name": "Nico Rehwaldt",
20 | "url": "https://github.com/nikku"
21 | },
22 | "contributors": [
23 | {
24 | "name": "bpmn.io contributors",
25 | "url": "https://github.com/bpmn-io"
26 | }
27 | ],
28 | "license": "MIT",
29 | "devDependencies": {
30 | "copy-webpack-plugin": "^13.0.0",
31 | "css-loader": "^7.1.2",
32 | "npm-run-all2": "^8.0.0",
33 | "raw-loader": "^4.0.0",
34 | "style-loader": "^4.0.0",
35 | "webpack": "^5.97.1",
36 | "webpack-cli": "^6.0.1",
37 | "webpack-dev-server": "^5.2.0"
38 | },
39 | "dependencies": {
40 | "bpmn-js": "^18.6.2"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/i18n/resources/newDiagram.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/i18n/resources/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/i18n/resources/screenshot.png
--------------------------------------------------------------------------------
/i18n/src/app.js:
--------------------------------------------------------------------------------
1 | import 'bpmn-js/dist/assets/diagram-js.css';
2 | import 'bpmn-js/dist/assets/bpmn-js.css';
3 |
4 | import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
5 |
6 | import BpmnModeler from 'bpmn-js/lib/Modeler';
7 |
8 | import customTranslate from './customTranslate/customTranslate';
9 |
10 | import diagramXML from '../resources/newDiagram.bpmn';
11 |
12 |
13 | // Our custom translation module
14 | // We need to use the array syntax that is used by bpmn-js internally
15 | // 'value' tells bmpn-js to use the function instead of trying to instanciate it
16 | var customTranslateModule = {
17 | translate: [ 'value', customTranslate ]
18 | };
19 |
20 | // Spin up an instance of the modeler that uses our custom translation module
21 | var modeler = new BpmnModeler({
22 | container: '#canvas',
23 | additionalModules: [
24 | customTranslateModule
25 | ]
26 | });
27 |
28 | // Import our diagram
29 | modeler.importXML(diagramXML).then(function() {
30 |
31 | console.log('Success!');
32 | }).catch(function(err) {
33 |
34 | console.error('Error', err);
35 | });
36 |
--------------------------------------------------------------------------------
/i18n/src/customTranslate/customTranslate.js:
--------------------------------------------------------------------------------
1 | import translations from './translations';
2 |
3 |
4 | export default function customTranslate(template, replacements) {
5 | replacements = replacements || {};
6 |
7 | // Translate
8 | template = translations[template] || template;
9 |
10 | // Replace
11 | return template.replace(/{([^}]+)}/g, function(_, key) {
12 | return replacements[key] || '{' + key + '}';
13 | });
14 | }
--------------------------------------------------------------------------------
/i18n/src/customTranslate/translations.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This is a sample file that should be replaced with the actual translation.
3 | *
4 | * Checkout https://github.com/bpmn-io/bpmn-js-i18n for a list of available
5 | * translations and labels to translate.
6 | */
7 | export default {
8 | 'Exclusive Gateway': 'Exklusives Gateway',
9 | 'Parallel Gateway': 'Paralleles Gateway',
10 | 'Inclusive Gateway': 'Inklusives Gateway',
11 | 'Complex Gateway': 'Komplexes Gateway',
12 | 'Event based Gateway': 'Ereignis-basiertes Gateway',
13 | 'Message Start Event': '消息启动事件',
14 | 'Timer Start Event': '定时启动事件',
15 | 'Conditional Start Event': '条件启动事件',
16 | 'Signal Start Event': '信号启动事件',
17 | 'Error Start Event': '错误启动事件',
18 | 'Escalation Start Event': '升级启动事件',
19 | 'Compensation Start Event': '补偿启动事件',
20 | 'Message Start Event (non-interrupting)': '消息启动事件 (非中断)',
21 | 'Timer Start Event (non-interrupting)': '定时启动事件 (非中断)',
22 | 'Conditional Start Event (non-interrupting)': '条件启动事件 (非中断)',
23 | 'Signal Start Event (non-interrupting)': '信号启动事件 (非中断)',
24 | 'Escalation Start Event (non-interrupting)': '升级启动事件 (非中断)',
25 | };
--------------------------------------------------------------------------------
/i18n/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bpmn-js i18n demo
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/i18n/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | module.exports = {
4 | entry: {
5 | bundle: [ './src/app.js' ]
6 | },
7 | output: {
8 | path: __dirname + '/public',
9 | filename: 'app.js'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.css$/,
15 | use: [
16 | 'style-loader',
17 | 'css-loader',
18 | ]
19 | },
20 | {
21 | test: /\.bpmn$/,
22 | use: 'raw-loader'
23 | }
24 | ]
25 | },
26 | plugins: [
27 | new CopyWebpackPlugin({
28 | patterns: [
29 | { from: 'src/index.html', to: '.' }
30 | ]
31 | })
32 | ],
33 | mode: 'development',
34 | devtool: 'source-map'
35 | };
36 |
--------------------------------------------------------------------------------
/interaction/README.md:
--------------------------------------------------------------------------------
1 | # bpmn-js interaction example
2 |
3 | An example that showcases the different ways to enable user interaction with
4 | BPMN diagrams using [bpmn-js](https://github.com/bpmn-io/bpmn-js).
5 |
6 | [__Try out__](https://cdn.statically.io/gh/bpmn-io/bpmn-js-examples/main/interaction/index.html).
7 |
8 |
9 | ## About
10 |
11 | The embeds a BPMN viewer, opens a BPMN 2.0 diagram and logs user interactions.
12 |
13 |
14 | ## Usage summary
15 |
16 | You may attach interaction event listeners to a BPMN viewer/modeler as soon as
17 | it has a diagram loaded:
18 |
19 |
20 | ```javascript
21 | var viewer = new BpmnJS({ container: SOME_CONTAINER });
22 |
23 | try {
24 | await viewer.importXML(diagramXM);
25 |
26 | // diagram is loaded, add interaction to it now
27 | // see below for options
28 | // ...
29 | } catch (err) {
30 | console.error('Error happened: ', err);
31 | }
32 | ```
33 |
34 | Two options exists for making your diagram interactive.
35 |
36 |
37 | ### Hook into diagram events
38 |
39 | Use the `eventBus` service to hook into `element.*` interaction events.
40 | [bpmn-js](https://github.com/bpmn-io/bpmn-js) makes sure the events are
41 | properly dispatched, even if the user works on a touch device.
42 |
43 | ```javascript
44 | var eventBus = viewer.get('eventBus');
45 |
46 | // you may hook into any of the following events
47 | var events = [
48 | 'element.hover',
49 | 'element.out',
50 | 'element.click',
51 | 'element.dblclick',
52 | 'element.mousedown',
53 | 'element.mouseup'
54 | ];
55 |
56 | events.forEach(function(event) {
57 |
58 | eventBus.on(event, function(e) {
59 | // e.element = the model element
60 | // e.gfx = the graphical element
61 |
62 | log(event, 'on', e.element.id);
63 | });
64 | });
65 | ```
66 |
67 |
68 | ### Directly attach listener to DOM
69 |
70 | You have more control on which elements you would like to address by directly
71 | attaching listeners to the underlying DOM (i.e. HTML/SVG) nodes.
72 |
73 | You can do so by searching for selectors like `[data-element-id=ID_OF_ELEMENT]`:
74 |
75 | ```javascript
76 | // each model element a data-element-id attribute attached to
77 | // it in HTML
78 |
79 | // select the end event
80 | var endEventNode = document.querySelector('[data-element-id=END_EVENT]');
81 | endEventNode.addEventListener('click', function(e) {
82 | alert('clicked the end event!');
83 | });
84 | ```
85 |
86 | Both options allow you to intercept user interaction with the diagram and
87 | handle it accordingly.
88 |
89 |
90 | ## Run this Example
91 |
92 | Download and open the [example HTML page](https://cdn.statically.io/gh/bpmn-io/bpmn-js-examples/main/interaction/index.html).
93 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "node_modules/lerna/schemas/lerna-schema.json",
3 | "version": "0.0.0"
4 | }
5 |
--------------------------------------------------------------------------------
/minimap/README.md:
--------------------------------------------------------------------------------
1 | # bpmn-js Minimap Example
2 |
3 | This example uses [bpmn-js](https://github.com/bpmn-io/bpmn-js) and [diagram-js-minimap](https://github.com/bpmn-io/diagram-js-minimap). It implements a BPMN 2.0 modeler with a minimap that lets you navigate the diagram.
4 |
5 | 
6 |
7 |
8 | ## Usage
9 |
10 | Add [diagram-js-minimap](https://github.com/bpmn-io/diagram-js-minimap) to your project:
11 |
12 | ```sh
13 | npm install --save diagram-js-minimap
14 | ```
15 |
16 | Now load the minimap module along with the [bpmn-js](https://github.com/bpmm-io/bpmn-js) instance:
17 |
18 | ```javascript
19 | import BpmnModeler from 'bpmn-js/lib/Modeler';
20 |
21 | import minimapModule from 'diagram-js-minimap';
22 |
23 | var bpmnModeler = new BpmnModeler({
24 | container: '#canvas',
25 | additionalModules: [
26 | minimapModule
27 | ]
28 | });
29 |
30 | await bpmnModeler.importXML(xml);
31 |
32 | console.log('Awesome! Ready to navigate!');
33 | ```
34 |
35 | Checkout [`src/app.js`](src/app.js) for details.
36 |
37 |
38 | ## Run the Example
39 |
40 | You need a [NodeJS](http://nodejs.org) development stack with [npm](https://npmjs.org) installed to build the project.
41 |
42 | To install all project dependencies execute
43 |
44 | ```sh
45 | npm install
46 | ```
47 |
48 | To start the example execute
49 |
50 | ```sh
51 | npm start
52 | ```
53 |
54 | To build the example into the `public` folder execute
55 |
56 | ```sh
57 | npm run all
58 | ```
59 |
--------------------------------------------------------------------------------
/minimap/docs/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/minimap/docs/screenshot.png
--------------------------------------------------------------------------------
/minimap/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-minimap",
3 | "version": "0.0.0",
4 | "description": "Use the diagram-js minimap with the bpmn-js modeler",
5 | "scripts": {
6 | "all": "run-s build",
7 | "build": "webpack --mode production",
8 | "dev": "webpack-dev-server --static=public --open",
9 | "start": "run-s dev"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
14 | },
15 | "keywords": [
16 | "bpmnjs-example"
17 | ],
18 | "author": {
19 | "name": "Philipp Fromme",
20 | "url": "https://github.com/philippfromme"
21 | },
22 | "contributors": [
23 | {
24 | "name": "bpmn.io contributors",
25 | "url": "https://github.com/bpmn-io"
26 | }
27 | ],
28 | "license": "MIT",
29 | "devDependencies": {
30 | "copy-webpack-plugin": "^13.0.0",
31 | "css-loader": "^7.1.2",
32 | "npm-run-all2": "^8.0.0",
33 | "raw-loader": "^4.0.0",
34 | "style-loader": "^4.0.0",
35 | "webpack": "^5.97.1",
36 | "webpack-cli": "^6.0.1",
37 | "webpack-dev-server": "^5.2.0"
38 | },
39 | "dependencies": {
40 | "bpmn-js": "^18.6.2",
41 | "diagram-js-minimap": "^5.0.0",
42 | "jquery": "^3.3.1"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/minimap/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bpmn-js minimap demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
Ooops, we could not display the BPMN 2.0 diagram.
12 |
13 |
14 |
cause of the problem
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/minimap/src/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | box-sizing: border-box;
3 | }
4 |
5 | body, html {
6 |
7 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
8 |
9 | font-size: 12px;
10 |
11 | height: 100%;
12 | padding: 0;
13 | margin: 0;
14 | }
15 |
16 | a:link {
17 | text-decoration: none;
18 | }
19 |
20 | .content,
21 | .content > div {
22 | width: 100%;
23 | height: 100%;
24 | position: relative;
25 | }
26 |
27 | .content > .message {
28 | text-align: center;
29 | display: table;
30 |
31 | font-size: 16px;
32 | color: #111;
33 | }
34 |
35 | .content > .message .note {
36 | vertical-align: middle;
37 | text-align: center;
38 | display: table-cell;
39 | }
40 |
41 | .content .error .details {
42 | max-width: 500px;
43 | font-size: 12px;
44 | margin: 20px auto;
45 | text-align: left;
46 | }
47 |
48 | .content .error pre {
49 | border: solid 1px #CCC;
50 | background: #EEE;
51 | padding: 10px;
52 | }
53 |
54 | .content:not(.with-error) .error,
55 | .content.with-error .intro,
56 | .content.with-diagram .intro {
57 | display: none;
58 | }
59 |
60 |
61 | .content .canvas,
62 | .content.with-error .canvas {
63 | visibility: hidden;
64 | }
65 |
66 | .content.with-diagram .canvas {
67 | visibility: visible;
68 | }
69 |
70 | .buttons {
71 | position: fixed;
72 | bottom: 20px;
73 | left: 20px;
74 |
75 | padding: 0;
76 | margin: 0;
77 | list-style: none;
78 | }
79 |
80 | .buttons > li {
81 | display: inline-block;
82 | margin-right: 10px;
83 | }
84 | .buttons > li > a {
85 | background: #DDD;
86 | border: solid 1px #666;
87 | display: inline-block;
88 | padding: 5px;
89 | }
90 |
91 | .buttons a {
92 | opacity: 0.3;
93 | }
94 |
95 | .buttons a.active {
96 | opacity: 1.0;
97 | }
98 |
--------------------------------------------------------------------------------
/minimap/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | module.exports = {
4 | entry: {
5 | bundle: [ './src/app.js' ]
6 | },
7 | output: {
8 | path: __dirname + '/public',
9 | filename: 'app.js'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.css$/,
15 | use: [
16 | 'style-loader',
17 | 'css-loader',
18 | ]
19 | },
20 | {
21 | test: /\.bpmn$/,
22 | use: 'raw-loader'
23 | }
24 | ]
25 | },
26 | plugins: [
27 | new CopyWebpackPlugin({
28 | patterns: [
29 | { from: 'src/index.html', to: '.' }
30 | ]
31 | })
32 | ],
33 | mode: 'development',
34 | devtool: 'source-map'
35 | };
36 |
--------------------------------------------------------------------------------
/modeler/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | public/
--------------------------------------------------------------------------------
/modeler/README.md:
--------------------------------------------------------------------------------
1 | # bpmn-js Modeler Example
2 |
3 | This example uses [bpmn-js](https://github.com/bpmn-io/bpmn-js) to implement a modeler for BPMN 2.0 process diagrams. It serves as the basis of the bpmn-js demo application available at [demo.bpmn.io](http://demo.bpmn.io).
4 |
5 | ## About
6 |
7 | This example is a node-style web application that builds a user interface around the bpmn-js BPMN 2.0 modeler.
8 |
9 | 
10 |
11 |
12 | ## Building
13 |
14 | You need a [NodeJS](http://nodejs.org) development stack with [npm](https://npmjs.org) installed to build the project.
15 |
16 | To install all project dependencies execute
17 |
18 | ```
19 | npm install
20 | ```
21 |
22 | Build the application (including [bpmn-js](https://github.com/bpmn-io/bpmn-js)) via
23 |
24 | ```
25 | npm run all
26 | ```
27 |
28 | You may also spawn a development setup by executing
29 |
30 | ```
31 | npm run dev
32 | ```
33 |
34 | Both tasks generate the distribution ready client-side modeler application into the `public` folder.
35 |
36 | Serve the application locally or via a web server (nginx, apache, embedded).
--------------------------------------------------------------------------------
/modeler/docs/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/modeler/docs/screenshot.png
--------------------------------------------------------------------------------
/modeler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bpmn-js-example-modeler",
3 | "version": "0.0.0",
4 | "description": "A simple modeler built with bpmn-js",
5 | "scripts": {
6 | "all": "run-s build",
7 | "build": "webpack --mode production",
8 | "dev": "webpack-dev-server --static=public --open",
9 | "start": "run-s dev"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
14 | },
15 | "keywords": [
16 | "bpmnjs-example"
17 | ],
18 | "author": {
19 | "name": "Nico Rehwaldt",
20 | "url": "https://github.com/nikku"
21 | },
22 | "contributors": [
23 | {
24 | "name": "bpmn.io contributors",
25 | "url": "https://github.com/bpmn-io"
26 | }
27 | ],
28 | "license": "MIT",
29 | "devDependencies": {
30 | "copy-webpack-plugin": "^13.0.0",
31 | "css-loader": "^7.1.2",
32 | "npm-run-all2": "^8.0.0",
33 | "raw-loader": "^4.0.0",
34 | "style-loader": "^4.0.0",
35 | "webpack": "^5.97.1",
36 | "webpack-cli": "^6.0.1",
37 | "webpack-dev-server": "^5.2.0"
38 | },
39 | "dependencies": {
40 | "bpmn-js": "^18.6.2",
41 | "diagram-js": "^15.1.0",
42 | "jquery": "^3.3.1"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/modeler/resources/newDiagram.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/modeler/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bpmn-js modeler demo
5 |
6 |
7 |
8 |
9 |
14 |
15 |
16 |
17 |
Ooops, we could not display the BPMN 2.0 diagram.
18 |
19 |
20 |
cause of the problem
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/modeler/src/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | box-sizing: border-box;
3 | }
4 |
5 | body, html {
6 |
7 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
8 |
9 | font-size: 12px;
10 |
11 | height: 100%;
12 | padding: 0;
13 | margin: 0;
14 | }
15 |
16 | a:link {
17 | text-decoration: none;
18 | }
19 |
20 | .content,
21 | .content > div {
22 | width: 100%;
23 | height: 100%;
24 | overflow: hidden;
25 | }
26 |
27 | .content > .message {
28 | text-align: center;
29 | display: table;
30 |
31 | font-size: 16px;
32 | color: #111;
33 | }
34 |
35 | .content > .message .note {
36 | vertical-align: middle;
37 | text-align: center;
38 | display: table-cell;
39 | }
40 |
41 | .content > .error .details {
42 | max-width: 500px;
43 | font-size: 12px;
44 | margin: 20px auto;
45 | text-align: left;
46 | }
47 |
48 | .content > .error pre {
49 | border: solid 1px #CCC;
50 | background: #EEE;
51 | padding: 10px;
52 | }
53 |
54 | .content:not(.with-error) > .error,
55 | .content.with-error > .intro,
56 | .content.with-diagram > .intro {
57 | display: none;
58 | }
59 |
60 |
61 | .content .canvas,
62 | .content.with-error .canvas {
63 | visibility: hidden;
64 | }
65 |
66 | .content.with-diagram .canvas {
67 | visibility: visible;
68 | }
69 |
70 | .buttons {
71 | position: fixed;
72 | bottom: 20px;
73 | left: 20px;
74 |
75 | padding: 0;
76 | margin: 0;
77 | list-style: none;
78 | }
79 |
80 | .buttons > li {
81 | display: inline-block;
82 | margin-right: 10px;
83 | }
84 | .buttons > li > a {
85 | background: #DDD;
86 | border: solid 1px #666;
87 | display: inline-block;
88 | padding: 5px;
89 | }
90 |
91 | .buttons a {
92 | opacity: 0.3;
93 | }
94 |
95 | .buttons a.active {
96 | opacity: 1.0;
97 | }
--------------------------------------------------------------------------------
/modeler/webpack.config.js:
--------------------------------------------------------------------------------
1 | const CopyWebpackPlugin = require('copy-webpack-plugin');
2 |
3 | module.exports = {
4 | entry: {
5 | bundle: [ './src/app.js' ]
6 | },
7 | output: {
8 | path: __dirname + '/public',
9 | filename: 'app.js'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.css$/,
15 | use: [
16 | 'style-loader',
17 | 'css-loader',
18 | ]
19 | },
20 | {
21 | test: /\.bpmn$/,
22 | use: 'raw-loader'
23 | }
24 | ]
25 | },
26 | plugins: [
27 | new CopyWebpackPlugin({
28 | patterns: [
29 | { from: 'src/index.html', to: '.' }
30 | ]
31 | })
32 | ],
33 | mode: 'development',
34 | devtool: 'source-map'
35 | };
36 |
--------------------------------------------------------------------------------
/modeling-api/README.md:
--------------------------------------------------------------------------------
1 | # bpmn-js Example: Modeling Using the Api
2 |
3 | A step-by-step introduction to modeling using the API. You'll learn how create and edit shapes and connections.
4 |
5 | 
6 |
7 | ## About This Example
8 |
9 | This example is built as a webpage that introduces you to the basics of working with bpmn-js' API, including:
10 |
11 | * creating and editing shapes and connections
12 | * editing the BPMN properties of an element
13 | * creating collaborations, participants and lanes
14 |
15 | ## Running the Example
16 |
17 | Install the dependencies:
18 |
19 | ```
20 | npm install
21 | ```
22 |
23 | Build and open the example in the browser:
24 |
25 | ```
26 | npm start
27 | ```
28 |
29 | ## License
30 |
31 | MIT
32 |
--------------------------------------------------------------------------------
/modeling-api/docs/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/e2ab40bea617a33ed181573e89dee0167c11c528/modeling-api/docs/screenshot.png
--------------------------------------------------------------------------------
/modeling-api/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "modeling-api",
3 | "version": "0.0.0",
4 | "description": "Modeling bpmn-js using the API",
5 | "scripts": {
6 | "all": "run-s build",
7 | "build": "webpack --mode production",
8 | "dev": "webpack-dev-server --static=public --open",
9 | "start": "run-s dev"
10 | },
11 | "devDependencies": {
12 | "copy-webpack-plugin": "^13.0.0",
13 | "css-loader": "^7.1.2",
14 | "npm-run-all2": "^8.0.0",
15 | "raw-loader": "^4.0.0",
16 | "style-loader": "^4.0.0",
17 | "webpack": "^5.97.1",
18 | "webpack-cli": "^6.0.1",
19 | "webpack-dev-server": "^5.2.0"
20 | },
21 | "dependencies": {
22 | "bpmn-js": "^18.6.2",
23 | "diagram-js": "^15.1.0",
24 | "highlight.js": "^11.10.0",
25 | "min-dom": "^4.2.1"
26 | },
27 | "repository": {
28 | "type": "git",
29 | "url": "https://github.com/bpmn-io/bpmn-js-examples"
30 | },
31 | "keywords": [
32 | "bpmnjs-example"
33 | ],
34 | "author": {
35 | "name": "bpmn.io team",
36 | "url": "https://github.com/bpmn-io"
37 | },
38 | "license": "MIT"
39 | }
40 |
--------------------------------------------------------------------------------
/modeling-api/resources/diagram.bpmn:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modeling-api/src/app.js:
--------------------------------------------------------------------------------
1 | import 'bpmn-js/dist/assets/diagram-js.css';
2 | import 'bpmn-js/dist/assets/bpmn-js.css';
3 |
4 | import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
5 |
6 | import './style.css';
7 |
8 | import BpmnModeler from 'bpmn-js/lib/Modeler';
9 |
10 | import hljs from 'highlight.js/lib/core';
11 | import javascript from 'highlight.js/lib/languages/javascript';
12 |
13 | import diagram from '../resources/diagram.bpmn';
14 |
15 | import { domify } from 'min-dom';
16 |
17 | import snippets from './snippets';
18 |
19 | hljs.registerLanguage('javascript', javascript);
20 | hljs.initHighlightingOnLoad();
21 |
22 | const container = document.querySelector('.modeler');
23 |
24 | const modeler = new BpmnModeler({
25 | container
26 | });
27 |
28 | async function openDiagram(xml) {
29 | return modeler.importXML(xml).catch(err => {
30 | console.log(err);
31 | });
32 | }
33 |
34 | /**
35 | * Load snippet, display code and show resulting diagram.
36 | *
37 | * @param {Function} fn
38 | * @param {String} diagram
39 | */
40 | function loadSnippet(fn, diagram) {
41 | openDiagram(diagram).then(() => {
42 |
43 | // (1) Reset zoom
44 | modeler.get('canvas').zoom('fit-viewport');
45 |
46 | // (2) Execute snippet
47 | fn(modeler);
48 |
49 | // (3) Display snippet code
50 | let code = formatSnippetCode(fn.toString());
51 |
52 | document.querySelector('.snippet__code').textContent = code;
53 |
54 | hljs.highlightBlock(document.querySelector('.snippet__code'));
55 |
56 | // (4) Export to console
57 | modeler.saveXML({ format: true }).then(({ xml }) => console.info(xml));
58 | });
59 | }
60 |
61 | /**
62 | * Set up snippets.
63 | *
64 | * @param {Array