Skip to content

Commit

Permalink
fix: bug (#41)
Browse files Browse the repository at this point in the history
fix: multi desp id error

fix: desp erors
  • Loading branch information
mizy authored Jan 12, 2024
1 parent e80ff35 commit e111d20
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
32 changes: 31 additions & 1 deletion src/Shape/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -152,6 +155,33 @@ class Graph extends Utils.Event {
this.fire("update");
}



initDefs() {
if(document.getElementById("ve-svg-defs")) return;
this.shadow = svgWrapper(
`<svg id="ve-svg-defs" style="position:absolute;left:-9999px;top:-9999px;" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="ve-black-shadow" >
<feGaussianBlur in="SourceAlpha" stdDeviation="4"></feGaussianBlur>
<feGaussianBlur stdDeviation="3" />
<feOffset dx="0" dy="0" result="offsetblur"></feOffset>
<feFlood flood-color="#333333"></feFlood>
<feComposite in2="offsetblur" operator="in"></feComposite>
<feComponentTransfer>
<feFuncA type="linear" slope="0.3"></feFuncA>
</feComponentTransfer>
<feMerge>
<feMergeNode />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>
</svg>`,
) as SVGSVGElement;
document.body.appendChild(this.shadow);
}

/**
* 清空画布
*/
Expand Down
10 changes: 6 additions & 4 deletions src/Shape/Lines/Line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 1 addition & 25 deletions src/Shape/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class Node {
paper: SVGGElement;
nodeG: SVGGElement;
actives: {};
shadow: SVGElement;
shapes: {
[key: string]: NodeRender;
};
Expand All @@ -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 = {
Expand All @@ -74,28 +72,6 @@ class Node {
};
}

initDefs() {
this.shadow = svgWrapper(
`<defs>
<filter id="ve-black-shadow" filterUnits="userSpaceOnUse">
<feGaussianBlur in="SourceAlpha" stdDeviation="4"></feGaussianBlur>
<feGaussianBlur stdDeviation="3" />
<feOffset dx="0" dy="0" result="offsetblur"></feOffset>
<feFlood flood-color="#333333"></feFlood>
<feComposite in2="offsetblur" operator="in"></feComposite>
<feComponentTransfer>
<feFuncA type="linear" slope="0.3"></feFuncA>
</feComponentTransfer>
<feMerge>
<feMergeNode />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>`,
this.paper
);
}

// 监听事件
listenEvent() {
this.graph.on("paper:click", () => {
Expand Down Expand Up @@ -479,7 +455,7 @@ class Node {

unActiveNode(node: InstanceNode) {
node.dom.classList.remove("active");
setAttrs(node.dom, {
setAttrs(node.shape, {
filter: null,
});
}
Expand Down

0 comments on commit e111d20

Please sign in to comment.