kangax/fabric.js — pull request #1778 by jafferhaider (2014-10-23 11:49:42+00:00)
Title: A Textbox with text wrapping and box resizing (subclasses IText)

For [Issue 187](https://github.com/kangax/fabric.js/issues/187). This is a more fully featured implementation than [Pull Request 725](https://github.com/kangax/fabric.js/pull/725).

I need this feature for my product, so I fully intend to support this class if it is made official.

### Summary of features
- Subclasses IText, so gets all of its goodness.
- Text wraps as user types and/or resizes textbox. Works with all textAlign values.
- User can change width of textbox. Font size of text does not change.
- Refactored the ton of `this.text.split(this._reNewline)` calls into a function that gets overwritten by subclasses.
- Tested on latest versions of Safari (OSX & iOS), Chrome (OSX & Win), Firefox and Internet Explorer.

### Open issues
1. Polymorphism bug in IText.toSVG(). The `callSuper` in `_setSVGTextLineText` goes into a recursive loop if called on a Textbox object. It works fine if I replace the `callSuper` call with a call to a copy of `Text._setSVGTextLineText`. Have you encountered something like this before? Any opinions on how to fix this?
2. I have performance improvements in mind. Wrapped lines can be cached since in some flows they're calculated multiple times. I am working on implementing it but I just wanted to get this pull request out so you could give feedback.

Please list changes that you'd like me to make before this can be made official. I saw in the other pull request that @kangax wasn't too sure about the 'Textbox' name ... we can change it.

Btw, this pull request also includes fixes for the multi-touch gestures related [Issue 1297](https://github.com/kangax/fabric.js/issues/1297).