util.breakText(text, size [, attrs, opt])

Break the text into lines so that the text fits into the bounding box defined by size.width and, optionally, size.height. attrs is an object with SVG attributes that will be set on the SVG text before measuring it (such as font-weight, font, ...). This function creates a temporary SVG <text> element with the attributes provided and continuously measures its width and height trying to fit as many words as possible on each line. When the text overflows the size.height, it is cut. The return value is a string with automatically added newline characters (\n) so that the text fits into the bounding box specified.

joint.util.breakText('this is quite a long text', { width: 50 })
// 'this is\nquite a\nlong\ntext'

The method accepts the following options (via opt).