Skip to content

Commit

Permalink
6.6.0 release
Browse files Browse the repository at this point in the history
Former-commit-id: 670a3bf
  • Loading branch information
davidjgraph committed May 16, 2017
1 parent 4b7ab54 commit f5a9b70
Show file tree
Hide file tree
Showing 49 changed files with 2,806 additions and 2,169 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
16-MAY-2017: 6.6.0

- Adds Venn diagram templates
- Starts .vsdx export functionality
- Improvements and bug fixes for Electron build
- Fixes for Gliffy importer
- Adds autosave for libraries in Chrome App

13-MAY-2017: 6.5.10

- Fixes case sensitivity issue for template names and folders
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.10
6.6.0
241 changes: 136 additions & 105 deletions etc/electron/ElectronApp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
window.OPEN_URL = 'https://www.draw.io/open';
window.TEMPLATE_PATH = 'templates';
FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';

Expand Down Expand Up @@ -86,14 +87,16 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
// Replaces file menu to replace openFrom menu with open and rename downloadAs to export
this.put('file', new Menu(mxUtils.bind(this, function(menu, parent)
{
this.addMenuItems(menu, ['new', 'open', '-', 'save', 'saveAs', '-'], parent);
this.addMenuItems(menu, ['new', 'open', '-', 'save', 'saveAs', '-', 'import'], parent);
this.addSubmenu('exportAs', menu, parent);
this.addSubmenu('embed', menu, parent);
this.addMenuItems(menu, ['-', 'newLibrary', 'openLibrary', '-', 'documentProperties', 'print'], parent);
})));

this.put('extras', new Menu(mxUtils.bind(this, function(menu, parent)
{
this.addSubmenu('insert', menu, parent);
menu.addSeparator(parent);
this.addMenuItems(menu, ['copyConnect', 'collapseExpand', '-', 'mathematicalTypesetting', 'autosave', '-',
'createShape', 'editDiagram', '-', 'online'], parent);
})));
Expand Down Expand Up @@ -129,88 +132,99 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
editorUi.pickLibrary(App.MODE_DEVICE);
}));

// // Replaces import action
// this.actions.addAction('import...', mxUtils.bind(this, function()
// {
// if (this.getCurrentFile() != null)
// {
// chrome.fileSystem.chooseEntry({type: 'openFile', acceptsAllTypes: true}, mxUtils.bind(this, function(fileEntry)
// {
// if (!chrome.runtime.lastError)
// {
// fileEntry.file(mxUtils.bind(this, function(fileObject)
// {
// if (editorUi.spinner.spin(document.body, mxResources.get('loading')))
// {
// var reader = new FileReader();
//
// reader.onload = function(evt)
// {
// editorUi.spinner.stop();
//
// try
// {
// var data = reader.result;
//
// if (fileObject.type.substring(0, 9) == 'image/png')
// {
// data = editorUi.extractGraphModelFromPng(data);
// }
// else if (fileObject.type.substring(0, 6) == 'image/')
// {
// data = null;
// }
//
// if (data != null)
// {
// graph.setSelectionCells(editorUi.importXml(data));
// }
// else
// {
// var img = new Image();
// img.onload = function()
// {
// editorUi.resizeImage(img, reader.result, function(data2, w, h)
// {
// var pt = graph.getInsertPoint();
// graph.setSelectionCell(graph.insertVertex(null, null, '', pt.x, pt.y, w, h,
// 'shape=image;aspect=fixed;image=' + editorUi.convertDataUri(data2) + ';'));
// }, true);
// };
// img.src = reader.result;
// }
// }
// catch(e)
// {
// console.log(e);
// editorUi.handleError(e);
// }
// };
//
// reader.onerror = function(ev)
// {
// editorUi.spinner.stop();
// editorUi.handleError(ev);
// };
//
// if (fileObject.type.substring(0, 6) == 'image/')
// {
// reader.readAsDataURL(fileObject);
// }
// else
// {
// reader.readAsText(fileObject);
// }
// }
// }));
// }
// else if (chrome.runtime.lastError.message != 'User cancelled')
// {
// editorUi.handleError(chrome.runtime.lastError);
// }
// }));
// }
// }));
// Replaces import action
this.actions.addAction('import...', mxUtils.bind(this, function()
{
if (editorUi.getCurrentFile() != null)
{
const electron = require('electron');
var remote = electron.remote;
var dialog = remote.dialog;

var paths = dialog.showOpenDialog({properties: ['openFile']});

if (paths !== undefined && paths[0] != null)
{
var fs = require('fs');
var path = paths[0];
var index = path.lastIndexOf('.png');
var isPng = index > -1 && index == path.length - 4;
var encoding = (isPng || /\.gif$/i.test(path) || /\.jpe?g$/i.test(path) ||
/\.vsdx$/i.test(path)) ? 'base64' : 'utf-8'

if (editorUi.spinner.spin(document.body, mxResources.get('loading')))
{
fs.readFile(path, encoding, mxUtils.bind(this, function (e, data)
{
if (e)
{
editorUi.spinner.stop();
editorUi.handleError(e);
}
else
{
try
{
if (isPng)
{
var tmp = editorUi.extractGraphModelFromPng(data);

if (tmp != null)
{
data = tmp;
}
}

if (!editorUi.isOffline() && new XMLHttpRequest().upload && editorUi.isRemoteFileFormat(data, path))
{
// Asynchronous parsing via server
editorUi.parseFile(editorUi.base64ToBlob(data, 'application/octet-stream'), mxUtils.bind(this, function(xhr)
{
if (xhr.readyState == 4)
{
editorUi.spinner.stop();

if (xhr.status >= 200 && xhr.status <= 299)
{

editorUi.editor.graph.setSelectionCells(editorUi.insertTextAt(xhr.responseText, 0, 0, true));
}
}
}), path);
}
else if (isPng || /\.gif$/i.test(path) || /\.jpe?g$/i.test(path))
{
var img = new Image();
img.onload = function()
{
editorUi.resizeImage(img, img.src, function(data2, w, h)
{
editorUi.spinner.stop();
var pt = graph.getInsertPoint();
graph.setSelectionCell(graph.insertVertex(null, null, '', pt.x, pt.y, w, h,
'shape=image;aspect=fixed;image=' + editorUi.convertDataUri(data2) + ';'));
}, true);
};

img.src = 'data:image/png;base64,' + data;
}
else if (data != null)
{
editorUi.spinner.stop();
graph.setSelectionCells(editorUi.importXml(data));
}
}
catch(e)
{
editorUi.spinner.stop();
editorUi.handleError(e);
}
}
}));
}
}
}
}));

// Replaces new action
var oldNew = this.actions.get('new').funct;
Expand Down Expand Up @@ -292,9 +306,16 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
{
this.chooseFileEntry(mxUtils.bind(this, function(fileEntry, data)
{
var library = new LocalLibrary(this, data, fileEntry.name);
library.fileObject = fileEntry;
this.loadLibrary(library);
try
{
var library = new LocalLibrary(this, data, fileEntry.name);
library.fileObject = fileEntry;
this.loadLibrary(library);
}
catch (e)
{
this.handleError(e, mxResources.get('errorLoadingFile'));
}
}));
};

Expand All @@ -305,7 +326,7 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
var remote = electron.remote;
var dialog = remote.dialog;

var paths = dialog.showOpenDialog({properties: [ 'openFile' ] });
var paths = dialog.showOpenDialog({properties: ['openFile']});

if (paths !== undefined && paths[0] != null)
{
Expand Down Expand Up @@ -352,7 +373,7 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';

LocalFile.prototype.isAutosave = function()
{
return this.ui.editor.autosave;
return this.ui.editor.autosave && this.fileObject != null;
};

LocalFile.prototype.isAutosaveOptional = function()
Expand All @@ -362,12 +383,12 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';

LocalLibrary.prototype.isAutosave = function()
{
return true;
return this.fileObject != null;
};

LocalFile.prototype.getTitle = function()
{
return (this.fileObject != null) ? this.fileObject.name : null;
return (this.fileObject != null) ? this.fileObject.name : this.title;
};

LocalFile.prototype.isRenamable = function()
Expand All @@ -385,11 +406,6 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
this.saveFile(revision, success, error);
};

LocalLibrary.prototype.save = function(revision, success, error)
{
this.saveFile(revision, success, error);
};

LocalFile.prototype.saveFile = function(revision, success, error)
{
var fn = mxUtils.bind(this, function()
Expand Down Expand Up @@ -423,8 +439,8 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
{
this.savingFile = false;
this.isModified = prevModified;

this.contentChanged();
this.lastData = data;

if (success != null)
{
Expand All @@ -436,7 +452,10 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
else
{
// TODO, already saving. Need a better error
error();
if (error != null)
{
error();
}
}
});

Expand Down Expand Up @@ -511,8 +530,8 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
const electron = require('electron');
var remote = electron.remote;
var dialog = remote.dialog;
var path = dialog.showSaveDialog({defaultPath: this.title});

var path = dialog.showSaveDialog({defaultPath: this.title});

if (path != null)
{
Expand All @@ -522,12 +541,21 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
this.fileObject.type = 'utf-8';
fn();
}
else if (error != null)
{
error();
}
}
else
{
fn();
}
};

LocalLibrary.prototype.save = function(revision, success, error)
{
LocalFile.prototype.saveFile.apply(this, arguments);
};

LocalFile.prototype.saveAs = function(title, success, error)
{
Expand All @@ -543,7 +571,7 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
filename += '.xml';
}

var path = dialog.showSaveDialog({defaultPath: filename});
var path = dialog.showSaveDialog({defaultPath: filename});

if (path != null)
{
Expand All @@ -553,6 +581,10 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
this.fileObject.type = 'utf-8';
this.save(false, success, error);
}
else if (error != null)
{
error();
}
};

App.prototype.saveFile = function(forceDialog)
Expand Down Expand Up @@ -693,11 +725,10 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';

fs.writeFile(this.fileObject.path, data, this.fileObject.type, mxUtils.bind(this, function (e)
{
if (e)
{
// TODO
}

if (e)
{
this.handleError({message: mxResources.get('errorSavingFile')});
}
}));
}
};
Expand Down
Loading

0 comments on commit f5a9b70

Please sign in to comment.