ronds-metadata 1.3.25 → 1.3.27
Sign up to get free protection for your applications and to get access to all the features.
@@ -68,7 +68,7 @@ declare class DPGraph extends GraphCore<BaseNode, BaseEdge> {
|
|
68
68
|
edges: DPEdge[];
|
69
69
|
}): void;
|
70
70
|
onContextMenu(data: ContextMenuInfo): any;
|
71
|
-
onAddCopyCells(nodes:
|
71
|
+
onAddCopyCells(nodes: any[], edges: any[]): void;
|
72
72
|
onCopyNodes(args: any[]): void;
|
73
73
|
updateNodeNameById(id: string, name: string): void;
|
74
74
|
clearContextMenuInfo: () => void;
|
@@ -16,7 +16,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
16
16
|
/*
|
17
17
|
* @Author: wangxian
|
18
18
|
* @Date: 2022-05-24 14:31:01
|
19
|
-
* @LastEditTime: 2023-12-
|
19
|
+
* @LastEditTime: 2023-12-05 10:24:27
|
20
20
|
*/
|
21
21
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
22
22
|
import produce from 'immer';
|
@@ -30,7 +30,7 @@ import { GraphCore } from '../../framework/graph';
|
|
30
30
|
import NodeElement from './comps/NodeElement';
|
31
31
|
import { DPEdge } from './comps/shape/edge';
|
32
32
|
import { DPNode } from './comps/shape/node';
|
33
|
-
import { formatGraphData, formatNodeInfoToNodeMeta, formattedEdgesToEdgeMeta } from './utils';
|
33
|
+
import { formatGraphData, copy, formatNodeInfoToNodeMeta, formattedEdgesToEdgeMeta, isClipboardEmpty, cleanClipboard, getCellsInClipboard } from './utils';
|
34
34
|
import { deepClone, guid } from '../../utils';
|
35
35
|
import { MetadataService } from '../../framework/metadata/MetadataService';
|
36
36
|
import { tr } from '../../framework/locale';
|
@@ -734,12 +734,11 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
|
|
734
734
|
}, {
|
735
735
|
key: "onAddCopyCells",
|
736
736
|
value: function onAddCopyCells(nodes, edges) {
|
737
|
-
var _this2 = this
|
738
|
-
_this$graph;
|
737
|
+
var _this2 = this;
|
739
738
|
var cells = [];
|
740
739
|
var randomId = guid().substring(0, 4);
|
741
740
|
nodes.map(function (cell) {
|
742
|
-
var _node = cell.
|
741
|
+
var _node = cell.data;
|
743
742
|
_node = _objectSpread(_objectSpread({}, _node), {}, {
|
744
743
|
id: "".concat(_node.id, "_copy_").concat(randomId),
|
745
744
|
x: _node.x + 30,
|
@@ -750,7 +749,7 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
|
|
750
749
|
_this2.addNode(newNode);
|
751
750
|
});
|
752
751
|
edges.map(function (cell) {
|
753
|
-
var _edge = cell.
|
752
|
+
var _edge = cell.data;
|
754
753
|
_edge = _objectSpread(_objectSpread({}, _edge), {}, {
|
755
754
|
source: "".concat(_edge.source, "_copy_").concat(randomId),
|
756
755
|
target: "".concat(_edge.target, "_copy_").concat(randomId)
|
@@ -759,11 +758,11 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
|
|
759
758
|
var newEdge = formattedEdgesToEdgeMeta(_edge);
|
760
759
|
_this2.addEdge(newEdge);
|
761
760
|
});
|
762
|
-
|
761
|
+
cleanClipboard();
|
763
762
|
// 回显选中复制的之后的节点
|
764
763
|
nodes.map(function (cell) {
|
765
764
|
var _this2$graph;
|
766
|
-
var _node = cell.
|
765
|
+
var _node = cell.data;
|
767
766
|
var _cell = (_this2$graph = _this2.graph) === null || _this2$graph === void 0 ? void 0 : _this2$graph.getCellById("".concat(_node.id, "_copy_").concat(randomId));
|
768
767
|
cells.push(_cell);
|
769
768
|
});
|
@@ -779,22 +778,21 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
|
|
779
778
|
switch (action) {
|
780
779
|
case 'command+c':
|
781
780
|
case 'ctrl+c':
|
782
|
-
|
783
|
-
|
784
|
-
}
|
785
|
-
_message.success(tr('复制成功'));
|
781
|
+
if (selectedCells && selectedCells.length > 0) {
|
782
|
+
copy(selectedCells, this.graph);
|
783
|
+
}
|
786
784
|
break;
|
787
785
|
case 'command+v':
|
788
786
|
case 'ctrl+v':
|
789
|
-
if (
|
787
|
+
if (isClipboardEmpty()) {
|
790
788
|
_message.info(tr('剪切板为空,不可粘贴'));
|
791
789
|
} else {
|
792
|
-
var clipboardCells =
|
793
|
-
var selectedNodes = clipboardCells.filter(function (cell) {
|
794
|
-
return cell.
|
790
|
+
var clipboardCells = getCellsInClipboard();
|
791
|
+
var selectedNodes = clipboardCells === null || clipboardCells === void 0 ? void 0 : clipboardCells.filter(function (cell) {
|
792
|
+
return (cell === null || cell === void 0 ? void 0 : cell.type) === 'node';
|
795
793
|
});
|
796
|
-
var selectedEdges = clipboardCells.filter(function (cell) {
|
797
|
-
return cell.
|
794
|
+
var selectedEdges = clipboardCells === null || clipboardCells === void 0 ? void 0 : clipboardCells.filter(function (cell) {
|
795
|
+
return (cell === null || cell === void 0 ? void 0 : cell.shape) === 'DPEdge';
|
798
796
|
});
|
799
797
|
this.onAddCopyCells(selectedNodes, selectedEdges);
|
800
798
|
_message.success(tr('粘贴成功'));
|
@@ -147,3 +147,7 @@ export declare function formatGraphData(graphData: NDPGraph.GraphData): {
|
|
147
147
|
color?: string;
|
148
148
|
}[];
|
149
149
|
};
|
150
|
+
export declare function isClipboardEmpty(): boolean;
|
151
|
+
export declare function getCellsInClipboard(): unknown;
|
152
|
+
export declare function cleanClipboard(): void;
|
153
|
+
export declare function copy(selectedCells: any, graph: Graph): void;
|
@@ -1,12 +1,16 @@
|
|
1
|
+
import "antd/es/message/style";
|
2
|
+
import _message from "antd/es/message";
|
1
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
5
|
/*
|
4
6
|
* @Author: wangxian
|
5
7
|
* @Date: 2022-05-24 16:40:49
|
6
|
-
* @LastEditTime: 2023-
|
8
|
+
* @LastEditTime: 2023-12-05 09:56:52
|
7
9
|
*/
|
8
10
|
import { sortBy } from 'lodash-es';
|
9
11
|
import { NODE_HEIGHT, NODE_WIDTH } from './constant';
|
12
|
+
import { delFromLS, getFromLS, saveToLS } from '../../utils';
|
13
|
+
import { tr } from '../../framework/locale';
|
10
14
|
// 将画布上的点转换成相对于 offset parent 的点
|
11
15
|
export function graphPointToOffsetPoint(graph, graphPoint, containerElem) {
|
12
16
|
if (graph) {
|
@@ -134,4 +138,28 @@ export function formatGraphData(graphData) {
|
|
134
138
|
nodes: _toConsumableArray(formattedNodes),
|
135
139
|
edges: formattedEdges
|
136
140
|
};
|
141
|
+
}
|
142
|
+
var CLIPBOARD_KEY = 'x6.clipboard.cells';
|
143
|
+
var CLIPBOARD_KEY_NEW = 'my.clipboard.cells';
|
144
|
+
export function isClipboardEmpty() {
|
145
|
+
var cells = getFromLS(CLIPBOARD_KEY_NEW);
|
146
|
+
return cells ? false : true;
|
147
|
+
}
|
148
|
+
export function getCellsInClipboard() {
|
149
|
+
var cells = getFromLS(CLIPBOARD_KEY_NEW);
|
150
|
+
return cells;
|
151
|
+
}
|
152
|
+
export function cleanClipboard() {
|
153
|
+
delFromLS(CLIPBOARD_KEY_NEW);
|
154
|
+
}
|
155
|
+
export function copy(selectedCells, graph) {
|
156
|
+
graph.copy(selectedCells, {
|
157
|
+
useLocalStorage: true
|
158
|
+
});
|
159
|
+
var cells = getFromLS(CLIPBOARD_KEY);
|
160
|
+
if (cells) {
|
161
|
+
saveToLS(CLIPBOARD_KEY_NEW, cells);
|
162
|
+
delFromLS(CLIPBOARD_KEY);
|
163
|
+
_message.success(tr('复制成功'));
|
164
|
+
}
|
137
165
|
}
|
package/es/utils.d.ts
CHANGED
@@ -30,3 +30,6 @@ export declare function getConstantValue(array: any[], key: string | number, str
|
|
30
30
|
* @param fileName string
|
31
31
|
*/
|
32
32
|
export declare function handleMd2Doc(mdText: string, fileName: string, isFirstLineCenter?: boolean): Promise<void>;
|
33
|
+
export declare function getFromLS<T>(key: string): T | null;
|
34
|
+
export declare function saveToLS<T>(key: string, value: T | null | undefined): void;
|
35
|
+
export declare function delFromLS(key: string): void;
|
package/es/utils.js
CHANGED
@@ -6,7 +6,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
/*
|
7
7
|
* @Author: wangxian
|
8
8
|
* @Date: 2021-09-18 14:15:04
|
9
|
-
* @LastEditTime: 2023-
|
9
|
+
* @LastEditTime: 2023-12-05 09:05:07
|
10
10
|
*/
|
11
11
|
import saveAs from 'file-saver';
|
12
12
|
import { asBlob } from 'html-docx-js-typescript';
|
@@ -283,4 +283,26 @@ function convertImagePathToBase64(imagePath) {
|
|
283
283
|
|
284
284
|
return uint8Array;
|
285
285
|
}
|
286
|
+
}
|
287
|
+
export function getFromLS(key) {
|
288
|
+
if (window.localStorage) {
|
289
|
+
try {
|
290
|
+
return JSON.parse(window.localStorage.getItem(key) || '');
|
291
|
+
} catch (e) {
|
292
|
+
/*Ignore*/
|
293
|
+
}
|
294
|
+
}
|
295
|
+
return null;
|
296
|
+
}
|
297
|
+
export function saveToLS(key, value) {
|
298
|
+
if (window.localStorage) {
|
299
|
+
if (value === null || value === undefined) {
|
300
|
+
window.localStorage.removeItem(key);
|
301
|
+
} else {
|
302
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
303
|
+
}
|
304
|
+
}
|
305
|
+
}
|
306
|
+
export function delFromLS(key) {
|
307
|
+
window.localStorage.removeItem(key);
|
286
308
|
}
|