mxgraph 之 增添工具类,粘贴复制,撤销还原等
mxClipboard类用于实现这些方法:(直接在按钮的点击事件中写即可)
粘贴:
mxClipboard.paste(graph);
var cells = new Array();cells = graph.getSelectionCells();mxClipboard.copy(graph,cells);
var cells = new Array();cells = graph.getSelectionCells();mxClipboard.cut(graph,cells);
var cells = new Array();cells = graph.getSelectionCells();mxClipboard.removeCells(graph,cells);
var undoMng = new mxUndoManager(); var listener = function(sender, evt) { undoMng.undoableEditHappened(evt.getProperty('edit')); }; graph.getModel().addListener(mxEvent.UNDO, listener); graph.getView().addListener(mxEvent.UNDO, listener);
undoMng.undo();
undoMng.redo();