Estoy usando fabric.js y han IText cuadros de texto en el lienzo. El usuario puede moverse libremente en el cuadro de texto de todo tipo y también modificar el texto dentro. Cómo evitar un cuadro de texto que se elimina (eliminado de la tela) cuando el usuario elimina el texto utilizando la tecla supr y no hay más texto?
Gracias por la respuesta.
deleteText(activeObject) {
var startIndex = activeObject.selectionStart;
var endIndex = activeObject.selectionEnd;
if (endIndex > 0 && startIndex != endIndex) {
var text = activeObject.text;
var newText =
text.substring(0, startIndex) +
text.substring(endIndex + 1, text.length);
activeObject.set("text", newText);
this.canvas.fire("object:modified");
} else {
this.canvas.remove(activeObject);
}
}