瀏覽代碼

10.4.3 release

Gaudenz Alder 6 年之前
父節點
當前提交
5587c6c084

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+12-MAR-2019: 10.4.3
+
+- Uses mxGraph 4.0.1 beta 1
+
 11-MAR-2019: 10.4.2
 
 - Adds logging

+ 1 - 1
VERSION

@@ -1 +1 @@
-10.4.2
+10.4.3

File diff suppressed because it is too large
+ 6 - 7
etc/mxgraph/mxClient.js


+ 2 - 3
src/main/java/com/mxgraph/online/ProxyServlet.java

@@ -67,14 +67,14 @@ public class ProxyServlet extends HttpServlet
 			String ua = request.getHeader("User-Agent");
 			String dom = getCorsDomain(ref, ua);
 
-			try
+			try(OutputStream out = response.getOutputStream())
 			{
 				request.setCharacterEncoding("UTF-8");
 				response.setCharacterEncoding("UTF-8");
 
 				URL url = new URL(urlParam);
 				URLConnection connection = url.openConnection();
-				OutputStream out = response.getOutputStream();
+				
 				response.setHeader("Cache-Control", "private, max-age=86400");
 
 				// Workaround for 451 response from Iconfinder CDN
@@ -123,7 +123,6 @@ public class ProxyServlet extends HttpServlet
 				}
 
 				out.flush();
-				out.close();
 
 				log.log(Level.FINEST, "processed proxy request: url="
 						+ ((urlParam != null) ? urlParam : "[null]")

+ 1 - 1
src/main/webapp/cache.manifest

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 03/11/2019 09:44 AM
+# 03/12/2019 09:54 AM
 
 app.html
 index.html?offline=1

File diff suppressed because it is too large
+ 300 - 301
src/main/webapp/js/app.min.js


+ 1 - 23
src/main/webapp/js/diagramly/App.js

@@ -1023,7 +1023,7 @@ App.prototype.init = function()
 							var day = new Date().getDay();
 							var isWeekend = (day === 6) || (day === 0);
 							
-							if (isWeekend || Math.random() > 0.8)
+							if (isWeekend || Math.random() > 0.6)
 							{
 								var footer = document.createElement('div');
 								footer.style.cssText = 'position:absolute;bottom:0px;max-width:90%;padding:10px;padding-right:26px;' +
@@ -3193,28 +3193,6 @@ App.prototype.saveFile = function(forceDialog, success)
 	}
 };
 
-/**
- * Returns true if the given binary data is a Visio file.
- */
-App.prototype.isVisioData = function(data)
-{
-	return data.length > 8 && (data.charCodeAt(0) == 0xD0 && data.charCodeAt(1) == 0xCF &&
-		data.charCodeAt(2) == 0x11 && data.charCodeAt(3) == 0xE0 && data.charCodeAt(4) == 0xA1 && data.charCodeAt(5) == 0xB1 &&
-		data.charCodeAt(6) == 0x1A && data.charCodeAt(7) == 0xE1) || (data.charCodeAt(0) == 0x50 && data.charCodeAt(1) == 0x4B &&
-		data.charCodeAt(2) == 0x03 && data.charCodeAt(3) == 0x04) || (data.charCodeAt(0) == 0x50 && data.charCodeAt(1) == 0x4B &&
-		data.charCodeAt(2) == 0x03 && data.charCodeAt(3) == 0x06);
-};
-
-/**
- * Returns true if the given binary data is a PNG file.
- */
-App.prototype.isPngData = function(data)
-{
-	return data.length > 8 && data.charCodeAt(0) == 137 && data.charCodeAt(1) == 80 &&
-		data.charCodeAt(2) == 78 && data.charCodeAt(3) == 71 && data.charCodeAt(4) == 13 &&
-		data.charCodeAt(5) == 10 && data.charCodeAt(6) == 26 && data.charCodeAt(7) == 10;
-};
-
 /**
  * Translates this point by the given vector.
  * 

+ 8 - 0
src/main/webapp/js/diagramly/DrawioFile.js

@@ -1035,6 +1035,14 @@ DrawioFile.prototype.loadPatchDescriptor = function(success, error)
 	}), error);
 };
 
+/**
+ * Adds the listener for automatically saving the diagram for local changes.
+ */
+DrawioFile.prototype.patchDescriptor = function(desc, patch)
+{
+	this.setDescriptorEtag(desc, this.getDescriptorEtag(patch));
+};
+
 /**
  * Creates a starts the synchronization.
  */

+ 10 - 11
src/main/webapp/js/diagramly/DrawioFileSync.js

@@ -630,9 +630,7 @@ DrawioFileSync.prototype.fileChanged = function(success, error, abort)
 						}
 						else
 						{
-							this.catchup(this.file.getDescriptorEtag(desc),
-								this.file.getDescriptorSecret(desc),
-								success, error, abort);
+							this.catchup(desc, success, error, abort);
 						}
 					}
 				}), error);
@@ -684,12 +682,14 @@ DrawioFileSync.prototype.updateDescriptor = function(desc)
 /**
  * Adds the listener for automatically saving the diagram for local changes.
  */
-DrawioFileSync.prototype.catchup = function(etag, secret, success, error, abort)
+DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
 {
 	if (abort == null || !abort())
 	{
+		var secret = this.file.getDescriptorSecret(desc);
+		var etag = this.file.getDescriptorEtag(desc);
 		var current = this.file.getCurrentEtag();
-	
+		
 		if (current == etag)
 		{
 			if (success != null)
@@ -820,7 +820,7 @@ DrawioFileSync.prototype.catchup = function(etag, secret, success, error, abort)
 										if (temp.length > 0)
 										{
 											this.file.stats.cacheHits++;
-											this.merge(temp, checksum, etag, success, error, abort);
+											this.merge(temp, checksum, desc, success, error, abort);
 										}
 										// Retries if cache entry was not yet there
 										else if (cacheReadyRetryCount <= this.maxCacheReadyRetries &&
@@ -882,7 +882,7 @@ DrawioFileSync.prototype.reload = function(success, error, abort, shadow)
 /**
  * Adds the listener for automatically saving the diagram for local changes.
  */
-DrawioFileSync.prototype.merge = function(patches, checksum, etag, success, error, abort)
+DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, error, abort)
 {
 	try
 	{
@@ -897,6 +897,7 @@ DrawioFileSync.prototype.merge = function(patches, checksum, etag, success, erro
 			this.ui.diffPages(this.file.shadowPages,
 			this.ui.pages) : null;
 		var ignored = this.file.ignorePatches(patches);
+		var etag = this.file.getDescriptorEtag(desc);
 
 		if (!ignored)
 		{
@@ -946,7 +947,7 @@ DrawioFileSync.prototype.merge = function(patches, checksum, etag, success, erro
 
 		this.file.invalidChecksum = false;
 		this.file.inConflictState = false;
-		this.file.setCurrentEtag(etag);
+		this.file.patchDescriptor(this.file.getDescriptor(), desc);
 		this.file.backupPatch = null;
 		
 		if (success != null)
@@ -1147,9 +1148,7 @@ DrawioFileSync.prototype.fileConflict = function(desc, success, error)
 		
 		if (desc != null)
 		{
-			var etag = this.file.getDescriptorEtag(desc);
-			var secret = this.file.getDescriptorSecret(desc);
-			this.catchup(etag, secret, success, error);
+			this.catchup(desc, success, error);
 		}
 		else
 		{

+ 31 - 23
src/main/webapp/js/diagramly/DriveClient.js

@@ -61,7 +61,7 @@ DriveClient.prototype.allFields = 'kind,id,parents,headRevisionId,etag,title,mim
  * 
  * TODO: Limit to etag and ekey property only
  */
-DriveClient.prototype.catchupFields = 'etag,properties(key,value)';
+DriveClient.prototype.catchupFields = 'etag,headRevisionId,modifiedDate,properties(key,value)';
 
 /**
  * Specifies if thumbnails should be enabled. Default is true.
@@ -789,6 +789,11 @@ DriveClient.prototype.getFile = function(id, success, error, readXml, readLibrar
 				// Redirects title to originalFilename to
 				// match expected descriptor interface
 				resp.title = resp.originalFilename;
+				
+				// Uses ID of file instead of revision ID in descriptor
+				// to avoid a change of the document hash property
+				resp.headRevisionId = resp.id;
+				resp.id = id;
 
    				this.getXmlFile(resp, success, error);
 			}), error);
@@ -952,10 +957,12 @@ DriveClient.prototype.getXmlFile = function(resp, success, error, ignoreMime, re
 				}
 				else
 				{
+					var importFile = false;
+					
 					if (/\.png$/i.test(resp.title))
 					{
 						var index = data.lastIndexOf(',');
-		
+						
 						if (index > 0)
 						{
 							var xml = this.ui.extractGraphModelFromPng(data.substring(index + 1));
@@ -971,22 +978,24 @@ DriveClient.prototype.getXmlFile = function(resp, success, error, ignoreMime, re
 								// is required for creating the images for .PNG and .SVG files.
 								try
 								{
-									var temp = atob(data.substring(index + 1));
+									var xml = data.substring(index + 1);
+									var temp = (window.atob && !mxClient.IS_IE && !mxClient.IS_IE11) ?
+										atob(xml) : Base64.decode(xml);
+									var node = this.ui.editor.extractGraphModel(
+										mxUtils.parseXml(temp).documentElement, true);
 									
-									if (temp != null && (temp.substring(0, 8) === '<mxfile ' ||
-										temp.substring(0, 14) === '<mxGraphModel ' ||
-										temp.substring(0, 14) === '<mxGraphModel>'))
-			    					{
-										data = temp;
-			    					}
+									if (node == null || node.getElementsByTagName('parsererror').length > 0)
+									{
+										importFile = true;
+									}
 									else
 									{
-										// TODO: Import as PNG
+										data = temp;
 									}
 								}
 								catch (e)
 								{
-									// ignore
+									importFile = true;
 								}
 							}
 						}
@@ -998,7 +1007,7 @@ DriveClient.prototype.getXmlFile = function(resp, success, error, ignoreMime, re
 						data = (window.atob && !mxClient.IS_SF) ? atob(temp) : Base64.decode(temp);
 					}
 					
-					success(new DriveFile(this.ui, data, resp));
+					success((importFile) ? new LocalFile(this.ui, data, resp.title, true) : new DriveFile(this.ui, data, resp));
 				}
 			}
 			catch (e)
@@ -2451,7 +2460,7 @@ DriveClient.prototype.convertRealtimeFiles = function()
 			var day = new Date().getDay();
 			var isWeekend = (day === 6) || (day === 0);
 			var q = 'mimeType=\'application/vnd.jgraph.mxfile.realtime\'';
-			var convertDelay = (isWeekend) ? 2000 : 15000;
+			var convertDelay = (isWeekend) ? 1000 : 5000;
 			var convertedIds = {};
 			var converted = 0;
 			var fromJson = 0;
@@ -2483,15 +2492,14 @@ DriveClient.prototype.convertRealtimeFiles = function()
 				{
 					var dt = Date.now() - t0;
 					
-					EditorUi.sendReport('Convert Realtime Report ' +
-						new Date().toISOString() + ':' +
-						'\n\nBrowser=' + navigator.userAgent +
-						'\nUser=' + ((this.user != null) ? this.user.id : 'unknown') +
-						'\nFound=' + total  + ' (Backup: ' + fromXml + ', Realtime: ' + fromJson + ')' +
-						'\nConverted=' + converted +
-						'\nFailed=' + failed  + ' (Load: ' + loadFail + ', Save: ' +
-							saveFail + ', Invalid: ' + invalid + ')' +
-						'\ndt=' + Math.round(dt / 1000) + ' sec(s)');
+					// Logs conversion
+					EditorUi.logEvent({category: 'AUTO-CONVERT',
+						action: 'total-' + total + '-xml-' + fromXml +
+						'-json-' + fromJson + '-done-' + converted +
+						'-fail-' + failed + '-load-' + loadFail +
+						'-save-' + saveFail + '-invalid-' + invalid +
+						'-dt-' + Math.round(dt / 1000),
+						label: (this.user != null) ? this.user.id : 'unknown-user'});
 				}
 				catch (e)
 				{
@@ -2622,7 +2630,7 @@ DriveClient.prototype.convertRealtimeFiles = function()
 															if (acceptResponse)
 															{
 																converted++;
-																print('<img src="' + Editor.checkmarkImage + '" border="0" valign="middle"/>');
+																print('OK <img src="' + Editor.checkmarkImage + '" border="0" valign="middle"/>');
 																doNextPage();
 															}
 														}), mxUtils.bind(this, function(err)

+ 11 - 0
src/main/webapp/js/diagramly/DriveFile.js

@@ -643,6 +643,17 @@ DriveFile.prototype.loadPatchDescriptor = function(success, error)
 	}), error);
 };
 
+/**
+ * Adds the listener for automatically saving the diagram for local changes.
+ */
+DriveFile.prototype.patchDescriptor = function(desc, patch)
+{
+	DrawioFile.prototype.patchDescriptor.apply(this, arguments);
+	
+	desc.headRevisionId = patch.headRevisionId;
+	desc.modifiedDate = patch.modifiedDate;
+};
+
 /**
  * Adds the listener for automatically saving the diagram for local changes.
  */

+ 45 - 9
src/main/webapp/js/diagramly/EditorUi.js

@@ -652,6 +652,28 @@
 		return false;
 	};
 
+	/**
+	 * Returns true if the given binary data is a Visio file.
+	 */
+	EditorUi.prototype.isVisioData = function(data)
+	{
+		return data.length > 8 && (data.charCodeAt(0) == 0xD0 && data.charCodeAt(1) == 0xCF &&
+			data.charCodeAt(2) == 0x11 && data.charCodeAt(3) == 0xE0 && data.charCodeAt(4) == 0xA1 && data.charCodeAt(5) == 0xB1 &&
+			data.charCodeAt(6) == 0x1A && data.charCodeAt(7) == 0xE1) || (data.charCodeAt(0) == 0x50 && data.charCodeAt(1) == 0x4B &&
+			data.charCodeAt(2) == 0x03 && data.charCodeAt(3) == 0x04) || (data.charCodeAt(0) == 0x50 && data.charCodeAt(1) == 0x4B &&
+			data.charCodeAt(2) == 0x03 && data.charCodeAt(3) == 0x06);
+	};
+
+	/**
+	 * Returns true if the given binary data is a PNG file.
+	 */
+	EditorUi.prototype.isPngData = function(data)
+	{
+		return data.length > 8 && data.charCodeAt(0) == 137 && data.charCodeAt(1) == 80 &&
+			data.charCodeAt(2) == 78 && data.charCodeAt(3) == 71 && data.charCodeAt(4) == 13 &&
+			data.charCodeAt(5) == 10 && data.charCodeAt(6) == 26 && data.charCodeAt(7) == 10;
+	};
+
 	/**
 	 * Extracts the mxfile from the given HTML data from a data transfer event.
 	 */
@@ -7954,19 +7976,33 @@
 	 */
 	EditorUi.prototype.loadImage = function(uri, onload, onerror)
 	{
-		var img = new Image();
-		
-		img.onload = function()
+		try
 		{
-			onload(img);
+			var img = new Image();
+			
+			img.onload = function()
+			{
+				onload(img);
+			}
+			
+			if (onerror != null)
+			{
+				img.onerror = onerror;
+			}
+			
+			img.src = uri;
 		}
-		
-		if (onerror != null)
+		catch (e)
 		{
-			img.onerror = onerror;
+			if (onerror != null)
+			{
+				onerror(e);
+			}
+			else
+			{
+				throw e;
+			}
 		}
-		
-		img.src = uri;
 	};
 
 	// Initializes the user interface

+ 1 - 1
src/main/webapp/js/diagramly/Menus.js

@@ -1823,7 +1823,7 @@
 						// as slightly different semantic, but works the same way.
 						service.getFile(id, function(file)
 						{
-							var mime = getMimeType(file.getTitle());
+							var mime = (file.getData().substring(0, 11) == 'data:image/') ? getMimeType(file.getTitle()) : 'text/xml';
 							
 							// Imports SVG as images
 							if (/\.svg$/i.test(file.getTitle()) && !editorUi.editor.isDataSvg(file.getData()))

+ 2 - 1
src/main/webapp/js/diagramly/OneDriveFile.js

@@ -43,7 +43,8 @@ OneDriveFile.prototype.getParentId = function()
 OneDriveFile.prototype.getIdOf = function(itemObj, parent)
 {
 	//TODO driveId is most probably always there. No need to check if it exists. Also, after some time, the code that check the old id format won't be needed 
-	return (itemObj.parentReference.driveId? itemObj.parentReference.driveId + '/' : '') + (parent? itemObj.parentReference.id : itemObj.id);
+	return ((itemObj.parentReference != null && itemObj.parentReference.driveId != null) ? itemObj.parentReference.driveId + '/' : '') +
+		((parent != null) ? itemObj.parentReference.id : itemObj.id);
 };
 
 /**

File diff suppressed because it is too large
+ 1022 - 1021
src/main/webapp/js/viewer.min.js