feat: align to origin after serialization

This commit is contained in:
Philipp Fromme 2021-01-21 10:02:07 +01:00
parent c87167c8c6
commit 4b39a44ec3
4 changed files with 30 additions and 9 deletions

View File

@ -376,20 +376,21 @@ BaseViewer.prototype.saveXML = wrapForCompatibility(function saveXML(options) {
var xml = result.xml; var xml = result.xml;
try { try {
xml = self._emit('saveXML.serialized', { self._emit('saveXML.serialized', {
error: null, error: null,
xml: xml xml: xml
}) || xml; }).then(function(result) {
self._emit('saveXML.done', {
error: null,
xml: result.xml
});
self._emit('saveXML.done', { return resolve({ xml: result.xml });
error: null,
xml: xml
}); });
} catch (e) { } catch (e) {
console.error('error in saveXML life-cycle listener', e); console.error('error in saveXML life-cycle listener', e);
} }
return resolve({ xml: xml });
}).catch(function(err) { }).catch(function(err) {
return reject(err); return reject(err);

8
package-lock.json generated
View File

@ -1308,6 +1308,14 @@
"integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==", "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==",
"dev": true "dev": true
}, },
"align-to-origin-xml": {
"version": "git://github.com/philippfromme/align-to-origin-xml.git#1d958138e2fbe36b5ac6c5cad610c4b1af06220e",
"from": "git://github.com/philippfromme/align-to-origin-xml.git",
"requires": {
"bpmn-moddle": "^7.0.4",
"min-dash": "^3.5.2"
}
},
"ansi-colors": { "ansi-colors": {
"version": "3.2.4", "version": "3.2.4",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz",

View File

@ -86,6 +86,7 @@
"webpack": "^4.44.2" "webpack": "^4.44.2"
}, },
"dependencies": { "dependencies": {
"align-to-origin-xml": "git://github.com/philippfromme/align-to-origin-xml.git",
"bpmn-moddle": "^7.0.4", "bpmn-moddle": "^7.0.4",
"css.escape": "^1.5.1", "css.escape": "^1.5.1",
"diagram-js": "^7.0.0", "diagram-js": "^7.0.0",

View File

@ -14,6 +14,8 @@ import {
collectTranslations collectTranslations
} from 'test/TestHelper'; } from 'test/TestHelper';
import AlignToOrigin from 'align-to-origin-xml';
var singleStart = window.__env__ && window.__env__.SINGLE_START === 'modeler'; var singleStart = window.__env__ && window.__env__.SINGLE_START === 'modeler';
@ -36,7 +38,10 @@ describe('Modeler', function() {
container: container, container: container,
keyboard: { keyboard: {
bindTo: document bindTo: document
} },
additionalModules: [
AlignToOrigin
]
}); });
setBpmnJS(modeler); setBpmnJS(modeler);
@ -49,11 +54,17 @@ describe('Modeler', function() {
} }
(singleStart ? it.only : it)('should import simple process', function() { it.only('should import simple process', function() {
var xml = require('../fixtures/bpmn/simple.bpmn'); var xml = require('../fixtures/bpmn/simple.bpmn');
return createModeler(xml).then(function(result) { return createModeler(xml).then(function(result) {
expect(result.error).not.to.exist; expect(result.error).not.to.exist;
result.modeler.on('commandStack.changed', function() {
result.modeler.saveXML({ format: true }).then(function(result) {
console.log(result.xml);
});
})
}); });
}); });