Commit 942c1972 authored by techird's avatar techird

add free mind support

parent dc0d874f
Subproject commit 8f52e73cc57a447f268e71783d44e34ee028f763
Subproject commit 95da81322148afe2f03c632777148feba75e918e
......@@ -88,8 +88,55 @@ KityMinder.registerProtocol('freemind', function(minder) {
});
},
// 不支持
encode: null
encode: function(json, km, options) {
var url = 'native-support/export.php';
var data = JSON.stringify(json);
function fetch() {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = resolve;
xhr.onerror = reject;
xhr.open('POST', url);
var form = new FormData();
form.append('type', 'freemind');
form.append('data', data);
xhr.send(form);
}).then(function(e) {
return e.target.response;
});
}
function download() {
var filename = options.filename || 'freemind.mm';
var form = document.createElement('form');
form.setAttribute('action', url);
form.setAttribute('method', 'POST');
form.appendChild(field('filename', filename));
form.appendChild(field('type', 'freemind'));
form.appendChild(field('data', data));
form.appendChild(field('download', '1'));
form.submit();
function field(name, content) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = content;
return input;
}
}
if (options && options.download) {
return download();
} else {
return fetch();
}
}
};
});
\ No newline at end of file
......@@ -179,6 +179,8 @@ KityMinder.registerProtocol('xmind', function(minder) {
}
}
return download();
if (options && options.download) {
return download();
} else {
......
......@@ -56,6 +56,8 @@ KityMinder.registerUI('menu/save/download', function(minder) {
minder.exportData(protocol.name, options).then(function(data) {
if (protocol.name == 'freemind') return;
switch (protocol.dataType) {
case 'text':
return doDownload(buildDataUrl(mineType, data), filename, 'text');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment