Browse Source

17.2.3 release

David Benson 3 years ago
parent
commit
a0729487fe

+ 1 - 3
.github/workflows/codeql-analysis.yml

@@ -56,8 +56,6 @@ jobs:
       run: |
         cd etc/build
         npm install workbox-cli@6.3.0 --global
-        ant clean
-        ant javac
         ant
 
     # ℹ️ Command-line programs to run using the OS shell.
@@ -72,4 +70,4 @@ jobs:
     #   make release
 
     - name: Perform CodeQL Analysis
-      uses: github/codeql-action/analyze@v1
+      uses: github/codeql-action/analyze@v1

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+25-MAR-2022: 17.2.3
+
+- Fixes custom links in duplicated page for realtime
+- Uses same domain for realtime in production
+
 24-MAR-2022: 17.2.2
 
 - Adds Shift+Alt for floating connections https://github.com/jgraph/drawio/issues/DID-4550

+ 1 - 1
VERSION

@@ -1 +1 @@
-17.2.2
+17.2.3

File diff suppressed because it is too large
+ 44 - 45
src/main/webapp/js/app.min.js


+ 11 - 3
src/main/webapp/js/diagramly/DiffSync.js

@@ -655,9 +655,17 @@ EditorUi.prototype.patchCell = function(model, cell, diff, resolve)
 };
 
 /**
- * Gets a file node that is comparable with a remote file node
- * so that using isEqualNode returns true if the files can be
- * considered equal.
+ * Returns the pages for the given XML string.
+ */
+EditorUi.prototype.getPagesForXml = function(data)
+{
+	var doc = mxUtils.parseXml(data);
+
+	return this.getPagesForNode(doc.documentElement);
+};
+
+/**
+ * Returns the pages for the given node.
  */
 EditorUi.prototype.getPagesForNode = function(node, nodeName)
 {

+ 16 - 31
src/main/webapp/js/diagramly/DrawioFile.js

@@ -19,8 +19,7 @@ DrawioFile = function(ui, data)
 	 * @default 0
 	 */
 	this.data = data || '';
-	this.shadowData = this.data;
-	this.shadowPages = null;
+	this.shadowPages = this.ui.getPagesForXml(this.data);
 	this.created = new Date().getTime();
 	
 	// Creates the stats object
@@ -137,11 +136,6 @@ DrawioFile.prototype.shadowModified = false;
  */
 DrawioFile.prototype.data = null;
 
-/**
- * Holds a copy of the last saved file data.
- */
-DrawioFile.prototype.shadowData = null;
-
 /**
  * Holds a copy of the parsed last saved file data.
  */
@@ -284,16 +278,10 @@ DrawioFile.prototype.mergeFile = function(file, success, error, diffShadow)
 	{
 		this.stats.fileMerged++;
 
-		// Takes copy of current shadow document
-		var shadow = (this.shadowPages != null) ? this.shadowPages :
-			this.ui.getPagesForNode(mxUtils.parseXml(
-				this.shadowData).documentElement);
-		
 		// Loads new document as shadow document
-		var pages = this.ui.getPagesForNode(
-			mxUtils.parseXml(file.data).
-				documentElement)
-		
+		var shadow = this.shadowPages;
+		var pages = file.shadowPages;
+
 		if (pages != null && pages.length > 0)
 		{
 			// Patches the current document
@@ -310,9 +298,8 @@ DrawioFile.prototype.mergeFile = function(file, success, error, diffShadow)
 				}
 		
 				// Creates a patch for backup if the checksum fails
-				this.backupPatch = (this.isModified()) ?
-					this.ui.diffPages(shadow,
-						this.ui.pages) : null;
+				this.backupPatch = (!this.isModified()) ? null :
+					this.ui.diffPages(shadow, this.ui.pages);
 				
 				// Patching previous shadow to verify checksum
 				var patchedDetails = {};
@@ -511,10 +498,11 @@ DrawioFile.prototype.checksumError = function(error, patches, details, etag, fun
 			{
 				var json = this.compressReportData(
 					JSON.stringify(patches, null, 2));
-				var remote = (file != null) ? this.compressReportData(
-					this.getAnonymizedXmlForPages(
-					this.ui.getPagesForNode(
-					mxUtils.parseXml(file.data).documentElement)), 25000) : 'n/a';
+				var remote = (file == null) ?  'n/a' :
+					this.compressReportData(
+						this.getAnonymizedXmlForPages(
+							this.ui.getPagesForXml(file.data)),
+								25000);
 				
 				this.sendErrorReport('Checksum Error in ' + functionName + ' ' + this.getHash(),
 					((details != null) ? (details) : '') +  '\n\nPatches:\n' + json +
@@ -1202,9 +1190,7 @@ DrawioFile.prototype.open = function()
 		// only if the file has not been modified and reopened
 		if (!this.isModified())
 		{
-			this.shadowData = mxUtils.getXml(
-				this.ui.getXmlFileData());
-			this.shadowPages = null;
+			this.shadowPages = this.ui.clonePages(this.ui.pages);
 		}
 	}
 
@@ -2186,11 +2172,11 @@ DrawioFile.prototype.fileSaved = function(savedData, lastDesc, success, error, t
 		this.stats.saved++;
 		this.inConflictState = false;
 		this.invalidChecksum = false;
+		var pages = this.ui.getPagesForXml(savedData)
 
 		if (this.sync == null || this.isOptimisticSync())
 		{
-			this.shadowPages = this.ui.getPagesForNode(
-				mxUtils.parseXml(savedData).documentElement);
+			this.shadowPages = pages;
 			
 			if (this.sync != null)
 			{
@@ -2210,9 +2196,8 @@ DrawioFile.prototype.fileSaved = function(savedData, lastDesc, success, error, t
 		}
 		else
 		{
-			this.sync.fileSaved(this.ui.getPagesForNode(
-				mxUtils.parseXml(savedData).documentElement),
-				lastDesc, success, error, token);
+			this.sync.fileSaved(pages, lastDesc,
+				success, error, token);
 		}
 	}
 	catch (e)

+ 35 - 37
src/main/webapp/js/diagramly/DrawioFileSync.js

@@ -989,6 +989,12 @@ DrawioFileSync.prototype.scheduleCleanup = function(lazy)
 			}));
 		}), this.cleanupDelay);
 	}
+
+	if (urlParams['test'] == '1')
+	{
+		EditorUi.debug('Sync.scheduleCleanup',
+			[this], 'lazy', lazy);
+	}
 };
 
 /**
@@ -1004,20 +1010,20 @@ DrawioFileSync.prototype.cleanup = function(success, error, checkFile)
 		!this.file.inConflictState &&
 		!this.file.isModified())
 	{
-		var patch = this.ui.diffPages(this.ui.pages,
-			this.file.ownPages);
+		var patches = [this.ui.diffPages(this.ui.pages,
+			this.file.ownPages)];
 		this.file.theirPages = this.ui.clonePages(
 			this.file.ownPages);
 		
-		if (!mxUtils.isEmptyObject(patch))
+		if (!this.file.ignorePatches(patches))
 		{
-			this.file.patch([patch]);
+			this.file.patch(patches);
 		}
 		
 		if (urlParams['test'] == '1')
 		{
 			EditorUi.debug('Sync.cleanup',
-				[this], 'patch', patch,
+				[this], 'patches', patches,
 				'checkFile', checkFile);
 		}
 
@@ -1037,9 +1043,7 @@ DrawioFileSync.prototype.cleanup = function(success, error, checkFile)
 					if (this.file.isRealtime() && this.isValidState() &&
 						!this.file.inConflictState)
 					{
-						var pages = this.ui.getPagesForNode(
-							mxUtils.parseXml(newFile.data).
-							documentElement);
+						var pages = this.ui.getPagesForXml(newFile.data);
 						var patches = [this.ui.diffPages(this.ui.pages, pages),
 							this.ui.diffPages(pages, this.file.ownPages)];
 						
@@ -1083,6 +1087,16 @@ DrawioFileSync.prototype.cleanup = function(success, error, checkFile)
 	}
 };
 
+/**
+ * Extracts local changes by diffing remote pages and patched remote pages.
+ */
+DrawioFileSync.prototype.extractLocal = function(patch)
+{
+	return (mxUtils.isEmptyObject(patch)) ? {} : this.ui.diffPages(
+		this.file.theirPages, this.ui.patchPages(this.ui.clonePages(
+			this.file.theirPages), patch));
+};
+
 /**
  * Extracts remove operations for pages and cells from the given patch.
  */
@@ -1125,37 +1139,27 @@ DrawioFileSync.prototype.extractRemove = function(patch)
 /**
  * Updates the realtime models and saves pending local changes.
  */
-DrawioFileSync.prototype.patchRealtime = function(patches, backupPatch, ownPending)
+DrawioFileSync.prototype.patchRealtime = function(patches, backup, own)
 {
-	var allPending = null;
+	var all = null;
 
 	if (this.file.isRealtime())
 	{
 		// Gets pending changes that must be saved after remote
-		// changes are applied, ie. remove of remote shape.
+		// changes are applied, ie. local remove of remote shape.
 		// TODO: Currently only implemented for pending removes as
 		// remote changes are not received in the order in which
 		// they are finally saved in the file.
-		allPending = this.extractRemove(this.ui.diffPages(
+		all = this.extractRemove(this.ui.diffPages(
 			this.file.shadowPages, this.ui.pages));
-		
-		// Extracts local changes by diffing remote pages (where
-		// no local changes have been applied) and remote pages
-		// patched with all pending changes. Eg. a remote shape
-		// was removed locally, then it is still in remote pages
-		// and removing it there will result in a diff.
-		var local = (mxUtils.isEmptyObject(allPending)) ? {} :
-			this.extractRemove(this.ui.diffPages(
-				this.file.theirPages, this.ui.patchPages(
-					this.ui.clonePages(this.file.theirPages),
-						allPending)));
+		var local = this.extractRemove(this.extractLocal(all));
 		
 		// Applies incoming, own and local changes to own pages
-		var applied = ((ownPending == null) ? patches :
-			patches.concat(ownPending)).concat([local]);
+		var applied = ((own == null) ? patches :
+			patches.concat(own)).concat([local]);
 		this.file.ownPages = this.ui.applyPatches(
 			this.file.ownPages, applied, true,
-				backupPatch);
+				backup);
 		
 		// Triggers a file change to save pending local
 		// changes or updates the UI and and schedules
@@ -1172,13 +1176,13 @@ DrawioFileSync.prototype.patchRealtime = function(patches, backupPatch, ownPendi
 		if (urlParams['test'] == '1')
 		{
 			EditorUi.debug('Sync.patchRealtime', [this],
-				'patches', patches, 'backupPatch', backupPatch,
-				'ownPending', ownPending, 'allPending', allPending,
-				'local', local, 'applied', applied);
+				'patches', patches, 'backup', backup,
+				'own', own, 'all', all, 'local', local,
+				'applied', applied);
 		}
 	}
 
-	return allPending;
+	return all;
 };
 
 /**
@@ -1253,9 +1257,6 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
 	{
 		this.file.stats.merged++;
 		this.lastModified = new Date();
-		this.file.shadowPages = (this.file.shadowPages != null) ?
-			this.file.shadowPages : this.ui.getPagesForNode(
-			mxUtils.parseXml(this.file.shadowData).documentElement)
 		var etag = this.file.getDescriptorRevisionId(desc);
 		var ignored = this.file.ignorePatches(patches);
 		
@@ -1840,12 +1841,9 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
 			}
 			else
 			{
-				var shadow = (this.file.shadowPages != null) ?
-					this.file.shadowPages : this.ui.getPagesForNode(
-					mxUtils.parseXml(this.file.shadowData).documentElement)
+				var diff = this.ui.diffPages(this.file.shadowPages, pages);
 				var lastSecret = this.file.getDescriptorSecret(lastDesc);
 				var checksum = this.ui.getHashValueForPages(pages);
-				var diff = this.ui.diffPages(shadow, pages);
 				
 				// Data is stored in cache and message is sent to all listeners
 				var data = this.objectToString(this.createMessage({patch: diff, checksum: checksum}));

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

@@ -62,7 +62,7 @@
 
 	if (EditorUi.cacheUrl == null && typeof DrawioFile !== 'undefined')
 	{
-		DrawioFile.SYNC = 'none'; //Disable real-time sync
+		DrawioFile.SYNC = 'none'; // Disables real-time sync
 	}
 	
 	/**

+ 2 - 1
src/main/webapp/js/diagramly/Init.js

@@ -36,7 +36,8 @@ window.OPEN_URL = window.OPEN_URL || 'import';
 window.PROXY_URL = window.PROXY_URL || 'proxy';
 window.DRAWIO_VIEWER_URL = window.DRAWIO_VIEWER_URL || null;
 window.NOTIFICATIONS_URL = window.NOTIFICATIONS_URL || 'https://www.draw.io/notifications';
-window.RT_WEBSOCKET_URL = window.RT_WEBSOCKET_URL || 'wss://app.diagrams.net/rt';
+window.RT_WEBSOCKET_URL = window.RT_WEBSOCKET_URL || 'wss://' + ((urlParams['dev'] == '1') ?
+	'app.diagrams.net' : window.location.hostname) + '/rt';
 
 // Paths and files
 window.SHAPES_PATH = window.SHAPES_PATH || 'shapes';

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

@@ -1871,8 +1871,7 @@
 				{
 					var buttons = [['Snapshot', function(evt, input)
 					{
-						snapshot = editorUi.getPagesForNode(mxUtils.parseXml(
-							editorUi.getFileData(true)).documentElement);
+						snapshot = editorUi.getPagesForXml(editorUi.getFileData(true));
 						dlg.textarea.value = 'Snapshot updated ' + new Date().toLocaleString() +
 							' Checksum ' + editorUi.getHashValueForPages(snapshot);
 					}], ['Diff', function(evt, input)
@@ -1910,8 +1909,7 @@
 			    	
 					if (snapshot == null)
 					{
-						snapshot = editorUi.getPagesForNode(mxUtils.parseXml(
-							editorUi.getFileData(true)).documentElement);
+						snapshot = editorUi.getPagesForXml(editorUi.getFileData(true));
 						dlg.textarea.value = 'Snapshot created ' + new Date().toLocaleString() +
 							' Checksum ' + editorUi.getHashValueForPages(snapshot);
 					}

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

@@ -15,7 +15,7 @@ mxUtils.extend(OneDriveFile, DrawioFile);
 /**
  * Shorter autosave delay for optimistic sync.
  */
-OneDriveFile.prototype.autosaveDelay = 400;
+OneDriveFile.prototype.autosaveDelay = 500;
 
 /**
  * Hook for subclassers.

+ 16 - 5
src/main/webapp/js/diagramly/Pages.js

@@ -1185,7 +1185,18 @@ EditorUi.prototype.duplicatePage = function(page, name)
 			var lookup = graph.createCellLookup([graph.model.root]);
 
 			var newPage = new DiagramPage(node);
-			newPage.root = graph.cloneCell(graph.model.root, null, cloneMap);
+			newPage.root = graph.cloneCell(graph.model.root,
+				null, cloneMap);
+			// Updates cell IDs
+			var model = new mxGraphModel();
+			model.prefix = Editor.guid() + '-';
+			model.setRoot(newPage.root);
+
+			// Updates custom links
+			graph.updateCustomLinks(graph.createCellMapping(
+				cloneMap, lookup), [newPage.root]);
+			
+			// Initializes diagram node
 			newPage.viewState = (page == this.currentPage) ?
 				graph.getViewState() : page.viewState;
 			this.initDiagramNode(newPage);
@@ -1198,10 +1209,10 @@ EditorUi.prototype.duplicatePage = function(page, name)
 			newPage.viewState.defaultParent = null;
 			newPage.setName(name);
 			
-			newPage = this.insertPage(newPage, mxUtils.indexOf(this.pages, page) + 1);
-
-			// Updates custom links after inserting into the model for cells to have new IDs
-			graph.updateCustomLinks(graph.createCellMapping(cloneMap, lookup), [newPage.root]);
+			// Inserts new page after duplicated page
+			newPage = this.insertPage(newPage,
+				mxUtils.indexOf(this.pages,
+					page) + 1);
 		}
 	}
 	catch (e)

+ 0 - 21
src/main/webapp/js/grapheditor/Graph.js

@@ -4538,27 +4538,6 @@ Graph.prototype.updateHorizontalStyle = function(cell, style)
 	return style;
 };
 
-/**
- * Returns the cell style with no colors replaced.
- */
-Graph.prototype.getCellStyleWithDefaultColors = function(cell)
-{
-	// Temporary override color conversion
-	var replaceDefaultColors = this.replaceDefaultColors;
-
-	this.replaceDefaultColors = function(cell, style)
-	{
-		return style;
-	};
-
-	var result = this.getCellStyle(cell);
-
-	// Restores color conversion
-	this.replaceDefaultColors = replaceDefaultColors;
-
-	return result;
-};
-
 /**
  * Replaces default colors. 
  */

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

@@ -2253,7 +2253,7 @@ Sidebar.prototype.updateShapes = function(source, targets)
 			if ((graph.getModel().isVertex(targetCell) == graph.getModel().isVertex(source)) ||
 				(graph.getModel().isEdge(targetCell) == graph.getModel().isEdge(source)))
 			{
-				var style = graph.getCellStyleWithDefaultColors(targets[i]);
+				var style = graph.getCellStyle(targets[i], false);
 				graph.getModel().setStyle(targetCell, cellStyle);
 				
 				// Removes all children of composite cells

File diff suppressed because it is too large
+ 44 - 45
src/main/webapp/js/integrate.min.js


File diff suppressed because it is too large
+ 21 - 22
src/main/webapp/js/viewer-static.min.js


File diff suppressed because it is too large
+ 21 - 22
src/main/webapp/js/viewer.min.js


File diff suppressed because it is too large
+ 1 - 1
src/main/webapp/mxgraph/mxClient.js


File diff suppressed because it is too large
+ 1 - 1
src/main/webapp/service-worker.js


File diff suppressed because it is too large
+ 1 - 1
src/main/webapp/service-worker.js.map