David Benson [draw.io] 5 лет назад
Родитель
Сommit
f247b0bdc1

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+09-JUL-2020: 13.4.1
+
+- Disables eval in HTML embed code
+
 08-JUL-2020: 13.4.0
 
 - Adds border for lightbox export

+ 1 - 1
VERSION

@@ -1 +1 @@
-13.4.0
+13.4.1

+ 5 - 5
etc/build/build.xml

@@ -63,7 +63,6 @@
 		</concat>
 		<echo file="${basedir}/Graph-Stylesheet.js" append="true">`).documentElement;</echo>
 
-		
 		<delete file="${basedir}/.tmp2.js"/>
 		<copy file="${war.dir}/resources/dia.txt" tofile="${basedir}/.tmp2.xml" overwrite="true"/>
 		<replaceregexp file="${basedir}/.tmp2.xml" match="${line.separator}" flags="g" replace="\\\\n"/>
@@ -244,15 +243,16 @@
 			<filelist dir="${basedir}" files="base-viewer.min.js,.tmp2.min.js"/>
     	</concat>
 
+		<!-- Disables eval for JS (uses shapes.min.js) -->
 		<echo file="${basedir}/.tmp3.js">
-			// Disables eval for JS (uses shapes.min.js)
 			mxStencilRegistry.allowEval = false;
 		</echo>
 		
 		<concat destfile="${war.dir}/js/viewer-static.min.js" fixlastline="yes" append="no">
-			<filelist dir="${war.dir}/js" files="viewer.min.js,shapes.min.js"/>
-			<filelist dir="${basedir}" files=".tmp3.js"/>
-    	</concat>
+			<filelist dir="${basedir}" files="base-viewer.min.js"/>
+			<filelist dir="${war.dir}/js" files="shapes.min.js"/>
+				<filelist dir="${basedir}" files=".tmp3.js,.tmp2.min.js"/>
+		</concat>
 
 		<delete file="${war.dir}/js/extensions.min.js"/>
 		<delete file="${basedir}/.tmp0.js"/>

+ 1 - 1
src/main/java/com/mxgraph/online/EmbedServlet2.java

@@ -426,7 +426,7 @@ public class EmbedServlet2 extends HttpServlet
 				+ "var script = document.createElement('script');"
 				+ "script.type = 'text/javascript';" + "script.src = '" + proto
 				+ ((dev != null && dev.equals("1")) ? "test" : "www")
-				+ ".draw.io/js/viewer.min.js';"
+				+ ".draw.io/js/viewer-static.min.js';"
 				+ "t[0].parentNode.appendChild(script);}";
 	}
 

+ 93 - 22
src/main/webapp/connect/confluence/admin.js

@@ -415,16 +415,57 @@ var GliffyMassImporter = function(logDiv, doneFn)
 	link.href = location.href;
 	link.href = link.href; //to have 'host' populated under IE
 	var hostUrl = link.protocol + '//' + link.hostname;
+	var convertedDiagrams = {};
 
 	function importGliffyAtt(pageId, pageType, spaceKey, params, macroId, success, error, skip) 
 	{
 		var attName = params[0];
+		var linkedPageId = params[1];
+		pageId = linkedPageId || pageId;
 		
+		if (!attName)
+		{ 	//This is a draft diagram that is stored on Gliffy servers and only accessed by 'macroId' and requires authentication
+			error({macroId:macroId});
+			return;
+		}
+		
+		var diagKey = pageId + '-' + attName;
 		logDiv.append($('<div>' + mxResources.get('confAGliffyDiagFound', [AC.htmlEntities(attName), 'Gliffy']) + '...</div>'));
+
+		function localSuccess(info)
+		{
+			var attInfo = {
+				name: attName + ".drawio",
+				macroId: macroId,
+				contentId: info.contentId,
+				contentVer: info.contentVer,
+				//TODO get the actual width & height
+				//TODO It works with this hardcoded number, but it is better to get the actual value
+				width: 500,
+				height: 500
+			};
+			
+			if (linkedPageId != null)
+			{
+				attInfo.isInc = true;
+				attInfo.pageId = linkedPageId;
+				
+				logDiv.append($('<div>' + mxResources.get('confAGliffyDiagImported', [AC.htmlEntities(attName), 'Gliffy (Linked)']) + '</div>'));
+			}
+			else
+			{
+				attInfo.revision = info.revision;
+				attInfo.previewPng = attName + ".png";
+				
+				logDiv.append($('<div>' + mxResources.get('confAGliffyDiagImported', [AC.htmlEntities(attName), 'Gliffy']) + '</div>'));
+			}
+			
+			success(attInfo);
+		};
 		
-		//Get the latest version (no version parameter)
-		//keeping the block of AP.require to minimize the number of changes!
+		function convertDiagram()
 		{
+			//Get the latest version (no version parameter)
 			AP.request({
 				url:  "/download/attachments/" + pageId + "/"
 					+ encodeURIComponent(attName.trim()), //Conf removes spaces from attachments file names
@@ -452,37 +493,28 @@ var GliffyMassImporter = function(logDiv, doneFn)
 								function(resp)
 								{
 				 					resp = JSON.parse(resp);
-				 					
-				 					var attInfo = {
-				 						name: attName + ".drawio", 
-				 						revision: resp.results[0].version.number,
-				 						macroId: macroId,
-				 						previewPng: attName + ".png",
-					 					//TODO get the actual width & height
-				 						//TODO It works with this hardcoded number, but it is better to get the actual value
-		 								width: 500,
-		 								height: 500
-			 						};
+				 					var revision = resp.results[0].version.number;
 				 					
 				 					//Add custom content
-				 					AC.saveCustomContent(spaceKey, pageId, pageType, attName + ".drawio", attName + ".drawio", attInfo.revision, null, null, 
+				 					AC.saveCustomContent(spaceKey, pageId, pageType, attName + ".drawio", attName + ".drawio", revision, null, null, 
 				 							function(responseText)
 				 							{
-				 								logDiv.append($('<div>' + mxResources.get('confAGliffyDiagImported', [AC.htmlEntities(attName), 'Gliffy']) + '</div>'));
-				 								
 				 								var content = JSON.parse(responseText);
 												
-				 								attInfo.contentId = content.id;
-				 								attInfo.contentVer = content.version.number;
-												
-							 					success(attInfo);
+							 					var info = {
+							 						revision: revision,
+							 						contentId: content.id,
+							 						contentVer: content.version.number
+							 					};
+							 					
+							 					convertedDiagrams[diagKey] = info;
+							 					localSuccess(info);
 				 							}, function(err)
 				 							{
 				 								logDiv.append($('<div style="color:red">' + mxResources.get('confASavingImpGliffyFailed', [AC.htmlEntities(attName), 'Gliffy']) + '</div>'));
 							 					console.log(err);
 							 					error({macroId:macroId});
 				 							});
-				 					
 				 				}, function(err) 
 				 				{
 				 					logDiv.append($('<div style="color:red">' + mxResources.get('confASavingImpGliffyFailed', [AC.htmlEntities(attName), 'Gliffy']) + '</div>'));
@@ -509,11 +541,50 @@ var GliffyMassImporter = function(logDiv, doneFn)
 				}
 			});
 		};
+		
+		var info = convertedDiagrams[diagKey];
+		
+		if (info === true) //Pending, wait
+		{
+			var trials = 0;
+			
+			function waitForConversion()
+			{
+				trials++;
+				info = convertedDiagrams[diagKey];
+				
+				if (info !== true)
+				{
+					localSuccess(info)
+				}
+				else if (trials < 15) //4.5 second wait, during test. It took about 2 sec
+				{
+					setTimeout(waitForConversion, 300);
+				}
+				else
+				{
+					//Try conversion again in case an error occured
+					convertDiagram();
+				}
+			}
+			
+			setTimeout(waitForConversion, 300);
+		}
+		else if (info != null)
+		{
+			//Diagram is already converted, so directly convert the macro
+			localSuccess(info);
+		}
+		else
+		{
+			convertedDiagrams[diagKey] = true;
+			convertDiagram();
+		}
 	};
 	
 	logDiv.html("<br>");
 	
-	MassDiagramsProcessor('gliffy', 'Gliffy', ['name'], importGliffyAtt, logDiv, doneFn);
+	MassDiagramsProcessor('gliffy', 'Gliffy', ['name', 'pageid'], importGliffyAtt, logDiv, doneFn);
 };
 
 function cleanBrokenCustomContents(logDiv, callback, error)

Разница между файлами не показана из-за своего большого размера
+ 59 - 59
src/main/webapp/js/app.min.js


+ 4 - 5
src/main/webapp/js/diagramly/Editor.js

@@ -49,12 +49,11 @@
 		{commonStyle: {fontColor: '#095C86', strokeColor: '#AF45ED', fillColor: '#F694C1'},
 			edgeStyle: {strokeColor: '#60E696'}},
 		{commonStyle: {fontColor: '#46495D', strokeColor: '#788AA3', fillColor: '#B2C9AB'}},
-		{commonStyle:  {fontColor: '#5AA9E6', strokeColor: '#FF6392', fillColor: '#FFE45E'},
-			graph: {background: '#F9F9F9'}},
-		{commonStyle:  {fontColor: '#393C56', strokeColor: '#E07A5F', fillColor: '#F2CC8F'},
-			graph: {background: '#F4F1DE'}},
-		{commonStyle: {fontColor: '#1D3557', strokeColor: '#457B9D', fillColor: '#A8DADC'},
+		{commonStyle:  {fontColor: '#5AA9E6', strokeColor: '#FF6392', fillColor: '#FFE45E'}},
+		{commonStyle: {fontColor: '#1D3557', strokeColor: '#457B9D', fillColor: '#A8DADC'},	
 			graph: {background: '#F1FAEE'}},
+		{commonStyle:  {fontColor: '#393C56', strokeColor: '#E07A5F', fillColor: '#F2CC8F'},	
+			graph: {background: '#F4F1DE', gridColor: '#D4D0C0'}},
 		{commonStyle: {fontColor: '#143642', strokeColor: '#0F8B8D', fillColor: '#FAE5C7'},
 			edgeStyle: {strokeColor: '#A8201A'},
 			graph: {background: '#DAD2D8', gridColor: '#ABA4A9'}},

+ 5 - 7
src/main/webapp/js/diagramly/EditorUi.js

@@ -1567,9 +1567,7 @@
 	 */
 	EditorUi.prototype.getHtml2 = function(xml, graph, title, editLink, redirect)
 	{
-		var bg = null;
-		var js = window.DRAWIO_VIEWER_URL || EditorUi.drawHost + '/js/viewer.min.js';
-		var s = '';
+		var js = window.DRAWIO_VIEWER_URL || EditorUi.drawHost + '/js/viewer-static.min.js';
 	
 		// Makes XHTML compatible
 		if (redirect != null)
@@ -5184,11 +5182,11 @@
 			'https://test.draw.io/embed2.js?dev=1' :
 			EditorUi.drawHost + '/embed2.js?')) + fetchParam :
 			(((urlParams['dev'] == '1') ?
-			'https://test.draw.io/js/viewer.min.js' :
-			window.VIEWER_URL ? window.VIEWER_URL : EditorUi.drawHost + '/js/viewer.min.js'));
-		var scr = '<script type="text/javascript" src="' + s2 + '"></script>';
+			'https://test.draw.io/js/viewer-static.min.js' :
+			window.VIEWER_URL ? window.VIEWER_URL : EditorUi.drawHost + '/js/viewer-static.min.js'));
+		var src = '<script type="text/javascript" src="' + s2 + '"></script>';
 		
-		fn(value, scr);
+		fn(value, src);
 	};
 
 	/**

+ 6 - 1
src/main/webapp/js/diagramly/Extensions.js

@@ -5424,10 +5424,15 @@ LucidImporter = {};
 	{
 		try
 		{
+			if (obj.Action != null && obj.Action.Properties != null)
+			{
+				obj = obj.Action.Properties;
+			}
+			
 			var group = new mxCell('', new mxGeometry(), 'group;dropTarget=0;');
 			group.vertex = true;
 			var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
-			var members = obj.Members || obj.Action.Properties.Members;
+			var members = obj.Members;
 				
 			for (var key in members)
 			{

+ 2 - 0
src/main/webapp/js/diagramly/GraphViewer.js

@@ -1342,6 +1342,8 @@ GraphViewer.prototype.addClickHandler = function(graph, ui)
 			(mxEvent.isTouchEvent(evt) || !mxEvent.isPopupTrigger(evt)) &&
 			graph.customLinkClicked(href))
 		{
+			// Workaround for text selection in Firefox on Windows
+			mxUtils.clearSelection();
 			mxEvent.consume(evt);
 		}
 	}), mxUtils.bind(this, function(evt)

Разница между файлами не показана из-за своего большого размера
+ 4 - 4
src/main/webapp/js/extensions.min.js


+ 12 - 6
src/main/webapp/js/mxgraph/Format.js

@@ -453,7 +453,7 @@ Format.prototype.refresh = function()
 		if (Editor.styles != null)
 		{
 			diagramPanel.style.display = 'none';
-			label.style.width = '106px';
+			label.style.width = (this.showCloseButton) ? '106px' : '50%';
 			label.style.cursor = 'pointer';
 			label.style.backgroundColor = this.inactiveTabBackgroundColor;
 			
@@ -512,7 +512,6 @@ Format.prototype.refresh = function()
 			
 			div.appendChild(label2);
 		}
-		
 	}
 	else if (graph.isEditing())
 	{
@@ -5937,8 +5936,11 @@ DiagramStylePanel.prototype.addView = function(div)
 				change.ignoreImage = true;
 				model.execute(change);
 				
-				model.execute(new ChangeGridColor(ui, (graphStyle != null) ? graphStyle.gridColor ||
-					graph.view.defaultGridColor : graph.view.defaultGridColor));
+				if (graphStyle != null && graphStyle.background != null)
+				{
+					model.execute(new ChangeGridColor(ui, (graphStyle != null) ? graphStyle.gridColor ||
+						graph.view.defaultGridColor : graph.view.defaultGridColor));
+				}
 			}
 			finally
 			{
@@ -5953,8 +5955,12 @@ DiagramStylePanel.prototype.addView = function(div)
 			var prevGrid = graph.view.gridColor;
 
 			graph.background = (graphStyle != null) ? graphStyle.background : null;
-			graph.view.gridColor = (graphStyle != null) ? graphStyle.gridColor ||
-				graph.view.defaultGridColor : graph.view.defaultGridColor;
+			
+			if (graphStyle != null && graphStyle.background != null)
+			{
+				graph.view.gridColor = (graphStyle != null) ? graphStyle.gridColor ||
+					graph.view.defaultGridColor : graph.view.defaultGridColor;
+			}
 			
 			graph.getCellStyle = function(cell)
 			{

Разница между файлами не показана из-за своего большого размера
+ 50 - 51
src/main/webapp/js/viewer-static.min.js


Разница между файлами не показана из-за своего большого размера
+ 49 - 49
src/main/webapp/js/viewer.min.js


+ 2 - 2
src/main/webapp/service-worker.js

@@ -6,11 +6,11 @@ if (workbox)
 	workbox.precaching.precacheAndRoute([
   {
     "url": "js/app.min.js",
-    "revision": "5c78133585f46412bda6b075020dd391"
+    "revision": "bf5396686a7ae89e2ca33041b929b4ba"
   },
   {
     "url": "js/extensions.min.js",
-    "revision": "6025816d5cdf862d2ad3f199c4a5af47"
+    "revision": "7e985a8c8ea46163d24e15c0177203ed"
   },
   {
     "url": "js/stencils.min.js",