Reputation: 21
I would like to know how to retrieve text (IText / Text) value from text object?
var textObj = new fabric.IText('hello friends', { left: 100, top: 100 });
canvas.add(textObj);
So how I can retrieve the text value of 'textObj'?
Upvotes: 2
Views: 3616
Reputation: 100331
textObj.text
or textObj.get('text')
works on Fabricjs 2.x
To get the text from the selected object
const obj = canvas.getActiveObject()
if (obj && obj.isType('textbox')) {
const { text } = obj
// ...
}
Upvotes: 4