bpmn-js 0.20.6 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +33 -33
- package/.npmignore +8 -8
- package/.travis.yml +19 -17
- package/.wiredeps +88 -88
- package/CONTRIBUTING.md +55 -55
- package/Gruntfile.js +129 -129
- package/LICENSE +22 -22
- package/README.md +113 -113
- package/assets/bpmn-font/css/bpmn-embedded.css +159 -159
- package/assets/bpmn-font/css/bpmn.css +161 -161
- package/assets/bpmn-font/font/bpmn.svg +116 -116
- package/docs/architecture/overview.svg +48 -48
- package/docs/project/COMMIT_MESSAGES.md +82 -82
- package/docs/project/SETUP.md +66 -66
- package/docs/project/setup-alternative.sh +41 -41
- package/docs/project/setup.bat +45 -45
- package/docs/project/setup.sh +40 -40
- package/docs/translations.json +97 -97
- package/lib/Modeler.js +208 -208
- package/lib/NavigatedViewer.js +27 -27
- package/lib/Viewer.js +503 -503
- package/lib/core/index.js +5 -5
- package/lib/draw/BpmnRenderer.js +1934 -1934
- package/lib/draw/PathMap.js +478 -478
- package/lib/draw/index.js +5 -5
- package/lib/features/auto-resize/BpmnAutoResize.js +34 -34
- package/lib/features/auto-resize/BpmnAutoResizeProvider.js +51 -51
- package/lib/features/auto-resize/index.js +5 -5
- package/lib/features/context-pad/ContextPadProvider.js +374 -374
- package/lib/features/context-pad/index.js +11 -11
- package/lib/features/copy-paste/BpmnCopyPaste.js +157 -154
- package/lib/features/copy-paste/index.js +7 -7
- package/lib/features/distribute-elements/BpmnDistributeElements.js +34 -34
- package/lib/features/distribute-elements/index.js +7 -7
- package/lib/features/editor-actions/BpmnEditorActions.js +130 -130
- package/lib/features/editor-actions/index.js +15 -15
- package/lib/features/global-connect/BpmnGlobalConnect.js +49 -49
- package/lib/features/global-connect/index.js +7 -7
- package/lib/features/keyboard/BpmnKeyBindings.js +72 -72
- package/lib/features/keyboard/index.js +7 -7
- package/lib/features/label-editing/LabelEditingPreview.js +122 -0
- package/lib/features/label-editing/LabelEditingProvider.js +292 -193
- package/lib/features/label-editing/LabelUtil.js +43 -43
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +116 -112
- package/lib/features/label-editing/index.js +14 -9
- package/lib/features/modeling/BpmnFactory.js +97 -97
- package/lib/features/modeling/BpmnLayouter.js +191 -191
- package/lib/features/modeling/BpmnUpdater.js +692 -688
- package/lib/features/modeling/ElementFactory.js +218 -218
- package/lib/features/modeling/Modeling.js +183 -183
- package/lib/features/modeling/behavior/AppendBehavior.js +42 -42
- package/lib/features/modeling/behavior/CopyPasteBehavior.js +69 -69
- package/lib/features/modeling/behavior/CreateBoundaryEventBehavior.js +51 -51
- package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +37 -37
- package/lib/features/modeling/behavior/CreateParticipantBehavior.js +91 -91
- package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +151 -151
- package/lib/features/modeling/behavior/DeleteLaneBehavior.js +107 -107
- package/lib/features/modeling/behavior/DropOnFlowBehavior.js +165 -131
- package/lib/features/modeling/behavior/ImportDockingFix.js +80 -80
- package/lib/features/modeling/behavior/LabelBehavior.js +222 -222
- package/lib/features/modeling/behavior/ModelingFeedback.js +50 -50
- package/lib/features/modeling/behavior/RemoveElementBehavior.js +73 -73
- package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +50 -50
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +128 -128
- package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +118 -116
- package/lib/features/modeling/behavior/ResizeLaneBehavior.js +59 -59
- package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +138 -138
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +27 -27
- package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +54 -54
- package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +156 -156
- package/lib/features/modeling/behavior/index.js +44 -44
- package/lib/features/modeling/behavior/util/GeometricUtil.js +129 -129
- package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +218 -218
- package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +233 -233
- package/lib/features/modeling/behavior/util/LineIntersect.js +36 -36
- package/lib/features/modeling/cmd/AddLaneHandler.js +83 -83
- package/lib/features/modeling/cmd/IdClaimHandler.js +41 -41
- package/lib/features/modeling/cmd/ResizeLaneHandler.js +125 -125
- package/lib/features/modeling/cmd/SplitLaneHandler.js +82 -82
- package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +78 -78
- package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +185 -185
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +264 -264
- package/lib/features/modeling/index.js +23 -23
- package/lib/features/modeling/util/LaneUtil.js +157 -157
- package/lib/features/modeling/util/ModelingUtil.js +48 -48
- package/lib/features/ordering/BpmnOrderingProvider.js +147 -147
- package/lib/features/ordering/index.js +6 -6
- package/lib/features/palette/PaletteProvider.js +158 -158
- package/lib/features/palette/index.js +13 -13
- package/lib/features/popup-menu/ReplaceMenuProvider.js +479 -479
- package/lib/features/popup-menu/index.js +7 -7
- package/lib/features/popup-menu/util/TypeUtil.js +41 -41
- package/lib/features/replace/BpmnReplace.js +197 -197
- package/lib/features/replace/ReplaceOptions.js +787 -787
- package/lib/features/replace/index.js +7 -7
- package/lib/features/replace-preview/BpmnReplacePreview.js +113 -113
- package/lib/features/replace-preview/index.js +5 -5
- package/lib/features/rules/BpmnRules.js +807 -806
- package/lib/features/rules/index.js +7 -7
- package/lib/features/search/BpmnSearchProvider.js +128 -128
- package/lib/features/search/index.js +7 -7
- package/lib/features/snapping/BpmnSnapping.js +511 -495
- package/lib/features/snapping/BpmnSnappingUtil.js +159 -159
- package/lib/features/snapping/index.js +3 -3
- package/lib/import/BpmnImporter.js +302 -302
- package/lib/import/BpmnTreeWalker.js +445 -445
- package/lib/import/Importer.js +69 -69
- package/lib/import/Util.js +8 -8
- package/lib/import/index.js +5 -5
- package/lib/util/DiUtil.js +60 -60
- package/lib/util/LabelUtil.js +139 -139
- package/lib/util/ModelUtil.js +31 -31
- package/lib/util/PoweredByUtil.js +82 -82
- package/lib/util/model/ModelCloneHelper.js +201 -201
- package/lib/util/model/ModelCloneUtils.js +35 -35
- package/package.json +22 -22
- package/resources/initial.bpmn +12 -12
- package/resources/screencast.gif +0 -0
- package/tasks/banner.txt +11 -11
- package/tasks/bundle.js +162 -162
- package/test/TestHelper.js +17 -17
- package/test/config/karma.unit.js +46 -46
- package/test/config/translation-reporter.js +48 -48
- package/test/fixtures/bpmn/align-elements.bpmn +136 -136
- package/test/fixtures/bpmn/basic.bpmn +17 -17
- package/test/fixtures/bpmn/boundary-events.bpmn +59 -59
- package/test/fixtures/bpmn/collaboration/collaboration-empty-participant.bpmn +13 -13
- package/test/fixtures/bpmn/collaboration/collaboration-message-flows.bpmn +89 -89
- package/test/fixtures/bpmn/collaboration/collaboration-participant.bpmn +59 -59
- package/test/fixtures/bpmn/collaboration/process-empty.bpmn +6 -6
- package/test/fixtures/bpmn/collaboration/process.bpmn +47 -47
- package/test/fixtures/bpmn/collaboration-data-items.bpmn +81 -81
- package/test/fixtures/bpmn/collaboration-message-flows.bpmn +82 -82
- package/test/fixtures/bpmn/collaboration-sequence-flows.bpmn +83 -83
- package/test/fixtures/bpmn/collaboration.bpmn +50 -50
- package/test/fixtures/bpmn/complex.bpmn +2151 -2151
- package/test/fixtures/bpmn/conditions.bpmn +82 -82
- package/test/fixtures/bpmn/containers.bpmn +128 -128
- package/test/fixtures/bpmn/distribute-elements-filtering.bpmn +58 -58
- package/test/fixtures/bpmn/distribute-elements.bpmn +232 -232
- package/test/fixtures/bpmn/draw/activity-markers-combination.bpmn +141 -141
- package/test/fixtures/bpmn/draw/activity-markers-simple.bpmn +47 -47
- package/test/fixtures/bpmn/draw/activity-markers.bpmn +212 -212
- package/test/fixtures/bpmn/draw/associations.bpmn +55 -55
- package/test/fixtures/bpmn/draw/boundary-event-with-refnode.bpmn +81 -81
- package/test/fixtures/bpmn/draw/boundary-event-without-refnode.bpmn +81 -81
- package/test/fixtures/bpmn/draw/boundary-event-z-index.bpmn +82 -82
- package/test/fixtures/bpmn/draw/call-activity.bpmn +12 -12
- package/test/fixtures/bpmn/draw/colors.bpmn +411 -411
- package/test/fixtures/bpmn/draw/conditional-flow-default.bpmn +100 -100
- package/test/fixtures/bpmn/draw/conditional-flow-gateways.bpmn +72 -72
- package/test/fixtures/bpmn/draw/conditional-flow-typed-task.bpmn +33 -33
- package/test/fixtures/bpmn/draw/conditional-flow.bpmn +248 -248
- package/test/fixtures/bpmn/draw/data-objects.bpmn +265 -265
- package/test/fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn +200 -200
- package/test/fixtures/bpmn/draw/event-subprocesses-expanded.bpmn +274 -274
- package/test/fixtures/bpmn/draw/events-interrupting.bpmn +370 -370
- package/test/fixtures/bpmn/draw/events.bpmn +374 -374
- package/test/fixtures/bpmn/draw/gateway-type-default.bpmn +45 -45
- package/test/fixtures/bpmn/draw/gateways.bpmn +61 -61
- package/test/fixtures/bpmn/draw/group.bpmn +24 -24
- package/test/fixtures/bpmn/draw/message-marker.bpmn +112 -112
- package/test/fixtures/bpmn/draw/pools-with-collection-marker.bpmn +104 -104
- package/test/fixtures/bpmn/draw/pools.bpmn +82 -82
- package/test/fixtures/bpmn/draw/task-types.bpmn +77 -77
- package/test/fixtures/bpmn/draw/text-annotation.bpmn +71 -71
- package/test/fixtures/bpmn/draw/xor.bpmn +45 -45
- package/test/fixtures/bpmn/empty-definitions.bpmn +4 -4
- package/test/fixtures/bpmn/error/categoryValue.bpmn +26 -26
- package/test/fixtures/bpmn/error/di-plane-no-bpmn-element.bpmn +9 -9
- package/test/fixtures/bpmn/error/duplicate-ids.bpmn +14 -14
- package/test/fixtures/bpmn/error/invalid-child.bpmn +6 -6
- package/test/fixtures/bpmn/error/missing-namespace.bpmn +12 -12
- package/test/fixtures/bpmn/event-sub-processes.bpmn +47 -47
- package/test/fixtures/bpmn/extension/camunda.bpmn +52 -52
- package/test/fixtures/bpmn/extension/custom-override.bpmn +53 -53
- package/test/fixtures/bpmn/extension/custom.bpmn +53 -53
- package/test/fixtures/bpmn/features/copy-paste/basic.bpmn +111 -111
- package/test/fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn +102 -102
- package/test/fixtures/bpmn/features/copy-paste/collaboration.bpmn +74 -74
- package/test/fixtures/bpmn/features/copy-paste/data-associations.bpmn +61 -61
- package/test/fixtures/bpmn/features/copy-paste/properties.bpmn +43 -43
- package/test/fixtures/bpmn/features/drop/drop.bpmn +41 -41
- package/test/fixtures/bpmn/features/drop/recursive-task.bpmn +37 -37
- package/test/fixtures/bpmn/features/label-editing/labels.bpmn +178 -248
- package/test/fixtures/bpmn/features/modeling/update-label.bpmn +24 -24
- package/test/fixtures/bpmn/features/replace/01_replace.bpmn +193 -193
- package/test/fixtures/bpmn/features/replace/association-gateways.bpmn +173 -173
- package/test/fixtures/bpmn/features/replace/cancel-events.bpmn +49 -49
- package/test/fixtures/bpmn/features/replace/clone-properties.bpmn +141 -141
- package/test/fixtures/bpmn/features/replace/connection.bpmn +42 -42
- package/test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn +72 -72
- package/test/fixtures/bpmn/features/rules/link-event.bpmn +35 -35
- package/test/fixtures/bpmn/features/rules/text-annotation-association.bpmn +30 -30
- package/test/fixtures/bpmn/flow-markers.bpmn +212 -212
- package/test/fixtures/bpmn/import/boundaryEvent.bpmn +33 -33
- package/test/fixtures/bpmn/import/collaboration.bpmn +50 -50
- package/test/fixtures/bpmn/import/collapsed/collaboration.bpmn +76 -76
- package/test/fixtures/bpmn/import/collapsed/process.bpmn +84 -84
- package/test/fixtures/bpmn/import/collapsed/processWithChildren.bpmn +273 -273
- package/test/fixtures/bpmn/import/default-attrs.bpmn +24 -24
- package/test/fixtures/bpmn/import/error/boundaryEvent-invalidAttachToRef.bpmn +30 -30
- package/test/fixtures/bpmn/import/error/boundaryEvent-missingAttachToRef.bpmn +33 -33
- package/test/fixtures/bpmn/import/error/dangling-process-message-flow.bpmn +81 -81
- package/test/fixtures/bpmn/import/error/invalid-flow-element.bpmn +35 -35
- package/test/fixtures/bpmn/import/error/multiple-dis.bpmn +23 -23
- package/test/fixtures/bpmn/import/labels/collaboration-message-flows.bpmn +41 -41
- package/test/fixtures/bpmn/import/labels/collaboration.bpmn +72 -72
- package/test/fixtures/bpmn/import/labels/embedded.bpmn +39 -39
- package/test/fixtures/bpmn/import/labels/external-no-di.bpmn +42 -42
- package/test/fixtures/bpmn/import/labels/external.bpmn +69 -69
- package/test/fixtures/bpmn/import/position/position-testcase.bpmn +57 -57
- package/test/fixtures/bpmn/import/process.bpmn +60 -60
- package/test/fixtures/bpmn/nested-subprocesses.bpmn +118 -118
- package/test/fixtures/bpmn/sequence-flows.bpmn +60 -60
- package/test/fixtures/bpmn/simple-cropping.bpmn +84 -84
- package/test/fixtures/bpmn/simple-resizable.bpmn +50 -50
- package/test/fixtures/bpmn/simple.bpmn +60 -60
- package/test/fixtures/json/model/camunda.json +1042 -1042
- package/test/fixtures/json/model/custom-override.json +39 -39
- package/test/fixtures/json/model/custom.json +39 -39
- package/test/helper/TranslationCollector.js +17 -17
- package/test/helper/index.js +249 -249
- package/test/integration/CustomElementsSpec.js +223 -223
- package/test/integration/ReimportSpec.js +89 -89
- package/test/integration/SimpleModelingSpec.js +29 -29
- package/test/integration/custom-elements/CustomElementFactory.js +77 -77
- package/test/integration/custom-elements/CustomRenderer.js +151 -151
- package/test/integration/custom-elements/CustomRules.js +148 -148
- package/test/integration/custom-elements/CustomUpdater.js +115 -115
- package/test/integration/custom-elements/index.js +7 -7
- package/test/integration/model/BpmnModdleSpec.js +65 -65
- package/test/matchers/JSONMatcher.js +19 -19
- package/test/spec/ModelerSpec.js +401 -401
- package/test/spec/NavigatedViewerSpec.js +58 -58
- package/test/spec/ViewerSpec.js +977 -977
- package/test/spec/draw/BpmnRendererSpec.js +311 -311
- package/test/spec/environment/MockingSpec.js +53 -53
- package/test/spec/features/align-elements/BpmnAlignElementsSpec.js +137 -137
- package/test/spec/features/auto-resize/AutoResize.lanes.bpmn +54 -54
- package/test/spec/features/auto-resize/AutoResize.multi-selection.bpmn +22 -22
- package/test/spec/features/auto-resize/AutoResize.nested-sub-processes.bpmn +47 -47
- package/test/spec/features/auto-resize/AutoResize.participant.bpmn +38 -38
- package/test/spec/features/auto-resize/AutoResize.space-tool.bpmn +38 -38
- package/test/spec/features/auto-resize/AutoResize.sub-processes.bpmn +37 -37
- package/test/spec/features/auto-resize/AutoResizeSpec.js +607 -607
- package/test/spec/features/context-pad/ContextPad.activation.bpmn +51 -51
- package/test/spec/features/context-pad/ContextPadProviderSpec.js +440 -440
- package/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +763 -725
- package/test/spec/features/copy-paste/DescriptorTree.js +58 -58
- package/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js +113 -113
- package/test/spec/features/editor-actions/BpmnEditorActionsSpec.js +72 -72
- package/test/spec/features/global-connect/BpmnGlobalConnectSpec.js +61 -61
- package/test/spec/features/keyboard/BpmnKeyBindingsSpec.js +142 -142
- package/test/spec/features/label-editing/LabelEditingPreviewSpec.js +133 -0
- package/test/spec/features/label-editing/LabelEditingProviderSpec.js +636 -601
- package/test/spec/features/label-editing/TouchIntegrationSpec.js +40 -40
- package/test/spec/features/modeling/AppendShapeSpec.js +332 -332
- package/test/spec/features/modeling/BendpointsSpec.js +25 -25
- package/test/spec/features/modeling/BpmnFactorySpec.js +73 -73
- package/test/spec/features/modeling/BpmnUpdater.bpmn +99 -99
- package/test/spec/features/modeling/BpmnUpdaterSpec.js +79 -79
- package/test/spec/features/modeling/CreateConnectionSpec.js +171 -171
- package/test/spec/features/modeling/DeleteConnectionSpec.js +75 -75
- package/test/spec/features/modeling/DeleteParticipantSpec.js +97 -97
- package/test/spec/features/modeling/DeleteShapeSpec.js +75 -75
- package/test/spec/features/modeling/DropSpec.js +123 -123
- package/test/spec/features/modeling/IdClaim.bpmn +13 -13
- package/test/spec/features/modeling/IdClaimSpec.js +50 -50
- package/test/spec/features/modeling/LabelBoundsSpec.js +342 -340
- package/test/spec/features/modeling/LabelBoundsSpec.simple.bpmn +27 -27
- package/test/spec/features/modeling/LabelLayouting.initial.bpmn +37 -37
- package/test/spec/features/modeling/LabelLayouting.move.bpmn +99 -99
- package/test/spec/features/modeling/LabelLayouting.special.bpmn +76 -76
- package/test/spec/features/modeling/LabelLayoutingSpec.js +603 -603
- package/test/spec/features/modeling/MoveConnectionSpec.js +101 -101
- package/test/spec/features/modeling/MoveElements.flow-collaboration.bpmn +45 -45
- package/test/spec/features/modeling/MoveElementsSpec.js +70 -70
- package/test/spec/features/modeling/MoveRulesSpec.js +151 -151
- package/test/spec/features/modeling/MoveShapeSpec.js +353 -353
- package/test/spec/features/modeling/ResizeShapeSpec.js +73 -73
- package/test/spec/features/modeling/SpaceToolSpec.js +251 -251
- package/test/spec/features/modeling/UpdateAttachmentSpec.js +96 -96
- package/test/spec/features/modeling/UpdateLabelSpec.js +130 -130
- package/test/spec/features/modeling/UpdatePropertiesSpec.js +503 -503
- package/test/spec/features/modeling/append/TextAnnotationSpec.js +136 -136
- package/test/spec/features/modeling/behavior/CompensationAssociationBehavior.bpmn +26 -26
- package/test/spec/features/modeling/behavior/CompensationAssociationBehaviorSpec.js +43 -43
- package/test/spec/features/modeling/behavior/CreateBoundaryEventBehaviorSpec.js +58 -58
- package/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js +224 -224
- package/test/spec/features/modeling/behavior/DataInputAssociationBehavior.bpmn +33 -33
- package/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js +146 -146
- package/test/spec/features/modeling/behavior/DataObjectBehavior.create-data-association.bpmn +21 -21
- package/test/spec/features/modeling/behavior/DataObjectBehavior.data-object-reference.bpmn +13 -13
- package/test/spec/features/modeling/behavior/DataObjectBehavior.remove-data-association.bpmn +41 -41
- package/test/spec/features/modeling/behavior/DataObjectBehaviorSpec.js +297 -297
- package/test/spec/features/modeling/behavior/DataStoreBehavior.bpmn +26 -26
- package/test/spec/features/modeling/behavior/DataStoreBehavior.connect.bpmn +57 -57
- package/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js +228 -228
- package/test/spec/features/modeling/behavior/DropOnFlowBehavior.bpmn +71 -67
- package/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js +591 -418
- package/test/spec/features/modeling/behavior/ImportDockingFix.bpmn +61 -61
- package/test/spec/features/modeling/behavior/ImportDockingFixSpec.js +37 -37
- package/test/spec/features/modeling/behavior/LabelBehaviorSpec.js +277 -277
- package/test/spec/features/modeling/behavior/ReconnectConnection.data-association.bpmn +41 -41
- package/test/spec/features/modeling/behavior/ReconnectConnectionSpec.js +120 -120
- package/test/spec/features/modeling/behavior/RemoveElementBehavior.bpmn +181 -181
- package/test/spec/features/modeling/behavior/RemoveElementBehavior.perpendicular.bpmn +159 -159
- package/test/spec/features/modeling/behavior/RemoveElementBehaviorSpec.js +251 -251
- package/test/spec/features/modeling/behavior/RemoveParticipantBehaviorSpec.js +125 -125
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.association.bpmn +26 -26
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.boundary-events.bpmn +40 -40
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.message-sequence-flow.bpmn +121 -121
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js +439 -439
- package/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js +450 -450
- package/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js +653 -653
- package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.bpmn +48 -48
- package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.js +77 -77
- package/test/spec/features/modeling/behavior/util/GeometricUtilSpec.js +127 -127
- package/test/spec/features/modeling/behavior/util/LabelLayoutUtilSpec.js +75 -75
- package/test/spec/features/modeling/behavior/util/LineAttachmentUtilSpec.js +294 -294
- package/test/spec/features/modeling/behavior/util/LineIntersectSpec.js +32 -32
- package/test/spec/features/modeling/lanes/AddLaneSpec.js +263 -263
- package/test/spec/features/modeling/lanes/DeleteLaneSpec.js +126 -126
- package/test/spec/features/modeling/lanes/ResizeLaneSpec.js +366 -366
- package/test/spec/features/modeling/lanes/SplitLaneSpec.js +216 -216
- package/test/spec/features/modeling/lanes/UpdateFlowNodeRefsSpec.js +271 -271
- package/test/spec/features/modeling/lanes/flowNodeRefs.bpmn +56 -56
- package/test/spec/features/modeling/lanes/lanes.bpmn +83 -83
- package/test/spec/features/modeling/lanes/participant-lane.bpmn +27 -27
- package/test/spec/features/modeling/lanes/participant-no-lane.bpmn +22 -22
- package/test/spec/features/modeling/layout/Helper.js +64 -64
- package/test/spec/features/modeling/layout/LayoutAssociationSpec.js +101 -101
- package/test/spec/features/modeling/layout/LayoutConnectionSpec.js +98 -98
- package/test/spec/features/modeling/layout/LayoutDataAssociationSpec.js +98 -98
- package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.bpmn +119 -119
- package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js +313 -313
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.boundaryEvents.bpmn +65 -65
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.flowElements.bpmn +70 -70
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js +323 -323
- package/test/spec/features/ordering/BpmnOrderingProviderSpec.js +231 -231
- package/test/spec/features/ordering/Helper.js +185 -185
- package/test/spec/features/ordering/ordering-start-event.bpmn +17 -17
- package/test/spec/features/ordering/ordering-subprocesses.bpmn +41 -41
- package/test/spec/features/ordering/ordering.bpmn +105 -105
- package/test/spec/features/palette/PaletteProviderSpec.js +33 -33
- package/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn +13 -13
- package/test/spec/features/popup-menu/ReplaceMenuProvider.compensation-activity.bpmn +12 -12
- package/test/spec/features/popup-menu/ReplaceMenuProvider.conditionalFlows.bpmn +66 -66
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlows.bpmn +126 -126
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn +48 -48
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromInclusiveGateways.bpmn +48 -48
- package/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +1957 -1957
- package/test/spec/features/replace/BpmnReplace.collaboration.bpmn +70 -70
- package/test/spec/features/replace/BpmnReplace.compensation.bpmn +12 -12
- package/test/spec/features/replace/BpmnReplace.eventSubProcesses.bpmn +126 -126
- package/test/spec/features/replace/BpmnReplaceSpec.js +1302 -1302
- package/test/spec/features/replace/ReplaceRulesSpec.js +78 -78
- package/test/spec/features/replace/SubProcess-collapsed.bpmn +36 -36
- package/test/spec/features/replace-preview/BpmnReplacePreviewSpec.js +304 -304
- package/test/spec/features/rules/BpmnRules.boundaryEvent.bpmn +93 -93
- package/test/spec/features/rules/BpmnRules.collaboration-dataAssociation.bpmn +35 -35
- package/test/spec/features/rules/BpmnRules.collaboration-lanes.bpmn +79 -79
- package/test/spec/features/rules/BpmnRules.collaboration.bpmn +138 -138
- package/test/spec/features/rules/BpmnRules.compensation.bpmn +65 -65
- package/test/spec/features/rules/BpmnRules.dataAssociation.bpmn +33 -33
- package/test/spec/features/rules/BpmnRules.eventBasedGateway.bpmn +82 -82
- package/test/spec/features/rules/BpmnRules.messageFlow.bpmn +27 -27
- package/test/spec/features/rules/BpmnRules.multiSelectionPools.bpmn +37 -37
- package/test/spec/features/rules/BpmnRules.process.bpmn +91 -91
- package/test/spec/features/rules/BpmnRules.subProcess-dataAssociation.bpmn +44 -44
- package/test/spec/features/rules/BpmnRulesSpec.js +1468 -1424
- package/test/spec/features/rules/Helper.js +82 -82
- package/test/spec/features/search/BpmnSearchProviderSpec.js +158 -158
- package/test/spec/features/search/bpmn-search-collaboration.bpmn +106 -106
- package/test/spec/features/search/bpmn-search.bpmn +100 -100
- package/test/spec/features/snapping/BpmnSnapping.connect.bpmn +36 -36
- package/test/spec/features/snapping/BpmnSnapping.labels.bpmn +27 -27
- package/test/spec/features/snapping/BpmnSnapping.lanes-resize.bpmn +43 -43
- package/test/spec/features/snapping/BpmnSnapping.participant-resize.bpmn +50 -50
- package/test/spec/features/snapping/BpmnSnapping.sequenceFlow.bpmn +41 -0
- package/test/spec/features/snapping/BpmnSnapping.subProcess-resize.bpmn +21 -21
- package/test/spec/features/snapping/BpmnSnapping.textAnnotation-resize.bpmn +22 -22
- package/test/spec/features/snapping/BpmnSnappingSpec.js +824 -758
- package/test/spec/features/snapping/BpmnSnappingUtil.lanes-flowNodes.bpmn +82 -82
- package/test/spec/features/snapping/BpmnSnappingUtil.lanes.bpmn +35 -35
- package/test/spec/features/snapping/BpmnSnappingUtilSpec.js +285 -285
- package/test/spec/i18n/custom-translate/custom-translate.js +14 -14
- package/test/spec/i18n/custom-translate/index.js +2 -2
- package/test/spec/i18n/translateSpec.js +56 -56
- package/test/spec/import/ImporterSpec.js +428 -428
- package/test/spec/import/ModelWiringSpec.js +194 -194
- package/test/spec/import/elements/AssociationSpec.collaboration.bpmn +51 -51
- package/test/spec/import/elements/AssociationSpec.compensation.bpmn +28 -28
- package/test/spec/import/elements/AssociationSpec.data-association.bpmn +39 -39
- package/test/spec/import/elements/AssociationSpec.data-input-output.bpmn +40 -40
- package/test/spec/import/elements/AssociationSpec.events.bpmn +51 -51
- package/test/spec/import/elements/AssociationSpec.js +175 -175
- package/test/spec/import/elements/AssociationSpec.text-annotation.bpmn +37 -37
- package/test/spec/import/elements/CollapsedSpec.js +118 -118
- package/test/spec/import/elements/LabelSpec.js +85 -85
- package/test/spec/import/lane-flowNodes.bpmn +44 -44
- package/test/spec/import/lane-missing-flowNodeRef.bpmn +24 -24
- package/test/spec/util/ModelCloneHelperSpec.js +381 -381
- package/test/spec/util/ModelUtilSpec.js +65 -65
- package/test/spec/util/camunda-moddle.js +70 -70
- package/test/util/MockEvents.js +62 -62
- package/test/util/ModelingUtil.js +117 -117
- package/test/util/custom-rules/CustomRules.js +18 -18
- package/test/util/custom-rules/index.js +4 -4
package/lib/Viewer.js
CHANGED
|
@@ -1,503 +1,503 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The code in the <project-logo></project-logo> area
|
|
3
|
-
* must not be changed.
|
|
4
|
-
*
|
|
5
|
-
* @see http://bpmn.io/license for more information.
|
|
6
|
-
*/
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
var assign = require('lodash/object/assign'),
|
|
10
|
-
omit = require('lodash/object/omit'),
|
|
11
|
-
isNumber = require('lodash/lang/isNumber');
|
|
12
|
-
|
|
13
|
-
var domify = require('min-dom/lib/domify'),
|
|
14
|
-
domQuery = require('min-dom/lib/query'),
|
|
15
|
-
domRemove = require('min-dom/lib/remove');
|
|
16
|
-
|
|
17
|
-
var innerSVG = require('tiny-svg/lib/innerSVG');
|
|
18
|
-
|
|
19
|
-
var Diagram = require('diagram-js'),
|
|
20
|
-
BpmnModdle = require('bpmn-moddle');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var inherits = require('inherits');
|
|
24
|
-
|
|
25
|
-
var Importer = require('./import/Importer');
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function checkValidationError(err) {
|
|
29
|
-
|
|
30
|
-
// check if we can help the user by indicating wrong BPMN 2.0 xml
|
|
31
|
-
// (in case he or the exporting tool did not get that right)
|
|
32
|
-
|
|
33
|
-
var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
|
|
34
|
-
var match = pattern.exec(err.message);
|
|
35
|
-
|
|
36
|
-
if (match) {
|
|
37
|
-
err.message =
|
|
38
|
-
'unparsable content <' + match[1] + '> detected; ' +
|
|
39
|
-
'this may indicate an invalid BPMN 2.0 diagram file' + match[2];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return err;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var DEFAULT_OPTIONS = {
|
|
46
|
-
width: '100%',
|
|
47
|
-
height: '100%',
|
|
48
|
-
position: 'relative'
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Ensure the passed argument is a proper unit (defaulting to px)
|
|
54
|
-
*/
|
|
55
|
-
function ensureUnit(val) {
|
|
56
|
-
return val + (isNumber(val) ? 'px' : '');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* A viewer for BPMN 2.0 diagrams.
|
|
61
|
-
*
|
|
62
|
-
* Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
|
|
63
|
-
* additional features.
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* ## Extending the Viewer
|
|
67
|
-
*
|
|
68
|
-
* In order to extend the viewer pass extension modules to bootstrap via the
|
|
69
|
-
* `additionalModules` option. An extension module is an object that exposes
|
|
70
|
-
* named services.
|
|
71
|
-
*
|
|
72
|
-
* The following example depicts the integration of a simple
|
|
73
|
-
* logging component that integrates with interaction events:
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* ```javascript
|
|
77
|
-
*
|
|
78
|
-
* // logging component
|
|
79
|
-
* function InteractionLogger(eventBus) {
|
|
80
|
-
* eventBus.on('element.hover', function(event) {
|
|
81
|
-
* console.log()
|
|
82
|
-
* })
|
|
83
|
-
* }
|
|
84
|
-
*
|
|
85
|
-
* InteractionLogger.$inject = [ 'eventBus' ]; // minification save
|
|
86
|
-
*
|
|
87
|
-
* // extension module
|
|
88
|
-
* var extensionModule = {
|
|
89
|
-
* __init__: [ 'interactionLogger' ],
|
|
90
|
-
* interactionLogger: [ 'type', InteractionLogger ]
|
|
91
|
-
* };
|
|
92
|
-
*
|
|
93
|
-
* // extend the viewer
|
|
94
|
-
* var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
|
|
95
|
-
* bpmnViewer.importXML(...);
|
|
96
|
-
* ```
|
|
97
|
-
*
|
|
98
|
-
* @param {Object} [options] configuration options to pass to the viewer
|
|
99
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
100
|
-
* @param {String|Number} [options.width] the width of the viewer
|
|
101
|
-
* @param {String|Number} [options.height] the height of the viewer
|
|
102
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
103
|
-
* @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
|
|
104
|
-
* @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
|
|
105
|
-
*/
|
|
106
|
-
function Viewer(options) {
|
|
107
|
-
|
|
108
|
-
options = assign({}, DEFAULT_OPTIONS, options);
|
|
109
|
-
|
|
110
|
-
this.moddle = this._createModdle(options);
|
|
111
|
-
|
|
112
|
-
this.container = this._createContainer(options);
|
|
113
|
-
|
|
114
|
-
/* <project-logo> */
|
|
115
|
-
|
|
116
|
-
addProjectLogo(this.container);
|
|
117
|
-
|
|
118
|
-
/* </project-logo> */
|
|
119
|
-
|
|
120
|
-
this._init(this.container, this.moddle, options);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
inherits(Viewer, Diagram);
|
|
124
|
-
|
|
125
|
-
module.exports = Viewer;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Parse and render a BPMN 2.0 diagram.
|
|
130
|
-
*
|
|
131
|
-
* Once finished the viewer reports back the result to the
|
|
132
|
-
* provided callback function with (err, warnings).
|
|
133
|
-
*
|
|
134
|
-
* ## Life-Cycle Events
|
|
135
|
-
*
|
|
136
|
-
* During import the viewer will fire life-cycle events:
|
|
137
|
-
*
|
|
138
|
-
* * import.parse.start (about to read model from xml)
|
|
139
|
-
* * import.parse.complete (model read; may have worked or not)
|
|
140
|
-
* * import.render.start (graphical import start)
|
|
141
|
-
* * import.render.complete (graphical import finished)
|
|
142
|
-
* * import.done (everything done)
|
|
143
|
-
*
|
|
144
|
-
* You can use these events to hook into the life-cycle.
|
|
145
|
-
*
|
|
146
|
-
* @param {String} xml the BPMN 2.0 xml
|
|
147
|
-
* @param {Function} [done] invoked with (err, warnings=[])
|
|
148
|
-
*/
|
|
149
|
-
Viewer.prototype.importXML = function(xml, done) {
|
|
150
|
-
|
|
151
|
-
// done is optional
|
|
152
|
-
done = done || function() {};
|
|
153
|
-
|
|
154
|
-
var self = this;
|
|
155
|
-
|
|
156
|
-
// hook in pre-parse listeners +
|
|
157
|
-
// allow xml manipulation
|
|
158
|
-
xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
|
159
|
-
|
|
160
|
-
this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
|
|
161
|
-
|
|
162
|
-
// hook in post parse listeners +
|
|
163
|
-
// allow definitions manipulation
|
|
164
|
-
definitions = self._emit('import.parse.complete', {
|
|
165
|
-
error: err,
|
|
166
|
-
definitions: definitions,
|
|
167
|
-
context: context
|
|
168
|
-
}) || definitions;
|
|
169
|
-
|
|
170
|
-
if (err) {
|
|
171
|
-
err = checkValidationError(err);
|
|
172
|
-
|
|
173
|
-
self._emit('import.done', { error: err });
|
|
174
|
-
|
|
175
|
-
return done(err);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
var parseWarnings = context.warnings;
|
|
179
|
-
|
|
180
|
-
self.importDefinitions(definitions, function(err, importWarnings) {
|
|
181
|
-
var allWarnings = [].concat(parseWarnings, importWarnings || []);
|
|
182
|
-
|
|
183
|
-
self._emit('import.done', { error: err, warnings: allWarnings });
|
|
184
|
-
|
|
185
|
-
done(err, allWarnings);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Export the currently displayed BPMN 2.0 diagram as
|
|
192
|
-
* a BPMN 2.0 XML document.
|
|
193
|
-
*
|
|
194
|
-
* @param {Object} [options] export options
|
|
195
|
-
* @param {Boolean} [options.format=false] output formated XML
|
|
196
|
-
* @param {Boolean} [options.preamble=true] output preamble
|
|
197
|
-
*
|
|
198
|
-
* @param {Function} done invoked with (err, xml)
|
|
199
|
-
*/
|
|
200
|
-
Viewer.prototype.saveXML = function(options, done) {
|
|
201
|
-
|
|
202
|
-
if (!done) {
|
|
203
|
-
done = options;
|
|
204
|
-
options = {};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
var definitions = this.definitions;
|
|
208
|
-
|
|
209
|
-
if (!definitions) {
|
|
210
|
-
return done(new Error('no definitions loaded'));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
this.moddle.toXML(definitions, options, done);
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Export the currently displayed BPMN 2.0 diagram as
|
|
218
|
-
* an SVG image.
|
|
219
|
-
*
|
|
220
|
-
* @param {Object} [options]
|
|
221
|
-
* @param {Function} done invoked with (err, svgStr)
|
|
222
|
-
*/
|
|
223
|
-
Viewer.prototype.saveSVG = function(options, done) {
|
|
224
|
-
|
|
225
|
-
if (!done) {
|
|
226
|
-
done = options;
|
|
227
|
-
options = {};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
var canvas = this.get('canvas');
|
|
231
|
-
|
|
232
|
-
var contentNode = canvas.getDefaultLayer(),
|
|
233
|
-
defsNode = domQuery('defs', canvas._svg);
|
|
234
|
-
|
|
235
|
-
var contents = innerSVG(contentNode),
|
|
236
|
-
defs = (defsNode && defsNode.outerHTML) || '';
|
|
237
|
-
|
|
238
|
-
var bbox = contentNode.getBBox();
|
|
239
|
-
|
|
240
|
-
var svg =
|
|
241
|
-
'<?xml version="1.0" encoding="utf-8"?>\n' +
|
|
242
|
-
'<!-- created with bpmn-js / http://bpmn.io -->\n' +
|
|
243
|
-
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
|
244
|
-
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
|
|
245
|
-
'width="' + bbox.width + '" height="' + bbox.height + '" ' +
|
|
246
|
-
'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
|
|
247
|
-
defs + contents +
|
|
248
|
-
'</svg>';
|
|
249
|
-
|
|
250
|
-
done(null, svg);
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Get a named diagram service.
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
*
|
|
258
|
-
* var elementRegistry = viewer.get('elementRegistry');
|
|
259
|
-
* var startEventShape = elementRegistry.get('StartEvent_1');
|
|
260
|
-
*
|
|
261
|
-
* @param {String} name
|
|
262
|
-
*
|
|
263
|
-
* @return {Object} diagram service instance
|
|
264
|
-
*
|
|
265
|
-
* @method Viewer#get
|
|
266
|
-
*/
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Invoke a function in the context of this viewer.
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
*
|
|
273
|
-
* viewer.invoke(function(elementRegistry) {
|
|
274
|
-
* var startEventShape = elementRegistry.get('StartEvent_1');
|
|
275
|
-
* });
|
|
276
|
-
*
|
|
277
|
-
* @param {Function} fn to be invoked
|
|
278
|
-
*
|
|
279
|
-
* @return {Object} the functions return value
|
|
280
|
-
*
|
|
281
|
-
* @method Viewer#invoke
|
|
282
|
-
*/
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Remove all drawn elements from the viewer.
|
|
286
|
-
*
|
|
287
|
-
* After calling this method the viewer can still
|
|
288
|
-
* be reused for opening another diagram.
|
|
289
|
-
*
|
|
290
|
-
* @method Viewer#clear
|
|
291
|
-
*/
|
|
292
|
-
|
|
293
|
-
Viewer.prototype.importDefinitions = function(definitions, done) {
|
|
294
|
-
|
|
295
|
-
// use try/catch to not swallow synchronous exceptions
|
|
296
|
-
// that may be raised during model parsing
|
|
297
|
-
try {
|
|
298
|
-
|
|
299
|
-
if (this.definitions) {
|
|
300
|
-
// clear existing rendered diagram
|
|
301
|
-
this.clear();
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// update definitions
|
|
305
|
-
this.definitions = definitions;
|
|
306
|
-
|
|
307
|
-
// perform graphical import
|
|
308
|
-
Importer.importBpmnDiagram(this, definitions, done);
|
|
309
|
-
} catch (e) {
|
|
310
|
-
|
|
311
|
-
// handle synchronous errors
|
|
312
|
-
done(e);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
Viewer.prototype.getModules = function() {
|
|
317
|
-
return this._modules;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Destroy the viewer instance and remove all its
|
|
322
|
-
* remainders from the document tree.
|
|
323
|
-
*/
|
|
324
|
-
Viewer.prototype.destroy = function() {
|
|
325
|
-
|
|
326
|
-
// diagram destroy
|
|
327
|
-
Diagram.prototype.destroy.call(this);
|
|
328
|
-
|
|
329
|
-
// dom detach
|
|
330
|
-
domRemove(this.container);
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Register an event listener
|
|
335
|
-
*
|
|
336
|
-
* Remove a previously added listener via {@link #off(event, callback)}.
|
|
337
|
-
*
|
|
338
|
-
* @param {String} event
|
|
339
|
-
* @param {Number} [priority]
|
|
340
|
-
* @param {Function} callback
|
|
341
|
-
* @param {Object} [that]
|
|
342
|
-
*/
|
|
343
|
-
Viewer.prototype.on = function(event, priority, callback, target) {
|
|
344
|
-
return this.get('eventBus').on(event, priority, callback, target);
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* De-register an event listener
|
|
349
|
-
*
|
|
350
|
-
* @param {String} event
|
|
351
|
-
* @param {Function} callback
|
|
352
|
-
*/
|
|
353
|
-
Viewer.prototype.off = function(event, callback) {
|
|
354
|
-
this.get('eventBus').off(event, callback);
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
Viewer.prototype.attachTo = function(parentNode) {
|
|
358
|
-
|
|
359
|
-
if (!parentNode) {
|
|
360
|
-
throw new Error('parentNode required');
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// ensure we detach from the
|
|
364
|
-
// previous, old parent
|
|
365
|
-
this.detach();
|
|
366
|
-
|
|
367
|
-
// unwrap jQuery if provided
|
|
368
|
-
if (parentNode.get && parentNode.constructor.prototype.jquery) {
|
|
369
|
-
parentNode = parentNode.get(0);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (typeof parentNode === 'string') {
|
|
373
|
-
parentNode = domQuery(parentNode);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
var container = this._container;
|
|
377
|
-
|
|
378
|
-
parentNode.appendChild(container);
|
|
379
|
-
|
|
380
|
-
this._emit('attach', {});
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
Viewer.prototype.detach = function() {
|
|
384
|
-
|
|
385
|
-
var container = this._container,
|
|
386
|
-
parentNode = container.parentNode;
|
|
387
|
-
|
|
388
|
-
if (!parentNode) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
this._emit('detach', {});
|
|
393
|
-
|
|
394
|
-
parentNode.removeChild(container);
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
Viewer.prototype._init = function(container, moddle, options) {
|
|
398
|
-
|
|
399
|
-
this._container = container;
|
|
400
|
-
var baseModules = options.modules || this.getModules(),
|
|
401
|
-
additionalModules = options.additionalModules || [],
|
|
402
|
-
staticModules = [
|
|
403
|
-
{
|
|
404
|
-
bpmnjs: [ 'value', this ],
|
|
405
|
-
moddle: [ 'value', moddle ]
|
|
406
|
-
}
|
|
407
|
-
];
|
|
408
|
-
|
|
409
|
-
var diagramModules = [].concat(staticModules, baseModules, additionalModules);
|
|
410
|
-
|
|
411
|
-
var diagramOptions = assign(omit(options, 'additionalModules'), {
|
|
412
|
-
canvas: assign({}, options.canvas, { container: container }),
|
|
413
|
-
modules: diagramModules
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
// invoke diagram constructor
|
|
417
|
-
Diagram.call(this, diagramOptions);
|
|
418
|
-
|
|
419
|
-
if (options && options.container) {
|
|
420
|
-
this.attachTo(options.container);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Emit an event on the underlying {@link EventBus}
|
|
426
|
-
*
|
|
427
|
-
* @param {String} type
|
|
428
|
-
* @param {Object} event
|
|
429
|
-
*
|
|
430
|
-
* @return {Object} event processing result (if any)
|
|
431
|
-
*/
|
|
432
|
-
Viewer.prototype._emit = function(type, event) {
|
|
433
|
-
return this.get('eventBus').fire(type, event);
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
Viewer.prototype._createContainer = function(options) {
|
|
437
|
-
|
|
438
|
-
var container = domify('<div class="bjs-container"></div>');
|
|
439
|
-
|
|
440
|
-
assign(container.style, {
|
|
441
|
-
width: ensureUnit(options.width),
|
|
442
|
-
height: ensureUnit(options.height),
|
|
443
|
-
position: options.position
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
return container;
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
Viewer.prototype._createModdle = function(options) {
|
|
450
|
-
var moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
|
|
451
|
-
|
|
452
|
-
return new BpmnModdle(moddleOptions);
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
// modules the viewer is composed of
|
|
457
|
-
Viewer.prototype._modules = [
|
|
458
|
-
require('./core'),
|
|
459
|
-
require('diagram-js/lib/i18n/translate'),
|
|
460
|
-
require('diagram-js/lib/features/selection'),
|
|
461
|
-
require('diagram-js/lib/features/overlays')
|
|
462
|
-
];
|
|
463
|
-
|
|
464
|
-
// default moddle extensions the viewer is composed of
|
|
465
|
-
Viewer.prototype._moddleExtensions = {};
|
|
466
|
-
|
|
467
|
-
/* <project-logo> */
|
|
468
|
-
|
|
469
|
-
var PoweredBy = require('./util/PoweredByUtil'),
|
|
470
|
-
domEvent = require('min-dom/lib/event');
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Adds the project logo to the diagram container as
|
|
474
|
-
* required by the bpmn.io license.
|
|
475
|
-
*
|
|
476
|
-
* @see http://bpmn.io/license
|
|
477
|
-
*
|
|
478
|
-
* @param {Element} container
|
|
479
|
-
*/
|
|
480
|
-
function addProjectLogo(container) {
|
|
481
|
-
var logoData = PoweredBy.BPMNIO_LOGO;
|
|
482
|
-
|
|
483
|
-
var linkMarkup =
|
|
484
|
-
'<a href="http://bpmn.io" ' +
|
|
485
|
-
'target="_blank" ' +
|
|
486
|
-
'class="bjs-powered-by" ' +
|
|
487
|
-
'title="Powered by bpmn.io" ' +
|
|
488
|
-
'style="position: absolute; bottom: 15px; right: 15px; z-index: 100">' +
|
|
489
|
-
'<img src="data:image/png;base64,' + logoData + '">' +
|
|
490
|
-
'</a>';
|
|
491
|
-
|
|
492
|
-
var linkElement = domify(linkMarkup);
|
|
493
|
-
|
|
494
|
-
container.appendChild(linkElement);
|
|
495
|
-
|
|
496
|
-
domEvent.bind(linkElement, 'click', function(event) {
|
|
497
|
-
PoweredBy.open();
|
|
498
|
-
|
|
499
|
-
event.preventDefault();
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/* </project-logo> */
|
|
1
|
+
/**
|
|
2
|
+
* The code in the <project-logo></project-logo> area
|
|
3
|
+
* must not be changed.
|
|
4
|
+
*
|
|
5
|
+
* @see http://bpmn.io/license for more information.
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var assign = require('lodash/object/assign'),
|
|
10
|
+
omit = require('lodash/object/omit'),
|
|
11
|
+
isNumber = require('lodash/lang/isNumber');
|
|
12
|
+
|
|
13
|
+
var domify = require('min-dom/lib/domify'),
|
|
14
|
+
domQuery = require('min-dom/lib/query'),
|
|
15
|
+
domRemove = require('min-dom/lib/remove');
|
|
16
|
+
|
|
17
|
+
var innerSVG = require('tiny-svg/lib/innerSVG');
|
|
18
|
+
|
|
19
|
+
var Diagram = require('diagram-js'),
|
|
20
|
+
BpmnModdle = require('bpmn-moddle');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var inherits = require('inherits');
|
|
24
|
+
|
|
25
|
+
var Importer = require('./import/Importer');
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function checkValidationError(err) {
|
|
29
|
+
|
|
30
|
+
// check if we can help the user by indicating wrong BPMN 2.0 xml
|
|
31
|
+
// (in case he or the exporting tool did not get that right)
|
|
32
|
+
|
|
33
|
+
var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
|
|
34
|
+
var match = pattern.exec(err.message);
|
|
35
|
+
|
|
36
|
+
if (match) {
|
|
37
|
+
err.message =
|
|
38
|
+
'unparsable content <' + match[1] + '> detected; ' +
|
|
39
|
+
'this may indicate an invalid BPMN 2.0 diagram file' + match[2];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return err;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var DEFAULT_OPTIONS = {
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: '100%',
|
|
48
|
+
position: 'relative'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Ensure the passed argument is a proper unit (defaulting to px)
|
|
54
|
+
*/
|
|
55
|
+
function ensureUnit(val) {
|
|
56
|
+
return val + (isNumber(val) ? 'px' : '');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A viewer for BPMN 2.0 diagrams.
|
|
61
|
+
*
|
|
62
|
+
* Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
|
|
63
|
+
* additional features.
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* ## Extending the Viewer
|
|
67
|
+
*
|
|
68
|
+
* In order to extend the viewer pass extension modules to bootstrap via the
|
|
69
|
+
* `additionalModules` option. An extension module is an object that exposes
|
|
70
|
+
* named services.
|
|
71
|
+
*
|
|
72
|
+
* The following example depicts the integration of a simple
|
|
73
|
+
* logging component that integrates with interaction events:
|
|
74
|
+
*
|
|
75
|
+
*
|
|
76
|
+
* ```javascript
|
|
77
|
+
*
|
|
78
|
+
* // logging component
|
|
79
|
+
* function InteractionLogger(eventBus) {
|
|
80
|
+
* eventBus.on('element.hover', function(event) {
|
|
81
|
+
* console.log()
|
|
82
|
+
* })
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* InteractionLogger.$inject = [ 'eventBus' ]; // minification save
|
|
86
|
+
*
|
|
87
|
+
* // extension module
|
|
88
|
+
* var extensionModule = {
|
|
89
|
+
* __init__: [ 'interactionLogger' ],
|
|
90
|
+
* interactionLogger: [ 'type', InteractionLogger ]
|
|
91
|
+
* };
|
|
92
|
+
*
|
|
93
|
+
* // extend the viewer
|
|
94
|
+
* var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
|
|
95
|
+
* bpmnViewer.importXML(...);
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} [options] configuration options to pass to the viewer
|
|
99
|
+
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
100
|
+
* @param {String|Number} [options.width] the width of the viewer
|
|
101
|
+
* @param {String|Number} [options.height] the height of the viewer
|
|
102
|
+
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
103
|
+
* @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
|
|
104
|
+
* @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
|
|
105
|
+
*/
|
|
106
|
+
function Viewer(options) {
|
|
107
|
+
|
|
108
|
+
options = assign({}, DEFAULT_OPTIONS, options);
|
|
109
|
+
|
|
110
|
+
this.moddle = this._createModdle(options);
|
|
111
|
+
|
|
112
|
+
this.container = this._createContainer(options);
|
|
113
|
+
|
|
114
|
+
/* <project-logo> */
|
|
115
|
+
|
|
116
|
+
addProjectLogo(this.container);
|
|
117
|
+
|
|
118
|
+
/* </project-logo> */
|
|
119
|
+
|
|
120
|
+
this._init(this.container, this.moddle, options);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
inherits(Viewer, Diagram);
|
|
124
|
+
|
|
125
|
+
module.exports = Viewer;
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Parse and render a BPMN 2.0 diagram.
|
|
130
|
+
*
|
|
131
|
+
* Once finished the viewer reports back the result to the
|
|
132
|
+
* provided callback function with (err, warnings).
|
|
133
|
+
*
|
|
134
|
+
* ## Life-Cycle Events
|
|
135
|
+
*
|
|
136
|
+
* During import the viewer will fire life-cycle events:
|
|
137
|
+
*
|
|
138
|
+
* * import.parse.start (about to read model from xml)
|
|
139
|
+
* * import.parse.complete (model read; may have worked or not)
|
|
140
|
+
* * import.render.start (graphical import start)
|
|
141
|
+
* * import.render.complete (graphical import finished)
|
|
142
|
+
* * import.done (everything done)
|
|
143
|
+
*
|
|
144
|
+
* You can use these events to hook into the life-cycle.
|
|
145
|
+
*
|
|
146
|
+
* @param {String} xml the BPMN 2.0 xml
|
|
147
|
+
* @param {Function} [done] invoked with (err, warnings=[])
|
|
148
|
+
*/
|
|
149
|
+
Viewer.prototype.importXML = function(xml, done) {
|
|
150
|
+
|
|
151
|
+
// done is optional
|
|
152
|
+
done = done || function() {};
|
|
153
|
+
|
|
154
|
+
var self = this;
|
|
155
|
+
|
|
156
|
+
// hook in pre-parse listeners +
|
|
157
|
+
// allow xml manipulation
|
|
158
|
+
xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
|
159
|
+
|
|
160
|
+
this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
|
|
161
|
+
|
|
162
|
+
// hook in post parse listeners +
|
|
163
|
+
// allow definitions manipulation
|
|
164
|
+
definitions = self._emit('import.parse.complete', {
|
|
165
|
+
error: err,
|
|
166
|
+
definitions: definitions,
|
|
167
|
+
context: context
|
|
168
|
+
}) || definitions;
|
|
169
|
+
|
|
170
|
+
if (err) {
|
|
171
|
+
err = checkValidationError(err);
|
|
172
|
+
|
|
173
|
+
self._emit('import.done', { error: err });
|
|
174
|
+
|
|
175
|
+
return done(err);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var parseWarnings = context.warnings;
|
|
179
|
+
|
|
180
|
+
self.importDefinitions(definitions, function(err, importWarnings) {
|
|
181
|
+
var allWarnings = [].concat(parseWarnings, importWarnings || []);
|
|
182
|
+
|
|
183
|
+
self._emit('import.done', { error: err, warnings: allWarnings });
|
|
184
|
+
|
|
185
|
+
done(err, allWarnings);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Export the currently displayed BPMN 2.0 diagram as
|
|
192
|
+
* a BPMN 2.0 XML document.
|
|
193
|
+
*
|
|
194
|
+
* @param {Object} [options] export options
|
|
195
|
+
* @param {Boolean} [options.format=false] output formated XML
|
|
196
|
+
* @param {Boolean} [options.preamble=true] output preamble
|
|
197
|
+
*
|
|
198
|
+
* @param {Function} done invoked with (err, xml)
|
|
199
|
+
*/
|
|
200
|
+
Viewer.prototype.saveXML = function(options, done) {
|
|
201
|
+
|
|
202
|
+
if (!done) {
|
|
203
|
+
done = options;
|
|
204
|
+
options = {};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var definitions = this.definitions;
|
|
208
|
+
|
|
209
|
+
if (!definitions) {
|
|
210
|
+
return done(new Error('no definitions loaded'));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.moddle.toXML(definitions, options, done);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Export the currently displayed BPMN 2.0 diagram as
|
|
218
|
+
* an SVG image.
|
|
219
|
+
*
|
|
220
|
+
* @param {Object} [options]
|
|
221
|
+
* @param {Function} done invoked with (err, svgStr)
|
|
222
|
+
*/
|
|
223
|
+
Viewer.prototype.saveSVG = function(options, done) {
|
|
224
|
+
|
|
225
|
+
if (!done) {
|
|
226
|
+
done = options;
|
|
227
|
+
options = {};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var canvas = this.get('canvas');
|
|
231
|
+
|
|
232
|
+
var contentNode = canvas.getDefaultLayer(),
|
|
233
|
+
defsNode = domQuery('defs', canvas._svg);
|
|
234
|
+
|
|
235
|
+
var contents = innerSVG(contentNode),
|
|
236
|
+
defs = (defsNode && defsNode.outerHTML) || '';
|
|
237
|
+
|
|
238
|
+
var bbox = contentNode.getBBox();
|
|
239
|
+
|
|
240
|
+
var svg =
|
|
241
|
+
'<?xml version="1.0" encoding="utf-8"?>\n' +
|
|
242
|
+
'<!-- created with bpmn-js / http://bpmn.io -->\n' +
|
|
243
|
+
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
|
244
|
+
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
|
|
245
|
+
'width="' + bbox.width + '" height="' + bbox.height + '" ' +
|
|
246
|
+
'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
|
|
247
|
+
defs + contents +
|
|
248
|
+
'</svg>';
|
|
249
|
+
|
|
250
|
+
done(null, svg);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Get a named diagram service.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
*
|
|
258
|
+
* var elementRegistry = viewer.get('elementRegistry');
|
|
259
|
+
* var startEventShape = elementRegistry.get('StartEvent_1');
|
|
260
|
+
*
|
|
261
|
+
* @param {String} name
|
|
262
|
+
*
|
|
263
|
+
* @return {Object} diagram service instance
|
|
264
|
+
*
|
|
265
|
+
* @method Viewer#get
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Invoke a function in the context of this viewer.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
*
|
|
273
|
+
* viewer.invoke(function(elementRegistry) {
|
|
274
|
+
* var startEventShape = elementRegistry.get('StartEvent_1');
|
|
275
|
+
* });
|
|
276
|
+
*
|
|
277
|
+
* @param {Function} fn to be invoked
|
|
278
|
+
*
|
|
279
|
+
* @return {Object} the functions return value
|
|
280
|
+
*
|
|
281
|
+
* @method Viewer#invoke
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Remove all drawn elements from the viewer.
|
|
286
|
+
*
|
|
287
|
+
* After calling this method the viewer can still
|
|
288
|
+
* be reused for opening another diagram.
|
|
289
|
+
*
|
|
290
|
+
* @method Viewer#clear
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
Viewer.prototype.importDefinitions = function(definitions, done) {
|
|
294
|
+
|
|
295
|
+
// use try/catch to not swallow synchronous exceptions
|
|
296
|
+
// that may be raised during model parsing
|
|
297
|
+
try {
|
|
298
|
+
|
|
299
|
+
if (this.definitions) {
|
|
300
|
+
// clear existing rendered diagram
|
|
301
|
+
this.clear();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// update definitions
|
|
305
|
+
this.definitions = definitions;
|
|
306
|
+
|
|
307
|
+
// perform graphical import
|
|
308
|
+
Importer.importBpmnDiagram(this, definitions, done);
|
|
309
|
+
} catch (e) {
|
|
310
|
+
|
|
311
|
+
// handle synchronous errors
|
|
312
|
+
done(e);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
Viewer.prototype.getModules = function() {
|
|
317
|
+
return this._modules;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Destroy the viewer instance and remove all its
|
|
322
|
+
* remainders from the document tree.
|
|
323
|
+
*/
|
|
324
|
+
Viewer.prototype.destroy = function() {
|
|
325
|
+
|
|
326
|
+
// diagram destroy
|
|
327
|
+
Diagram.prototype.destroy.call(this);
|
|
328
|
+
|
|
329
|
+
// dom detach
|
|
330
|
+
domRemove(this.container);
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Register an event listener
|
|
335
|
+
*
|
|
336
|
+
* Remove a previously added listener via {@link #off(event, callback)}.
|
|
337
|
+
*
|
|
338
|
+
* @param {String} event
|
|
339
|
+
* @param {Number} [priority]
|
|
340
|
+
* @param {Function} callback
|
|
341
|
+
* @param {Object} [that]
|
|
342
|
+
*/
|
|
343
|
+
Viewer.prototype.on = function(event, priority, callback, target) {
|
|
344
|
+
return this.get('eventBus').on(event, priority, callback, target);
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* De-register an event listener
|
|
349
|
+
*
|
|
350
|
+
* @param {String} event
|
|
351
|
+
* @param {Function} callback
|
|
352
|
+
*/
|
|
353
|
+
Viewer.prototype.off = function(event, callback) {
|
|
354
|
+
this.get('eventBus').off(event, callback);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
Viewer.prototype.attachTo = function(parentNode) {
|
|
358
|
+
|
|
359
|
+
if (!parentNode) {
|
|
360
|
+
throw new Error('parentNode required');
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ensure we detach from the
|
|
364
|
+
// previous, old parent
|
|
365
|
+
this.detach();
|
|
366
|
+
|
|
367
|
+
// unwrap jQuery if provided
|
|
368
|
+
if (parentNode.get && parentNode.constructor.prototype.jquery) {
|
|
369
|
+
parentNode = parentNode.get(0);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (typeof parentNode === 'string') {
|
|
373
|
+
parentNode = domQuery(parentNode);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
var container = this._container;
|
|
377
|
+
|
|
378
|
+
parentNode.appendChild(container);
|
|
379
|
+
|
|
380
|
+
this._emit('attach', {});
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
Viewer.prototype.detach = function() {
|
|
384
|
+
|
|
385
|
+
var container = this._container,
|
|
386
|
+
parentNode = container.parentNode;
|
|
387
|
+
|
|
388
|
+
if (!parentNode) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
this._emit('detach', {});
|
|
393
|
+
|
|
394
|
+
parentNode.removeChild(container);
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
Viewer.prototype._init = function(container, moddle, options) {
|
|
398
|
+
|
|
399
|
+
this._container = container;
|
|
400
|
+
var baseModules = options.modules || this.getModules(),
|
|
401
|
+
additionalModules = options.additionalModules || [],
|
|
402
|
+
staticModules = [
|
|
403
|
+
{
|
|
404
|
+
bpmnjs: [ 'value', this ],
|
|
405
|
+
moddle: [ 'value', moddle ]
|
|
406
|
+
}
|
|
407
|
+
];
|
|
408
|
+
|
|
409
|
+
var diagramModules = [].concat(staticModules, baseModules, additionalModules);
|
|
410
|
+
|
|
411
|
+
var diagramOptions = assign(omit(options, 'additionalModules'), {
|
|
412
|
+
canvas: assign({}, options.canvas, { container: container }),
|
|
413
|
+
modules: diagramModules
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
// invoke diagram constructor
|
|
417
|
+
Diagram.call(this, diagramOptions);
|
|
418
|
+
|
|
419
|
+
if (options && options.container) {
|
|
420
|
+
this.attachTo(options.container);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Emit an event on the underlying {@link EventBus}
|
|
426
|
+
*
|
|
427
|
+
* @param {String} type
|
|
428
|
+
* @param {Object} event
|
|
429
|
+
*
|
|
430
|
+
* @return {Object} event processing result (if any)
|
|
431
|
+
*/
|
|
432
|
+
Viewer.prototype._emit = function(type, event) {
|
|
433
|
+
return this.get('eventBus').fire(type, event);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
Viewer.prototype._createContainer = function(options) {
|
|
437
|
+
|
|
438
|
+
var container = domify('<div class="bjs-container"></div>');
|
|
439
|
+
|
|
440
|
+
assign(container.style, {
|
|
441
|
+
width: ensureUnit(options.width),
|
|
442
|
+
height: ensureUnit(options.height),
|
|
443
|
+
position: options.position
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
return container;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
Viewer.prototype._createModdle = function(options) {
|
|
450
|
+
var moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
|
|
451
|
+
|
|
452
|
+
return new BpmnModdle(moddleOptions);
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
// modules the viewer is composed of
|
|
457
|
+
Viewer.prototype._modules = [
|
|
458
|
+
require('./core'),
|
|
459
|
+
require('diagram-js/lib/i18n/translate'),
|
|
460
|
+
require('diagram-js/lib/features/selection'),
|
|
461
|
+
require('diagram-js/lib/features/overlays')
|
|
462
|
+
];
|
|
463
|
+
|
|
464
|
+
// default moddle extensions the viewer is composed of
|
|
465
|
+
Viewer.prototype._moddleExtensions = {};
|
|
466
|
+
|
|
467
|
+
/* <project-logo> */
|
|
468
|
+
|
|
469
|
+
var PoweredBy = require('./util/PoweredByUtil'),
|
|
470
|
+
domEvent = require('min-dom/lib/event');
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Adds the project logo to the diagram container as
|
|
474
|
+
* required by the bpmn.io license.
|
|
475
|
+
*
|
|
476
|
+
* @see http://bpmn.io/license
|
|
477
|
+
*
|
|
478
|
+
* @param {Element} container
|
|
479
|
+
*/
|
|
480
|
+
function addProjectLogo(container) {
|
|
481
|
+
var logoData = PoweredBy.BPMNIO_LOGO;
|
|
482
|
+
|
|
483
|
+
var linkMarkup =
|
|
484
|
+
'<a href="http://bpmn.io" ' +
|
|
485
|
+
'target="_blank" ' +
|
|
486
|
+
'class="bjs-powered-by" ' +
|
|
487
|
+
'title="Powered by bpmn.io" ' +
|
|
488
|
+
'style="position: absolute; bottom: 15px; right: 15px; z-index: 100">' +
|
|
489
|
+
'<img src="data:image/png;base64,' + logoData + '">' +
|
|
490
|
+
'</a>';
|
|
491
|
+
|
|
492
|
+
var linkElement = domify(linkMarkup);
|
|
493
|
+
|
|
494
|
+
container.appendChild(linkElement);
|
|
495
|
+
|
|
496
|
+
domEvent.bind(linkElement, 'click', function(event) {
|
|
497
|
+
PoweredBy.open();
|
|
498
|
+
|
|
499
|
+
event.preventDefault();
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/* </project-logo> */
|