|
|
@@ -30,20 +30,20 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
window.openNew = true;
|
|
|
window.openKey = 'open';
|
|
|
-
|
|
|
+
|
|
|
ui.openFile();
|
|
|
});
|
|
|
this.addAction('import...', function()
|
|
|
{
|
|
|
window.openNew = false;
|
|
|
window.openKey = 'import';
|
|
|
-
|
|
|
+
|
|
|
// Closes dialog after open
|
|
|
window.openFile = new OpenFile(mxUtils.bind(this, function()
|
|
|
{
|
|
|
ui.hideDialog();
|
|
|
}));
|
|
|
-
|
|
|
+
|
|
|
window.openFile.setConsumer(mxUtils.bind(this, function(xml, filename)
|
|
|
{
|
|
|
try
|
|
|
@@ -65,7 +65,16 @@ Actions.prototype.init = function()
|
|
|
}).isEnabled = isGraphEnabled;
|
|
|
//this.addAction('exportAs', function() { ui.savePng(); }, null, null, Editor.ctrlKey + '+Shift+S').isEnabled = isGraphEnabled;
|
|
|
this.addAction('exportAsPng', function() { ui.savePng(); }, null, null, ).isEnabled = isGraphEnabled;
|
|
|
- this.addAction('exportAsXml', function() { ui.saveXml(); }, null, null, ).isEnabled = isGraphEnabled;
|
|
|
+ this.addAction('exportAsXml', function () {
|
|
|
+ // 1. 获取当前绘图的 XML 数据(draw.io 核心 API)
|
|
|
+ var xml = editor.getGraphXml(); // editor 是当前绘图编辑器实例
|
|
|
+ // 2. 存储 XML 到 window 全局变量(供外部调用)
|
|
|
+ window.drawIoXml = xml;
|
|
|
+ // 3. 触发自定义事件(通知父页面 XML 已就绪)
|
|
|
+ window.dispatchEvent(new CustomEvent('xmlReady', { detail: xml }));
|
|
|
+ // 4. 保留原下载逻辑(可选)
|
|
|
+ ui.saveXml();
|
|
|
+ }, null, null,).isEnabled = isGraphEnabled;
|
|
|
this.addAction('xmlImport', function()
|
|
|
{
|
|
|
var dlg = new EditDiagramDialog(ui);
|
|
|
@@ -75,7 +84,7 @@ Actions.prototype.init = function()
|
|
|
//this.addAction('pageSetup...', function() { ui.showDialog(new PageSetupDialog(ui).container, 320, 220, true, true); }).isEnabled = isGraphEnabled;
|
|
|
this.addAction('print...', function() { ui.showDialog(new PrintDialog(ui).container, 300, 180, true, true); }, null, 'sprite-print', Editor.ctrlKey + '+P');
|
|
|
this.addAction('preview', function() { mxUtils.show(graph, null, 10, 10); });
|
|
|
-
|
|
|
+
|
|
|
// Edit actions
|
|
|
this.addAction('undo', function() { ui.undo(); }, null, 'sprite-undo', Editor.ctrlKey + '+Z');
|
|
|
this.addAction('redo', function() { ui.redo(); }, null, 'sprite-redo', (!mxClient.IS_WIN) ? Editor.ctrlKey + '+Shift+Z' : Editor.ctrlKey + '+Y');
|
|
|
@@ -96,11 +105,11 @@ Actions.prototype.init = function()
|
|
|
try
|
|
|
{
|
|
|
var cells = mxClipboard.paste(graph);
|
|
|
-
|
|
|
+
|
|
|
if (cells != null)
|
|
|
{
|
|
|
var includeEdges = true;
|
|
|
-
|
|
|
+
|
|
|
for (var i = 0; i < cells.length && includeEdges; i++)
|
|
|
{
|
|
|
includeEdges = includeEdges && graph.model.isEdge(cells[i]);
|
|
|
@@ -111,11 +120,11 @@ Actions.prototype.init = function()
|
|
|
var dx = t.x;
|
|
|
var dy = t.y;
|
|
|
var bb = null;
|
|
|
-
|
|
|
+
|
|
|
if (cells.length == 1 && includeEdges)
|
|
|
{
|
|
|
var geo = graph.getCellGeometry(cells[0]);
|
|
|
-
|
|
|
+
|
|
|
if (geo != null)
|
|
|
{
|
|
|
bb = geo.getTerminalPoint(true);
|
|
|
@@ -123,12 +132,12 @@ Actions.prototype.init = function()
|
|
|
}
|
|
|
|
|
|
bb = (bb != null) ? bb : graph.getBoundingBoxFromGeometry(cells, includeEdges);
|
|
|
-
|
|
|
+
|
|
|
if (bb != null)
|
|
|
{
|
|
|
var x = Math.round(graph.snap(graph.popupMenuHandler.triggerX / s - dx));
|
|
|
var y = Math.round(graph.snap(graph.popupMenuHandler.triggerY / s - dy));
|
|
|
-
|
|
|
+
|
|
|
graph.cellsMoved(cells, x - bb.x, y - bb.y);
|
|
|
}
|
|
|
}
|
|
|
@@ -139,15 +148,15 @@ Actions.prototype.init = function()
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
this.addAction('copySize', function(evt)
|
|
|
{
|
|
|
var cell = graph.getSelectionCell();
|
|
|
-
|
|
|
+
|
|
|
if (graph.isEnabled() && cell != null && graph.getModel().isVertex(cell))
|
|
|
{
|
|
|
var geo = graph.getCellGeometry(cell);
|
|
|
-
|
|
|
+
|
|
|
if (geo != null)
|
|
|
{
|
|
|
ui.copiedSize = new mxRectangle(geo.x, geo.y, geo.width, geo.height);
|
|
|
@@ -160,23 +169,23 @@ Actions.prototype.init = function()
|
|
|
if (graph.isEnabled() && !graph.isSelectionEmpty() && ui.copiedSize != null)
|
|
|
{
|
|
|
graph.getModel().beginUpdate();
|
|
|
-
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
var cells = graph.getSelectionCells();
|
|
|
-
|
|
|
+
|
|
|
for (var i = 0; i < cells.length; i++)
|
|
|
{
|
|
|
if (graph.getModel().isVertex(cells[i]))
|
|
|
{
|
|
|
var geo = graph.getCellGeometry(cells[i]);
|
|
|
-
|
|
|
+
|
|
|
if (geo != null)
|
|
|
{
|
|
|
geo = geo.clone();
|
|
|
geo.width = ui.copiedSize.width;
|
|
|
geo.height = ui.copiedSize.height;
|
|
|
-
|
|
|
+
|
|
|
graph.getModel().setGeometry(cells[i], geo);
|
|
|
}
|
|
|
}
|
|
|
@@ -188,23 +197,23 @@ Actions.prototype.init = function()
|
|
|
}
|
|
|
}
|
|
|
}, null, null, 'Alt+Shit+V');
|
|
|
-
|
|
|
+
|
|
|
function deleteCells(includeEdges)
|
|
|
{
|
|
|
// Cancels interactive operations
|
|
|
graph.escape();
|
|
|
var cells = graph.getDeletableCells(graph.getSelectionCells());
|
|
|
-
|
|
|
+
|
|
|
if (cells != null && cells.length > 0)
|
|
|
{
|
|
|
var parents = graph.model.getParents(cells);
|
|
|
graph.removeCells(cells, includeEdges);
|
|
|
-
|
|
|
+
|
|
|
// Selects parents for easier editing of groups
|
|
|
if (parents != null)
|
|
|
{
|
|
|
var select = [];
|
|
|
-
|
|
|
+
|
|
|
for (var i = 0; i < parents.length; i++)
|
|
|
{
|
|
|
if (graph.model.contains(parents[i]) &&
|
|
|
@@ -214,12 +223,12 @@ Actions.prototype.init = function()
|
|
|
select.push(parents[i]);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
graph.setSelectionCells(select);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
this.addAction('delete', function(evt)
|
|
|
{
|
|
|
deleteCells(evt != null && mxEvent.isShiftDown(evt));
|
|
|
@@ -268,7 +277,7 @@ Actions.prototype.init = function()
|
|
|
this.addAction('enterGroup', function() { graph.enterGroup(); }, null, null, Editor.ctrlKey + '+Shift+End');
|
|
|
this.addAction('collapse', function() { graph.foldCells(true); }, null, null, Editor.ctrlKey + '+Home');
|
|
|
this.addAction('expand', function() { graph.foldCells(false); }, null, null, Editor.ctrlKey + '+End');
|
|
|
-
|
|
|
+
|
|
|
// Arrange actions
|
|
|
this.addAction('toFront', function() { graph.orderCells(false); }, null, null, Editor.ctrlKey + '+Shift+F');
|
|
|
this.addAction('toBack', function() { graph.orderCells(true); }, null, null, Editor.ctrlKey + '+Shift+B');
|
|
|
@@ -311,22 +320,22 @@ Actions.prototype.init = function()
|
|
|
this.addAction('editTooltip...', function()
|
|
|
{
|
|
|
var graph = ui.editor.graph;
|
|
|
-
|
|
|
+
|
|
|
if (graph.isEnabled() && !graph.isSelectionEmpty())
|
|
|
{
|
|
|
var cell = graph.getSelectionCell();
|
|
|
var tooltip = '';
|
|
|
-
|
|
|
+
|
|
|
if (mxUtils.isNode(cell.value))
|
|
|
{
|
|
|
var tmp = cell.value.getAttribute('tooltip');
|
|
|
-
|
|
|
+
|
|
|
if (tmp != null)
|
|
|
{
|
|
|
tooltip = tmp;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var dlg = new TextareaDialog(ui, mxResources.get('editTooltip') + ':', tooltip, function(newValue)
|
|
|
{
|
|
|
graph.setTooltipForCell(cell, newValue);
|
|
|
@@ -338,7 +347,7 @@ Actions.prototype.init = function()
|
|
|
this.addAction('openLink', function()
|
|
|
{
|
|
|
var link = graph.getLinkForCell(graph.getSelectionCell());
|
|
|
-
|
|
|
+
|
|
|
if (link != null)
|
|
|
{
|
|
|
graph.openLink(link);
|
|
|
@@ -347,12 +356,12 @@ Actions.prototype.init = function()
|
|
|
this.addAction('editLink...', function()
|
|
|
{
|
|
|
var graph = ui.editor.graph;
|
|
|
-
|
|
|
+
|
|
|
if (graph.isEnabled() && !graph.isSelectionEmpty())
|
|
|
{
|
|
|
var cell = graph.getSelectionCell();
|
|
|
var value = graph.getLinkForCell(cell) || '';
|
|
|
-
|
|
|
+
|
|
|
ui.showLinkDialog(value, mxResources.get('apply'), function(link)
|
|
|
{
|
|
|
link = mxUtils.trim(link);
|
|
|
@@ -367,24 +376,24 @@ Actions.prototype.init = function()
|
|
|
ui.showLinkDialog('', mxResources.get('insert'), function(link, docs)
|
|
|
{
|
|
|
link = mxUtils.trim(link);
|
|
|
-
|
|
|
+
|
|
|
if (link.length > 0)
|
|
|
{
|
|
|
var icon = null;
|
|
|
var title = graph.getLinkTitle(link);
|
|
|
-
|
|
|
+
|
|
|
if (docs != null && docs.length > 0)
|
|
|
{
|
|
|
icon = docs[0].iconUrl;
|
|
|
title = docs[0].name || docs[0].type;
|
|
|
title = title.charAt(0).toUpperCase() + title.substring(1);
|
|
|
-
|
|
|
+
|
|
|
if (title.length > 30)
|
|
|
{
|
|
|
title = title.substring(0, 30) + '...';
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var pt = graph.getFreeInsertPoint();
|
|
|
var linkCell = new mxCell(title, new mxGeometry(pt.x, pt.y, 100, 40),
|
|
|
'fontColor=#0000EE;fontStyle=4;rounded=1;overflow=hidden;' + ((icon != null) ?
|
|
|
@@ -405,7 +414,7 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
graph.getModel().endUpdate();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
graph.setSelectionCell(linkCell);
|
|
|
graph.scrollCellToVisible(graph.getSelectionCell());
|
|
|
}
|
|
|
@@ -415,7 +424,7 @@ Actions.prototype.init = function()
|
|
|
this.addAction('link...', mxUtils.bind(this, function()
|
|
|
{
|
|
|
var graph = ui.editor.graph;
|
|
|
-
|
|
|
+
|
|
|
if (graph.isEnabled())
|
|
|
{
|
|
|
if (graph.cellEditor.isContentEditing())
|
|
|
@@ -423,7 +432,7 @@ Actions.prototype.init = function()
|
|
|
var elt = graph.getSelectedElement();
|
|
|
var link = graph.getParentByName(elt, 'A', graph.cellEditor.textarea);
|
|
|
var oldValue = '';
|
|
|
-
|
|
|
+
|
|
|
// Workaround for FF returning the outermost selected element after double
|
|
|
// click on a DOM hierarchy with a link inside (but not as topmost element)
|
|
|
if (link == null && elt != null && elt.getElementsByTagName != null)
|
|
|
@@ -431,7 +440,7 @@ Actions.prototype.init = function()
|
|
|
// Finds all links in the selected DOM and uses the link
|
|
|
// where the selection text matches its text content
|
|
|
var links = elt.getElementsByTagName('a');
|
|
|
-
|
|
|
+
|
|
|
for (var i = 0; i < links.length && link == null; i++)
|
|
|
{
|
|
|
if (links[i].textContent == elt.textContent)
|
|
|
@@ -446,9 +455,9 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
oldValue = link.getAttribute('href') || '';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var selState = graph.cellEditor.saveSelection();
|
|
|
-
|
|
|
+
|
|
|
ui.showLinkDialog(oldValue, mxResources.get('apply'), mxUtils.bind(this, function(value)
|
|
|
{
|
|
|
graph.cellEditor.restoreSelection(selState);
|
|
|
@@ -472,7 +481,7 @@ Actions.prototype.init = function()
|
|
|
this.addAction('autosize', function()
|
|
|
{
|
|
|
var cells = graph.getSelectionCells();
|
|
|
-
|
|
|
+
|
|
|
if (cells != null)
|
|
|
{
|
|
|
graph.getModel().beginUpdate();
|
|
|
@@ -481,7 +490,7 @@ Actions.prototype.init = function()
|
|
|
for (var i = 0; i < cells.length; i++)
|
|
|
{
|
|
|
var cell = cells[i];
|
|
|
-
|
|
|
+
|
|
|
if (graph.getModel().getChildCount(cell))
|
|
|
{
|
|
|
graph.updateGroupBounds([cell], 20);
|
|
|
@@ -514,12 +523,12 @@ Actions.prototype.init = function()
|
|
|
this.addAction('formattedText', function()
|
|
|
{
|
|
|
var state = graph.getView().getState(graph.getSelectionCell());
|
|
|
-
|
|
|
+
|
|
|
if (state != null)
|
|
|
{
|
|
|
var value = '1';
|
|
|
graph.stopEditing();
|
|
|
-
|
|
|
+
|
|
|
graph.getModel().beginUpdate();
|
|
|
try
|
|
|
{
|
|
|
@@ -527,36 +536,36 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
value = null;
|
|
|
var label = graph.convertValueToString(state.cell);
|
|
|
-
|
|
|
+
|
|
|
if (mxUtils.getValue(state.style, 'nl2Br', '1') != '0')
|
|
|
{
|
|
|
// Removes newlines from HTML and converts breaks to newlines
|
|
|
// to match the HTML output in plain text
|
|
|
label = label.replace(/\n/g, '').replace(/<br\s*.?>/g, '\n');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Removes HTML tags
|
|
|
var temp = document.createElement('div');
|
|
|
temp.innerHTML = label;
|
|
|
label = mxUtils.extractTextWithWhitespace(temp.childNodes);
|
|
|
-
|
|
|
+
|
|
|
graph.cellLabelChanged(state.cell, label);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// Converts HTML tags to text
|
|
|
var label = mxUtils.htmlEntities(graph.convertValueToString(state.cell), false);
|
|
|
-
|
|
|
+
|
|
|
if (mxUtils.getValue(state.style, 'nl2Br', '1') != '0')
|
|
|
{
|
|
|
// Converts newlines in plain text to breaks in HTML
|
|
|
// to match the plain text output
|
|
|
label = label.replace(/\n/g, '<br/>');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
graph.cellLabelChanged(state.cell, graph.sanitizeHtml(label));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
graph.setCellStyles('html', value);
|
|
|
ui.fireEvent(new mxEventObject('styleChanged', 'keys', ['html'],
|
|
|
'values', [(value != null) ? value : '0'], 'cells',
|
|
|
@@ -572,9 +581,9 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
var state = graph.getView().getState(graph.getSelectionCell());
|
|
|
var value = 'wrap';
|
|
|
-
|
|
|
+
|
|
|
graph.stopEditing();
|
|
|
-
|
|
|
+
|
|
|
if (state != null && state.style[mxConstants.STYLE_WHITE_SPACE] == 'wrap')
|
|
|
{
|
|
|
value = null;
|
|
|
@@ -586,7 +595,7 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
var value = '0';
|
|
|
var state = graph.getView().getState(graph.getSelectionCell());
|
|
|
-
|
|
|
+
|
|
|
if (state != null)
|
|
|
{
|
|
|
value = state.style[mxConstants.STYLE_ROTATION] || value;
|
|
|
@@ -599,7 +608,7 @@ Actions.prototype.init = function()
|
|
|
graph.setCellStyles(mxConstants.STYLE_ROTATION, newValue);
|
|
|
}
|
|
|
}, mxResources.get('enterValue') + ' (' + mxResources.get('rotation') + ' 0-360)');
|
|
|
-
|
|
|
+
|
|
|
ui.showDialog(dlg.container, 375, 80, true, true);
|
|
|
dlg.init();
|
|
|
});
|
|
|
@@ -618,14 +627,14 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
this.get('pageView').funct();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var fmt = graph.pageFormat;
|
|
|
var ps = graph.pageScale;
|
|
|
var cw = graph.container.clientWidth - 10;
|
|
|
var ch = graph.container.clientHeight - 10;
|
|
|
var scale = Math.floor(20 * Math.min(cw / fmt.width / ps, ch / fmt.height / ps)) / 20;
|
|
|
graph.zoomTo(scale);
|
|
|
-
|
|
|
+
|
|
|
if (mxUtils.hasScrollbars(graph.container))
|
|
|
{
|
|
|
var pad = graph.getPagePadding();
|
|
|
@@ -639,15 +648,15 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
this.get('pageView').funct();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var fmt = graph.pageFormat;
|
|
|
var ps = graph.pageScale;
|
|
|
var cw = graph.container.clientWidth - 10;
|
|
|
var ch = graph.container.clientHeight - 10;
|
|
|
-
|
|
|
+
|
|
|
var scale = Math.floor(20 * Math.min(cw / (2 * fmt.width) / ps, ch / fmt.height / ps)) / 20;
|
|
|
graph.zoomTo(scale);
|
|
|
-
|
|
|
+
|
|
|
if (mxUtils.hasScrollbars(graph.container))
|
|
|
{
|
|
|
var pad = graph.getPagePadding();
|
|
|
@@ -661,14 +670,14 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
this.get('pageView').funct();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var fmt = graph.pageFormat;
|
|
|
var ps = graph.pageScale;
|
|
|
var cw = graph.container.clientWidth - 10;
|
|
|
|
|
|
var scale = Math.floor(20 * cw / fmt.width / ps) / 20;
|
|
|
graph.zoomTo(scale);
|
|
|
-
|
|
|
+
|
|
|
if (mxUtils.hasScrollbars(graph.container))
|
|
|
{
|
|
|
var pad = graph.getPagePadding();
|
|
|
@@ -681,7 +690,7 @@ Actions.prototype.init = function()
|
|
|
var dlg = new FilenameDialog(this.editorUi, parseInt(graph.getView().getScale() * 100), mxResources.get('apply'), mxUtils.bind(this, function(newValue)
|
|
|
{
|
|
|
var val = parseInt(newValue);
|
|
|
-
|
|
|
+
|
|
|
if (!isNaN(val) && val > 0)
|
|
|
{
|
|
|
graph.zoomTo(val / 100);
|
|
|
@@ -695,7 +704,7 @@ Actions.prototype.init = function()
|
|
|
var dlg = new FilenameDialog(this.editorUi, parseInt(graph.pageScale * 100), mxResources.get('apply'), mxUtils.bind(this, function(newValue)
|
|
|
{
|
|
|
var val = parseInt(newValue);
|
|
|
-
|
|
|
+
|
|
|
if (!isNaN(val) && val > 0)
|
|
|
{
|
|
|
ui.setPageScale(val / 100);
|
|
|
@@ -715,7 +724,7 @@ Actions.prototype.init = function()
|
|
|
action.setToggleAction(true);
|
|
|
action.setSelectedCallback(function() { return graph.isGridEnabled(); });
|
|
|
action.setEnabled(false);
|
|
|
-
|
|
|
+
|
|
|
action = this.addAction('guides', function()
|
|
|
{
|
|
|
graph.graphHandler.guidesEnabled = !graph.graphHandler.guidesEnabled;
|
|
|
@@ -724,21 +733,21 @@ Actions.prototype.init = function()
|
|
|
action.setToggleAction(true);
|
|
|
action.setSelectedCallback(function() { return graph.graphHandler.guidesEnabled; });
|
|
|
action.setEnabled(false);
|
|
|
-
|
|
|
+
|
|
|
action = this.addAction('tooltips', function()
|
|
|
{
|
|
|
graph.tooltipHandler.setEnabled(!graph.tooltipHandler.isEnabled());
|
|
|
});
|
|
|
action.setToggleAction(true);
|
|
|
action.setSelectedCallback(function() { return graph.tooltipHandler.isEnabled(); });
|
|
|
-
|
|
|
+
|
|
|
action = this.addAction('collapseExpand', function()
|
|
|
{
|
|
|
var change = new ChangePageSetup(ui);
|
|
|
change.ignoreColor = true;
|
|
|
change.ignoreImage = true;
|
|
|
change.foldingEnabled = !graph.foldingEnabled;
|
|
|
-
|
|
|
+
|
|
|
graph.model.execute(change);
|
|
|
});
|
|
|
action.setToggleAction(true);
|
|
|
@@ -786,22 +795,22 @@ Actions.prototype.init = function()
|
|
|
action.setSelectedCallback(function() { return ui.editor.autosave; });
|
|
|
action.isEnabled = isGraphEnabled;
|
|
|
action.visible = false;
|
|
|
-
|
|
|
+
|
|
|
// Help actions
|
|
|
this.addAction('help', function()
|
|
|
{
|
|
|
var ext = '';
|
|
|
-
|
|
|
+
|
|
|
if (mxResources.isLanguageSupported(mxClient.language))
|
|
|
{
|
|
|
ext = '_' + mxClient.language;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
graph.openLink(RESOURCES_PATH + '/help' + ext + '.html');
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
var showingAbout = false;
|
|
|
-
|
|
|
+
|
|
|
this.put('about', new Action(mxResources.get('about') + ' Graph Editor...', function()
|
|
|
{
|
|
|
if (!showingAbout)
|
|
|
@@ -810,11 +819,11 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
showingAbout = false;
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
showingAbout = true;
|
|
|
}
|
|
|
}, null, null, 'F1'));
|
|
|
-
|
|
|
+
|
|
|
// Font style actions
|
|
|
var toggleFontStyle = mxUtils.bind(this, function(key, style, fn, shortcut)
|
|
|
{
|
|
|
@@ -827,19 +836,19 @@ Actions.prototype.init = function()
|
|
|
else
|
|
|
{
|
|
|
graph.stopEditing(false);
|
|
|
-
|
|
|
+
|
|
|
graph.getModel().beginUpdate();
|
|
|
try
|
|
|
{
|
|
|
graph.toggleCellStyleFlags(mxConstants.STYLE_FONTSTYLE, style);
|
|
|
-
|
|
|
+
|
|
|
// Removes bold and italic tags and CSS styles inside labels
|
|
|
if ((style & mxConstants.FONT_BOLD) == mxConstants.FONT_BOLD)
|
|
|
{
|
|
|
graph.updateLabelElements(graph.getSelectionCells(), function(elt)
|
|
|
{
|
|
|
elt.style.fontWeight = null;
|
|
|
-
|
|
|
+
|
|
|
if (elt.nodeName == 'B')
|
|
|
{
|
|
|
graph.replaceElement(elt);
|
|
|
@@ -851,7 +860,7 @@ Actions.prototype.init = function()
|
|
|
graph.updateLabelElements(graph.getSelectionCells(), function(elt)
|
|
|
{
|
|
|
elt.style.fontStyle = null;
|
|
|
-
|
|
|
+
|
|
|
if (elt.nodeName == 'I')
|
|
|
{
|
|
|
graph.replaceElement(elt);
|
|
|
@@ -863,7 +872,7 @@ Actions.prototype.init = function()
|
|
|
graph.updateLabelElements(graph.getSelectionCells(), function(elt)
|
|
|
{
|
|
|
elt.style.textDecoration = null;
|
|
|
-
|
|
|
+
|
|
|
if (elt.nodeName == 'U')
|
|
|
{
|
|
|
graph.replaceElement(elt);
|
|
|
@@ -878,11 +887,11 @@ Actions.prototype.init = function()
|
|
|
}
|
|
|
}, null, null, shortcut);
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
toggleFontStyle('bold', mxConstants.FONT_BOLD, function() { document.execCommand('bold', false, null); }, Editor.ctrlKey + '+B');
|
|
|
toggleFontStyle('italic', mxConstants.FONT_ITALIC, function() { document.execCommand('italic', false, null); }, Editor.ctrlKey + '+I');
|
|
|
toggleFontStyle('underline', mxConstants.FONT_UNDERLINE, function() { document.execCommand('underline', false, null); }, Editor.ctrlKey + '+U');
|
|
|
-
|
|
|
+
|
|
|
// Color actions
|
|
|
this.addAction('fontColor...', function() { ui.menus.pickColor(mxConstants.STYLE_FONTCOLOR, 'forecolor', '000000'); });
|
|
|
this.addAction('strokeColor...', function() { ui.menus.pickColor(mxConstants.STYLE_STROKECOLOR); });
|
|
|
@@ -890,7 +899,7 @@ Actions.prototype.init = function()
|
|
|
this.addAction('gradientColor...', function() { ui.menus.pickColor(mxConstants.STYLE_GRADIENTCOLOR); });
|
|
|
this.addAction('backgroundColor...', function() { ui.menus.pickColor(mxConstants.STYLE_LABEL_BACKGROUNDCOLOR, 'backcolor'); });
|
|
|
this.addAction('borderColor...', function() { ui.menus.pickColor(mxConstants.STYLE_LABEL_BORDERCOLOR); });
|
|
|
-
|
|
|
+
|
|
|
// Format actions
|
|
|
this.addAction('vertical', function() { ui.menus.toggleStyle(mxConstants.STYLE_HORIZONTAL, true); });
|
|
|
this.addAction('shadow', function() { ui.menus.toggleStyle(mxConstants.STYLE_SHADOW); });
|
|
|
@@ -980,7 +989,7 @@ Actions.prototype.init = function()
|
|
|
var state = graph.view.getState(cells[0]);
|
|
|
var style = (state != null) ? state.style : graph.getCellStyle(cells[0]);
|
|
|
var value = (mxUtils.getValue(style, mxConstants.STYLE_ROUNDED, '0') == '1') ? '0' : '1';
|
|
|
-
|
|
|
+
|
|
|
graph.setCellStyles(mxConstants.STYLE_ROUNDED, value);
|
|
|
graph.setCellStyles(mxConstants.STYLE_CURVED, null);
|
|
|
ui.fireEvent(new mxEventObject('styleChanged', 'keys', [mxConstants.STYLE_ROUNDED, mxConstants.STYLE_CURVED],
|
|
|
@@ -1011,12 +1020,12 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
var state = graph.view.getState(graph.getSelectionCell());
|
|
|
var value = '1';
|
|
|
-
|
|
|
+
|
|
|
if (state != null && graph.getFoldingImage(state) != null)
|
|
|
{
|
|
|
- value = '0';
|
|
|
+ value = '0';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
graph.setCellStyles('collapsible', value);
|
|
|
ui.fireEvent(new mxEventObject('styleChanged', 'keys', ['collapsible'],
|
|
|
'values', [value], 'cells', graph.getSelectionCells()));
|
|
|
@@ -1024,11 +1033,11 @@ Actions.prototype.init = function()
|
|
|
this.addAction('editStyle...', mxUtils.bind(this, function()
|
|
|
{
|
|
|
var cells = graph.getSelectionCells();
|
|
|
-
|
|
|
+
|
|
|
if (cells != null && cells.length > 0)
|
|
|
{
|
|
|
var model = graph.getModel();
|
|
|
-
|
|
|
+
|
|
|
var dlg = new TextareaDialog(this.editorUi, mxResources.get('editStyle') + ':',
|
|
|
model.getStyle(cells[0]) || '', function(newValue)
|
|
|
{
|
|
|
@@ -1058,33 +1067,33 @@ Actions.prototype.init = function()
|
|
|
this.addAction('addWaypoint', function()
|
|
|
{
|
|
|
var cell = graph.getSelectionCell();
|
|
|
-
|
|
|
+
|
|
|
if (cell != null && graph.getModel().isEdge(cell))
|
|
|
{
|
|
|
var handler = editor.graph.selectionCellsHandler.getHandler(cell);
|
|
|
-
|
|
|
+
|
|
|
if (handler instanceof mxEdgeHandler)
|
|
|
{
|
|
|
var t = graph.view.translate;
|
|
|
var s = graph.view.scale;
|
|
|
var dx = t.x;
|
|
|
var dy = t.y;
|
|
|
-
|
|
|
+
|
|
|
var parent = graph.getModel().getParent(cell);
|
|
|
var pgeo = graph.getCellGeometry(parent);
|
|
|
-
|
|
|
+
|
|
|
while (graph.getModel().isVertex(parent) && pgeo != null)
|
|
|
{
|
|
|
dx += pgeo.x;
|
|
|
dy += pgeo.y;
|
|
|
-
|
|
|
+
|
|
|
parent = graph.getModel().getParent(parent);
|
|
|
pgeo = graph.getCellGeometry(parent);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var x = Math.round(graph.snap(graph.popupMenuHandler.triggerX / s - dx));
|
|
|
var y = Math.round(graph.snap(graph.popupMenuHandler.triggerY / s - dy));
|
|
|
-
|
|
|
+
|
|
|
handler.addPointAt(handler.state, x, y);
|
|
|
}
|
|
|
}
|
|
|
@@ -1093,7 +1102,7 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
// TODO: Action should run with "this" set to action
|
|
|
var rmWaypointAction = ui.actions.get('removeWaypoint');
|
|
|
-
|
|
|
+
|
|
|
if (rmWaypointAction.handler != null)
|
|
|
{
|
|
|
// NOTE: Popupevent handled and action updated in Menus.createPopupMenu
|
|
|
@@ -1103,22 +1112,22 @@ Actions.prototype.init = function()
|
|
|
this.addAction('clearWaypoints', function()
|
|
|
{
|
|
|
var cells = graph.getSelectionCells();
|
|
|
-
|
|
|
+
|
|
|
if (cells != null)
|
|
|
{
|
|
|
cells = graph.addAllEdges(cells);
|
|
|
-
|
|
|
+
|
|
|
graph.getModel().beginUpdate();
|
|
|
try
|
|
|
{
|
|
|
for (var i = 0; i < cells.length; i++)
|
|
|
{
|
|
|
var cell = cells[i];
|
|
|
-
|
|
|
+
|
|
|
if (graph.getModel().isEdge(cell))
|
|
|
{
|
|
|
var geo = graph.getCellGeometry(cell);
|
|
|
-
|
|
|
+
|
|
|
if (geo != null)
|
|
|
{
|
|
|
geo = geo.clone();
|
|
|
@@ -1155,14 +1164,14 @@ Actions.prototype.init = function()
|
|
|
var title = mxResources.get('image') + ' (' + mxResources.get('url') + '):';
|
|
|
var state = graph.getView().getState(graph.getSelectionCell());
|
|
|
var value = '';
|
|
|
-
|
|
|
+
|
|
|
if (state != null)
|
|
|
{
|
|
|
value = state.style[mxConstants.STYLE_IMAGE] || value;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var selectionState = graph.cellEditor.saveSelection();
|
|
|
-
|
|
|
+
|
|
|
ui.showImageDialog(title, value, function(newValue, w, h)
|
|
|
{
|
|
|
// Inserts image into HTML text
|
|
|
@@ -1174,11 +1183,11 @@ Actions.prototype.init = function()
|
|
|
else
|
|
|
{
|
|
|
var cells = graph.getSelectionCells();
|
|
|
-
|
|
|
+
|
|
|
if (newValue != null && (newValue.length > 0 || cells.length > 0))
|
|
|
{
|
|
|
var select = null;
|
|
|
-
|
|
|
+
|
|
|
graph.getModel().beginUpdate();
|
|
|
try
|
|
|
{
|
|
|
@@ -1191,13 +1200,13 @@ Actions.prototype.init = function()
|
|
|
select = cells;
|
|
|
graph.fireEvent(new mxEventObject('cellsInserted', 'cells', select));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
graph.setCellStyles(mxConstants.STYLE_IMAGE, (newValue.length > 0) ? newValue : null, cells);
|
|
|
-
|
|
|
+
|
|
|
// Sets shape only if not already shape with image (label or image)
|
|
|
var state = graph.view.getState(cells[0]);
|
|
|
var style = (state != null) ? state.style : graph.getCellStyle(cells[0]);
|
|
|
-
|
|
|
+
|
|
|
if (style[mxConstants.STYLE_SHAPE] != 'image' && style[mxConstants.STYLE_SHAPE] != 'label')
|
|
|
{
|
|
|
graph.setCellStyles(mxConstants.STYLE_SHAPE, 'image', cells);
|
|
|
@@ -1206,14 +1215,14 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
graph.setCellStyles(mxConstants.STYLE_SHAPE, null, cells);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (graph.getSelectionCount() == 1)
|
|
|
{
|
|
|
if (w != null && h != null)
|
|
|
{
|
|
|
var cell = cells[0];
|
|
|
var geo = graph.getModel().getGeometry(cell);
|
|
|
-
|
|
|
+
|
|
|
if (geo != null)
|
|
|
{
|
|
|
geo = geo.clone();
|
|
|
@@ -1228,7 +1237,7 @@ Actions.prototype.init = function()
|
|
|
{
|
|
|
graph.getModel().endUpdate();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (select != null)
|
|
|
{
|
|
|
graph.setSelectionCells(select);
|
|
|
@@ -1299,7 +1308,7 @@ Actions.prototype.init = function()
|
|
|
this.outlineWindow.window.setVisible(!this.outlineWindow.window.isVisible());
|
|
|
}
|
|
|
}), null, null, Editor.ctrlKey + '+Shift+O');
|
|
|
-
|
|
|
+
|
|
|
action.setToggleAction(true);
|
|
|
action.setSelectedCallback(mxUtils.bind(this, function() { return this.outlineWindow != null && this.outlineWindow.window.isVisible(); }));
|
|
|
};
|
|
|
@@ -1310,7 +1319,7 @@ Actions.prototype.init = function()
|
|
|
Actions.prototype.addAction = function(key, funct, enabled, iconCls, shortcut)
|
|
|
{
|
|
|
var title;
|
|
|
-
|
|
|
+
|
|
|
if (key.substring(key.length - 3) == '...')
|
|
|
{
|
|
|
key = key.substring(0, key.length - 3);
|
|
|
@@ -1320,7 +1329,7 @@ Actions.prototype.addAction = function(key, funct, enabled, iconCls, shortcut)
|
|
|
{
|
|
|
title = mxResources.get(key);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return this.put(key, new Action(title, funct, enabled, iconCls, shortcut));
|
|
|
};
|
|
|
|
|
|
@@ -1330,7 +1339,7 @@ Actions.prototype.addAction = function(key, funct, enabled, iconCls, shortcut)
|
|
|
Actions.prototype.put = function(name, action)
|
|
|
{
|
|
|
this.actions[name] = action;
|
|
|
-
|
|
|
+
|
|
|
return action;
|
|
|
};
|
|
|
|