Skip to content

Commit 482c09c

Browse files
fix: emit event when click label
1 parent 88eb05a commit 482c09c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-visual-modeling",
3-
"version": "1.0.44",
3+
"version": "1.0.45",
44
"description": "一个基于React的数据可视化建模的DAG图,适用于UML,数据库建模,数据仓库建设等业务",
55
"main": "dist/index.js",
66
"pack": "pack/index.js",

src/canvas/edge.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,29 @@ export default class BaseEdge extends Edge {
7474
return container[0];
7575
}
7676

77+
let dom = null;
7778
// 存在 labelRender 但是没有 label 的时候,需要 labelRender 拿到这个 dom 去渲染
7879
if(labelRender) {
7980
const span = document.createElement('span');
8081
span.className = 'visual-modeling-label';
8182
span.style.position = 'absolute';
8283
span.style.zIndex = 500;
83-
return span;
84+
dom = span;
8485
}
8586

8687
if (label && typeof label === 'string') {
8788
let container = $('<span class="butterflies-label visual-modeling-label"></span>');
8889
container.text(label);
89-
90-
return container[0];
90+
dom = container[0];
9191
}
92+
93+
$(dom).on('click', () => {
94+
this.emit('system.link.click', {
95+
edge: this
96+
});
97+
});
98+
99+
return dom;
92100
}
93101

94102
isConnect() {

0 commit comments

Comments
 (0)