浏览代码

12.3.7 release

Gaudenz Alder 5 年之前
父节点
当前提交
7fd83d14c9

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+05-DEC-2019: 12.3.7
+
+- Fixes handling of clipboard data
+- Uses mxGraph 4.0.6 beta 9
+
 03-DEC-2019: 12.3.6
 
 - Moves rotation handle to top right corner

+ 1 - 1
VERSION

@@ -1 +1 @@
-12.3.6
+12.3.7

文件差异内容过多而无法显示
+ 9 - 9
etc/mxgraph/mxClient.js


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

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 12/03/2019 01:52 PM
+# 12/05/2019 10:46 AM
 
 app.html
 index.html?offline=1

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

@@ -297,7 +297,11 @@
 				}
 			  	
 			  	var t = document.getElementsByTagName('script')[0];
-			  	t.parentNode.insertBefore(s, t);
+			  	
+			  	if (t != null)
+			  	{
+			  		t.parentNode.insertBefore(s, t);
+			  	}
 			}
 			else
 			{

文件差异内容过多而无法显示
+ 1221 - 1219
src/main/webapp/js/app.min.js


+ 20 - 10
src/main/webapp/js/diagramly/App.js

@@ -1296,17 +1296,27 @@ App.prototype.init = function()
 		{
 			if (typeof window.Trello !== 'undefined')
 			{
-				this.trello = new TrelloClient(this);
-				
-				//TODO we have no user info from Trello so we don't set a user
-				this.trello.addListener('userChanged', mxUtils.bind(this, function()
+				try
 				{
-					this.updateUserElement();
-					this.restoreLibraries();
-				}));
-				
-				// Notifies listeners of new client
-				this.fireEvent(new mxEventObject('clientLoaded', 'client', this.trello));
+					this.trello = new TrelloClient(this);
+					
+					//TODO we have no user info from Trello so we don't set a user
+					this.trello.addListener('userChanged', mxUtils.bind(this, function()
+					{
+						this.updateUserElement();
+						this.restoreLibraries();
+					}));
+					
+					// Notifies listeners of new client
+					this.fireEvent(new mxEventObject('clientLoaded', 'client', this.trello));
+				}
+				catch (e)
+				{
+					if (window.console != null)
+					{
+						console.error(e);
+					}
+				}
 			}
 			else if (window.DrawTrelloClientCallback == null)
 			{

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

@@ -232,7 +232,7 @@ EditorUi.prototype.patchViewState = function(page, diff)
 		
 		if (page == this.currentPage)
 		{
-			this.editor.graph.setViewState(page.viewState);
+			this.editor.graph.setViewState(page.viewState, true);
 		}
 	}
 };

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

@@ -1062,6 +1062,23 @@ DrawioFile.prototype.open = function()
 	
 	if (data != null)
 	{
+		//Remove external fonts of previous file
+		function removeExtFont(elems)
+		{
+			for (var i = 0; elems != null && i < elems.length; i++)
+			{
+				var e = elems[i];
+				
+				if (e.id != null && e.id.indexOf('extFont_') == 0)
+				{
+					e.parentNode.removeChild(e);
+				}
+			}
+		};
+		
+		removeExtFont(document.querySelectorAll('head > style[id]'));
+		removeExtFont(document.querySelectorAll('head > link[id]'));
+		
 		this.ui.setFileData(data);
 		
 		// Updates shadow in case any page IDs have been updated

+ 54 - 23
src/main/webapp/js/diagramly/EditorUi.js

@@ -7538,26 +7538,33 @@
 
 						img.onload = function()
 						{
-							var w = img.width;
-							var h = img.height;
-
-							// Workaround for 0 image size in IE11
-							if (w == 0 && h == 0)
+							try
 							{
-								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)
+								var w = img.width;
+								var h = img.height;
+	
+								// Workaround for 0 image size in IE11
+								if (w == 0 && h == 0)
 								{
-									w = parseFloat(svgs[0].getAttribute('width'));
-									h = parseFloat(svgs[0].getAttribute('height'));
+									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'));
+									}
 								}
+								
+								success(reader.result, w, h);
+							}
+							catch (e)
+							{
+								error(e);
 							}
-							
-							success(reader.result, w, h);
 						};
 
 						img.src = reader.result;
@@ -10154,12 +10161,36 @@
 		{
 			var elt = realElt;
 			
-			if (useEvent && evt.clipboardData != null)
+			if (useEvent && evt.clipboardData != null && evt.clipboardData.getData)
 			{
-				// Creates a dummy element and parses the HTML to get
-				// consistent behaviour for system paste HTML into elt
-				elt = document.createElement('div');
-				elt.innerHTML = evt.clipboardData.getData('text/html');
+				var data = evt.clipboardData.getData('text/html');
+				
+				if (data != null && data.length > 0)
+				{
+					elt = document.createElement('div');
+					elt.innerHTML = data;
+					
+					// Workaround for innerText not ignoring style elements in Chrome
+					var styles = elt.getElementsByTagName('style');
+					
+					if (styles != null)
+					{
+						while (styles.length > 0)
+						{
+							styles[0].parentNode.removeChild(styles[0]);
+						}
+					}
+				}
+				else
+				{
+					data = evt.clipboardData.getData('text/plain');
+					
+					if (data != null && data.length > 0)
+					{
+						elt = document.createElement('div');
+						mxUtils.setTextContent(elt, data);
+					}
+				}
 			}
 			
 			var spans = elt.getElementsByTagName('span');
@@ -10198,8 +10229,8 @@
 			}
 			else
 			{
-				var xml = mxUtils.trim((mxClient.IS_QUIRKS || document.documentMode == 8) ?
-					mxUtils.getTextContent(elt) : elt.textContent);
+				var xml = mxUtils.trim((elt.innerText == null) ?
+					mxUtils.getTextContent(elt) : elt.innerText);
 				var compat = false;
 				
 				// Workaround for junk after XML in VM

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

@@ -628,7 +628,7 @@ Graph.prototype.getViewState = function()
 /**
  * Overrides setDefaultParent
  */
-Graph.prototype.setViewState = function(state)
+Graph.prototype.setViewState = function(state, removeOldExtFonts)
 {
 	if (state != null)
 	{
@@ -656,7 +656,9 @@ Graph.prototype.setViewState = function(state)
 		var oldExtFonts = this.extFonts;
 		this.extFonts = state.extFonts || [];
 
-		if (oldExtFonts != null)
+		// Removing old fonts is important for real-time synchronization
+		// But, for page change, it results in undesirable font flicker
+		if (removeOldExtFonts && oldExtFonts != null)
 		{
 			for (var i = 0; i < oldExtFonts.length; i++)
 			{

+ 4 - 4
src/main/webapp/js/mxgraph/Actions.js

@@ -647,9 +647,9 @@ Actions.prototype.init = function()
 	}, null, null, Editor.ctrlKey + '+H');
 	this.addAction('zoomIn', function(evt)
 	{
-		if (urlParams['zoom'] != 'nocss')
+		if (graph.isFastZoomEnabled())
 		{
-			graph.lazyZoom(true, true);
+			graph.lazyZoom(true, true, ui.buttonZoomDelay);
 		}
 		else
 		{
@@ -658,9 +658,9 @@ Actions.prototype.init = function()
 	}, null, null, Editor.ctrlKey + ' + (Numpad) / Alt+Mousewheel');
 	this.addAction('zoomOut', function(evt)
 	{
-		if (urlParams['zoom'] != 'nocss')
+		if (graph.isFastZoomEnabled())
 		{
-			graph.lazyZoom(false, true);
+			graph.lazyZoom(false, true, ui.buttonZoomDelay);
 		}
 		else
 		{

+ 16 - 33
src/main/webapp/js/mxgraph/EditorUi.js

@@ -1380,7 +1380,12 @@ EditorUi.prototype.lazyZoomDelay = 20;
 /**
  * Delay before update of DOM when using preview.
  */
-EditorUi.prototype.previewZoomDelay = 420;
+EditorUi.prototype.wheelZoomDelay = 400;
+
+/**
+ * Delay before update of DOM when using preview.
+ */
+EditorUi.prototype.buttonZoomDelay = 600;
 
 /**
  * Initializes the infinite canvas.
@@ -2077,13 +2082,7 @@ EditorUi.prototype.initCanvas = function()
 	var cursorPosition = null;
 	var scrollPosition = null;
 	
-	var isFastZoomEnabled = function()
-	{
-		return urlParams['zoom'] != 'nocss' && !graph.mathEnabled &&
-			!mxClient.NO_FO && !graph.useCssTransforms;
-	};
-	
-	var scheduleZoom = function(immediate)
+	var scheduleZoom = function(delay)
 	{
 		if (updateZoomTimeout != null)
 		{
@@ -2096,7 +2095,7 @@ EditorUi.prototype.initCanvas = function()
 			{
 				updateZoomTimeout = window.setTimeout(mxUtils.bind(this, function()
 		        {
-		        	if (isFastZoomEnabled())
+		        	if (graph.isFastZoomEnabled())
 		    		{
 		            	// Transforms background page
 		  				if (graph.view.backgroundPageShape != null && graph.view.backgroundPageShape.node != null)
@@ -2156,12 +2155,12 @@ EditorUi.prototype.initCanvas = function()
 		            updateZoomTimeout = null;
 		            scrollPosition = null;
 		            cursorPosition = null;
-		        }), (immediate) ? 0 : ((isFastZoomEnabled()) ? ui.previewZoomDelay : ui.lazyZoomDelay));
+		        }), (delay != null) ? delay : ((graph.isFastZoomEnabled()) ? ui.wheelZoomDelay : ui.lazyZoomDelay));
 			}
 		}, 0);
 	};
 
-	graph.lazyZoom = function(zoomIn, ignoreCursorPosition)
+	graph.lazyZoom = function(zoomIn, ignoreCursorPosition, delay)
 	{
 		if (ignoreCursorPosition)
 		{
@@ -2202,7 +2201,7 @@ EditorUi.prototype.initCanvas = function()
 
 		this.cumulativeZoomFactor = Math.max(0.05, Math.min(this.view.scale * this.cumulativeZoomFactor, 160)) / this.view.scale;
 
-		if (isFastZoomEnabled())
+		if (graph.isFastZoomEnabled())
 		{
 			scrollPosition = new mxPoint(graph.container.scrollLeft, graph.container.scrollTop);
 			var cx = (ignoreCursorPosition) ? graph.container.scrollLeft + graph.container.clientWidth / 2 :
@@ -2240,11 +2239,11 @@ EditorUi.prototype.initCanvas = function()
 			}
 		}
 		
-		scheduleZoom();
+		scheduleZoom(delay);
 	};
 	
 	// Holds back repaint until after mouse gestures
-	mxEvent.addGestureListeners(document.body, function(evt)
+	mxEvent.addGestureListeners(graph.container, function(evt)
 	{
 		if (updateZoomTimeout != null)
 		{
@@ -2254,17 +2253,16 @@ EditorUi.prototype.initCanvas = function()
 	{
 		if (graph.cumulativeZoomFactor != 1)
 		{
-			// Forces immediate rendering on non-panning clicks
-			scheduleZoom(mxEvent.isLeftMouseButton(evt));
+			scheduleZoom(0);
 		}
 	});
 	
 	// Holds back repaint until scroll ends
 	mxEvent.addListener(graph.container, 'scroll', function()
 	{
-		if (updateZoomTimeout && !graph.isMouseDown)
+		if (updateZoomTimeout && !graph.isMouseDown && graph.cumulativeZoomFactor != 1)
 		{
-			scheduleZoom();
+			scheduleZoom(0);
 		}
 	});
 
@@ -2279,23 +2277,8 @@ EditorUi.prototype.initCanvas = function()
 			{
 				if (source == graph.container)
 				{
-					var cp = cursorPosition;
-					var cz = graph.cumulativeZoomFactor; 
-					
 					cursorPosition = new mxPoint(mxEvent.getClientX(evt), mxEvent.getClientY(evt));;
 					graph.lazyZoom(up);
-					
-					if (cp != null)
-					{
-						// FIXME: Wheel on point then move and wheel again within timeout jumps around
-						var f = cz / graph.cumulativeZoomFactor;
-						var tx = (cursorPosition.x - cp.x) * f / graph.view.scale;
-						var ty = (cursorPosition.y - cp.y) * f / graph.view.scale;
-						//console.log('cp', cursorPosition, cp, cz / graph.cumulativeZoomFactor, tx, graph.zoomFactor, f);
-						graph.container.scrollLeft -= tx;
-						graph.container.scrollTop -= ty;
-					}
-					
 					mxEvent.consume(evt);
 			
 					return false;

+ 16 - 4
src/main/webapp/js/mxgraph/Graph.js

@@ -1353,6 +1353,15 @@ Graph.prototype.init = function(container)
 	 */
 	Graph.prototype.currentTranslate = new mxPoint(0, 0);
 
+	/**
+	 * Returns true if fast zoom preview should be used.
+	 */
+	Graph.prototype.isFastZoomEnabled = function()
+	{
+		return mxClient.IS_GC && urlParams['zoom'] != 'nocss' && !this.mathEnabled &&
+			!mxClient.NO_FO && !this.useCssTransforms;
+	};
+	
 	/**
 	 * Only foreignObject supported for now (no IE11).
 	 */
@@ -5712,11 +5721,14 @@ if (typeof mxVertexHandler != 'undefined')
 		 */
 		Graph.prototype.processElements = function(elt, fn)
 		{
-			var elts = elt.getElementsByTagName('*');
-			
-			for (var i = 0; i < elts.length; i++)
+			if (elt != null)
 			{
-				fn(elts[i]);
+				var elts = elt.getElementsByTagName('*');
+				
+				for (var i = 0; i < elts.length; i++)
+				{
+					fn(elts[i]);
+				}
 			}
 		};
 		

+ 1 - 1
src/main/webapp/js/mxgraph/Sidebar.js

@@ -3300,7 +3300,7 @@ Sidebar.prototype.addClickHandler = function(elt, ds, cells)
  */
 Sidebar.prototype.createVertexTemplateEntry = function(style, width, height, value, title, showLabel, showTitle, tags)
 {
-	tags = (tags != null && tags.length > 0) ? tags : title.toLowerCase();
+	tags = (tags != null && tags.length > 0) ? tags : ((title != null) ? title.toLowerCase() : '');
 	
 	return this.addEntry(tags, mxUtils.bind(this, function()
  	{

文件差异内容过多而无法显示
+ 1165 - 1163
src/main/webapp/js/viewer.min.js