fix: remove text shape if content is empty

pull/6489/head
Peng Xiao 2022-08-24 14:12:52 +08:00
parent 1c54e62580
commit 6b3c5bbd2c
1 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,21 @@ export class EditingShapeState<
}
onExit = () => {
// cleanup text shapes
if ('text' in this.editingShape.props) {
// @ts-expect-error better typing
const newText = this.editingShape.props['text'].trim()
if (newText === '' && this.editingShape.props.type === 'text') {
this.app.deleteShapes([this.editingShape])
} else {
this.editingShape.onResetBounds()
this.editingShape.update({
text: newText,
})
}
}
this.app.persist()
this.app.setEditingShape()