parent
43314c85af
commit
b6e3b2fdc2
10 changed files with 531 additions and 506 deletions
|
@ -1,3 +1,10 @@
|
|||
09-JUL-2019: 10.9.2
|
||||
|
||||
- Fixes reset of handles after remote style changes
|
||||
- Fixes background color for rotated text editing
|
||||
- Improves command line export in Electron
|
||||
- Uses mxGraph 4.0.2 beta 3
|
||||
|
||||
09-JUL-2019: 10.9.1
|
||||
|
||||
- Fixes NPE in Electron and ChromeOS apps
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
10.9.1
|
||||
10.9.2
|
|
@ -1540,9 +1540,9 @@ mxVertexHandler.prototype.moveSizerTo=function(a,b,c){null!=a&&(a.bounds.x=Math.
|
|||
mxVertexHandler.prototype.getHandleForEvent=function(a){function b(b){return null!=b&&(a.isSource(b)||null!=d&&mxUtils.intersects(b.bounds,d)&&"none"!=b.node.style.display&&"hidden"!=b.node.style.visibility)}var c=mxEvent.isMouseEvent(a.getEvent())?1:this.tolerance,d=this.allowHandleBoundsCheck&&(mxClient.IS_IE||0<c)?new mxRectangle(a.getGraphX()-c,a.getGraphY()-c,2*c,2*c):null;if(null!=this.customHandles&&this.isCustomHandleEvent(a))for(c=this.customHandles.length-1;0<=c;c--)if(b(this.customHandles[c].shape))return mxEvent.CUSTOM_HANDLE-
|
||||
c;if(b(this.rotationShape))return mxEvent.ROTATION_HANDLE;if(b(this.labelShape))return mxEvent.LABEL_HANDLE;if(null!=this.sizers)for(c=0;c<this.sizers.length;c++)if(b(this.sizers[c]))return c;return null};mxVertexHandler.prototype.isCustomHandleEvent=function(a){return!0};
|
||||
mxVertexHandler.prototype.mouseDown=function(a,b){var c=mxEvent.isMouseEvent(b.getEvent())?0:this.tolerance;!b.isConsumed()&&this.graph.isEnabled()&&(0<c||b.getState()==this.state)&&(c=this.getHandleForEvent(b),null!=c&&(this.start(b.getGraphX(),b.getGraphY(),c),b.consume()))};mxVertexHandler.prototype.isLivePreviewBorder=function(){return null!=this.state.shape&&null==this.state.shape.fill&&null==this.state.shape.stroke};
|
||||
mxVertexHandler.prototype.start=function(a,b,c){this.inTolerance=!0;this.childOffsetY=this.childOffsetX=0;this.index=c;this.startX=a;this.startY=b;a=this.state.view.graph.model;b=a.getParent(this.state.cell);this.state.view.currentRoot!=b&&(a.isVertex(b)||a.isEdge(b))&&(this.parentState=this.state.view.graph.view.getState(b));this.selectionBorder.node.style.display=c==mxEvent.ROTATION_HANDLE?"inline":"none";if(!this.livePreview||this.isLivePreviewBorder())this.preview=this.createSelectionShape(this.bounds),
|
||||
mxClient.IS_SVG&&0!=Number(this.state.style[mxConstants.STYLE_ROTATION]||"0")||null==this.state.text||this.state.text.node.parentNode!=this.graph.container?(this.preview.dialect=this.graph.dialect!=mxConstants.DIALECT_SVG?mxConstants.DIALECT_VML:mxConstants.DIALECT_SVG,this.preview.init(this.graph.view.getOverlayPane())):(this.preview.dialect=mxConstants.DIALECT_STRICTHTML,this.preview.init(this.graph.container));if(this.livePreview)for(this.hideSizers(),c==mxEvent.ROTATION_HANDLE?this.rotationShape.node.style.display=
|
||||
"":c==mxEvent.LABEL_HANDLE?this.labelShape.node.style.display="":null!=this.sizers&&null!=this.sizers[c]?this.sizers[c].node.style.display="":c<=mxEvent.CUSTOM_HANDLE&&null!=this.customHandles&&this.customHandles[mxEvent.CUSTOM_HANDLE-c].setVisible(!0),c=this.graph.getEdges(this.state.cell),this.edgeHandlers=[],a=0;a<c.length;a++)b=this.graph.selectionCellsHandler.getHandler(c[a]),null!=b&&this.edgeHandlers.push(b)};
|
||||
mxVertexHandler.prototype.start=function(a,b,c){if(null!=this.selectionBorder){this.inTolerance=!0;this.childOffsetY=this.childOffsetX=0;this.index=c;this.startX=a;this.startY=b;a=this.state.view.graph.model;b=a.getParent(this.state.cell);this.state.view.currentRoot!=b&&(a.isVertex(b)||a.isEdge(b))&&(this.parentState=this.state.view.graph.view.getState(b));this.selectionBorder.node.style.display=c==mxEvent.ROTATION_HANDLE?"inline":"none";if(!this.livePreview||this.isLivePreviewBorder())this.preview=
|
||||
this.createSelectionShape(this.bounds),mxClient.IS_SVG&&0!=Number(this.state.style[mxConstants.STYLE_ROTATION]||"0")||null==this.state.text||this.state.text.node.parentNode!=this.graph.container?(this.preview.dialect=this.graph.dialect!=mxConstants.DIALECT_SVG?mxConstants.DIALECT_VML:mxConstants.DIALECT_SVG,this.preview.init(this.graph.view.getOverlayPane())):(this.preview.dialect=mxConstants.DIALECT_STRICTHTML,this.preview.init(this.graph.container));if(this.livePreview)for(this.hideSizers(),c==
|
||||
mxEvent.ROTATION_HANDLE?this.rotationShape.node.style.display="":c==mxEvent.LABEL_HANDLE?this.labelShape.node.style.display="":null!=this.sizers&&null!=this.sizers[c]?this.sizers[c].node.style.display="":c<=mxEvent.CUSTOM_HANDLE&&null!=this.customHandles&&this.customHandles[mxEvent.CUSTOM_HANDLE-c].setVisible(!0),c=this.graph.getEdges(this.state.cell),this.edgeHandlers=[],a=0;a<c.length;a++)b=this.graph.selectionCellsHandler.getHandler(c[a]),null!=b&&this.edgeHandlers.push(b)}};
|
||||
mxVertexHandler.prototype.setHandlesVisible=function(a){if(null!=this.sizers)for(var b=0;b<this.sizers.length;b++)this.sizers[b].node.style.display=a?"":"none";if(null!=this.customHandles)for(b=0;b<this.customHandles.length;b++)this.customHandles[b].setVisible(a)};mxVertexHandler.prototype.hideSizers=function(){this.setHandlesVisible(!1)};
|
||||
mxVertexHandler.prototype.checkTolerance=function(a){this.inTolerance&&null!=this.startX&&null!=this.startY&&(mxEvent.isMouseEvent(a.getEvent())||Math.abs(a.getGraphX()-this.startX)>this.graph.tolerance||Math.abs(a.getGraphY()-this.startY)>this.graph.tolerance)&&(this.inTolerance=!1)};mxVertexHandler.prototype.updateHint=function(a){};mxVertexHandler.prototype.removeHint=function(){};mxVertexHandler.prototype.roundAngle=function(a){return Math.round(10*a)/10};
|
||||
mxVertexHandler.prototype.roundLength=function(a){return Math.round(a)};
|
||||
|
@ -1558,8 +1558,8 @@ c=new mxPoint(this.bounds.getCenterX(),this.bounds.getCenterY());l=c.x-b.x;d=c.y
|
|||
0==b&&0==c?this.childOffsetY=this.childOffsetX=0:(this.childOffsetX=this.state.x-this.bounds.x+e,this.childOffsetY=this.state.y-this.bounds.y+g);this.livePreview&&this.updateLivePreview(a);null!=this.preview&&this.drawPreview()};
|
||||
mxVertexHandler.prototype.updateLivePreview=function(a){var b=this.graph.view.scale,c=this.graph.view.translate;a=this.state.clone();this.state.x=this.bounds.x;this.state.y=this.bounds.y;this.state.origin=new mxPoint(this.state.x/b-c.x,this.state.y/b-c.y);this.state.width=this.bounds.width;this.state.height=this.bounds.height;this.state.unscaledWidth=null;b=this.state.absoluteOffset;new mxPoint(b.x,b.y);this.state.absoluteOffset.x=0;this.state.absoluteOffset.y=0;b=this.graph.getCellGeometry(this.state.cell);
|
||||
null!=b&&(c=b.offset||this.EMPTY_POINT,null==c||b.relative||(this.state.absoluteOffset.x=this.state.view.scale*c.x,this.state.absoluteOffset.y=this.state.view.scale*c.y),this.state.view.updateVertexLabelOffset(this.state));this.state.view.graph.cellRenderer.redraw(this.state,!0);this.state.view.invalidate(this.state.cell);this.state.invalid=!1;this.state.view.validate();this.redrawHandles();this.state.setState(a)};
|
||||
mxVertexHandler.prototype.mouseUp=function(a,b){if(null!=this.index&&null!=this.state){var c=new mxPoint(b.getGraphX(),b.getGraphY());this.graph.getModel().beginUpdate();try{if(this.index<=mxEvent.CUSTOM_HANDLE)null!=this.customHandles&&(this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].active=!1,this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].execute());else if(this.index==mxEvent.ROTATION_HANDLE)if(null!=this.currentAlpha){var d=this.currentAlpha-(this.state.style[mxConstants.STYLE_ROTATION]||
|
||||
0);0!=d&&this.rotateCell(this.state.cell,d)}else this.rotateClick();else{var e=this.graph.isGridEnabledEvent(b.getEvent()),f=mxUtils.toRadians(this.state.style[mxConstants.STYLE_ROTATION]||"0"),g=Math.cos(-f),k=Math.sin(-f),l=c.x-this.startX,m=c.y-this.startY,c=k*l+g*m,l=g*l-k*m,m=c,n=this.graph.view.scale,p=this.isRecursiveResize(this.state,b);this.resizeCell(this.state.cell,this.roundLength(l/n),this.roundLength(m/n),this.index,e,this.isConstrainedEvent(b),p)}}finally{this.graph.getModel().endUpdate()}b.consume();
|
||||
mxVertexHandler.prototype.mouseUp=function(a,b){if(null!=this.index&&null!=this.state){var c=new mxPoint(b.getGraphX(),b.getGraphY()),d=this.index;this.index=null;this.graph.getModel().beginUpdate();try{if(d<=mxEvent.CUSTOM_HANDLE)null!=this.customHandles&&(this.customHandles[mxEvent.CUSTOM_HANDLE-d].active=!1,this.customHandles[mxEvent.CUSTOM_HANDLE-d].execute());else if(d==mxEvent.ROTATION_HANDLE)if(null!=this.currentAlpha){var e=this.currentAlpha-(this.state.style[mxConstants.STYLE_ROTATION]||
|
||||
0);0!=e&&this.rotateCell(this.state.cell,e)}else this.rotateClick();else{var f=this.graph.isGridEnabledEvent(b.getEvent()),g=mxUtils.toRadians(this.state.style[mxConstants.STYLE_ROTATION]||"0"),k=Math.cos(-g),l=Math.sin(-g),m=c.x-this.startX,n=c.y-this.startY,c=l*m+k*n,m=k*m-l*n,n=c,p=this.graph.view.scale,q=this.isRecursiveResize(this.state,b);this.resizeCell(this.state.cell,this.roundLength(m/p),this.roundLength(n/p),d,f,this.isConstrainedEvent(b),q)}}finally{this.graph.getModel().endUpdate()}b.consume();
|
||||
this.reset()}};mxVertexHandler.prototype.isRecursiveResize=function(a,b){return this.graph.isRecursiveResize(this.state)};mxVertexHandler.prototype.rotateClick=function(){};
|
||||
mxVertexHandler.prototype.rotateCell=function(a,b,c){if(0!=b){var d=this.graph.getModel();if(d.isVertex(a)||d.isEdge(a)){if(!d.isEdge(a)){var e=this.graph.view.getState(a),e=null!=e?e.style:this.graph.getCellStyle(a);null!=e&&this.graph.setCellStyles(mxConstants.STYLE_ROTATION,(e[mxConstants.STYLE_ROTATION]||0)+b,[a])}e=this.graph.getCellGeometry(a);if(null!=e){var f=this.graph.getCellGeometry(c);null==f||d.isEdge(c)||(e=e.clone(),e.rotate(b,new mxPoint(f.width/2,f.height/2)),d.setGeometry(a,e));
|
||||
if(d.isVertex(a)&&!e.relative||d.isEdge(a))for(c=d.getChildCount(a),e=0;e<c;e++)this.rotateCell(d.getChildAt(a,e),b,a)}}}};
|
||||
|
@ -1630,10 +1630,10 @@ mxEdgeHandler.prototype.mouseMove=function(a,b){if(null!=this.index&&null!=this.
|
|||
this.customHandles&&this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].processEvent(b);else if(this.isLabel)this.label.x=this.currentPoint.x,this.label.y=this.currentPoint.y;else{this.points=this.getPreviewPoints(this.currentPoint,b);var c=this.isSource||this.isTarget?this.getPreviewTerminalState(b):null;if(null!=this.constraintHandler.currentConstraint&&null!=this.constraintHandler.currentFocus&&null!=this.constraintHandler.currentPoint)this.currentPoint=this.constraintHandler.currentPoint.clone();
|
||||
else if(this.outlineConnect){var d=this.isSource||this.isTarget?this.isOutlineConnectEvent(b):!1;d?c=this.marker.highlight.state:null!=c&&c!=b.getState()&&null!=this.marker.highlight.shape&&(this.marker.highlight.shape.stroke="transparent",this.marker.highlight.repaint(),c=null)}null!=c&&this.graph.isCellLocked(c.cell)&&(c=null,this.marker.reset());var e=this.clonePreviewState(this.currentPoint,null!=c?c.cell:null);this.updatePreviewState(e,this.currentPoint,c,b,d);this.setPreviewColor(null==this.error?
|
||||
this.marker.validColor:this.marker.invalidColor);this.abspoints=e.absolutePoints;this.active=!0}this.updateHint(b,this.currentPoint);this.drawPreview();mxEvent.consume(b.getEvent());b.consume()}else mxClient.IS_IE&&null!=this.getHandleForEvent(b)&&b.consume(!1)};
|
||||
mxEdgeHandler.prototype.mouseUp=function(a,b){if(null!=this.index&&null!=this.marker){var c=this.state.cell;if(b.getX()!=this.startX||b.getY()!=this.startY){var d=!this.graph.isIgnoreTerminalEvent(b.getEvent())&&this.graph.isCloneEvent(b.getEvent())&&this.cloneEnabled&&this.graph.isCellsCloneable();if(null!=this.error)0<this.error.length&&this.graph.validationAlert(this.error);else if(this.index<=mxEvent.CUSTOM_HANDLE&&this.index>mxEvent.VIRTUAL_HANDLE){if(null!=this.customHandles){var e=this.graph.getModel();
|
||||
e.beginUpdate();try{this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].execute()}finally{e.endUpdate()}}}else if(this.isLabel)this.moveLabel(this.state,this.label.x,this.label.y);else if(this.isSource||this.isTarget){var f=null;null!=this.constraintHandler.currentConstraint&&null!=this.constraintHandler.currentFocus&&(f=this.constraintHandler.currentFocus.cell);null==f&&this.marker.hasValidState()&&null!=this.marker.highlight&&null!=this.marker.highlight.shape&&"transparent"!=this.marker.highlight.shape.stroke&&
|
||||
"white"!=this.marker.highlight.shape.stroke&&(f=this.marker.validState.cell);if(null!=f){var e=this.graph.getModel(),g=e.getParent(c);e.beginUpdate();try{if(d){var k=e.getGeometry(c),d=this.graph.cloneCell(c);e.add(g,d,e.getChildCount(g));null!=k&&(k=k.clone(),e.setGeometry(d,k));var l=e.getTerminal(c,!this.isSource);this.graph.connectCell(d,l,!this.isSource);c=d}c=this.connect(c,f,this.isSource,d,b)}finally{e.endUpdate()}}else this.graph.isAllowDanglingEdges()&&(e=this.abspoints[this.isSource?0:
|
||||
this.abspoints.length-1],e.x=this.roundLength(e.x/this.graph.view.scale-this.graph.view.translate.x),e.y=this.roundLength(e.y/this.graph.view.scale-this.graph.view.translate.y),f=this.graph.getView().getState(this.graph.getModel().getParent(c)),null!=f&&(e.x-=f.origin.x,e.y-=f.origin.y),e.x-=this.graph.panDx/this.graph.view.scale,e.y-=this.graph.panDy/this.graph.view.scale,c=this.changeTerminalPoint(c,e,this.isSource,d))}else this.active?c=this.changePoints(c,this.points,d):(this.graph.getView().invalidate(this.state.cell),
|
||||
mxEdgeHandler.prototype.mouseUp=function(a,b){if(null!=this.index&&null!=this.marker){var c=this.state.cell,d=this.index;this.index=null;if(b.getX()!=this.startX||b.getY()!=this.startY){var e=!this.graph.isIgnoreTerminalEvent(b.getEvent())&&this.graph.isCloneEvent(b.getEvent())&&this.cloneEnabled&&this.graph.isCellsCloneable();if(null!=this.error)0<this.error.length&&this.graph.validationAlert(this.error);else if(d<=mxEvent.CUSTOM_HANDLE&&d>mxEvent.VIRTUAL_HANDLE){if(null!=this.customHandles){var f=
|
||||
this.graph.getModel();f.beginUpdate();try{this.customHandles[mxEvent.CUSTOM_HANDLE-d].execute()}finally{f.endUpdate()}}}else if(this.isLabel)this.moveLabel(this.state,this.label.x,this.label.y);else if(this.isSource||this.isTarget)if(d=null,null!=this.constraintHandler.currentConstraint&&null!=this.constraintHandler.currentFocus&&(d=this.constraintHandler.currentFocus.cell),null==d&&this.marker.hasValidState()&&null!=this.marker.highlight&&null!=this.marker.highlight.shape&&"transparent"!=this.marker.highlight.shape.stroke&&
|
||||
"white"!=this.marker.highlight.shape.stroke&&(d=this.marker.validState.cell),null!=d){var f=this.graph.getModel(),g=f.getParent(c);f.beginUpdate();try{if(e){var k=f.getGeometry(c),e=this.graph.cloneCell(c);f.add(g,e,f.getChildCount(g));null!=k&&(k=k.clone(),f.setGeometry(e,k));var l=f.getTerminal(c,!this.isSource);this.graph.connectCell(e,l,!this.isSource);c=e}c=this.connect(c,d,this.isSource,e,b)}finally{f.endUpdate()}}else this.graph.isAllowDanglingEdges()&&(f=this.abspoints[this.isSource?0:this.abspoints.length-
|
||||
1],f.x=this.roundLength(f.x/this.graph.view.scale-this.graph.view.translate.x),f.y=this.roundLength(f.y/this.graph.view.scale-this.graph.view.translate.y),k=this.graph.getView().getState(this.graph.getModel().getParent(c)),null!=k&&(f.x-=k.origin.x,f.y-=k.origin.y),f.x-=this.graph.panDx/this.graph.view.scale,f.y-=this.graph.panDy/this.graph.view.scale,c=this.changeTerminalPoint(c,f,this.isSource,e));else this.active?c=this.changePoints(c,this.points,e):(this.graph.getView().invalidate(this.state.cell),
|
||||
this.graph.getView().validate(this.state.cell))}null!=this.marker&&(this.reset(),c!=this.state.cell&&this.graph.setSelectionCell(c));b.consume()}};
|
||||
mxEdgeHandler.prototype.reset=function(){this.active&&this.refresh();this.snapPoint=this.points=this.label=this.index=this.error=null;this.active=this.isTarget=this.isSource=this.isLabel=!1;if(this.livePreview&&null!=this.sizers)for(var a=0;a<this.sizers.length;a++)null!=this.sizers[a]&&(this.sizers[a].node.style.display="");null!=this.marker&&this.marker.reset();null!=this.constraintHandler&&this.constraintHandler.reset();if(null!=this.customHandles)for(a=0;a<this.customHandles.length;a++)this.customHandles[a].reset();
|
||||
this.setPreviewColor(mxConstants.EDGE_SELECTION_COLOR);this.removeHint();this.redraw()};mxEdgeHandler.prototype.setPreviewColor=function(a){null!=this.shape&&(this.shape.stroke=a)};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CACHE MANIFEST
|
||||
|
||||
# THIS FILE WAS GENERATED. DO NOT MODIFY!
|
||||
# 07/09/2019 07:25 AM
|
||||
# 07/09/2019 03:09 PM
|
||||
|
||||
app.html
|
||||
index.html?offline=1
|
||||
|
|
|
@ -325,8 +325,8 @@ app.on('ready', e =>
|
|||
{
|
||||
var filePath = path.join(dir, file);
|
||||
stat = fs.statSync(filePath);
|
||||
|
||||
if (stat.isFile())
|
||||
|
||||
if (stat.isFile() && path.basename(filePath).charAt(0) != '.')
|
||||
{
|
||||
files.push(filePath);
|
||||
}
|
||||
|
@ -356,7 +356,12 @@ app.on('ready', e =>
|
|||
|
||||
try
|
||||
{
|
||||
expArgs.xml = fs.readFileSync(curFile, 'utf-8');
|
||||
expArgs.xml = fs.readFileSync(curFile, (path.extname(curFile) === '.png') ? null : 'utf-8');
|
||||
|
||||
if (path.extname(curFile) === '.png')
|
||||
{
|
||||
expArgs.xml = new Buffer(expArgs.xml).toString('base64');
|
||||
}
|
||||
|
||||
var mockEvent = {
|
||||
reply: function(msg, data)
|
||||
|
@ -375,7 +380,7 @@ app.on('ready', e =>
|
|||
{
|
||||
if (outType.isDir)
|
||||
{
|
||||
outFileName = path.join(program.output, path.basename(curFile, path.extname(curFile))) + '.' + format;
|
||||
outFileName = path.join(program.output, path.basename(curFile)) + '.' + format;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -384,11 +389,11 @@ app.on('ready', e =>
|
|||
}
|
||||
else if (inStat.isFile())
|
||||
{
|
||||
outFileName = path.join(path.dirname(paths[0]), path.basename(paths[0], path.extname(paths[0]))) + '.' + format;
|
||||
outFileName = path.join(path.dirname(paths[0]), path.basename(paths[0])) + '.' + format;
|
||||
}
|
||||
else //dir
|
||||
{
|
||||
outFileName = path.join(path.dirname(curFile), path.basename(curFile, path.extname(curFile))) + '.' + format;
|
||||
outFileName = path.join(path.dirname(curFile), path.basename(curFile)) + '.' + format;
|
||||
}
|
||||
|
||||
try
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
catch(e){}
|
||||
|
||||
//PNG+XML format
|
||||
if (extras != null && extras.isPng)
|
||||
if (data.xml.substring(0, 5) == 'iVBOR' || (extras != null && extras.isPng))
|
||||
{
|
||||
var pngData = 'data:image/png;base64,' + data.xml;
|
||||
//A hacky way to invoke extractGraphModelFromPng without EditorUi instance
|
||||
|
@ -61,8 +61,27 @@
|
|||
}
|
||||
|
||||
// Parses XML
|
||||
var xmlDoc = mxUtils.parseXml(data.xml);
|
||||
var doc = mxUtils.parseXml(data.xml);
|
||||
var node = Editor.extractGraphModel(doc.documentElement, true);
|
||||
|
||||
if (node == null)
|
||||
{
|
||||
//Electron pdf export
|
||||
try
|
||||
{
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
ipcRenderer.send('render-finished', null);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
var xmlDoc = node.ownerDocument;
|
||||
var diagrams = null;
|
||||
var from = 0;
|
||||
|
||||
|
@ -577,47 +596,32 @@
|
|||
renderMath(document.body);
|
||||
// Immediate return if not waiting for any content
|
||||
decrementWaitCounter();
|
||||
|
||||
return graph;
|
||||
};
|
||||
|
||||
//Code taken from https://github.com/languitar/drawio-batch
|
||||
//Must be called after rendering is finished
|
||||
function getSvgData()
|
||||
/**
|
||||
* Returns the exported SVG for the given graph (see EditorUi.exportSvg).
|
||||
*/
|
||||
function getSvgData(graph)
|
||||
{
|
||||
// extracts the inline SVG element used for rendering the diagram and puts it into a file with appropriate SVG headers
|
||||
|
||||
// get the rendered page content as valid SVG
|
||||
const xmlns = 'http://www.w3.org/2000/xmlns/'
|
||||
const xlinkns = 'http://www.w3.org/1999/xlink'
|
||||
const svgns = 'http://www.w3.org/2000/svg'
|
||||
|
||||
svg = document.getElementsByTagName('svg')[0]
|
||||
svg.setAttribute('version', '1.1')
|
||||
|
||||
var defsEl = document.createElement('defs')
|
||||
svg.insertBefore(defsEl, svg.firstChild)
|
||||
|
||||
var styleEl = document.createElement('style')
|
||||
defsEl.appendChild(styleEl)
|
||||
styleEl.setAttribute('type', 'text/css')
|
||||
|
||||
// removing attributes so they aren't doubled up
|
||||
svg.removeAttribute('xmlns')
|
||||
svg.removeAttribute('xlink')
|
||||
|
||||
// These are needed for the svg
|
||||
if (!svg.hasAttributeNS(xmlns, 'xmlns')) {
|
||||
svg.setAttributeNS(xmlns, 'xmlns', svgns)
|
||||
}
|
||||
|
||||
if (!svg.hasAttributeNS(xmlns, 'xmlns:xlink')) {
|
||||
svg.setAttributeNS(xmlns, 'xmlns:xlink', xlinkns)
|
||||
}
|
||||
|
||||
//This page(code) is designed for Chrome (Puppeteer or Electron) which supports this
|
||||
var source = (new XMLSerializer()).serializeToString(svg);
|
||||
|
||||
return '<?xml version="1.0" standalone="no"?>\r\n' + source;
|
||||
}
|
||||
var bg = graph.background;
|
||||
|
||||
if (bg == mxConstants.NONE)
|
||||
{
|
||||
bg = null;
|
||||
}
|
||||
|
||||
var svgRoot = graph.getSvg(bg, 1, 0, false, null, true, null, null, null);
|
||||
|
||||
if (graph.shadowVisible)
|
||||
{
|
||||
graph.addSvgShadow(svgRoot);
|
||||
}
|
||||
|
||||
return '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
||||
mxUtils.getXml(svgRoot);
|
||||
};
|
||||
|
||||
//Electron pdf export
|
||||
if (mxIsElectron)
|
||||
|
@ -625,15 +629,16 @@
|
|||
try
|
||||
{
|
||||
const { ipcRenderer } = require('electron');
|
||||
var graph = null;
|
||||
|
||||
ipcRenderer.on('render', (event, arg) =>
|
||||
{
|
||||
render(arg);
|
||||
graph = render(arg);
|
||||
});
|
||||
|
||||
ipcRenderer.on('get-svg-data', (event, arg) =>
|
||||
{
|
||||
ipcRenderer.send('svg-data', getSvgData());
|
||||
ipcRenderer.send('svg-data', getSvgData(graph));
|
||||
});
|
||||
}
|
||||
catch(e)
|
||||
|
@ -645,5 +650,4 @@
|
|||
</head>
|
||||
<body style="margin:0px;">
|
||||
<div id="graph" style="width:100%;height:100%;"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
270
src/main/webapp/js/app.min.js
vendored
270
src/main/webapp/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -313,7 +313,123 @@
|
|||
'Edward Morrison,Brand Manager,emo,Office 2,Evan Miller,me@example.com,#d5e8d4,#82b366,,https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-10-3-128.png\n' +
|
||||
'Ron Donovan,System Admin,rdo,Office 3,Evan Miller,me@example.com,#d5e8d4,#82b366,"emo,tva",https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-2-128.png\n' +
|
||||
'Tessa Valet,HR Director,tva,Office 4,Evan Miller,me@example.com,#d5e8d4,#82b366,,https://www.draw.io,https://cdn3.iconfinder.com/data/icons/user-avatars-1/512/users-3-128.png\n';
|
||||
|
||||
/**
|
||||
* Helper function to extract the graph model XML node.
|
||||
*/
|
||||
Editor.extractGraphModel = function(node, allowMxFile)
|
||||
{
|
||||
if (node != null && typeof(pako) !== 'undefined')
|
||||
{
|
||||
var tmp = node.ownerDocument.getElementsByTagName('div');
|
||||
var divs = [];
|
||||
|
||||
if (tmp != null && tmp.length > 0)
|
||||
{
|
||||
for (var i = 0; i < tmp.length; i++)
|
||||
{
|
||||
if (tmp[i].getAttribute('class') == 'mxgraph')
|
||||
{
|
||||
divs.push(tmp[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (divs.length > 0)
|
||||
{
|
||||
var data = divs[0].getAttribute('data-mxgraph');
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
var config = JSON.parse(data);
|
||||
|
||||
if (config != null && config.xml != null)
|
||||
{
|
||||
var doc2 = mxUtils.parseXml(config.xml);
|
||||
node = doc2.documentElement;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var divs2 = divs[0].getElementsByTagName('div');
|
||||
|
||||
if (divs2.length > 0)
|
||||
{
|
||||
var data = mxUtils.getTextContent(divs2[0]);
|
||||
data = Graph.decompress(data);
|
||||
|
||||
if (data.length > 0)
|
||||
{
|
||||
var doc2 = mxUtils.parseXml(data);
|
||||
node = doc2.documentElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node != null && node.nodeName == 'svg')
|
||||
{
|
||||
var tmp = node.getAttribute('content');
|
||||
|
||||
if (tmp != null && tmp.charAt(0) != '<' && tmp.charAt(0) != '%')
|
||||
{
|
||||
tmp = unescape((window.atob) ? atob(tmp) : Base64.decode(cont, tmp));
|
||||
}
|
||||
|
||||
if (tmp != null && tmp.charAt(0) == '%')
|
||||
{
|
||||
tmp = decodeURIComponent(tmp);
|
||||
}
|
||||
|
||||
if (tmp != null && tmp.length > 0)
|
||||
{
|
||||
node = mxUtils.parseXml(tmp).documentElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw {message: mxResources.get('notADiagramFile')};
|
||||
}
|
||||
}
|
||||
|
||||
if (node != null && !allowMxFile)
|
||||
{
|
||||
var diagramNode = null;
|
||||
|
||||
if (node.nodeName == 'diagram')
|
||||
{
|
||||
diagramNode = node;
|
||||
}
|
||||
else if (node.nodeName == 'mxfile')
|
||||
{
|
||||
var diagrams = node.getElementsByTagName('diagram');
|
||||
|
||||
if (diagrams.length > 0)
|
||||
{
|
||||
diagramNode = diagrams[Math.max(0, Math.min(diagrams.length - 1, urlParams['page'] || 0))];
|
||||
}
|
||||
}
|
||||
|
||||
if (diagramNode != null)
|
||||
{
|
||||
var tmp = Graph.decompress(mxUtils.getTextContent(diagramNode));
|
||||
|
||||
if (tmp != null && tmp.length > 0)
|
||||
{
|
||||
node = mxUtils.parseXml(tmp).documentElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node != null && node.nodeName != 'mxGraphModel' && (!allowMxFile || node.nodeName != 'mxfile'))
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
|
||||
return node;
|
||||
};
|
||||
|
||||
/**
|
||||
* Disables the shadow option in the format panel.
|
||||
*/
|
||||
|
@ -679,115 +795,7 @@
|
|||
*/
|
||||
Editor.prototype.extractGraphModel = function(node, allowMxFile)
|
||||
{
|
||||
if (node != null && typeof(pako) !== 'undefined')
|
||||
{
|
||||
var tmp = node.ownerDocument.getElementsByTagName('div');
|
||||
var divs = [];
|
||||
|
||||
if (tmp != null && tmp.length > 0)
|
||||
{
|
||||
for (var i = 0; i < tmp.length; i++)
|
||||
{
|
||||
if (tmp[i].getAttribute('class') == 'mxgraph')
|
||||
{
|
||||
divs.push(tmp[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (divs.length > 0)
|
||||
{
|
||||
var data = divs[0].getAttribute('data-mxgraph');
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
var config = JSON.parse(data);
|
||||
|
||||
if (config != null && config.xml != null)
|
||||
{
|
||||
var doc2 = mxUtils.parseXml(config.xml);
|
||||
node = doc2.documentElement;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var divs2 = divs[0].getElementsByTagName('div');
|
||||
|
||||
if (divs2.length > 0)
|
||||
{
|
||||
var data = mxUtils.getTextContent(divs2[0]);
|
||||
data = Graph.decompress(data);
|
||||
|
||||
if (data.length > 0)
|
||||
{
|
||||
var doc2 = mxUtils.parseXml(data);
|
||||
node = doc2.documentElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node != null && node.nodeName == 'svg')
|
||||
{
|
||||
var tmp = node.getAttribute('content');
|
||||
|
||||
if (tmp != null && tmp.charAt(0) != '<' && tmp.charAt(0) != '%')
|
||||
{
|
||||
tmp = unescape((window.atob) ? atob(tmp) : Base64.decode(cont, tmp));
|
||||
}
|
||||
|
||||
if (tmp != null && tmp.charAt(0) == '%')
|
||||
{
|
||||
tmp = decodeURIComponent(tmp);
|
||||
}
|
||||
|
||||
if (tmp != null && tmp.length > 0)
|
||||
{
|
||||
node = mxUtils.parseXml(tmp).documentElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw {message: mxResources.get('notADiagramFile')};
|
||||
}
|
||||
}
|
||||
|
||||
if (node != null && !allowMxFile)
|
||||
{
|
||||
var diagramNode = null;
|
||||
|
||||
if (node.nodeName == 'diagram')
|
||||
{
|
||||
diagramNode = node;
|
||||
}
|
||||
else if (node.nodeName == 'mxfile')
|
||||
{
|
||||
var diagrams = node.getElementsByTagName('diagram');
|
||||
|
||||
if (diagrams.length > 0)
|
||||
{
|
||||
diagramNode = diagrams[Math.max(0, Math.min(diagrams.length - 1, urlParams['page'] || 0))];
|
||||
}
|
||||
}
|
||||
|
||||
if (diagramNode != null)
|
||||
{
|
||||
var tmp = Graph.decompress(mxUtils.getTextContent(diagramNode));
|
||||
|
||||
if (tmp != null && tmp.length > 0)
|
||||
{
|
||||
node = mxUtils.parseXml(tmp).documentElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node != null && node.nodeName != 'mxGraphModel' && (!allowMxFile || node.nodeName != 'mxfile'))
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
|
||||
return node;
|
||||
return Editor.extractGraphModel.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -4479,7 +4479,7 @@ HoverIcons.prototype.setCurrentState = function(state)
|
|||
var shape = mxUtils.getValue(state.style, mxConstants.STYLE_SHAPE, null);
|
||||
|
||||
// Extracts and decodes stencil XML if shape has the form shape=stencil(value)
|
||||
if (shape != null && shape.substring(0, 8) == 'stencil(')
|
||||
if (shape != null && typeof shape === 'string' && shape.substring(0, 8) == 'stencil(')
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -4610,7 +4610,7 @@ mxStencilRegistry.getBasenameForStencil = function(name)
|
|||
{
|
||||
var tmp = null;
|
||||
|
||||
if (name != null)
|
||||
if (name != null && typeof name === 'string')
|
||||
{
|
||||
var parts = name.split('.');
|
||||
|
||||
|
@ -7189,7 +7189,7 @@ if (typeof mxVertexHandler != 'undefined')
|
|||
|
||||
return guide;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* HTML in-place editor
|
||||
*/
|
||||
|
@ -7365,8 +7365,6 @@ if (typeof mxVertexHandler != 'undefined')
|
|||
{
|
||||
checkNode(this.textarea, clone);
|
||||
}
|
||||
|
||||
this.textarea.innerHTML = this.graph.sanitizeHtml(this.textarea.innerHTML, true);
|
||||
}), 0);
|
||||
}));
|
||||
}
|
||||
|
@ -7649,23 +7647,26 @@ if (typeof mxVertexHandler != 'undefined')
|
|||
this.graph.getModel().endUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the background color to be used for the editing box. This returns
|
||||
* the label background for edge labels and null for all other cases.
|
||||
*/
|
||||
mxCellEditor.prototype.getBackgroundColor = function(state)
|
||||
{
|
||||
var color = null;
|
||||
|
||||
if (this.graph.getModel().isEdge(state.cell) || this.graph.getModel().isEdge(this.graph.getModel().getParent(state.cell)))
|
||||
var color = mxUtils.getValue(state.style, mxConstants.STYLE_LABEL_BACKGROUNDCOLOR, null);
|
||||
|
||||
if ((color == null || color == mxConstants.NONE) &&
|
||||
(state.cell.geometry != null && state.cell.geometry.width > 0) &&
|
||||
(mxUtils.getValue(state.style, mxConstants.STYLE_ROTATION, 0) != 0 ||
|
||||
mxUtils.getValue(state.style, mxConstants.STYLE_HORIZONTAL, 1) == 0))
|
||||
{
|
||||
var color = mxUtils.getValue(state.style, mxConstants.STYLE_LABEL_BACKGROUNDCOLOR, null);
|
||||
|
||||
if (color == mxConstants.NONE)
|
||||
{
|
||||
color = null;
|
||||
}
|
||||
color = mxUtils.getValue(state.style, mxConstants.STYLE_FILLCOLOR, null);
|
||||
}
|
||||
|
||||
if (color == mxConstants.NONE)
|
||||
{
|
||||
color = null;
|
||||
}
|
||||
|
||||
return color;
|
||||
|
|
374
src/main/webapp/js/viewer.min.js
vendored
374
src/main/webapp/js/viewer.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue