David Benson 3 rokov pred
rodič
commit
becda6ba8a

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+05-MAY-2022: 18.0.1
+
+- Adds support for windows line break in CSV files
+- [conf cloud] Fixes trailing space in diagram name during page IDs import
+- FIxes timestamp check in watchFile [819] [DND-487]
+- Hides menus and dropdowns if clicked again [2745]
+- Fixes cursor handling for composite cells [2756]
+- [desktop] Adds strict CSP after loading plugins (disabling unsafe-inline scripts)
+
 04-MAY-2022: 18.0.0
 
 - Replaces sanitizer with DOMpurify

+ 1 - 1
VERSION

@@ -1 +1 @@
-18.0.0
+18.0.1

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 516 - 516
src/main/webapp/js/app.min.js


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

@@ -13329,7 +13329,7 @@
         		
         		while (index < lines.length && lines[index].charAt(0) == '#')
         		{
-        			var text = lines[index];
+        			var text = lines[index].replace(/\r$/,''); // Remove trailing \r if the file uses \r\n line breaks
         			index++;
         			
         			while (index < lines.length && text.charAt(text.length - 1) == '\\' &&
@@ -13455,7 +13455,7 @@
         		}
         		
     			// Converts identity and parent to index and validates XML attribute names
-    			var keys = this.editor.csvToArray(lines[index]);
+    			var keys = this.editor.csvToArray(lines[index].replace(/\r$/,''));
         		var identityIndex = null;
     			var parentIndex = null;
     			var attribs = [];
@@ -13497,7 +13497,7 @@
     			
     			for (var i = index + 1; i < lines.length; i++)
 	    		{
-	    			var values = this.editor.csvToArray(lines[i]);
+	    			var values = this.editor.csvToArray(lines[i].replace(/\r$/,''));
 	    			
 	    			if (values == null)
 	    			{

+ 33 - 20
src/main/webapp/js/diagramly/ElectronApp.js

@@ -146,6 +146,21 @@ mxStencilRegistry.allowEval = false;
 			}
 		}
 		
+		//Remove old relaxed CSP and add strict one
+		var allMeta = document.getElementsByTagName('meta');
+
+		for (var i = 0; i < allMeta.length; i++)
+		{
+			if (allMeta[i].getAttribute('http-equiv') == 'Content-Security-Policy')
+			{
+				allMeta[i].parentNode.removeChild(allMeta[i]);
+			}
+
+			break;
+		}
+
+		mxmeta(null, 'default-src \'self\'; connect-src \'self\' https://*.draw.io https://fonts.googleapis.com https://fonts.gstatic.com; img-src * data:; media-src *; font-src *; style-src \'self\' \'unsafe-inline\' https://fonts.googleapis.com', 'Content-Security-Policy');
+
 		//Disable web plugins loading
 		urlParams['plugins'] = '0';
 		origAppMain.apply(this, arguments);
@@ -838,38 +853,36 @@ mxStencilRegistry.allowEval = false;
 					path: file.fileObject.path,
 					listener: mxUtils.bind(this, function(curr, prev) 
 					{
+						EditorUi.debug('EditorUi.watchFile', [this],
+							'file', [file], 'stat', [file.stat],
+							'curr', [curr], 'prev', [prev],
+							'inConflictState', file.inConflictState,
+							'unwatchedSaves', file.unwatchedSaves);
+						
 						//File is changed (not just accessed) && File is not already in a conflict state
 						if (curr.mtimeMs != prev.mtimeMs && !file.inConflictState)
 						{
 							//Ignore our own changes
-							if (file.unwatchedSaves || (file.state != null && file.stat.mtimeMs == curr.mtimeMs))
+							if (file.unwatchedSaves || (file.stat != null && file.stat.mtimeMs == curr.mtimeMs))
 							{
 								file.unwatchedSaves = false;
 								return;
 							}
 							
 							file.inConflictState = true;
-							
-							this.showError(mxResources.get('externalChanges'),
-								mxResources.get('fileChangedSyncDialog'),
-								mxResources.get('merge'), mxUtils.bind(this, function()
+
+							file.addConflictStatus(mxUtils.bind(this, function()
+							{
+								file.ui.editor.setStatus(mxUtils.htmlEntities(
+									mxResources.get('updatingDocument')));
+								file.synchronizeFile(mxUtils.bind(this, function()
 								{
-									if (this.spinner.spin(document.body, mxResources.get('updatingDocument')))
-									{
-										file.synchronizeFile(mxUtils.bind(this, function()
-										{
-											this.spinner.stop();
-										}), mxUtils.bind(this, function(err)
-										{
-											file.handleFileError(err, true);
-										}));
-									}
-								}), null, null, null,
-								mxResources.get('cancel'), mxUtils.bind(this, function()
+									file.handleFileSuccess(false);
+								}), mxUtils.bind(this, function(err)
 								{
-									this.hideDialog();
-									file.handleFileError(null, false);
-								}), 340, 130);
+									file.handleFileError(err, true);
+								}));
+							}));
 						}
 					})
 				});

+ 41 - 28
src/main/webapp/js/diagramly/Minimal.js

@@ -2323,41 +2323,54 @@ EditorUi.initMinimalTheme = function()
 
 				if (urlParams['embed'] != '1')
 				{
-					if (ui.statusContainer.children.length == 0 ||
-						(ui.statusContainer.children.length == 1 &&
-						typeof ui.statusContainer.firstChild.getAttribute === 'function' &&
-						ui.statusContainer.firstChild.getAttribute('class') == null))
+					ui.statusContainer.style.display = 'inline-block';
+					statusVisible = true;
+
+					if (ui.statusContainer.children.length == 1 &&
+						ui.editor.getStatus() == '')
 					{
-						var title = (ui.statusContainer.firstChild != null &&
-							typeof ui.statusContainer.firstChild.getAttribute === 'function') ?
-							ui.statusContainer.firstChild.getAttribute('title') :
-							ui.editor.getStatus();
-						setNotificationTitle(title);
-						var file = ui.getCurrentFile();
-						var key = (file != null) ? file.savingStatusKey : DrawioFile.prototype.savingStatusKey;
-						
-						if (title == mxResources.get(key) + '...')
+						menubar.style.visibility = 'hidden';
+					}
+					else
+					{
+						if (ui.statusContainer.children.length == 0 ||
+							(ui.statusContainer.children.length == 1 &&
+							typeof ui.statusContainer.firstChild.getAttribute === 'function' &&
+							ui.statusContainer.firstChild.getAttribute('class') == null))
+						{
+							var title = (ui.statusContainer.firstChild != null &&
+								typeof ui.statusContainer.firstChild.getAttribute === 'function') ?
+								ui.statusContainer.firstChild.getAttribute('title') :
+								ui.editor.getStatus();
+							setNotificationTitle(title);
+							var file = ui.getCurrentFile();
+							var key = (file != null) ? file.savingStatusKey :
+								DrawioFile.prototype.savingStatusKey;
+							
+							if (title == mxResources.get(key) + '...')
+							{
+								ui.statusContainer.innerHTML = '<img title="' + mxUtils.htmlEntities(
+									mxResources.get(key)) + '...' + '"src="' + Editor.tailSpin + '">';
+								ui.statusContainer.style.display = 'inline-block';
+								statusVisible = true;
+							}
+							else if (ui.buttonContainer.clientWidth > 6)
+							{
+								ui.statusContainer.style.display = 'none';
+								statusVisible = false;
+							}
+						}
+						else
 						{
-							ui.statusContainer.innerHTML = '<img title="' + mxUtils.htmlEntities(
-								mxResources.get(key)) + '...' + '"src="' + Editor.tailSpin + '">';
 							ui.statusContainer.style.display = 'inline-block';
+							setNotificationTitle(null);
 							statusVisible = true;
 						}
-						else if (ui.buttonContainer.clientWidth > 6)
-						{	
-							ui.statusContainer.style.display = 'none';
-							statusVisible = false;
-						}
-					}
-					else
-					{
-						ui.statusContainer.style.display = 'inline-block';
-						setNotificationTitle(null);
-						statusVisible = true;
+
+						menubar.style.visibility = (menubar.clientWidth < 20 &&
+							!statusVisible) ? 'hidden' : '';
 					}
 				}
-
-				menubar.style.visibility = (menubar.clientWidth < 20 && !statusVisible) ? 'hidden' : '';
 			}));
 			
 			elt = addMenu('diagram', null, Editor.menuImage);

+ 9 - 9
src/main/webapp/js/diagramly/sidebar/Sidebar-ER.js

@@ -65,16 +65,16 @@
 		
 				return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'List');
 			}),
-			this.addEntry(dt + ' list', function()	
-			{	
-				return sb.createVertexTemplateFromCells([row.clone()], row.geometry.width, row.geometry.height, 'List Item 1');	
+			this.addEntry(dt + ' list', function()
+			{
+				return sb.createVertexTemplateFromCells([row.clone()], row.geometry.width, row.geometry.height, 'List Item 1');
 			}),
-			this.addEntry(dt + 'table row', function()	
-			{	
+			this.addEntry(dt + 'table row', function()
+			{
 	   			var cell = new mxCell(row.value, new mxGeometry(0, 0, 90, row.geometry.height), 'shape=partialRectangle;fillColor=none;align=left;verticalAlign=middle;strokeColor=none;spacingLeft=34;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;dropTarget=0;');	
-	   			cell.vertex = true;	
+	   			cell.vertex = true;
 
-	   			var cell1 = sb.cloneCell(row, '');	
+	   			var cell1 = sb.cloneCell(row, '');
 	   			cell1.connectable = false;	
 	   			cell1.style = 'shape=partialRectangle;top=0;left=0;bottom=0;fillColor=none;stokeWidth=1;dashed=1;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[];portConstraint=eastwest;part=1;'	
 	   			cell1.geometry.width = 30;	
@@ -82,8 +82,8 @@
 
 				return sb.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'List Item 2');	
 			}),
-			this.addEntry(dt + 'table row divider hline line separator', function()	
-			{	
+			this.addEntry(dt + 'table row divider hline line separator', function()
+			{
 				var divider = new mxCell('', new mxGeometry(0, 0, 60, 10), 'line;strokeWidth=1;rotatable=0;dashed=0;labelPosition=right;align=left;verticalAlign=middle;spacingTop=0;spacingLeft=6;points=[];portConstraint=eastwest;');	
 				divider.vertex = true;	
 

+ 101 - 100
src/main/webapp/js/grapheditor/EditorUi.js

@@ -5417,134 +5417,136 @@ EditorUi.prototype.createKeyHandler = function(editor)
 		{
 			stepSize = (stepSize != null) ? stepSize : 1;
 
-			if (resize)
+			var cells = graph.getCompositeParents(graph.getSelectionCells());
+			var cell = (cells.length > 0) ? cells[0] : null;
+
+			if (cell != null)
 			{
-				// Resizes all selected vertices
-				graph.getModel().beginUpdate();
-				try
+				if (resize)
 				{
-					var cells = graph.getSelectionCells();
-					
-					for (var i = 0; i < cells.length; i++)
+					// Resizes all selected vertices
+					graph.getModel().beginUpdate();
+					try
 					{
-						if (graph.getModel().isVertex(cells[i]) && graph.isCellResizable(cells[i]))
+						for (var i = 0; i < cells.length; i++)
 						{
-							var geo = graph.getCellGeometry(cells[i]);
-							
-							if (geo != null)
+							if (graph.getModel().isVertex(cells[i]) && graph.isCellResizable(cells[i]))
 							{
-								geo = geo.clone();
+								var geo = graph.getCellGeometry(cells[i]);
 								
-								if (keyCode == 37)
+								if (geo != null)
 								{
-									geo.width = Math.max(0, geo.width - stepSize);
-								}
-								else if (keyCode == 38)
-								{
-									geo.height = Math.max(0, geo.height - stepSize);
-								}
-								else if (keyCode == 39)
-								{
-									geo.width += stepSize;
-								}
-								else if (keyCode == 40)
-								{
-									geo.height += stepSize;
+									geo = geo.clone();
+									
+									if (keyCode == 37)
+									{
+										geo.width = Math.max(0, geo.width - stepSize);
+									}
+									else if (keyCode == 38)
+									{
+										geo.height = Math.max(0, geo.height - stepSize);
+									}
+									else if (keyCode == 39)
+									{
+										geo.width += stepSize;
+									}
+									else if (keyCode == 40)
+									{
+										geo.height += stepSize;
+									}
+									
+									graph.getModel().setGeometry(cells[i], geo);
 								}
-								
-								graph.getModel().setGeometry(cells[i], geo);
 							}
 						}
 					}
-				}
-				finally
-				{
-					graph.getModel().endUpdate();
-				}
-			}
-			else
-			{
-				// Moves vertices up/down in a stack layout
-				var cell = graph.getSelectionCell();
-				var parent = graph.model.getParent(cell);
-				var scale = graph.getView().scale;
-				var layout = null;
-
-				if (graph.getSelectionCount() == 1 && graph.model.isVertex(cell) &&
-					graph.layoutManager != null && !graph.isCellLocked(cell))
-				{
-					layout = graph.layoutManager.getLayout(parent);
-				}
-				
-				if (layout != null && layout.constructor == mxStackLayout)
-				{
-					var index = parent.getIndex(cell);
-					
-					if (keyCode == 37 || keyCode == 38)
-					{
-						graph.model.add(parent, cell, Math.max(0, index - 1));
-					}
-					else if (keyCode == 39 ||keyCode == 40)
+					finally
 					{
-						graph.model.add(parent, cell, Math.min(graph.model.getChildCount(parent), index + 1));
+						graph.getModel().endUpdate();
 					}
 				}
 				else
 				{
-					var handler = graph.graphHandler;
+					// Moves vertices up/down in a stack layout
+					var parent = graph.model.getParent(cell);
+					var scale = graph.getView().scale;
+					var layout = null;
 
-					if (handler != null)
+					if (graph.getSelectionCount() == 1 && graph.model.isVertex(cell) &&
+						graph.layoutManager != null && !graph.isCellLocked(cell))
 					{
-						if (handler.first == null)
+						layout = graph.layoutManager.getLayout(parent);
+					}
+					
+					if (layout != null && layout.constructor == mxStackLayout)
+					{
+						var index = parent.getIndex(cell);
+						
+						if (keyCode == 37 || keyCode == 38)
 						{
-							handler.start(graph.getSelectionCell(),
-								0, 0, graph.getSelectionCells());
+							graph.model.add(parent, cell, Math.max(0, index - 1));
 						}
+						else if (keyCode == 39 ||keyCode == 40)
+						{
+							graph.model.add(parent, cell, Math.min(graph.model.getChildCount(parent), index + 1));
+						}
+					}
+					else
+					{
+						var handler = graph.graphHandler;
 
-						if (handler.first != null)
+						if (handler != null)
 						{
-							var dx = 0;
-							var dy = 0;
-							
-							if (keyCode == 37)
+							if (handler.first == null)
 							{
-								dx = -stepSize;
+								handler.start(cell, 0, 0, cells);
 							}
-							else if (keyCode == 38)
+
+							if (handler.first != null)
 							{
-								dy = -stepSize;
+								var dx = 0;
+								var dy = 0;
+								
+								if (keyCode == 37)
+								{
+									dx = -stepSize;
+								}
+								else if (keyCode == 38)
+								{
+									dy = -stepSize;
+								}
+								else if (keyCode == 39)
+								{
+									dx = stepSize;
+								}
+								else if (keyCode == 40)
+								{
+									dy = stepSize;
+								}
+
+								handler.currentDx += dx * scale;
+								handler.currentDy += dy * scale;
+								handler.checkPreview();
+								handler.updatePreview();
 							}
-							else if (keyCode == 39)
+
+							// Groups move steps in undoable change
+							if (thread != null)
 							{
-								dx = stepSize;
+								window.clearTimeout(thread);
 							}
-							else if (keyCode == 40)
+							
+							thread = window.setTimeout(function()
 							{
-								dy = stepSize;
-							}
-
-							handler.currentDx += dx * scale;
-							handler.currentDy += dy * scale;
-							handler.checkPreview();
-							handler.updatePreview();
-						}
-
-						// Groups move steps in undoable change
-						if (thread != null)
-						{
-							window.clearTimeout(thread);
+								if (handler.first != null)
+								{
+									var dx = handler.roundLength(handler.currentDx / scale);
+									var dy = handler.roundLength(handler.currentDy / scale);
+									handler.moveCells(handler.cells, dx, dy);
+									handler.reset();
+								}
+							}, 400);
 						}
-						
-						thread = window.setTimeout(function()
-						{
-							if (handler.first != null)
-							{
-								var dx = handler.roundLength(handler.currentDx / scale);
-								var dy = handler.roundLength(handler.currentDy / scale);
-								handler.moveCells(handler.cells, dx, dy);
-								handler.reset();
-							}
-						}, 400);
 					}
 				}
 			}
@@ -5553,8 +5555,7 @@ EditorUi.prototype.createKeyHandler = function(editor)
 	
 	// Overridden to handle special alt+shift+cursor keyboard shortcuts
 	var directions = {37: mxConstants.DIRECTION_WEST, 38: mxConstants.DIRECTION_NORTH,
-			39: mxConstants.DIRECTION_EAST, 40: mxConstants.DIRECTION_SOUTH};
-	
+		39: mxConstants.DIRECTION_EAST, 40: mxConstants.DIRECTION_SOUTH};
 	var keyHandlerGetFunction = keyHandler.getFunction;
 
 	mxKeyHandler.prototype.getFunction = function(evt)

+ 33 - 1
src/main/webapp/js/grapheditor/Graph.js

@@ -2524,7 +2524,7 @@ Graph.prototype.init = function(container)
 		
 		return result;
 	};
-		
+	
 	/**
 	 * Returns the first parent that is not a part.
 	 */
@@ -2534,6 +2534,38 @@ Graph.prototype.init = function(container)
 			this.isTableCell(cell) || this.isTableRow(cell);
 	};
 	
+	/**
+	 * Returns the first parent that is not a part.
+	 */
+	Graph.prototype.getCompositeParents = function(cells)
+	{
+		var lookup = new mxDictionary();
+		var newCells = [];
+	
+		for (var i = 0; i < cells.length; i++)
+		{
+			var cell = this.getCompositeParent(cells[i]);
+
+			if (this.isTableCell(cell))
+			{
+				cell = this.graph.model.getParent(cell);
+			}
+
+			if (this.isTableRow(cell))
+			{
+				cell = this.graph.model.getParent(cell);
+			}
+
+			if (cell != null && !lookup.get(cell))
+			{
+				lookup.put(cell, true);
+				newCells.push(cell);
+			}
+		}
+
+		return newCells;
+	};
+	
 	/**
 	 * Returns the first parent that is not a part.
 	 */

+ 2 - 2
src/main/webapp/js/grapheditor/Menus.js

@@ -1726,7 +1726,7 @@ Menubar.prototype.addMenuHandler = function(elt, funct)
 		
 		var clickHandler = mxUtils.bind(this, function(evt)
 		{
-			if (show && elt.enabled == null || elt.enabled)
+			if (show && (elt.enabled == null || elt.enabled))
 			{
 				this.editorUi.editor.graph.popupMenuHandler.hideMenu();
 				var menu = new mxPopupMenu(funct);
@@ -1765,7 +1765,7 @@ Menubar.prototype.addMenuHandler = function(elt, funct)
         mxEvent.addListener(elt, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown',
         	mxUtils.bind(this, function(evt)
 		{
-			show = this.currentElt != elt;
+			show = this.editorUi.currentMenu == null;
 			evt.preventDefault();
 		}));
 

+ 7 - 12
src/main/webapp/js/grapheditor/Toolbar.js

@@ -1036,11 +1036,7 @@ Toolbar.prototype.addMenuHandler = function(elt, showLabels, funct, showAll)
 				menu.showDisabled = showAll;
 				menu.labels = showLabels;
 				menu.autoExpand = true;
-				
-				var offset = mxUtils.getOffset(elt);
-				menu.popup(offset.x, offset.y + elt.offsetHeight, null, evt);
-				this.editorUi.setCurrentMenu(menu, elt);
-				
+
 				// Workaround for scrollbar hiding menu items
 				if (!showLabels && menu.div.scrollHeight > menu.div.clientHeight)
 				{
@@ -1053,12 +1049,10 @@ Toolbar.prototype.addMenuHandler = function(elt, showLabels, funct, showAll)
 					this.editorUi.resetCurrentMenu();
 					menu.destroy();
 				});
-				
-				// Extends destroy to reset global state
-				menu.addListener(mxEvent.EVENT_HIDE, mxUtils.bind(this, function()
-				{
-					this.currentElt = null;
-				}));
+
+				var offset = mxUtils.getOffset(elt);
+				menu.popup(offset.x, offset.y + elt.offsetHeight, null, evt);
+				this.editorUi.setCurrentMenu(menu, elt);
 			}
 			
 			show = true;
@@ -1069,7 +1063,8 @@ Toolbar.prototype.addMenuHandler = function(elt, showLabels, funct, showAll)
         mxEvent.addListener(elt, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown',
         	mxUtils.bind(this, function(evt)
 		{
-			show = this.currentElt != elt;
+			show = menu == null || menu.div == null ||
+				menu.div.parentNode == null;
 			evt.preventDefault();
 		}));
 	}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 512 - 512
src/main/webapp/js/integrate.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 531 - 530
src/main/webapp/js/viewer-static.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 531 - 530
src/main/webapp/js/viewer.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
src/main/webapp/mxgraph/mxClient.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
src/main/webapp/service-worker.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
src/main/webapp/service-worker.js.map