|
@@ -1,11 +1,11 @@
|
|
|
import { ContextMenuTool, edgeMenu } from "./contentMenu";
|
|
|
import Text from "@/components/basic/text";
|
|
|
-import baseNode from "@/components/base";
|
|
|
+import ImageNode from "@/components/ImageNode";
|
|
|
import { Cell, Edge, Graph, Node } from "@antv/x6";
|
|
|
import { nodeMenu } from "./contentMenu";
|
|
|
import { exportImage } from "@/components/ExportImage";
|
|
|
-import { BaseEdge } from "@/components/Edge";
|
|
|
-import { set, cloneDeep, get } from "lodash-es";
|
|
|
+import { BaseEdge } from "@/config/data";
|
|
|
+import { set, cloneDeep, get, merge } from "lodash-es";
|
|
|
import { defaultData } from "@/config/data";
|
|
|
import codeBlock from "@/components/basic/CodeBlock";
|
|
|
import { ConnectorType } from "@/enum";
|
|
@@ -162,15 +162,14 @@ export const handlePaste = (
|
|
|
const height = img.height;
|
|
|
// 插入图片
|
|
|
const node = {
|
|
|
- ...baseNode,
|
|
|
- data: {
|
|
|
- ...baseNode.data,
|
|
|
+ ...ImageNode,
|
|
|
+ data: merge(defaultData, {
|
|
|
+ ...ImageNode.data,
|
|
|
fill: {
|
|
|
- ...baseNode.data.fill,
|
|
|
fillType: "image",
|
|
|
imageUrl: dataUrl,
|
|
|
},
|
|
|
- },
|
|
|
+ }),
|
|
|
size: {
|
|
|
width,
|
|
|
height,
|
|
@@ -366,7 +365,7 @@ export const handleCreateEdge = (graph: Graph) => {
|
|
|
y: e.offsetY,
|
|
|
},
|
|
|
data: {
|
|
|
- connectorType: ConnectorType.Rounded
|
|
|
+ connectorType: ConnectorType.Rounded,
|
|
|
},
|
|
|
tools: [
|
|
|
{
|
|
@@ -553,7 +552,7 @@ export const handleSetAttr = (graph: Graph, path: string, value: any) => {
|
|
|
} else {
|
|
|
set(data, path, value);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
cell.setData({
|
|
|
...data,
|
|
|
});
|
|
@@ -799,18 +798,18 @@ export const handleLock = (graph: Graph) => {
|
|
|
* @param cell
|
|
|
*/
|
|
|
export const handleUnLock = (graph: Graph, cell?: Cell) => {
|
|
|
- if(cell) {
|
|
|
+ if (cell) {
|
|
|
cell.setData({
|
|
|
lock: false,
|
|
|
});
|
|
|
graph.select([cell]);
|
|
|
- if(cell.isNode()) {
|
|
|
- graph.createTransformWidget(cell)
|
|
|
+ if (cell.isNode()) {
|
|
|
+ graph.createTransformWidget(cell);
|
|
|
}
|
|
|
} else {
|
|
|
const cells = graph.getCells();
|
|
|
cells.forEach((cell) => {
|
|
|
- if(cell.data?.lock) {
|
|
|
+ if (cell.data?.lock) {
|
|
|
cell.setData({
|
|
|
lock: false,
|
|
|
});
|
|
@@ -830,20 +829,24 @@ export const handleDelete = (graph: Graph) => {
|
|
|
|
|
|
/**
|
|
|
* 设置连线样式
|
|
|
- * @param edge
|
|
|
- * @param style
|
|
|
+ * @param edge
|
|
|
+ * @param style
|
|
|
*/
|
|
|
-export const handleSetEdgeStyle = (edge: Cell, style: ConnectorType, jumpover: boolean) => {
|
|
|
- if(!edge.isEdge()) return;
|
|
|
- switch(style) {
|
|
|
+export const handleSetEdgeStyle = (
|
|
|
+ edge: Cell,
|
|
|
+ style: ConnectorType,
|
|
|
+ jumpover: boolean
|
|
|
+) => {
|
|
|
+ if (!edge.isEdge()) return;
|
|
|
+ switch (style) {
|
|
|
case ConnectorType.Rounded: {
|
|
|
edge.setRouter("manhattan");
|
|
|
- edge.setConnector(jumpover ? "jumpover" : "normal")
|
|
|
+ edge.setConnector(jumpover ? "jumpover" : "normal");
|
|
|
break;
|
|
|
}
|
|
|
case ConnectorType.Smooth: {
|
|
|
edge.setRouter("manhattan");
|
|
|
- edge.setConnector("smooth")
|
|
|
+ edge.setConnector("smooth");
|
|
|
break;
|
|
|
}
|
|
|
case ConnectorType.Normal: {
|
|
@@ -852,4 +855,4 @@ export const handleSetEdgeStyle = (edge: Cell, style: ConnectorType, jumpover: b
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+};
|