Skip to content

Commit

Permalink
backport path restore
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur committed Jul 3, 2024
1 parent ebb7c28 commit e480028
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/shapes/itext.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@
var styles = fabric.util.stylesFromArray(object.styles, object.text);
//copy object to prevent mutation
var objCopy = Object.assign({}, object, { styles: styles });
delete objCopy.path;
parseDecoration(objCopy);
if (objCopy.styles) {
for (var i in objCopy.styles) {
Expand All @@ -521,6 +522,17 @@
}
}
}
fabric.Object._fromObject('IText', objCopy, callback, 'text');
fabric.Object._fromObject('IText', objCopy, function(textInstance) {
textInstance.styles = fabric.util.stylesFromArray(object.styles, object.text);
if (object.path) {
fabric.Object._fromObject('Path', object.path, function(pathInstance) {
textInstance.set('path', pathInstance);
callback(textInstance);
}, 'path');
}
else {
callback(textInstance);
}
}, 'text');
};
})();
14 changes: 13 additions & 1 deletion src/shapes/textbox.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,18 @@
var styles = fabric.util.stylesFromArray(object.styles, object.text);
//copy object to prevent mutation
var objCopy = Object.assign({}, object, { styles: styles });
return fabric.Object._fromObject('Textbox', objCopy, callback, 'text');
delete objCopy.path;
return fabric.Object._fromObject('Textbox', objCopy, function(textInstance) {
textInstance.styles = fabric.util.stylesFromArray(object.styles, object.text);
if (object.path) {
fabric.Object._fromObject('Path', object.path, function(pathInstance) {
textInstance.set('path', pathInstance);
callback(textInstance);
}, 'path');
}
else {
callback(textInstance);
}
}, 'text');
};
})(typeof exports !== 'undefined' ? exports : this);

0 comments on commit e480028

Please sign in to comment.