Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复导出png格式的时候,data:格式图片导致的错误 #48

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions dist/kityminder.core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* ====================================================
* Kity Minder Core - v1.4.50 - 2018-09-17
* Kity Minder Core - v1.4.50 - 2018-10-23
* https://github.com/fex-team/kityminder-core
* GitHub: https://github.com/fex-team/kityminder-core.git
* Copyright (c) 2018 Baidu FEX; Licensed BSD-3-Clause
Expand Down Expand Up @@ -8159,27 +8159,42 @@ _p[66] = {
*/
function xhrLoadImage(info, callback) {
return Promise(function(resolve, reject) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", info.url + "?_=" + Date.now(), true);
xmlHttp.responseType = "blob";
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
var blob = xmlHttp.response;
var image = document.createElement("img");
image.src = DomURL.createObjectURL(blob);
image.onload = function() {
DomURL.revokeObjectURL(image.src);
resolve({
element: image,
x: info.x,
y: info.y,
width: info.width,
height: info.height
});
};
}
};
xmlHttp.send();
if (info.url.indexOf("data:") === 0) {
var image = document.createElement("img");
image.src = info.url;
image.onload = function() {
DomURL.revokeObjectURL(image.src);
resolve({
element: image,
x: info.x,
y: info.y,
width: info.width,
height: info.height
});
};
} else {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", info.url + "?_=" + Date.now(), true);
xmlHttp.responseType = "blob";
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
var blob = xmlHttp.response;
var image = document.createElement("img");
image.src = DomURL.createObjectURL(blob);
image.onload = function() {
DomURL.revokeObjectURL(image.src);
resolve({
element: image,
x: info.x,
y: info.y,
width: info.width,
height: info.height
});
};
}
};
xmlHttp.send();
}
});
}
function getSVGInfo(minder) {
Expand Down
4 changes: 2 additions & 2 deletions dist/kityminder.core.min.js

Large diffs are not rendered by default.

63 changes: 39 additions & 24 deletions src/protocol/png.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,46 @@ define(function(require, exports, module) {
*/
function xhrLoadImage(info, callback) {
return Promise(function (resolve, reject) {
var xmlHttp = new XMLHttpRequest();

xmlHttp.open('GET', info.url + '?_=' + Date.now(), true);
xmlHttp.responseType = 'blob';
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
var blob = xmlHttp.response;

var image = document.createElement('img');

image.src = DomURL.createObjectURL(blob);
image.onload = function () {
DomURL.revokeObjectURL(image.src);
resolve({
element: image,
x: info.x,
y: info.y,
width: info.width,
height: info.height
});
};
}
};
if (info.url.indexOf('data:') === 0) {
var image = document.createElement('img');
image.src = info.url;
image.onload = function () {
DomURL.revokeObjectURL(image.src);
resolve({
element: image,
x: info.x,
y: info.y,
width: info.width,
height: info.height
});
};
} else {
var xmlHttp = new XMLHttpRequest();

xmlHttp.open('GET', info.url + '?_=' + Date.now(), true);
xmlHttp.responseType = 'blob';
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
var blob = xmlHttp.response;

var image = document.createElement('img');

image.src = DomURL.createObjectURL(blob);
image.onload = function () {
DomURL.revokeObjectURL(image.src);
resolve({
element: image,
x: info.x,
y: info.y,
width: info.width,
height: info.height
});
};
}
};

xmlHttp.send();
xmlHttp.send();
}
});
}

Expand Down