浏览代码

11.1.4 release

David Benson [draw.io] 6 年之前
父节点
当前提交
82e122a841

+ 46 - 0
CODE_OF_CONDUCT.md

@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct:
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [coc@jgraph.com](mailto:coc@jgraph.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor-Covenant][homepage], version 1.4, available at [https://contributor-covenant.org/version/1/4][version]
+
+[homepage]: https://contributor-covenant.org
+[version]: https://contributor-covenant.org/version/1/4/

+ 11 - 0
ChangeLog

@@ -1,3 +1,14 @@
+08-AUG-2019: 11.1.4
+
+- Fixes grid NPE in export dialog
+
+08-AUG-2019: 11.1.3
+
+- Adds export option to include grid
+- Fixes last Gitlab project used in group
+- Adds custom Gitlab parameters
+- Fixes compressed XML export option
+
 05-AUG-2019: 11.1.2
 
 - Fixes encoding of embedded PNG data

+ 1 - 1
VERSION

@@ -1 +1 @@
-11.1.2
+11.1.4

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

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

+ 54 - 2
src/main/webapp/export3.html

@@ -48,8 +48,24 @@
 			{
 				extras = JSON.parse(data.extras);
 			} 
-			catch(e){}
+			catch(e)
+			{
+				try 
+				{
+					extras = JSON.parse(decodeURIComponent(data.extras));
+				}
+				catch(e){}
+			}
 
+			var gridColor = null;
+			
+			if (extras != null && extras.grid != null)
+			{
+				graph.gridSize = extras.grid.size;
+				graph.view.gridSteps = extras.grid.steps;
+				gridColor = extras.grid.color;
+			}
+			
 			//PNG+XML format
 			if (data.xml.substring(0, 5) == 'iVBOR' || (extras != null && extras.isPng))
 			{
@@ -239,6 +255,41 @@
 				}
 			};
 
+			function renderGrid()
+			{
+				if (gridColor == null) return;
+					
+				var view = graph.view;
+				var gridImage = btoa(unescape(encodeURIComponent(view.createSvgGrid(gridColor))));
+				gridImage = 'url(' + 'data:image/svg+xml;base64,' + gridImage + ')';
+                var phase = graph.gridSize * view.gridSteps * view.scale;
+                
+				var x0 = 0;
+				var y0 = 0;
+				
+				if (view.backgroundPageShape != null)
+				{
+					var bds = view.getBackgroundPageBounds();
+					
+					x0 = 1 + bds.x;
+					y0 = 1 + bds.y;
+				}
+				
+				// Computes the offset to maintain origin for grid
+				var position = -Math.round(phase - mxUtils.mod(view.translate.x * view.scale - x0, phase)) + 'px ' +
+					-Math.round(phase - mxUtils.mod(view.translate.y * view.scale - y0, phase)) + 'px';
+				
+				var pages = document.querySelectorAll('[id^=mxPage]');
+				
+				var cssTxt = 'margin: 0;padding: 0;background-image: ' + gridImage + ';background-position: ' + position;
+				document.body.style.cssText = cssTxt;
+
+				for (var i = 0; i < pages.length; i++)
+				{
+					pages[i].style.cssText = cssTxt;
+				}
+			};
+			
 			function renderPage()
 			{
 				// Enables math typesetting
@@ -287,7 +338,7 @@
 				{
 					document.body.style.backgroundColor = bg;
 				}
-
+				
 				//handle layers
 				if (extras != null && extras.layers != null)
 				{
@@ -586,6 +637,7 @@
 				renderPage();
 			}
 			
+			renderGrid();
 			// Includes images in SVG and HTML labels
 			waitForImages('image', 'xlink:href');
 			waitForImages('img', 'src');

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

@@ -232,7 +232,7 @@
 		.geFooterContainer>div#geFooter>img {
 			opacity:0.5;
 			border:1px solid transparent;
-			cusor:pointer;
+			cursor:pointer;
 			margin-top:3px;
 			margin-right:6px;
 			position:absolute;

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


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

@@ -1615,7 +1615,7 @@
 	 * @param {number} dx X-coordinate of the translation.
 	 * @param {number} dy Y-coordinate of the translation.
 	 */
-	EditorUi.prototype.downloadFile = function(format, nonCompressed, addShadow, ignoreSelection, currentPage, pageVisible, transparent, scale, border)
+	EditorUi.prototype.downloadFile = function(format, nonCompressed, addShadow, ignoreSelection, currentPage, pageVisible, transparent, scale, border, grid)
 	{
 		try
 		{
@@ -1716,7 +1716,7 @@
 							this.editor.graph.pageVisible = pageVisible;
 						}
 						
-						var req = this.createDownloadRequest(newTitle, format, ignoreSelection, base64, transparent, currentPage, scale, border);
+						var req = this.createDownloadRequest(newTitle, format, ignoreSelection, base64, transparent, currentPage, scale, border, grid);
 						this.editor.graph.pageVisible = prev;
 						
 						return req;
@@ -1740,7 +1740,7 @@
 	 * @param {number} dx X-coordinate of the translation.
 	 * @param {number} dy Y-coordinate of the translation.
 	 */
-	EditorUi.prototype.createDownloadRequest = function(filename, format, ignoreSelection, base64, transparent, currentPage, scale, border)
+	EditorUi.prototype.createDownloadRequest = function(filename, format, ignoreSelection, base64, transparent, currentPage, scale, border, grid)
 	{
 		var bounds = this.editor.graph.getGraphBounds();
 		
@@ -1798,6 +1798,13 @@
 			'&base64=' + base64 + '&embedXml=' + embed + '&xml=' +
 			encodeURIComponent(data) + ((filename != null) ?
 			'&filename=' + encodeURIComponent(filename) : '') +
+			(grid? '&extras=' + encodeURIComponent(JSON.stringify({
+				grid: {
+					size: this.editor.graph.gridSize,
+					steps: this.editor.graph.view.gridSteps,
+					color: this.editor.graph.view.gridColor
+				}
+			})) : '') +
 			(scale != null? '&scale=' + scale : '') +
 			(border != null? '&border=' + border : ''));
 	};
@@ -5357,6 +5364,14 @@
 			height += 26;
 		}
 		
+		var grid = null;
+		
+		if (format == 'png' || format == 'jpeg')
+		{
+			grid = this.addCheckbox(div, mxResources.get('grid'), false, this.isOffline() || !this.canvasSupported, false, true); 
+			height += 26;
+		}
+		
 		var include = this.addCheckbox(div, mxResources.get('includeCopyOfMyDiagram'), defaultInclude, null, null, format != 'jpeg');
 		var hasPages = this.pages != null && this.pages.length > 1;
 		var allPages = this.addCheckbox(div, (hasPages) ? mxResources.get('allPages') : '', hasPages, !hasPages, null, format != 'jpeg');
@@ -5423,7 +5438,7 @@
 			
 			callback(zoomInput.value, transparent.checked, !selection.checked, shadow.checked,
 				include.checked, cb5.checked, borderInput.value, cb6.checked, !allPages.checked,
-				linkSelect.value);
+				linkSelect.value, (grid != null? grid.checked : null));
 		}), null, btnLabel, helpLink);
 		this.showDialog(dlg.container, 340, height, true, true, null, null, null, null, true);
 		zoomInput.focus();
@@ -6001,7 +6016,7 @@
 	/**
 	 *
 	 */
-	EditorUi.prototype.exportImage = function(scale, transparentBackground, ignoreSelection, addShadow, editable, border, noCrop, currentPage, format)
+	EditorUi.prototype.exportImage = function(scale, transparentBackground, ignoreSelection, addShadow, editable, border, noCrop, currentPage, format, grid)
 	{
 		format = (format != null) ? format : 'png';
 		
@@ -6045,7 +6060,7 @@
 			   		this.spinner.stop();
 			   		this.handleError(e);
 			   	}), null, ignoreSelection, scale || 1, transparentBackground,
-			   		addShadow, null, null, border, noCrop);
+			   		addShadow, null, null, border, noCrop, grid);
 			}
 			catch (e)
 			{
@@ -6178,7 +6193,7 @@
 	 *
 	 */
 	EditorUi.prototype.exportToCanvas = function(callback, width, imageCache, background, error, limitHeight,
-		ignoreSelection, scale, transparentBackground, addShadow, converter, graph, border, noCrop)
+		ignoreSelection, scale, transparentBackground, addShadow, converter, graph, border, noCrop, grid)
 	{
 		try
 		{
@@ -6205,7 +6220,7 @@
 				bg = '#ffffff';
 			}
 			
-			this.convertImages(graph.getSvg(bg, null, null, noCrop, null, ignoreSelection, null, null, null, addShadow),
+			this.convertImages(graph.getSvg(null, null, null, noCrop, null, ignoreSelection, null, null, null, addShadow),
 				mxUtils.bind(this, function(svgRoot)
 			{
 				var img = new Image();
@@ -6239,22 +6254,60 @@
 							ctx.fill();
 				   		}
 	
-				   		ctx.scale(scale, scale);
-				   		
-				   		// Workaround for broken data URI images in Safari on first export
-				   		if (mxClient.IS_SF)
-				   		{			   		
-							window.setTimeout(function()
+					    ctx.scale(scale, scale);
+
+					    function drawImage()
+					    {
+					    	// Workaround for broken data URI images in Safari on first export
+					   		if (mxClient.IS_SF)
+					   		{			   		
+								window.setTimeout(function()
+								{
+									ctx.drawImage(img, border / scale, border / scale);
+									callback(canvas);
+								}, 0);
+					   		}
+					   		else
+					   		{
+					   			ctx.drawImage(img, border / scale, border / scale);
+					   			callback(canvas);
+					   		}
+					    };
+					    
+					    if (grid)
+					    {
+						    var view = graph.view;
+							var gridImage = btoa(unescape(encodeURIComponent(view.createSvgGrid(view.gridColor))));
+							gridImage = 'data:image/svg+xml;base64,' + gridImage;
+			                var phase = graph.gridSize * view.gridSteps * scale;
+			                
+			                var b = graph.getGraphBounds();
+							var x0 = b.x * scale;
+							var y0 = b.y * scale;
+							
+							var background = new Image();
+							background.src = gridImage;
+	
+							background.onload = function()
 							{
-								ctx.drawImage(img, border / scale, border / scale);
-								callback(canvas);
-							}, 0);
-				   		}
-				   		else
-				   		{
-				   			ctx.drawImage(img, border / scale, border / scale);
-				   			callback(canvas);
-				   		}
+								var x = -Math.round(phase - mxUtils.mod(view.translate.x * scale - x0, phase));
+								var y = -Math.round(phase - mxUtils.mod(view.translate.y * scale - y0, phase));
+	
+								for (var i = x; i < w; i += phase)
+								{
+									for (var j = y; j < h; j += phase)
+									{
+										ctx.drawImage(background, i / scale, j / scale);	
+									}
+								}
+							
+								drawImage();
+							};
+					    }
+					    else
+				    	{
+					    	drawImage();
+				    	}
 			   		}
 			   		catch (e)
 			   		{

+ 13 - 12
src/main/webapp/js/diagramly/GitLabClient.js

@@ -1094,19 +1094,20 @@ GitLabClient.prototype.showGitLabDialog = function(showFiles, fn)
 								temp.style.backgroundColor = (gray) ? '#eeeeee' : '';
 								gray = !gray;
 								
-								var project = projects[j];
-								
-								temp.appendChild(createLink(project.name_with_namespace, mxUtils.bind(this, function()
+								(mxUtils.bind(this, function(project)
 								{
-									org = group.full_path;
-									repo = project.path;
-									ref = project.default_branch || 'master';
-									path = '';
-			
-									selectFile();
-								})));
-
-								div.appendChild(temp);
+									temp.appendChild(createLink(project.name_with_namespace, mxUtils.bind(this, function()
+									{
+										org = group.full_path;
+										repo = project.path;
+										ref = project.default_branch || 'master';
+										path = '';
+				
+										selectFile();
+									})));
+	
+									div.appendChild(temp);
+								}))(projects[j]);
 							}
 						})));
 					}

+ 13 - 13
src/main/webapp/js/diagramly/Menus.js

@@ -170,10 +170,8 @@
 			
 			var selection = editorUi.addCheckbox(div, mxResources.get('selectionOnly'),
 				false, graph.isSelectionEmpty());
-			var compressed = editorUi.addCheckbox(div, mxResources.get('compressed'),
-				!noPages, noPages);
-			var pages = editorUi.addCheckbox(div, mxResources.get('allPages'),
-				true, noPages);
+			var compressed = editorUi.addCheckbox(div, mxResources.get('compressed'), true);
+			var pages = editorUi.addCheckbox(div, mxResources.get('allPages'), !noPages, noPages);
 			pages.style.marginBottom = '16px';
 			
 			mxEvent.addListener(selection, 'change', function()
@@ -190,11 +188,11 @@
 			
 			var dlg = new CustomDialog(editorUi, div, mxUtils.bind(this, function()
 			{
-				editorUi.downloadFile('xml', noPages || !compressed.checked, null,
+				editorUi.downloadFile('xml', !compressed.checked, null,
 					!selection.checked, noPages || !pages.checked);
 			}), null, mxResources.get('export'));
 			
-			editorUi.showDialog(dlg.container, 300, 176, true, true);
+			editorUi.showDialog(dlg.container, 300, 180, true, true);
 		}));
 		
 		editorUi.actions.put('exportUrl', new Action(mxResources.get('url') + '...', function()
@@ -268,7 +266,7 @@
 					}
 				};
 				
-				var dlgH = 146;
+				var dlgH = 172;
 				
 				if (editorUi.pdfPageExport && !noPages)
 				{
@@ -276,11 +274,12 @@
 					var currentPage = editorUi.addRadiobox(div, 'pages', mxResources.get('currentPage', null, 'Current Page'), false);
 					var selection = editorUi.addRadiobox(div, 'pages', mxResources.get('selectionOnly'), false, graph.isSelectionEmpty());
 					var crop = editorUi.addCheckbox(div, mxResources.get('crop'), false, true);
+					var grid = editorUi.addCheckbox(div, mxResources.get('grid'), false, false);
 					
 					mxEvent.addListener(allPages, 'change', cropEnableFn);
 					mxEvent.addListener(currentPage, 'change', cropEnableFn);
 					mxEvent.addListener(selection, 'change', cropEnableFn);
-					dlgH = 205;
+					dlgH = 231;
 				}
 				else
 				{
@@ -289,6 +288,7 @@
 					var crop = editorUi.addCheckbox(div, mxResources.get('crop'),
 							!graph.pageVisible || !editorUi.pdfPageExport,
 							!editorUi.pdfPageExport);
+					var grid = editorUi.addCheckbox(div, mxResources.get('grid'), false, false);
 					
 					// Crop is only enabled if selection only is selected
 					if (!editorUi.pdfPageExport)
@@ -299,7 +299,7 @@
 				
 				var dlg = new CustomDialog(editorUi, div, mxUtils.bind(this, function()
 				{
-					editorUi.downloadFile('pdf', null, null, !selection.checked, noPages? true : !allPages.checked, !crop.checked);
+					editorUi.downloadFile('pdf', null, null, !selection.checked, noPages? true : !allPages.checked, !crop.checked, null, null, null, grid.checked);
 				}), null, mxResources.get('export'));
 				editorUi.showDialog(dlg.container, 300, dlgH, true, true);
 			}
@@ -555,14 +555,14 @@
 				editorUi.showExportDialog(mxResources.get('image'), false, mxResources.get('export'),
 					'https://support.draw.io/display/DO/Exporting+Files',
 					mxUtils.bind(this, function(scale, transparentBackground, ignoreSelection,
-						addShadow, editable, embedImages, border, cropImage, currentPage)
+						addShadow, editable, embedImages, border, cropImage, currentPage, dummy, grid)
 					{
 						var val = parseInt(scale);
 						
 						if (!isNaN(val) && val > 0)
 						{
 						   	editorUi.exportImage(val / 100, transparentBackground, ignoreSelection,
-						   		addShadow, editable, border, !cropImage, currentPage);
+						   		addShadow, editable, border, !cropImage, currentPage, null, grid);
 						}
 					}), true, true, 'png');
 			}
@@ -582,14 +582,14 @@
 				editorUi.showExportDialog(mxResources.get('image'), false, mxResources.get('export'),
 					'https://support.draw.io/display/DO/Exporting+Files',
 					mxUtils.bind(this, function(scale, transparentBackground, ignoreSelection,
-						addShadow, editable, embedImages, border, cropImage, currentPage)
+						addShadow, editable, embedImages, border, cropImage, currentPage, dummy, grid)
 					{
 						var val = parseInt(scale);
 						
 						if (!isNaN(val) && val > 0)
 						{
 							editorUi.exportImage(val / 100, false, ignoreSelection,
-							   	addShadow, false, border, !cropImage, false, 'jpeg');
+							   	addShadow, false, border, !cropImage, false, 'jpeg', grid);
 						}
 					}), true, false, 'jpeg');
 			}

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