Skip to content

Commit

Permalink
Merge pull request #12 from shandowc/fix-undo
Browse files Browse the repository at this point in the history
fix: undo doesnt work
  • Loading branch information
marc0l92 authored Jul 19, 2022
2 parents a1603c5 + fb3e691 commit 32ac8d3
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/dialog/DiagramEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ function DiagramEditor(config, ui, done, initialized, urlParams) {
catch (e) {
console.error(e);
}
} else if (self.exportFrame != null && evt.source == self.exportFrame.contentWindow &&
evt.data.length > 0) {
try {
var msg = JSON.parse(evt.data);
if (msg != null && msg.event == 'export') {
self.setElementData(self.startElement, msg.data);
}
}
catch (e) {
console.error(e);
}
}
};
};
Expand Down Expand Up @@ -142,6 +153,12 @@ DiagramEditor.prototype.startEditing = function (data, format, title) {
this.getFrameUrl(),
this.getFrameStyle());
document.body.appendChild(this.frame);

this.exportFrame = this.createFrame(
this.getFrameUrl(),
'position: absolute; width:0; height:0; border:0;');
document.body.appendChild(this.exportFrame);

this.setWaiting(true);
}
};
Expand Down Expand Up @@ -203,7 +220,11 @@ DiagramEditor.prototype.stopEditing = function () {
*/
DiagramEditor.prototype.postMessage = function (msg) {
if (this.frame != null) {
this.frame.contentWindow.postMessage(JSON.stringify(msg), '*');
if (msg && msg.action == 'export') {
this.exportFrame.contentWindow.postMessage(JSON.stringify(msg), '*');
} else {
this.frame.contentWindow.postMessage(JSON.stringify(msg), '*');
}
}
};

Expand Down Expand Up @@ -292,7 +313,8 @@ DiagramEditor.prototype.handleMessage = function (msg) {
this.save(msg.xml, true, this.startElement);
}
else if (msg.event == 'export') {
this.setElementData(this.startElement, msg.data);
console.error('export in none export frame')
// this.setElementData(this.startElement, msg.data);
// this.stopEditing();
// this.xml = null;
}
Expand Down

0 comments on commit 32ac8d3

Please sign in to comment.