|
@@ -624,7 +624,7 @@ var SplashDialog = function(editorUi)
|
|
|
|
|
|
var link = document.createElement('a');
|
|
|
link.setAttribute('href', 'javascript:void(0)');
|
|
|
- link.style.display = 'block';
|
|
|
+ link.style.display = 'inline-block';
|
|
|
link.style.marginTop = '6px';
|
|
|
mxUtils.write(link, mxResources.get('signOut'));
|
|
|
|
|
@@ -649,7 +649,7 @@ var SplashDialog = function(editorUi)
|
|
|
|
|
|
var link = document.createElement('a');
|
|
|
link.setAttribute('href', 'javascript:void(0)');
|
|
|
- link.style.display = 'block';
|
|
|
+ link.style.display = 'inline-block';
|
|
|
link.style.marginTop = '6px';
|
|
|
mxUtils.write(link, mxResources.get('changeUser') + ' (' + driveUser.displayName + ')');
|
|
|
|
|
@@ -721,9 +721,10 @@ var SplashDialog = function(editorUi)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ mxUtils.br(buttons);
|
|
|
var link = document.createElement('a');
|
|
|
link.setAttribute('href', 'javascript:void(0)');
|
|
|
- link.style.display = 'block';
|
|
|
+ link.style.display = 'inline-block';
|
|
|
link.style.marginTop = '8px';
|
|
|
mxUtils.write(link, mxResources.get('notUsingService', [storage]));
|
|
|
|
|
@@ -2012,170 +2013,183 @@ var ParseDialog = function(editorUi, title, defaultType)
|
|
|
{
|
|
|
var plantUmlServerUrl = (type == 'plantUmlTxt') ? PLANT_URL + '/txt/' :
|
|
|
((type == 'plantUmlPng') ? PLANT_URL + '/png/' : PLANT_URL + '/svg/');
|
|
|
- var graph = editorUi.editor.graph;
|
|
|
-
|
|
|
- // TODO: Change server to return base64 & accept POST request
|
|
|
- if (editorUi.spinner.spin(document.body, mxResources.get('inserting')))
|
|
|
- {
|
|
|
- function encode64(data) {
|
|
|
- r = "";
|
|
|
- for (i=0; i<data.length; i+=3) {
|
|
|
- if (i+2==data.length) {
|
|
|
- r +=append3bytes(data.charCodeAt(i), data.charCodeAt(i+1), 0);
|
|
|
- } else if (i+1==data.length) {
|
|
|
- r += append3bytes(data.charCodeAt(i), 0, 0);
|
|
|
- } else {
|
|
|
- r += append3bytes(data.charCodeAt(i), data.charCodeAt(i+1),
|
|
|
- data.charCodeAt(i+2));
|
|
|
- }
|
|
|
- }
|
|
|
- return r;
|
|
|
- }
|
|
|
-
|
|
|
- function append3bytes(b1, b2, b3)
|
|
|
- {
|
|
|
- c1 = b1 >> 2;
|
|
|
- c2 = ((b1 & 0x3) << 4) | (b2 >> 4);
|
|
|
- c3 = ((b2 & 0xF) << 2) | (b3 >> 6);
|
|
|
- c4 = b3 & 0x3F;
|
|
|
- r = "";
|
|
|
- r += encode6bit(c1 & 0x3F);
|
|
|
- r += encode6bit(c2 & 0x3F);
|
|
|
- r += encode6bit(c3 & 0x3F);
|
|
|
- r += encode6bit(c4 & 0x3F);
|
|
|
- return r;
|
|
|
- }
|
|
|
-
|
|
|
- function encode6bit(b)
|
|
|
+ var graph = editorUi.editor.graph;
|
|
|
+
|
|
|
+ // TODO: Change server to return base64 and accept POST request
|
|
|
+ if (editorUi.spinner.spin(document.body, mxResources.get('inserting')))
|
|
|
{
|
|
|
- if (b < 10) {
|
|
|
- return String.fromCharCode(48 + b);
|
|
|
- }
|
|
|
- b -= 10;
|
|
|
- if (b < 26) {
|
|
|
- return String.fromCharCode(65 + b);
|
|
|
- }
|
|
|
- b -= 26;
|
|
|
- if (b < 26) {
|
|
|
- return String.fromCharCode(97 + b);
|
|
|
- }
|
|
|
- b -= 26;
|
|
|
- if (b == 0) {
|
|
|
- return '-';
|
|
|
+ function encode64(data)
|
|
|
+ {
|
|
|
+ r = "";
|
|
|
+
|
|
|
+ for (i = 0; i < data.length; i += 3)
|
|
|
+ {
|
|
|
+ if (i + 2 == data.length)
|
|
|
+ {
|
|
|
+ r += append3bytes(data.charCodeAt(i), data.charCodeAt(i + 1), 0);
|
|
|
+ }
|
|
|
+ else if (i + 1 == data.length)
|
|
|
+ {
|
|
|
+ r += append3bytes(data.charCodeAt(i), 0, 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ r += append3bytes(data.charCodeAt(i), data.charCodeAt(i + 1),
|
|
|
+ data.charCodeAt(i + 2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return r;
|
|
|
}
|
|
|
- if (b == 1) {
|
|
|
- return '_';
|
|
|
+
|
|
|
+ function append3bytes(b1, b2, b3)
|
|
|
+ {
|
|
|
+ c1 = b1 >> 2;
|
|
|
+ c2 = ((b1 & 0x3) << 4) | (b2 >> 4);
|
|
|
+ c3 = ((b2 & 0xF) << 2) | (b3 >> 6);
|
|
|
+ c4 = b3 & 0x3F;
|
|
|
+ r = "";
|
|
|
+ r += encode6bit(c1 & 0x3F);
|
|
|
+ r += encode6bit(c2 & 0x3F);
|
|
|
+ r += encode6bit(c3 & 0x3F);
|
|
|
+ r += encode6bit(c4 & 0x3F);
|
|
|
+
|
|
|
+ return r;
|
|
|
}
|
|
|
- return '?';
|
|
|
- }
|
|
|
-
|
|
|
- // TODO: Remove unescape, use btoa for compatibility with graph.compress
|
|
|
- function compress(s)
|
|
|
- {
|
|
|
- return encode64(graph.bytesToString(pako.deflateRaw(unescape(encodeURIComponent(s)))));
|
|
|
- };
|
|
|
-
|
|
|
- var xhr = new XMLHttpRequest();
|
|
|
- xhr.open('GET', plantUmlServerUrl + compress(text), true);
|
|
|
-
|
|
|
- if (type != 'plantUmlTxt')
|
|
|
- {
|
|
|
- xhr.responseType = 'blob';
|
|
|
- }
|
|
|
-
|
|
|
- xhr.onload = function(e)
|
|
|
- {
|
|
|
- if (this.status >= 200 && this.status < 300)
|
|
|
- {
|
|
|
- if (type == 'plantUmlTxt')
|
|
|
+
|
|
|
+ function encode6bit(b)
|
|
|
{
|
|
|
- editorUi.spinner.stop();
|
|
|
+ if (b < 10)
|
|
|
+ {
|
|
|
+ return String.fromCharCode(48 + b);
|
|
|
+ }
|
|
|
|
|
|
- graph.getModel().beginUpdate();
|
|
|
- try
|
|
|
+ b -= 10;
|
|
|
+
|
|
|
+ if (b < 26)
|
|
|
{
|
|
|
- cell = graph.insertVertex(null, null, '<pre>' + this.response + '</pre>',
|
|
|
- insertPoint.x, insertPoint.y, 1, 1, 'text;html=1;overflow=fill;');
|
|
|
- graph.updateCellSize(cell, true);
|
|
|
+ return String.fromCharCode(65 + b);
|
|
|
}
|
|
|
- finally
|
|
|
+
|
|
|
+ b -= 26;
|
|
|
+
|
|
|
+ if (b < 26)
|
|
|
{
|
|
|
- graph.getModel().endUpdate();
|
|
|
+ return String.fromCharCode(97 + b);
|
|
|
}
|
|
|
|
|
|
- graph.setSelectionCell(cell);
|
|
|
- graph.scrollCellToVisible(graph.getSelectionCell());
|
|
|
+ b -= 26;
|
|
|
+
|
|
|
+ if (b == 0)
|
|
|
+ {
|
|
|
+ return '-';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (b == 1)
|
|
|
+ {
|
|
|
+ return '_';
|
|
|
+ }
|
|
|
+
|
|
|
+ return '?';
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ // TODO: Remove unescape, use btoa for compatibility with graph.compress
|
|
|
+ function compress(s)
|
|
|
{
|
|
|
- var reader = new FileReader();
|
|
|
- reader.readAsDataURL(this.response);
|
|
|
-
|
|
|
- reader.onload = function(e)
|
|
|
- {
|
|
|
- var img = new Image();
|
|
|
-
|
|
|
- img.onload = function()
|
|
|
- {
|
|
|
- editorUi.spinner.stop();
|
|
|
- var w = img.width;
|
|
|
- var h = img.height;
|
|
|
-
|
|
|
- // Workaround for 0 image size in IE11
|
|
|
- if (w == 0 && h == 0)
|
|
|
- {
|
|
|
- var data = e.target.result;
|
|
|
- var comma = data.indexOf(',');
|
|
|
- var svgText = decodeURIComponent(escape(atob(data.substring(comma + 1))));
|
|
|
- var root = mxUtils.parseXml(svgText);
|
|
|
- var svgs = root.getElementsByTagName('svg');
|
|
|
-
|
|
|
- if (svgs.length > 0)
|
|
|
- {
|
|
|
- w = parseFloat(svgs[0].getAttribute('width'));
|
|
|
- h = parseFloat(svgs[0].getAttribute('height'));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- graph.getModel().beginUpdate();
|
|
|
- try
|
|
|
+ return encode64(graph.bytesToString(
|
|
|
+ pako.deflateRaw(unescape(
|
|
|
+ encodeURIComponent(s)))));
|
|
|
+ };
|
|
|
+
|
|
|
+ var xhr = new XMLHttpRequest();
|
|
|
+ xhr.open('GET', plantUmlServerUrl + compress(text), true);
|
|
|
+
|
|
|
+ if (type != 'plantUmlTxt')
|
|
|
+ {
|
|
|
+ xhr.responseType = 'blob';
|
|
|
+ }
|
|
|
+
|
|
|
+ xhr.onload = function(e)
|
|
|
+ {
|
|
|
+ if (this.status >= 200 && this.status < 300)
|
|
|
+ {
|
|
|
+ if (type == 'plantUmlTxt')
|
|
|
+ {
|
|
|
+ editorUi.spinner.stop();
|
|
|
+ graph.setSelectionCell(editorUi.insertAsPreText(
|
|
|
+ this.response, insertPoint.x, insertPoint.y));
|
|
|
+ graph.scrollCellToVisible(graph.getSelectionCell());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.readAsDataURL(this.response);
|
|
|
+
|
|
|
+ reader.onloadend = function(e)
|
|
|
{
|
|
|
- cell = graph.insertVertex(null, null, text, insertPoint.x, insertPoint.y,
|
|
|
- w, h, 'shape=image;noLabel=1;verticalAlign=top;aspect=fixed;imageAspect=0;' +
|
|
|
- 'image=' + editorUi.convertDataUri(e.target.result) + ';');
|
|
|
- }
|
|
|
- finally
|
|
|
+ var img = new Image();
|
|
|
+
|
|
|
+ img.onload = function()
|
|
|
+ {
|
|
|
+ editorUi.spinner.stop();
|
|
|
+ var w = img.width;
|
|
|
+ var h = img.height;
|
|
|
+
|
|
|
+ // Workaround for 0 image size in IE11
|
|
|
+ if (w == 0 && h == 0)
|
|
|
+ {
|
|
|
+ var data = reader.result;
|
|
|
+ var comma = data.indexOf(',');
|
|
|
+ var svgText = decodeURIComponent(escape(atob(data.substring(comma + 1))));
|
|
|
+ var root = mxUtils.parseXml(svgText);
|
|
|
+ var svgs = root.getElementsByTagName('svg');
|
|
|
+
|
|
|
+ if (svgs.length > 0)
|
|
|
+ {
|
|
|
+ w = parseFloat(svgs[0].getAttribute('width'));
|
|
|
+ h = parseFloat(svgs[0].getAttribute('height'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ graph.getModel().beginUpdate();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ cell = graph.insertVertex(null, null, text, insertPoint.x, insertPoint.y,
|
|
|
+ w, h, 'shape=image;noLabel=1;verticalAlign=top;aspect=fixed;imageAspect=0;' +
|
|
|
+ 'image=' + editorUi.convertDataUri(reader.result) + ';');
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ graph.getModel().endUpdate();
|
|
|
+ }
|
|
|
+
|
|
|
+ graph.setSelectionCell(cell);
|
|
|
+ graph.scrollCellToVisible(graph.getSelectionCell());
|
|
|
+ };
|
|
|
+
|
|
|
+ img.src = reader.result;
|
|
|
+ };
|
|
|
+
|
|
|
+ reader.onerror = function(e)
|
|
|
{
|
|
|
- graph.getModel().endUpdate();
|
|
|
- }
|
|
|
-
|
|
|
- graph.setSelectionCell(cell);
|
|
|
- graph.scrollCellToVisible(graph.getSelectionCell());
|
|
|
- };
|
|
|
-
|
|
|
- img.src = e.target.result;
|
|
|
- };
|
|
|
-
|
|
|
- reader.onerror = function(e)
|
|
|
- {
|
|
|
- editorUi.handleError(e);
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- editorUi.spinner.stop();
|
|
|
- editorUi.handleError(e);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- xhr.onerror = function(e)
|
|
|
- {
|
|
|
- editorUi.handleError(e);
|
|
|
- };
|
|
|
-
|
|
|
- xhr.send();
|
|
|
- }
|
|
|
+ editorUi.handleError(e);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ editorUi.spinner.stop();
|
|
|
+ editorUi.handleError(e);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ xhr.onerror = function(e)
|
|
|
+ {
|
|
|
+ editorUi.handleError(e);
|
|
|
+ };
|
|
|
+
|
|
|
+ xhr.send();
|
|
|
+ }
|
|
|
}
|
|
|
else if (type == 'table')
|
|
|
{
|
|
@@ -2958,18 +2972,16 @@ var NewDialog = function(editorUi, compact, showName, callback, createOnly, canc
|
|
|
|
|
|
if (title != null && title.length > 0)
|
|
|
{
|
|
|
- var tempMode = (editorUi.mode == App.MODE_ONEDRIVE || editorUi.mode == App.MODE_TRELLO ||
|
|
|
- (editorUi.mode == App.MODE_GOOGLE && (editorUi.stateArg == null ||
|
|
|
- editorUi.stateArg.folderId == null))) ? editorUi.mode : null;
|
|
|
-
|
|
|
- editorUi.pickFolder(tempMode, function(folderId)
|
|
|
+ editorUi.pickFolder(editorUi.mode, function(folderId)
|
|
|
{
|
|
|
editorUi.createFile(title, templateXml, (templateLibs != null &&
|
|
|
templateLibs.length > 0) ? templateLibs : null, null, function()
|
|
|
{
|
|
|
editorUi.hideDialog();
|
|
|
}, null, folderId);
|
|
|
- });
|
|
|
+ }, editorUi.mode != App.MODE_GOOGLE ||
|
|
|
+ editorUi.stateArg == null ||
|
|
|
+ editorUi.stateArg.folderId == null);
|
|
|
}
|
|
|
}
|
|
|
};
|