Explorar o código

11.2.2 release

David Benson [draw.io] %!s(int64=6) %!d(string=hai) anos
pai
achega
3096f7d47e

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+23-AUG-2019: 11.2.2
+
+- Add support for loading zipped draw.io and Gliffy formats
+
 20-AUG-2019: 11.2.1
 
 - Fixes possible NPEs

+ 1 - 1
VERSION

@@ -1 +1 @@
-11.2.1
+11.2.2

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

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 08/20/2019 06:38 PM
+# 08/23/2019 04:55 PM
 
 app.html
 index.html?offline=1

+ 6 - 0
src/main/webapp/disableUpdate.js

@@ -0,0 +1,6 @@
+module.exports = {
+	disableUpdate: function() 
+	{
+		return false;
+	}
+}

+ 13 - 2
src/main/webapp/electron.js

@@ -17,6 +17,7 @@ const Store = require('electron-store');
 const store = new Store();
 const ProgressBar = require('electron-progressbar');
 const { systemPreferences } = require('electron')
+const disableUpdate = require('./disableUpdate').disableUpdate();
 autoUpdater.logger = log
 autoUpdater.logger.transports.file.level = 'info'
 autoUpdater.autoDownload = false
@@ -204,7 +205,7 @@ app.on('ready', e =>
 	        .option('-r, --recursive', 'for a folder input, recursively convert all files in sub-folders also')
 	        .option('-o, --output <output file/folder>', 'specify the output file/folder. If omitted, the input file name is used for output with the specified format as extension')
 	        .option('-f, --format <format>',
-			    'if output file name extension is specified, this option is ignored (file type is determined from output extension)',
+			    'if output file name extension is specified, this option is ignored (file type is determined from output extension, possible export formats are pdf, png, jpg, svg, vsdx)',
 			    validFormatRegExp, 'pdf')
 			.option('-q, --quality <quality>',
 				'output image quality for JPEG (default: 90)', parseInt)
@@ -563,6 +564,11 @@ app.on('ready', e =>
 	      }]
 	}]
 	
+	if (disableUpdate)
+	{
+		template[0].submenu.splice(2, 1);
+	}
+	
 	if (process.platform === 'darwin')
 	{
 	    template = [{
@@ -600,6 +606,11 @@ app.on('ready', e =>
 	        selector: 'paste:'
 	      }]
 	    }]
+	    
+	    if (disableUpdate)
+		{
+			template[0].submenu.splice(2, 1);
+		}
 	}
 	
 	const menuBar = menu.buildFromTemplate(template)
@@ -611,7 +622,7 @@ app.on('ready', e =>
 		owner: 'jgraph'
 	})
 	
-	if (!store.get('dontCheckUpdates'))
+	if (!disableUpdate && !store.get('dontCheckUpdates'))
 	{
 		autoUpdater.checkForUpdates()
 	}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 685 - 685
src/main/webapp/js/app.min.js


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

@@ -1229,33 +1229,8 @@ App.prototype.init = function()
 			{
 				var doInit = mxUtils.bind(this, function()
 				{
-					/**
-					 * Holds the x-coordinate of the point.
-					 */
 					this.drive = new DriveClient(this);
 					
-					/**
-					 * Adds important notice for new app if drive file is loaded in old app.
-					 */
-					if (this.drive.appId == '420247213240')
-					{
-						this.editor.addListener('fileLoaded', mxUtils.bind(this, function()
-						{
-							var file = this.getCurrentFile();
-							
-							if (file != null && file.constructor == DriveFile)
-							{
-								var td = document.getElementById('geFooterItem2');
-								
-								if (td != null)
-								{
-									td.innerHTML = '<a href="https://support.draw.io/display/DO/2014/11/27/Switching+application+in+Google+Drive" ' +
-										'target="_blank" title="IMPORTANT NOTICE">IMPORTANT NOTICE</a>';
-								}
-							}
-						}));
-					}
-					
 					this.drive.addListener('userChanged', mxUtils.bind(this, function()
 					{
 						this.updateUserElement();
@@ -1657,8 +1632,7 @@ App.prototype.checkLicense = function()
 
 		// Timestamp is workaround for cached response in certain environments
 		mxUtils.post('/license', 'domain=' + encodeURIComponent(domain) + '&email=' + encodeURIComponent(email) + 
-				'&ds=' + encodeURIComponent(driveUser.displayName) + '&lc=' + encodeURIComponent(driveUser.locale) + 
-				'&ts=' + new Date().getTime(),
+				'&lc=' + encodeURIComponent(driveUser.locale) + '&ts=' + new Date().getTime(),
 			mxUtils.bind(this, function(req)
 			{
 				try

+ 23 - 19
src/main/webapp/js/diagramly/Dialogs.js

@@ -358,26 +358,30 @@ var StorageDialog = function(editorUi, fn, rowLimit)
 	var temp = document.createElement('div');
 	temp.style.marginBottom = '10px';
 	
-	var showMore = document.createElement('a');
-	showMore.style.color = 'gray';
-	showMore.style.fontSize = '12px';
-	showMore.style.cursor = 'pointer';
-	showMore.style.userSelect = 'none';
-	mxUtils.write(showMore, ((StorageDialog.extended) ? mxResources.get('showLess') : mxResources.get('showMore')) + '...');
-	
-	temp.appendChild(showMore);
-	p2.appendChild(temp);
-	p2.appendChild(cb);
-	
-	mxEvent.addListener(showMore, 'click', function(evt)
+	if (!editorUi.isOfflineApp())
 	{
-		container.innerHTML = '';
-		showMore.innerHTML = '';
-		StorageDialog.extended = !StorageDialog.extended;
-		addButtons();
+		var showMore = document.createElement('a');
+		showMore.style.color = 'gray';
+		showMore.style.fontSize = '12px';
+		showMore.style.cursor = 'pointer';
+		showMore.style.userSelect = 'none';
 		mxUtils.write(showMore, ((StorageDialog.extended) ? mxResources.get('showLess') : mxResources.get('showMore')) + '...');
-		mxEvent.consume(evt);
-	});
+		
+		temp.appendChild(showMore);
+		p2.appendChild(temp);
+		
+		mxEvent.addListener(showMore, 'click', function(evt)
+		{
+			container.innerHTML = '';
+			showMore.innerHTML = '';
+			StorageDialog.extended = !StorageDialog.extended;
+			addButtons();
+			mxUtils.write(showMore, ((StorageDialog.extended) ? mxResources.get('showLess') : mxResources.get('showMore')) + '...');
+			mxEvent.consume(evt);
+		});
+	}
+
+	p2.appendChild(cb);
 	
 	var span = document.createElement('span');
 	span.style.color = 'gray';
@@ -389,7 +393,7 @@ var StorageDialog = function(editorUi, fn, rowLimit)
 	
 	var recent = editorUi.getRecent();
 
-	if (recent != null && recent.length > 0)
+	if (!editorUi.isOfflineApp() && recent != null && recent.length > 0)
 	{
 		var recentSelect = document.createElement('select');
 		recentSelect.style.marginTop = '8px';

+ 133 - 3
src/main/webapp/js/diagramly/EditorUi.js

@@ -6937,7 +6937,30 @@
 								{
 									try
 									{
-										this.doImportVisio(xhr.response, done, onerror, filename);
+										var resp = xhr.response;
+
+										if (resp.type == 'text/xml')
+										{
+											var reader = new FileReader();
+											
+											reader.onload = mxUtils.bind(this, function(e)
+											{
+												try
+												{
+													done(e.target.result);
+												}
+												catch (e)
+												{
+													onerror({message: mxResources.get('errorLoadingFile')});
+												}
+											});
+					
+											reader.readAsText(resp);
+										}
+										else
+										{
+											this.doImportVisio(resp, done, onerror, filename);
+										}
 									}
 									catch (e)
 									{
@@ -7503,6 +7526,90 @@
 		}
 	};
 	
+	
+	EditorUi.prototype.importZipFile = function(file, success, onerror)
+	{
+		var ui = this;
+		
+		JSZip.loadAsync(file)                                   
+        .then(function(zip) 
+        {
+        	if (Object.keys(zip.files).length == 0)
+        	{
+        		onerror();
+        	}
+        	else
+        	{
+        		var gliffyLatestVer = {version: 0};
+        		var drawioFound = false;
+        		
+                zip.forEach(function (relativePath, zipEntry) 
+                {
+                	var name = zipEntry.name.toLowerCase();
+					
+                    if (name == 'diagram/diagram.xml') //draw.io zip format has the latest diagram version at diagram/diagram.xml
+                    {
+                    	drawioFound = true;
+                    	
+	                    zipEntry.async("string").then(function(str){
+	                    	if (str.indexOf('<mxfile ') == 0)
+	                    	{
+	                    		success(str);
+	                    	}
+	                    	else
+                    		{
+	                    		onerror();
+                    		}
+	                    });
+                    }
+                    else if (name.indexOf('versions/') == 0) //Gliffy zip format has the versions inside versions folder
+                   	{
+                    	var version = parseInt(name.substr(9)); //9 is the length of versions/
+                    	
+                    	if (version > gliffyLatestVer.version)
+                    	{
+                    		gliffyLatestVer = {version: version, zipEntry: zipEntry}
+                    	}
+                   	}
+                });
+                
+                if (gliffyLatestVer.version > 0)
+            	{
+                	gliffyLatestVer.zipEntry.async("string").then(function(data)
+                	{
+                		if (!ui.isOffline() && new XMLHttpRequest().upload && ui.isRemoteFileFormat(data, file.name))
+                		{
+                			ui.parseFile(new Blob([data], {type: 'application/octet-stream'}), mxUtils.bind(this, function(xhr)
+                			{
+                				if (xhr.readyState == 4)
+                				{
+                					if (xhr.status >= 200 && xhr.status <= 299)
+                					{
+                						success(xhr.responseText);
+                					}
+                					else
+                					{
+                						onerror();
+                					}
+                				}
+                			}), file.name);
+                		}
+                		else
+            			{
+                			onerror();
+            			}
+                	});
+            	}
+                else if (!drawioFound)
+            	{
+                	onerror();
+            	}
+        	}
+        }, function (e) {
+    		onerror(e);
+        });                    
+	};
+	
 	/**
 	 * Imports the given XML into the existing diagram.
 	 */
@@ -7603,6 +7710,17 @@
 				}
 			}), filename);
 		}
+		else if (data.indexOf('PK') == 0 && file != null)
+		{
+			async = true;
+			
+			this.importZipFile(file, handleResult, mxUtils.bind(this, function()
+			{
+				//If importing as a zip file failed, just insert as text
+				cells = this.insertTextAt(this.validateFileData(data), dx, dy, true, null, crop);
+				done(cells);
+			}));
+		}
 		else if (!/(\.v(sd|dx))($|\?)/i.test(filename) && !/(\.vs(s|x))($|\?)/i.test(filename))
 		{
 			cells = this.insertTextAt(this.validateFileData(data), dx, dy, true, null, crop);
@@ -7985,7 +8103,7 @@
 				    	    				{
 				    		    				return cells;
 				    	    				});
-										});
+										}, file);
 						    		}
 								}
 							});
@@ -9953,6 +10071,18 @@
 					    				this.handleError(e, mxResources.get('errorLoadingFile'));
 					    			}
 				    			}
+								else if (data.indexOf('PK') == 0)
+								{
+									this.importZipFile(file, mxUtils.bind(this, function(xml)
+									{
+										this.spinner.stop();
+										handleResult(xml);
+									}), mxUtils.bind(this, function()
+									{
+										this.spinner.stop();
+										this.openLocalFile(data, name, temp);
+									}));
+								}
 								else
 								{
 									if (file.type.substring(0, 9) == 'image/png')
@@ -12233,7 +12363,7 @@
 						else 
 						{
 							editorUi.exportImage(s, false, true,
-								false, false, b, true, false, 'jpeg', null, dpi);
+								false, false, b, true, false, 'jpeg');
 						}
 					}
 					else 

+ 6 - 13
src/main/webapp/js/diagramly/Init.js

@@ -181,19 +181,12 @@ window.uiTheme = window.uiTheme || (function()
 	{
 		if (ui == null)
 		{
-			if (window.mxIsElectron5 && require('electron').remote.systemPreferences.isDarkMode())
-			{
-				ui = 'dark';
-			}
-			else
-			{
-		        var iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
-	
-		        if (iw <= 414)
-		        {
-		        	ui = 'min';
-		        }
-			}
+	        var iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
+
+	        if (iw <= 414)
+	        {
+	        	ui = 'min';
+	        }
 		}
 	}
 	catch (e)

+ 6 - 6
src/main/webapp/js/diagramly/sidebar/Sidebar-Electrical.js

@@ -454,16 +454,16 @@
 
 		this.addPaletteFunctions('electrical\Instruments', 'Electrical / Instruments', false,
 		[
-			this.createVertexTemplateEntry(mein + 'ampermeter;', 
-					90, 90, '', 'Ampermeter', null, null, this.getTagsForStencil(gnmein, 'ampermeter', dtmein).join(' ')),
+			this.createVertexTemplateEntry('verticalLabelPosition=middle;shadow=0;dashed=0;align=center;fillColor=#ffffff;html=1;verticalAlign=middle;strokeWidth=1;shape=ellipse;aspect=fixed;fontSize=50;', 
+					90, 90, 'A', 'Ammeter', null, null, this.getTagsForStencil(gnmein, 'ampermeter ammeter', dtmein).join(' ')),
 			this.createVertexTemplateEntry(mein + 'galvanometer;', 
 					90, 90, '', 'Galvanometer', null, null, this.getTagsForStencil(gnmein, 'galvanometer', dtmein).join(' ')),
 			this.createVertexTemplateEntry(mein + 'oscilloscope;', 
 					90, 90, '', 'Oscilloscope', null, null, this.getTagsForStencil(gnmein, 'oscilloscope', dtmein).join(' ')),
 			this.createVertexTemplateEntry(mein + 'signal_generator;', 
 					90, 90, '', 'Signal Generator', null, null, this.getTagsForStencil(gnmein, 'signal_generator', dtmein).join(' ')),
-			this.createVertexTemplateEntry(mein + 'voltmeter;', 
-					90, 90, '', 'Voltmeter', null, null, this.getTagsForStencil(gnmein, 'voltmeter', dtmein).join(' '))
+			this.createVertexTemplateEntry('verticalLabelPosition=middle;shadow=0;dashed=0;align=center;fillColor=#ffffff;html=1;verticalAlign=middle;strokeWidth=1;shape=ellipse;aspect=fixed;fontSize=50;', 
+					90, 90, 'V', 'Voltmeter', null, null, this.getTagsForStencil(gnmein, 'ampermeter ammeter', dtmein).join(' '))
 		]);
 
 		this.addPaletteFunctions('electrical\Misc', 'Electrical / Misc', false,
@@ -476,8 +476,8 @@
 					64.8, 69.78, '', 'Loop Antenna', null, null, this.getTagsForStencil(gnmer, 'loop_antenna', dtmer).join(' ')),
 			this.createVertexTemplateEntry(mem + 'loop_antenna', 
 					100, 100, '', 'Loop Antenna', null, null, this.getTagsForStencil(gnmess, 'loop antenna', dtmem).join(' ')),
-			this.createVertexTemplateEntry(mxConstants.STYLE_SHAPE + '=mxgraph.electrical.electro-mechanical.motor_1;html=1;shadow=0;dashed=0;fillColor=#ffffff;align=center;fontSize=30;strokeColor=#000000;strokeWidth=1;', 
-					100, 60, 'M', 'Electrical Motor', null, null, this.getTagsForStencil(gnmeem, 'motor_1', dtmeem).join(' ')),
+			this.createVertexTemplateEntry('verticalLabelPosition=middle;shadow=0;dashed=0;align=center;fillColor=#ffffff;html=1;verticalAlign=middle;strokeWidth=1;shape=ellipse;aspect=fixed;fontSize=35;', 
+					60, 60, 'M', 'Electrical Motor', null, null, this.getTagsForStencil(gnmeem, 'motor_1', dtmeem).join(' ')),
 			this.createVertexTemplateEntry(mxConstants.STYLE_SHAPE + '=mxgraph.electrical.electro-mechanical.motor_2;html=1;shadow=0;dashed=0;fillColor=#ffffff;align=center;fontSize=30;strokeColor=#000000;strokeWidth=1;', 
 					100, 60, '', 'Motor Armature', null, null, this.getTagsForStencil(gnmeem, 'motor_2', dtmeem).join(' ')),
 			this.createVertexTemplateEntry(mem + 'co-ax;', 

+ 26 - 4
src/main/webapp/js/diagramly/vsdx/VsdxExport.js

@@ -840,10 +840,32 @@ function VsdxExport(editorUi)
 						
 						var diagramName = page.getName();
 						var graph = editorUi.editor.graph;
-						var modelAttrib = getGraphAttributes(graph);
-						pages[diagramName] = convertMxModel2Page(graph, modelAttrib);
-						addImagesRels(zip, i+1);
-						modelsAttr[diagramName] = modelAttrib;
+						
+						//Handles dark mode
+						var temp = null;
+						
+						if (graph.themes != null && graph.defaultThemeName == 'darkTheme')
+						{
+							temp = graph.stylesheet;
+							graph.stylesheet = graph.getDefaultStylesheet();
+							graph.refresh();
+						}
+						
+						try
+						{
+							var modelAttrib = getGraphAttributes(graph);
+							pages[diagramName] = convertMxModel2Page(graph, modelAttrib);
+							addImagesRels(zip, i+1);
+							modelsAttr[diagramName] = modelAttrib;
+						}
+						finally
+						{
+							if (temp != null)
+							{
+								graph.stylesheet = temp;
+								graph.refresh();
+							}
+						}
 					}
 					
 					if (currentPage != editorUi.currentPage)

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 403 - 402
src/main/webapp/js/extensions.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 3 - 3
src/main/webapp/js/mxgraph/Sidebar.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 513 - 512
src/main/webapp/js/viewer.min.js


+ 0 - 1
src/main/webapp/templates/index.xml

@@ -45,7 +45,6 @@
   <add>Uhttps://jgraph.github.io/drawio-libs/libs/fortinet/Fortinet_VM_Components.xml</add>
 </clibs>
 <template url="business/accd.xml" libs="general"/>
-<template url="business/accd.xml" libs="general"/>
 <template url="business/archimate.xml" libs="general;archimate3"/>
 <template url="business/bpmn.xml" libs="general;bpmn"/>
 <template url="business/business_model_1.xml" libs="general;signs"/>