From e111d2099cae1baaee3f895513aec37a8452febd Mon Sep 17 00:00:00 2001 From: Miao Zhuang <1060950782@163.com> Date: Fri, 12 Jan 2024 15:51:57 +0800 Subject: [PATCH] fix: bug (#41) fix: multi desp id error fix: desp erors --- package.json | 5 +++-- src/Shape/Graph.ts | 32 +++++++++++++++++++++++++++++++- src/Shape/Lines/Line.ts | 10 ++++++---- src/Shape/Node.ts | 26 +------------------------- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 34e1259..deb9f1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vesoft-inc/veditor", - "version": "4.4.7-beta.9", + "version": "4.4.12", "description": "svg flow editor", "main": "./dist/VEditor.js", "types": "./types/index.d.ts", @@ -12,7 +12,8 @@ "makeDts": "npx -p typescript tsc -p ./dts.json", "build:all": "npm run build && npm run makeDts && npm run build:browser && npm run build:demo ", "doc": "typedoc ", - "watch": "webpack --watch --env browser=true --config webpack.config.build.js" + "watch": "webpack --watch --env browser=true --config webpack.config.build.js", + "postpublish": "npx cnpm sync @vesoft-inc/veditor" }, "repository": { "type": "git", diff --git a/src/Shape/Graph.ts b/src/Shape/Graph.ts index 130cfd4..6dc94f4 100644 --- a/src/Shape/Graph.ts +++ b/src/Shape/Graph.ts @@ -2,7 +2,7 @@ import Node from "./Node"; import Line from "./Line"; import AnchorLine from "./AnchorLine"; import VEditor from "../VEditor"; -import { setAttrs } from "../Utils/dom"; +import { setAttrs, svgWrapper } from "../Utils/dom"; import { VEditorSchema } from "../Model/Schema"; import * as Utils from "../Utils"; const backSvg = require("../back.svg").default; @@ -14,12 +14,15 @@ class Graph extends Utils.Event { anchorLine: AnchorLine; linkStatus: string; data: VEditorSchema; + shadow: SVGSVGElement; + constructor(editor: VEditor) { super(); this.editor = editor; this.node = new Node(this); this.line = new Line(this); this.anchorLine = new AnchorLine(this); + this.initDefs(); this.listenEvents(); if (this.editor.config.showBackGrid) { @@ -152,6 +155,33 @@ class Graph extends Utils.Event { this.fire("update"); } + + + initDefs() { + if(document.getElementById("ve-svg-defs")) return; + this.shadow = svgWrapper( + ` + + + + + + + + + + + + + + + + + `, + ) as SVGSVGElement; + document.body.appendChild(this.shadow); + } + /** * 清空画布 */ diff --git a/src/Shape/Lines/Line.ts b/src/Shape/Lines/Line.ts index a30eb3d..b7ef43f 100644 --- a/src/Shape/Lines/Line.ts +++ b/src/Shape/Lines/Line.ts @@ -275,11 +275,13 @@ const DefaultLine: LineRender = { const { width, height } = line.label.textBBox; setAttrs(line.label.textRect, { fill: style.stroke, - width, - height, + width: width + 10, + height:height + 5, stroke: "transparent", - x: x - width * 0.5, - y: y - height-1, + x: x - width * 0.5 - 5, + y: y - height - 2.5, + rx: 5, + ry: 5, }); setAttrs(labelGroup, { class: "ve-line-label", diff --git a/src/Shape/Node.ts b/src/Shape/Node.ts index d7d53c8..c83ea70 100644 --- a/src/Shape/Node.ts +++ b/src/Shape/Node.ts @@ -50,7 +50,6 @@ class Node { paper: SVGGElement; nodeG: SVGGElement; actives: {}; - shadow: SVGElement; shapes: { [key: string]: NodeRender; }; @@ -64,7 +63,6 @@ class Node { this.paper = graph.editor.paper; this.nodeG = createSVGElement("g", this.paper) as SVGGElement; this.nodeG.classList.add("ve-nodes"); - this.initDefs(); this.listenEvent(); this.actives = {}; this.shapes = { @@ -74,28 +72,6 @@ class Node { }; } - initDefs() { - this.shadow = svgWrapper( - ` - - - - - - - - - - - - - - - `, - this.paper - ); - } - // 监听事件 listenEvent() { this.graph.on("paper:click", () => { @@ -479,7 +455,7 @@ class Node { unActiveNode(node: InstanceNode) { node.dom.classList.remove("active"); - setAttrs(node.dom, { + setAttrs(node.shape, { filter: null, }); }