Skip to content

Commit 15284e7

Browse files
authored
fix: 🐛 char ghosting when edit text (#2560) (#3043)
* fix: 🐛 char ghosting when edit text (#2560) * fix: 🐛 grammar style improvement
1 parent 1a0e8cf commit 15284e7

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

packages/x6/src/registry/tool/editor.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export class CellEditor extends ToolsView.ToolItem<
9494
}
9595
editor.innerText = text || ''
9696

97+
// clear display value when edit status because char ghosting.
98+
this.setCellText('')
99+
97100
return this
98101
}
99102

@@ -102,15 +105,7 @@ export class CellEditor extends ToolsView.ToolItem<
102105
const cell = this.cell
103106
const value = this.editor.innerText.replace(/\n$/, '') || ''
104107
// set value
105-
const setText = this.options.setText
106-
if (typeof setText === 'function') {
107-
FunctionExt.call(setText, this.cellView, {
108-
cell: this.cell,
109-
value,
110-
index: this.labelIndex,
111-
distance: this.distance,
112-
})
113-
}
108+
this.setCellText(value)
114109
// remove tool
115110
cell.removeTool(cell.isEdge() ? 'edge-editor' : 'node-editor')
116111
this.undelegateDocumentEvents()
@@ -141,6 +136,18 @@ export class CellEditor extends ToolsView.ToolItem<
141136
selection.addRange(range)
142137
}
143138
}
139+
140+
setCellText(value: string) {
141+
const setText = this.options.setText
142+
if (typeof setText === 'function') {
143+
FunctionExt.call(setText, this.cellView, {
144+
cell: this.cell,
145+
value,
146+
index: this.labelIndex,
147+
distance: this.distance,
148+
})
149+
}
150+
}
144151
}
145152

146153
export namespace CellEditor {

0 commit comments

Comments
 (0)