1 | import inherits from 'inherits';
|
2 |
|
3 | import CoreModule from './core';
|
4 | import TranslateModule from 'diagram-js/lib/i18n/translate';
|
5 | import SelectionModule from 'diagram-js/lib/features/selection';
|
6 | import OverlaysModule from 'diagram-js/lib/features/overlays';
|
7 |
|
8 | import BaseViewer from './BaseViewer';
|
9 |
|
10 |
|
11 | /**
|
12 | * A viewer for BPMN 2.0 diagrams.
|
13 | *
|
14 | * Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
|
15 | * additional features.
|
16 | *
|
17 | *
|
18 | * ## Extending the Viewer
|
19 | *
|
20 | * In order to extend the viewer pass extension modules to bootstrap via the
|
21 | * `additionalModules` option. An extension module is an object that exposes
|
22 | * named services.
|
23 | *
|
24 | * The following example depicts the integration of a simple
|
25 | * logging component that integrates with interaction events:
|
26 | *
|
27 | *
|
28 | * ```javascript
|
29 | *
|
30 | * // logging component
|
31 | * function InteractionLogger(eventBus) {
|
32 | * eventBus.on('element.hover', function(event) {
|
33 | * console.log()
|
34 | * })
|
35 | * }
|
36 | *
|
37 | * InteractionLogger.$inject = [ 'eventBus' ]; // minification save
|
38 | *
|
39 | * // extension module
|
40 | * var extensionModule = {
|
41 | * __init__: [ 'interactionLogger' ],
|
42 | * interactionLogger: [ 'type', InteractionLogger ]
|
43 | * };
|
44 | *
|
45 | * // extend the viewer
|
46 | * var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
|
47 | * bpmnViewer.importXML(...);
|
48 | * ```
|
49 | *
|
50 | * @param {Object} [options] configuration options to pass to the viewer
|
51 | * @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
52 | * @param {String|Number} [options.width] the width of the viewer
|
53 | * @param {String|Number} [options.height] the height of the viewer
|
54 | * @param {Object} [options.moddleExtensions] extension packages to provide
|
55 | * @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
|
56 | * @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
|
57 | */
|
58 | export default function Viewer(options) {
|
59 | BaseViewer.call(this, options);
|
60 | }
|
61 |
|
62 | inherits(Viewer, BaseViewer);
|
63 |
|
64 | // modules the viewer is composed of
|
65 | Viewer.prototype._modules = [
|
66 | CoreModule,
|
67 | TranslateModule,
|
68 | SelectionModule,
|
69 | OverlaysModule
|
70 | ];
|
71 |
|
72 | // default moddle extensions the viewer is composed of
|
73 | Viewer.prototype._moddleExtensions = {}; |
\ | No newline at end of file |