fix: 🐛 optimize setText for edge-editor (#1877)

This commit is contained in:
vector
2022-03-08 07:15:58 +08:00
committed by GitHub
parent 548f56e9c5
commit 928b678f35

View File

@ -99,7 +99,7 @@ export class CellEditor extends ToolsView.ToolItem<
const value = this.editor.innerText.replace(/\n$/, '') || ''
// set value
const setText = this.options.setText
if (value !== '' && typeof setText === 'function') {
if (typeof setText === 'function') {
FunctionExt.call(setText, this.cellView, {
cell: this.cell,
value,
@ -223,7 +223,11 @@ export namespace CellEditor {
},
})
} else {
edge.prop(`labels/${index}/attrs/label/text`, value)
if (value) {
edge.prop(`labels/${index}/attrs/label/text`, value)
} else if (typeof index === 'number') {
edge.removeLabelAt(index)
}
}
},
})