dmn-js-drd
Advanced tools
Comparing version 10.3.0 to 11.0.0
@@ -30,3 +30,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
import { innerSVG } from 'tiny-svg'; | ||
import { wrapForCompatibility } from '../../dmn-js-shared/src/util/CompatibilityUtils'; | ||
/** | ||
* @typedef {import('../../dmn-js-shared/src/base/View).OpenResult} OpenResult | ||
*/ | ||
/** | ||
* @typedef {import('../../dmn-js-shared/src/base/View).OpenError} OpenError | ||
*/ | ||
/** | ||
* A viewer for DMN diagrams. | ||
@@ -90,2 +99,10 @@ * | ||
/** | ||
* The saveSVG result. | ||
* | ||
* @typedef {Object} SaveSVGResult | ||
* | ||
* @property {string} svg | ||
*/ | ||
/** | ||
* Export the currently displayed DMN diagram as | ||
@@ -95,25 +112,26 @@ * an SVG image. | ||
* @param {Object} [options] | ||
* @param {Function} done invoked with (err, svgStr) | ||
* | ||
* @return {Promise<SaveSVGResult>} | ||
*/ | ||
Viewer.prototype.saveSVG = function (options, done) { | ||
if (!done) { | ||
done = options; | ||
options = {}; | ||
} | ||
Viewer.prototype.saveSVG = wrapForCompatibility(function (options) { | ||
var self = this; | ||
return new Promise(function (resolve) { | ||
var canvas = self.get('canvas'); | ||
var contentNode = canvas.getDefaultLayer(), | ||
defsNode = domQuery('defs', canvas._svg); | ||
var contents = innerSVG(contentNode), | ||
defs = defsNode && defsNode.outerHTML || ''; | ||
var bbox = contentNode.getBBox(); | ||
/* eslint-disable max-len */ | ||
var canvas = this.get('canvas'); | ||
var contentNode = canvas.getDefaultLayer(), | ||
defsNode = domQuery('defs', canvas._svg); | ||
var contents = innerSVG(contentNode), | ||
defs = defsNode && defsNode.outerHTML || ''; | ||
var bbox = contentNode.getBBox(); | ||
/* eslint-disable max-len */ | ||
var svg = '<?xml version="1.0" encoding="utf-8"?>\n' + '<!-- created with dmn-js / http://bpmn.io -->\n' + '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' + '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' + 'width="' + bbox.width + '" height="' + bbox.height + '" ' + 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' + defs + contents + '</svg>'; | ||
/* eslint-enable */ | ||
var svg = '<?xml version="1.0" encoding="utf-8"?>\n' + '<!-- created with dmn-js / http://bpmn.io -->\n' + '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' + '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' + 'width="' + bbox.width + '" height="' + bbox.height + '" ' + 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' + defs + contents + '</svg>'; | ||
/* eslint-enable */ | ||
resolve({ | ||
svg: svg | ||
}); | ||
}); | ||
}); | ||
done(null, svg); | ||
}; | ||
Viewer.prototype.getModules = function () { | ||
@@ -203,22 +221,49 @@ return this._modules; | ||
}; | ||
/** | ||
* Open diagram element. | ||
* | ||
* @param {ModdleElement} definitions | ||
* @returns {Promise} Resolves with {OpenResult} when successful | ||
* or rejects with {OpenError} | ||
*/ | ||
Viewer.prototype.open = function (definitions, done) { | ||
var err; // use try/catch to not swallow synchronous exceptions | ||
// that may be raised during model parsing | ||
try { | ||
if (this._definitions) { | ||
// clear existing rendered diagram | ||
this.clear(); | ||
} // update definitions | ||
Viewer.prototype.open = function (definitions) { | ||
var self = this; | ||
return new Promise(function (resolve, reject) { | ||
var err; // use try/catch to not swallow synchronous exceptions | ||
// that may be raised during model parsing | ||
try { | ||
if (self._definitions) { | ||
// clear existing rendered diagram | ||
self.clear(); | ||
} // update definitions | ||
this._definitions = definitions; // perform graphical import | ||
return importDRD(this, definitions, done); | ||
} catch (e) { | ||
err = e; | ||
} | ||
self._definitions = definitions; // perform graphical import | ||
return done(err); | ||
return importDRD(self, definitions, function (err, warnings) { | ||
if (err) { | ||
err.warnings = warnings || []; | ||
reject(err); | ||
} else { | ||
resolve({ | ||
warnings: warnings || [] | ||
}); | ||
} | ||
}); | ||
} catch (e) { | ||
err = e; | ||
} | ||
if (err) { | ||
err.warnings = err.warnings || []; | ||
reject(err); | ||
} else { | ||
resolve({ | ||
warnings: [] | ||
}); | ||
} | ||
}); | ||
}; | ||
@@ -225,0 +270,0 @@ /** |
{ | ||
"name": "dmn-js-drd", | ||
"description": "A decision requirements diagram view for dmn-js", | ||
"version": "10.3.0", | ||
"version": "11.0.0", | ||
"files": [ | ||
@@ -31,3 +31,3 @@ "assets", | ||
"diagram-js-direct-editing": "^1.6.3", | ||
"dmn-js-shared": "^10.3.0", | ||
"dmn-js-shared": "^11.0.0", | ||
"inherits": "^2.0.1", | ||
@@ -42,3 +42,3 @@ "min-dash": "^3.5.2", | ||
}, | ||
"gitHead": "9d3e194164b636b0540c25796a4e00538e68196a" | ||
"gitHead": "dd3238d9e1c7dfa3db02f6951214c7c9f77fdf97" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
429358
3908
1
+ Addeddmn-js-shared@11.1.1(transitive)
+ Addeddmn-moddle@10.0.0(transitive)
+ Addedmoddle-xml@9.0.6(transitive)
- Removeddmn-js-shared@10.3.0(transitive)
- Removeddmn-moddle@9.1.0(transitive)
- Removedmoddle-xml@8.0.8(transitive)
Updateddmn-js-shared@^11.0.0