I am using the LocalStorageCommandHandler so that I can copy parts between tabs; however, the links lose all their data. For example, the name (i.e. text) for the link and the arrow heads default to the original instead of what the copied version was. I noticed that the data is still there all the way up until copymap in the code below, but disappears when adding all the information to the set. Is there a way to keep the data on copy/paste?
LocalStorageCommandHandler.prototype.pasteFromClipboard = function() {
var coll = new go.Set(/*go.Part*/);
try {
var diagram = allDiagrams[0];
var clipstr = window.localStorage.getItem(this.StorageKey);
var clipfrmt = window.localStorage.getItem(this.FormatKey);
if (clipstr === null || clipstr === '' || clipfrmt !== diagram.model.dataFormat) {
return coll;
} else {
var clipdiag = new go.Diagram(); // create a temporary Diagram
// recover the model from the clipboard rendering
clipdiag.model = go.Model.fromJson(clipstr);
// copy all the CLIPDIAG Parts into this Diagram
var all = new go.List().addAll(clipdiag.parts).addAll(clipdiag.nodes).addAll(clipdiag.links);
var copymap = diagram.copyParts(all, diagram, false);
// return a Set of the copied Parts
console.log(new go.Set(/*go.Part*/).addAll(copymap.iteratorValues));
return new go.Set(/*go.Part*/).addAll(copymap.iteratorValues);
}
} catch (ex) {
// fallback implementation
return go.CommandHandler.prototype.pasteFromClipboard.call(this);
}
};
This is an example of what it is currently doing. The top is the original and the bottom is the copy: