bpmn-js/lib/Modeler.js

71 lines
2.1 KiB
JavaScript
Raw Normal View History

'use strict';
var Diagram = require('diagram-js'),
BpmnModdle = require('bpmn-moddle'),
IdSupport = require('bpmn-moddle/lib/id-support'),
Ids = require('ids');
var Viewer = require('./Viewer');
var initialDiagram =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
'xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" ' +
'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" ' +
'targetNamespace="http://bpmn.io/schema/bpmn" ' +
'id="Definitions_1">' +
'<bpmn:process id="Process_1" isExecutable="false">' +
'<bpmn:startEvent id="StartEvent_1"/>' +
'</bpmn:process>' +
'<bpmndi:BPMNDiagram id="BPMNDiagram_1">' +
'<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">' +
'<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">' +
'<dc:Bounds height="36.0" width="36.0" x="173.0" y="102.0"/>' +
'</bpmndi:BPMNShape>' +
'</bpmndi:BPMNPlane>' +
'</bpmndi:BPMNDiagram>' +
'</bpmn:definitions>';
/**
* A modeler for BPMN 2.0 diagrams.
*
* @class
*
* @inheritDoc djs.Viewer
*/
function Modeler(options) {
Viewer.call(this, options);
}
Modeler.prototype = Object.create(Viewer.prototype);
Modeler.prototype.createDiagram = function(done) {
return this.importXML(initialDiagram, done);
};
Modeler.prototype.createModdle = function() {
var moddle = new BpmnModdle();
IdSupport.extend(moddle, new Ids());
return moddle;
};
// modules the modeler is composed of
Modeler.prototype._modules = Modeler.prototype._modules.concat([
// non-modeling components
require('./features/label-editing'),
require('./features/zoomscroll'),
2014-06-27 12:21:38 +00:00
require('./features/touch'),
require('./features/movecanvas'),
// modeling components
require('./features/modeling'),
require('diagram-js/lib/features/move'),
require('./features/context-pad')
]);
module.exports = Modeler;