feat: 🐛 support click on the non-text area without adding a new label (#1894)

Co-authored-by: hetengfei <hetengfei@able-elec.com>
This commit is contained in:
何腾飞
2022-03-17 13:17:07 +08:00
committed by GitHub
parent 9637a254e0
commit 4ae1b9ef4f

View File

@ -49,6 +49,7 @@ export class CellEditor extends ToolsView.ToolItem<
const parent = target.parentElement
const isEdgeLabel =
parent && Dom.hasClass(parent, this.prefixClassName('edge-label'))
const labelAddable = this.options.labelAddable
if (isEdgeLabel) {
const index = parent.getAttribute('data-index') || '0'
this.labelIndex = parseInt(index, 10)
@ -57,6 +58,9 @@ export class CellEditor extends ToolsView.ToolItem<
pos = new Point(translation.tx, translation.ty)
minWidth = Dom.getBBox(target).width
} else {
if (!labelAddable) {
return this
}
pos = graph.clientToLocal(Point.create(e.clientX, e.clientY))
const view = this.cellView as EdgeView
const d = view.path.closestPointLength(pos)
@ -147,6 +151,7 @@ export namespace CellEditor {
color: string
backgroundColor: string
}
labelAddable: boolean
getText: (
this: CellView,
args: {
@ -203,6 +208,7 @@ export namespace CellEditor {
color: '#000',
backgroundColor: '#fff',
},
labelAddable: true,
getText({ cell, index }) {
if (index === -1) {
return ''