docs(Viewer): document APIs
This commit is contained in:
parent
0ad02aa780
commit
851dfb67d0
|
@ -144,6 +144,15 @@ function Viewer(options) {
|
|||
module.exports = Viewer;
|
||||
|
||||
|
||||
/**
|
||||
* Import and render a BPMN 2.0 diagram.
|
||||
*
|
||||
* Once finished the viewer reports back the result to the
|
||||
* provided callback function with (err, warnings).
|
||||
*
|
||||
* @param {String} xml the BPMN 2.0 xml
|
||||
* @param {Function} done invoked with (err, warnings=[])
|
||||
*/
|
||||
Viewer.prototype.importXML = function(xml, done) {
|
||||
|
||||
var self = this;
|
||||
|
@ -167,6 +176,16 @@ Viewer.prototype.importXML = function(xml, done) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Export the currently displayed BPMN 2.0 diagram as
|
||||
* a BPMN 2.0 XML document.
|
||||
*
|
||||
* @param {Object} [options] export options
|
||||
* @param {Boolean} [options.format=false] output formated XML
|
||||
* @param {Boolean} [options.preamble=true] output preamble
|
||||
*
|
||||
* @param {Function} done invoked with (err, xml)
|
||||
*/
|
||||
Viewer.prototype.saveXML = function(options, done) {
|
||||
|
||||
if (!done) {
|
||||
|
@ -187,6 +206,13 @@ Viewer.prototype.createModdle = function() {
|
|||
return new BpmnModdle(this.options.moddleExtensions);
|
||||
};
|
||||
|
||||
/**
|
||||
* Export the currently displayed BPMN 2.0 diagram as
|
||||
* an SVG image.
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* @param {Function} done invoked with (err, svgStr)
|
||||
*/
|
||||
Viewer.prototype.saveSVG = function(options, done) {
|
||||
|
||||
if (!done) {
|
||||
|
@ -217,6 +243,18 @@ Viewer.prototype.saveSVG = function(options, done) {
|
|||
done(null, svg);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a named diagram service.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var elementRegistry = viewer.get('elementRegistry');
|
||||
* var startEventShape = elementRegistry.get('StartEvent_1');
|
||||
*
|
||||
* @param {String} name
|
||||
*
|
||||
* @return {Object} diagram service instance
|
||||
*/
|
||||
Viewer.prototype.get = function(name) {
|
||||
|
||||
if (!this.diagram) {
|
||||
|
@ -226,6 +264,19 @@ Viewer.prototype.get = function(name) {
|
|||
return this.diagram.get(name);
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke a function in the context of this viewer.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* viewer.invoke(function(elementRegistry) {
|
||||
* var startEventShape = elementRegistry.get('StartEvent_1');
|
||||
* });
|
||||
*
|
||||
* @param {Function} fn to be invoked
|
||||
*
|
||||
* @return {Object} the functions return value
|
||||
*/
|
||||
Viewer.prototype.invoke = function(fn) {
|
||||
|
||||
if (!this.diagram) {
|
||||
|
|
Loading…
Reference in New Issue