Browse Source

10.7.6 release

David Benson 6 years ago
parent
commit
1d1e7eac5d

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+11-JUN-2019: 10.7.6
+
+- Removes fallback to print dialog if offline in Electron
+- Fixes broken link if Google Drive is not loading
+
 04-JUN-2019: 10.7.5
 
 - Fixes Math rendering in graph viewer

+ 1 - 1
VERSION

@@ -1 +1 @@
-10.7.5
+10.7.6

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

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 06/04/2019 02:23 PM
+# 06/11/2019 05:23 pm
 
 app.html
 index.html?offline=1

+ 43 - 1
src/main/webapp/electron.js

@@ -24,6 +24,8 @@ const __DEV__ = process.env.NODE_ENV === 'development'
 		
 let windowsRegistry = []
 let cmdQPressed = false
+let firstWinLoaded = false
+let firstWinFilePath = null
 
 function createWindow (opt = {})
 {
@@ -176,6 +178,7 @@ app.on('ready', e =>
 	})
 	
     let argv = process.argv
+    
     // https://github.com/electron/electron/issues/4690#issuecomment-217435222
     if (process.defaultApp != true)
     {
@@ -219,7 +222,7 @@ app.on('ready', e =>
 			'export all pages (for PDF format only)')
 		.option('-p, --page-index <pageIndex>',
 			'selects a specific page, if not specified and the format is an image, the first page is selected', parseInt)
-		.option('-g, --page-rage <from>..<to>',
+		.option('-g, --page-range <from>..<to>',
 			'selects a page range (for PDF format only)', argsRange)
         .parse(argv)
 
@@ -469,6 +472,20 @@ app.on('ready', e =>
     
     win.webContents.on('did-finish-load', function()
     {
+    	if (firstWinFilePath != null)
+		{
+    		if (program.args != null)
+    		{
+    			program.args.push(firstWinFilePath);
+    		}
+    		else
+			{
+    			program.args = [firstWinFilePath];
+			}
+		}
+    	
+    	firstWinLoaded = true;
+    	
         win.webContents.send('args-obj', program);
         
         win.webContents.setZoomFactor(1);
@@ -618,6 +635,31 @@ app.on('activate', function ()
 	}
 })
 
+app.on('will-finish-launching', function()
+{
+	app.on("open-file", function(event, path) 
+	{
+	    event.preventDefault();
+	    
+	    if (firstWinLoaded)
+	    {
+		    let win = createWindow();
+		    
+		    win.webContents.on('did-finish-load', function()
+		    {
+		        win.webContents.send('args-obj', {args: [path]});
+		        
+		        win.webContents.setZoomFactor(1);
+		        win.webContents.setVisualZoomLevelLimits(1, 1);
+		        win.webContents.setLayoutZoomLevelLimits(0, 0);
+		    });
+	    }
+	    else
+		{
+	    	firstWinFilePath = path
+		}
+	});
+});
 
 autoUpdater.on('error', e => log.error('@error@\n', e))
 

+ 1 - 0
src/main/webapp/index.html

@@ -360,6 +360,7 @@
 		// Electron
 		if (mxIsElectron)
 		{
+			mxscript('js/diagramly/DesktopLibrary.js');
 			mxscript('js/diagramly/ElectronApp.js');
 		}
 		

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


+ 14 - 0
src/main/webapp/js/diagramly/App.js

@@ -4372,6 +4372,20 @@ App.prototype.restoreLibraries = function()
 									}
 								}
 							}
+							else if (service == 'S' && this.loadDesktopLib != null)
+							{
+								try
+								{
+									this.loadDesktopLib(decodeURIComponent(id.substring(1)), function(desktopLib)
+									{
+										onload(desktopLib);
+									}, onerror);
+								}
+								catch (e)
+								{
+									onerror();
+								}
+							}
 							else
 							{
 								var peer = null;

+ 29 - 0
src/main/webapp/js/diagramly/DesktopLibrary.js

@@ -0,0 +1,29 @@
+// Copyright (c) 2006-2019, JGraph Ltd
+/**
+ */
+DesktopLibrary = function(ui, data, fileObj)
+{
+	LocalLibrary.call(this, ui, data, fileObj.name);
+	this.fileObj = fileObj;
+};
+
+//Extends LocalLibrary
+mxUtils.extend(DesktopLibrary, LocalLibrary);
+
+/**
+ * 
+ */
+DesktopLibrary.prototype.getHash = function()
+{
+	return 'S' + encodeURIComponent(this.fileObj.path);
+};
+
+DesktopLibrary.prototype.isAutosave = function()
+{
+	return this.fileObj != null;
+};
+
+DesktopLibrary.prototype.save = function(revision, success, error)
+{
+	LocalFile.prototype.saveFile.apply(this, arguments);
+};

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

@@ -434,7 +434,7 @@ var StorageDialog = function(editorUi, fn, rowLimit)
 				p3.style.fontSize = '9pt';
 				p3.style.marginTop = '-14px';
 				p3.innerHTML = '<a style="background-color:#dcdcdc;padding:5px;color:black;text-decoration:none;" ' +
-					'href="https://plus.google.com/u/0/+DrawIo1/posts/1HTrfsb5wDN" target="_blank">' +
+					'href="https://desk.draw.io/a/solutions/articles/16000074659" target="_blank">' +
 					'<img border="0" src="' + mxGraph.prototype.warningImage.src + '" align="top"> ' +
 					mxResources.get('googleDriveMissingClickHere') + '</a>';
 				div.appendChild(p3);

+ 2 - 4
src/main/webapp/js/diagramly/EditorUi.js

@@ -6614,9 +6614,7 @@
 							{
 								try
 								{
-									//add back the file name
-									xhr.response.name = filename;
-									this.doImportVisio(xhr.response, done, onerror);
+									this.doImportVisio(xhr.response, done, onerror, filename);
 								}
 								catch (e)
 								{
@@ -6636,7 +6634,7 @@
 				{
 					try
 					{
-						this.doImportVisio(file, done, onerror);
+						this.doImportVisio(file, done, onerror, filename);
 					}
 					catch (e)
 					{

+ 211 - 21
src/main/webapp/js/diagramly/ElectronApp.js

@@ -87,10 +87,54 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 			editorUi.openLink('https://www.draw.io/')
 		}));
 		
+		this.put('openRecent', new Menu(function(menu, parent)
+		{
+			var recent = editorUi.getRecent();
+
+			if (recent != null)
+			{
+				for (var i = 0; i < recent.length; i++)
+				{
+					(function(entry)
+					{
+						menu.addItem(entry.title, null, function()
+						{
+							function doOpenRecent()
+							{
+								//Simulate opening a file via args
+								editorUi.loadArgs({args: [entry.id]});
+							};
+							
+							var file = editorUi.getCurrentFile();
+							
+							if (file != null && file.isModified())
+							{
+								editorUi.confirm(mxResources.get('allChangesLost'), null, doOpenRecent,
+									mxResources.get('cancel'), mxResources.get('discardChanges'));
+							}
+							else
+							{
+								doOpenRecent();
+							}
+						}, parent);
+					})(recent[i]);
+				}
+
+				menu.addSeparator(parent);
+			}
+
+			menu.addItem(mxResources.get('reset'), null, function()
+			{
+				editorUi.resetRecent();
+			}, parent);
+		}));
+		
 		// 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', '-', 'synchronize', '-', 'save', 'saveAs', '-', 'import'], parent);
+			this.addMenuItems(menu, ['new', 'open'], parent);
+			this.addSubmenu('openRecent', menu, parent);
+			this.addMenuItems(menu, ['-', 'synchronize', '-', 'save', 'saveAs', '-', 'import'], parent);
 			this.addSubmenu('exportAs', menu, parent);
 			menu.addSeparator(parent);
 			this.addSubmenu('embed', menu, parent);
@@ -416,6 +460,47 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 		}		
 	}
 
+	var origFileLoaded = EditorUi.prototype.fileLoaded;
+	
+	EditorUi.prototype.fileLoaded = function(file)
+	{
+		
+		if (file != null)
+		{
+			if (file.fileObject == null)
+			{
+				var fname = file.getTitle();
+				
+				var fileInfo = openFilesMap[fname];
+				
+				if (fileInfo != null)
+				{
+					file.fileObject = {
+						name: fileInfo.name,
+						path: fileInfo.path,
+						type: fileInfo.type || 'utf-8'
+					};
+					//delete it such that it is not used again incorrectly
+					delete openFilesMap[fname];
+				}
+			}
+			
+			if (file.fileObject != null)
+			{
+				var title = file.fileObject.path;
+				
+				if (title.length > 100)
+				{
+					title = '...' + title.substr(title.length - 97);
+				}
+				
+				this.addRecent({id: file.fileObject.path, title: title});
+			}
+		}
+		
+		origFileLoaded.apply(this, arguments);
+	};
+	
 	// Uses local picker
 	App.prototype.pickFile = function()
 	{
@@ -454,8 +539,7 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 		{
 			try
 			{
-				var library = new LocalLibrary(this, data, fileEntry.name);
-				library.fileObject = fileEntry;
+				var library = new DesktopLibrary(this, data, fileEntry);
 				this.loadLibrary(library);
 			}
 			catch (e)
@@ -487,12 +571,29 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
         }
 	};
 
+	//In order not to repeat the logic for opening a file, we collect files information here and use them in openLocalFile
+	var origOpenFiles = EditorUi.prototype.openFiles;
+	var openFilesMap = {};
+	
+	EditorUi.prototype.openFiles = function(files, temp)
+	{
+		openFilesMap = {};
+
+		for (var i = 0; i < files.length; i++)
+		{
+			openFilesMap[files[i].name] = files[i];
+		}
+		
+		origOpenFiles.apply(this, arguments);
+	};
+	
 	App.prototype.readGraphFile = function(fn, fnErr, path)
 	{
 		var fs = require('fs');
 		var index = path.lastIndexOf('.png');
 		var isPng = index > -1 && index == path.length - 4;
-		var encoding = isPng ? 'base64' : 'utf-8'
+		var isVsdx = /\.vsdx$/i.test(path) || /\.vssx$/i.test(path);
+		var encoding = isVsdx? null : (isPng ? 'base64' : 'utf-8');
 
 		fs.readFile(path, encoding, mxUtils.bind(this, function (e, data)
 		{
@@ -502,6 +603,55 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 			}
 			else
 			{
+				var fileEntry = new Object();
+				fileEntry.path = path;
+				fileEntry.name = path.replace(/^.*[\\\/]/, '');
+				fileEntry.type = encoding;
+
+				//VSDX files are imported instead of being open
+				if (isVsdx)
+				{
+					var name = fileEntry.name;
+
+					this.importVisio(data, mxUtils.bind(this, function(xml)
+					{
+						var dot = name.lastIndexOf('.');
+						
+						if (dot >= 0)
+						{
+							name = name.substring(0, name.lastIndexOf('.')) + '.drawio';
+						}
+						else
+						{
+							name = name + '.drawio';
+						}
+						
+						if (xml.substring(0, 10) == '<mxlibrary')
+						{
+							// Creates new temporary file if library is dropped in splash screen
+							if (this.getCurrentFile() == null && urlParams['embed'] != '1')
+							{
+								this.openLocalFile(this.emptyDiagramXml, this.defaultFilename);
+							}
+						
+							try
+			    			{
+								this.loadLibrary(new LocalLibrary(this, xml, name));
+			    			}
+							catch (e)
+			    			{
+			    				this.handleError(e, mxResources.get('errorLoadingFile'));
+			    			}
+						}
+						else
+						{
+							this.openLocalFile(xml, name);
+						}
+					}), null, name);
+					
+					return;
+				}
+				
 				if (isPng)
 				{
 					// Detecting png by extension. Would need https://github.com/mscdex/mmmagic
@@ -509,11 +659,6 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 					data = this.extractGraphModelFromPng('data:image/png;base64,' + data);
 				}
 
-				var fileEntry = new Object();
-				fileEntry.path = path;
-				fileEntry.name = path.replace(/^.*[\\\/]/, '');
-				fileEntry.type = encoding;
-
 				fs.stat(path, function(err, stat)
 				{
 					if (err)
@@ -651,11 +796,6 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 		return this.fileObject != null;
 	};
 	
-	LocalLibrary.prototype.isAutosave = function()
-	{
-		return this.fileObject != null;
-	};
-	
 	LocalFile.prototype.getTitle = function()
 	{
 		return (this.fileObject != null) ? this.fileObject.name : this.title;
@@ -676,11 +816,6 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 		this.saveFile(revision, success, error, unloading, overwrite);
 	};
 
-	LocalLibrary.prototype.save = function(revision, success, error)
-	{
-		LocalFile.prototype.saveFile.apply(this, arguments);
-	};
-	
 	LocalFile.prototype.isConflict = function(stat)
 	{
 		return stat != null && this.stat != null && stat.mtimeMs != this.stat.mtimeMs;
@@ -1173,7 +1308,52 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 		// to give the spinner some time to stop spinning
 		window.setTimeout(mxUtils.bind(this, function()
 		{
-			var path = dialog.showSaveDialog({defaultPath: filename});
+			var dlgConfig = {defaultPath: filename};
+			var filters = null;
+			
+			switch (format)
+			{
+				case 'xmlpng':
+				case 'png':
+					filters = [
+				          { name: 'PNG Images', extensions: ['png'] }
+				       ];
+				break;
+				case 'jpg':
+				case 'jpeg':
+					filters = [
+				          { name: 'JPEG Images', extensions: ['jpg', 'jpeg'] }
+				       ];
+				break;
+				case 'svg':
+					filters = [
+				          { name: 'SVG Images', extensions: ['svg'] }
+				       ];
+				break;
+				case 'pdf':
+					filters = [
+				          { name: 'PDF Documents', extensions: ['pdf'] }
+				       ];
+				break;
+				case 'vsdx':
+					filters = [
+				          { name: 'VSDX Documents', extensions: ['vsdx'] }
+				       ];
+				break;
+				case 'html':
+					filters = [
+				          { name: 'HTML Documents', extensions: ['html'] }
+				       ];
+				break;
+				case 'xml':
+					filters = [
+				          { name: 'XML Documents', extensions: ['xml'] }
+				       ];
+				break;
+			};
+			
+			dlgConfig['filters'] = filters;
+			var path = dialog.showSaveDialog(dlgConfig);
 	
 	        if (path != null)
 	        {
@@ -1202,8 +1382,18 @@ FeedbackDialog.feedbackUrl = 'https://log.draw.io/email';
 		        	}));
 				}
 			}
-		}), 0);
+		}), 50);
 	};
 
 	EditorUi.prototype.addBeforeUnloadListener = function() {};
+	
+	EditorUi.prototype.loadDesktopLib = function(libPath, success, error)
+	{
+		this.readGraphFile(mxUtils.bind(this, function(fileEntry, data, stat)
+		{
+			var library = new DesktopLibrary(this, data, fileEntry);
+			this.loadLibrary(library);
+			success(library);
+		}), error, libPath);
+	};
 })();

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

@@ -208,7 +208,8 @@
 		
 		editorUi.actions.put('exportPdf', new Action(mxResources.get('formatPdf') + '...', function()
 		{
-			if (editorUi.isOffline() || editorUi.printPdfExport)
+			if ((typeof(mxIsElectron5) === 'undefined' || !mxIsElectron5) &&
+				(editorUi.isOffline() || editorUi.printPdfExport))
 			{
 				// Export PDF action for chrome OS (same as print with different dialog title)
 				editorUi.showDialog(new PrintDialog(editorUi, mxResources.get('formatPdf')).container, 360,

+ 4 - 2
src/main/webapp/js/diagramly/vsdx/importer.js

@@ -12060,9 +12060,11 @@ com.mxgraph.io.vsdx.mxPropertiesManager.__static_initialize();
 com.mxgraph.io.mxVsdxCodec.vsdxPlaceholder_$LI$();
 com.mxgraph.io.mxVsdxCodec.parsererrorNS_$LI$();
 
-EditorUi.prototype.doImportVisio = function(file, done, onerror)
+EditorUi.prototype.doImportVisio = function(file, done, onerror, filename)
 {
-	if (file.name != null && /(\.vs(x|sx?))($|\?)/i.test(file.name))
+	filename = filename || file.name;
+	
+	if (filename != null && /(\.vs(x|sx?))($|\?)/i.test(filename))
 	{
 		new com.mxgraph.io.mxVssxCodec().decodeVssx(file, done, null, onerror);
 	}

File diff suppressed because it is too large
+ 1 - 1
src/main/webapp/js/extensions.min.js


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


+ 36 - 0
src/main/webapp/plugins/electron.js

@@ -4,4 +4,40 @@
 Draw.loadPlugin(function(ui)
 {
 	ui.hideFooter();
+	
+	if (!window.mxIsElectron5)
+	{
+		var footer = document.createElement('div');
+		footer.style.cssText = 'position:absolute;bottom:0px;max-width:90%;padding:10px;padding-right:26px;' +
+			'white-space:nowrap;left:50%;bottom:2px;';
+		footer.className = 'geStatusAlert';
+		
+		mxUtils.setPrefixedStyle(footer.style, 'transform', 'translate(-50%,110%)');
+		mxUtils.setPrefixedStyle(footer.style, 'transition', 'all 1s ease');
+		footer.style.whiteSpace = 'nowrap';
+		footer.innerHTML = '<a href="http://about.draw.io/drawio-desktop-10-7-5-release" ' +
+			'target="_blank" style="display:inline;text-decoration:none;font-weight:700;font-size:13px;opacity:1;">' +
+			'<img src="' + this.editor.graph.warningImage.src + '" border="0" style="margin-top:-4px;margin-right:2px;" valign="middle"/>&nbsp;' +
+			'Important desktop security update, please upgrade. Click here.&nbsp;' +
+			'<img src="' + this.editor.graph.warningImage.src + '" border="0" style="margin-top:-4px;margin-left:2px;" valign="middle"/></a>';
+		
+		var img = document.createElement('img');
+		
+		img.setAttribute('src', Dialog.prototype.closeImage);
+		img.setAttribute('title', mxResources.get('close'));
+		img.style.position = 'absolute';
+		img.style.cursor = 'pointer';
+		img.style.right = '10px';
+		img.style.top = '12px';
+	
+		footer.appendChild(img);
+	
+		mxEvent.addListener(img, 'click', mxUtils.bind(this, function()
+		{
+			footer.parentNode.removeChild(footer);
+			this.hideFooter();
+		}));
+		
+		document.body.appendChild(footer);
+	}
 });