Global

Members

__cachedLines :Array

Cached array of text wrapping.
Type:
Source:

dynamicMinWidth :Number

Minimum calculated width of a textbox, in pixels. fixed to 2 so that an empty textbox cannot go to 0 and is still selectable without text.
Type:
  • Number
Default Value:
  • 2
Source:

lockScalingFlip

Override standard Object class values
Source:

lockScalingY

Override standard Object class values
Source:

minWidth :Number

Minimum width of textbox, in pixels.
Type:
  • Number
Default Value:
  • 20
Source:

noScaleCache

Override standard Object class values Textbox needs this on false
Source:

type :String

Type of an object
Type:
  • String
Default Value:
  • textbox
Source:

Methods

_getCursorBoundariesOffsets(chars, typeOfBoundaries) → {Object}

Overrides superclass function and uses text wrapping data to get cursor boundary offsets instead of the array of chars.
Parameters:
Name Type Description
chars Array Unused
typeOfBoundaries String Can be 'cursor' or 'selection'
Source:
Returns:
Object with 'top', 'left', and 'lineLeft' properties set.
Type
Object

_splitTextIntoLines() → {Array}

Gets lines of text to render in the Textbox. This function calculates text wrapping on the fly everytime it is called.
Source:
Returns:
Array of lines in the Textbox.
Type
Array

_wrapLine(ctx, text, lineIndex) → {Array}

Wraps a line of text using the width of the Textbox and a context.
Parameters:
Name Type Description
ctx CanvasRenderingContext2D Context to use for measurements
text String The string of text to split into lines
lineIndex Number
Source:
Returns:
Array of line(s) into which the given text is wrapped to.
Type
Array

_wrapText(ctx, text) → {Array}

Wraps text using the 'width' property of Textbox. First this function splits text on newlines, so we preserve newlines entered by the user. Then it wraps each line using the width of the Textbox by calling _wrapLine().
Parameters:
Name Type Description
ctx CanvasRenderingContext2D Context to use for measurements
text String The string of text that is split into lines
Source:
Returns:
Array of lines
Type
Array

applyFilters(callback, filters, imgElement, forResizing) → {CanvasElement}

Applies filters assigned to this image (from "filters" array)
Parameters:
Name Type Description
callback function Callback is invoked when all filters have been applied and new image is generated
filters Array to be applied
imgElement fabric.Image image to filter ( default to this._element )
forResizing Boolean
Source:
Returns:
canvasEl to be drawn immediately
Type
CanvasElement

get2DCursorLocation(selectionStartopt)

Returns 2d representation (lineIndex and charIndex) of cursor (or selection start). Overrides the superclass function to take into account text wrapping.
Parameters:
Name Type Attributes Description
selectionStart Number <optional>
Optional index. When not given, current selectionStart is used.
Source:

initialize(text, optionsopt) → {fabric.Textbox}

Constructor. Some scaling related property values are forced. Visibility of controls is also fixed; only the rotation and width controls are made available.
Parameters:
Name Type Attributes Description
text String Text string
options Object <optional>
Options object
Source:
Returns:
thisArg
Type
fabric.Textbox

setOnGroup(key, value)

When part of a group, we don't want the Textbox's scale to increase if the group's increases. That's why we reduce the scale of the Textbox by the amount that the group's increases. This is to maintain the effective scale of the Textbox at 1, so that font-size values make sense. Otherwise the same font-size value would result in different actual size depending on the value of the scale.
Parameters:
Name Type Description
key String
value *
Source:

toObject(propertiesToIncludeopt) → {Object}

Returns object representation of an instance
Parameters:
Name Type Attributes Description
propertiesToInclude Array <optional>
Any properties that you might want to additionally include in the output
Source:
Returns:
object representation of an instance
Type
Object

toObject(propertiesToIncludeopt) → {Object}

Returns object representation of an instance
Parameters:
Name Type Attributes Description
propertiesToInclude Array <optional>
Any properties that you might want to additionally include in the output
Source:
Returns:
object representation of an instance
Type
Object