Textbox
Defined in: src/shapes/Textbox.ts:54
Textbox class, based on IText, allows the user to resize the text rectangle and wraps lines automatically. Textboxes have their Y scaling locked, the user can only change width. Height is adjusted automatically based on the wrapping of lines.
Extends
Section titled “Extends”IText
<Props
,SProps
,EventSpec
>
Type Parameters
Section titled “Type Parameters”Props
extends TOptions
<TextboxProps
> = Partial
<TextboxProps
>
SProps
Section titled “SProps”SProps
extends SerializedTextboxProps
= SerializedTextboxProps
EventSpec
Section titled “EventSpec”EventSpec
extends ITextEvents
= ITextEvents
Implements
Section titled “Implements”UniqueTextboxProps
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Textbox<
Props
,SProps
,EventSpec
>(text
,options?
):Textbox
<Props
,SProps
,EventSpec
>
Defined in: src/shapes/Textbox.ts:110
Constructor
Parameters
Section titled “Parameters”string
Text string
options?
Section titled “options?”Props
Options object
Returns
Section titled “Returns”Textbox
<Props
, SProps
, EventSpec
>
Overrides
Section titled “Overrides”Properties
Section titled “Properties”__corner?
Section titled “__corner?”
optional
__corner:string
Defined in: src/shapes/Object/InteractiveObject.ts:105
keeps the value of the last hovered corner during mouse move. 0 is no corner, or ‘mt’, ‘ml’, ‘mtr’ etc.. It should be private, but there is no harm in using it as a read-only property. this isn’t cleaned automatically. Non selected objects may have wrong values
Inherited from
Section titled “Inherited from”__lineHeights
Section titled “__lineHeights”__lineHeights:
number
[]
Defined in: src/shapes/Text/Text.ts:411
Inherited from
Section titled “Inherited from”__lineWidths
Section titled “__lineWidths”__lineWidths:
number
[]
Defined in: src/shapes/Text/Text.ts:412
Inherited from
Section titled “Inherited from”_controlsVisibility
Section titled “_controlsVisibility”_controlsVisibility:
Record
<string
,boolean
>
Defined in: src/shapes/Object/InteractiveObject.ts:112
a map of control visibility for this object. this was left when controls were introduced to not break the api too much this takes priority over the generic control visibility
Inherited from
Section titled “Inherited from”_fontSizeMult
Section titled “_fontSizeMult”_fontSizeMult:
number
Defined in: src/shapes/Text/Text.ts:339
Text Line proportion to font Size (in pixels)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”_scaling?
Section titled “_scaling?”
optional
_scaling:boolean
Defined in: src/shapes/Object/InteractiveObject.ts:134
A boolean used from the gesture module to keep tracking of a scaling action when there is no scaling transform in place. This is an edge case and is used twice in all codebase. Probably added to keep track of some performance issues
use git blame to investigate why it was added DON’T USE IT. WE WILL TRY TO REMOVE IT
Inherited from
Section titled “Inherited from”_styleMap
Section titled “_styleMap”_styleMap:
StyleMap
Defined in: src/shapes/Textbox.ts:88
_text:
string
[]
Defined in: src/shapes/Text/Text.ts:409
Inherited from
Section titled “Inherited from”_textLines
Section titled “_textLines”_textLines:
string
[][]
Defined in: src/shapes/Text/Text.ts:406
same as textlines, but each line is an array of graphemes as split by splitByGrapheme
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”_unwrappedTextLines
Section titled “_unwrappedTextLines”_unwrappedTextLines:
string
[][]
Defined in: src/shapes/Text/Text.ts:408
Inherited from
Section titled “Inherited from”_wordJoiners
Section titled “_wordJoiners”_wordJoiners:
RegExp
Defined in: src/shapes/Textbox.ts:86
Implementation of
Section titled “Implementation of”UniqueTextboxProps._wordJoiners
absolutePositioned
Section titled “absolutePositioned”absolutePositioned:
boolean
Defined in: src/shapes/Object/Object.ts:215
Meaningful ONLY when the object is used as clipPath. if true, the clipPath will have its top and left relative to canvas, and will not be influenced by the object transform. This will make the clipPath relative to the canvas, but clipping just a particular object. WARNING this is beta, this feature may change or be renamed. since 2.4.0
Default
Section titled “Default”false
Inherited from
Section titled “Inherited from”aCoords
Section titled “aCoords”aCoords:
TCornerPoint
Defined in: src/shapes/Object/ObjectGeometry.ts:63
Describe object’s corner position in scene coordinates. The coordinates are derived from the following: left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth. The coordinates do not depend on viewport changes. The coordinates get updated with setCoords. You can calculate them without updating with ()
Inherited from
Section titled “Inherited from”angle:
TDegree
Defined in: src/shapes/Object/ObjectGeometry.ts:583
Angle of rotation of an object (in degrees)
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”backgroundColor
Section titled “backgroundColor”backgroundColor:
string
Defined in: src/shapes/Object/Object.ts:202
Background color of an object. takes css colors https://www.w3.org/TR/css-color-3/
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”borderColor
Section titled “borderColor”borderColor:
string
Defined in: src/shapes/Object/InteractiveObject.ts:74
Color of controlling borders of an object (when it’s active)
Default
Section titled “Default”rgb(178,204,255)
Inherited from
Section titled “Inherited from”borderDashArray
Section titled “borderDashArray”borderDashArray:
null
|number
[]
Defined in: src/shapes/Object/InteractiveObject.ts:75
Array specifying dash pattern of an object’s borders (hasBorder must be true)
1.6.2
Inherited from
Section titled “Inherited from”borderOpacityWhenMoving
Section titled “borderOpacityWhenMoving”borderOpacityWhenMoving:
number
Defined in: src/shapes/Object/InteractiveObject.ts:76
Opacity of object’s controlling borders when object is active and moving
Default
Section titled “Default”0.4
Inherited from
Section titled “Inherited from”borderScaleFactor
Section titled “borderScaleFactor”borderScaleFactor:
number
Defined in: src/shapes/Object/InteractiveObject.ts:77
Scale factor for the border of the objects ( selection box and controls stroke ). Bigger number will make a thicker border border default value is 1, so this scale value is equal to a border and control strokeWidth. If you need to divide border from control strokeWidth you will need to write your own render function for controls
Default
Section titled “Default”1
Inherited from
Section titled “Inherited from”caching
Section titled “caching”caching:
boolean
Defined in: src/shapes/IText/IText.ts:215
Indicates whether internal text char widths can be cached
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”centeredRotation
Section titled “centeredRotation”centeredRotation:
boolean
Defined in: src/shapes/Object/Object.ts:216
When true
the object will rotate on its center.
When false
will rotate around the origin point defined by originX and originY.
The value of this property is IGNORED during a transform if the canvas has already
centeredRotation set to true
The object method rotate
will always consider this property and never the canvas’s one.
1.3.4
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”centeredScaling
Section titled “centeredScaling”centeredScaling:
boolean
Defined in: src/shapes/Object/Object.ts:217
When true, this object will use center point as the origin of transformation when being scaled via the controls.
1.3.4
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”charSpacing
Section titled “charSpacing”charSpacing:
number
Defined in: src/shapes/Text/Text.ts:347
additional space between characters expressed in thousands of em unit
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”clipPath?
Section titled “clipPath?”
optional
clipPath:BaseFabricObject
<Partial
<ObjectProps
>,SerializedObjectProps
,ObjectEvents
>
Defined in: src/shapes/Object/Object.ts:213
Inherited from
Section titled “Inherited from”clipPathId?
Section titled “clipPathId?”
optional
clipPathId:string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:15
When an object is being exported as SVG as a clippath, a reference inside the SVG is needed. This reference is a UID in the fabric namespace and is temporary stored here.
Inherited from
Section titled “Inherited from”compositionColor
Section titled “compositionColor”compositionColor:
string
Defined in: src/shapes/IText/IText.ts:208
Inherited from
Section titled “Inherited from”compositionEnd
Section titled “compositionEnd”compositionEnd:
number
Defined in: src/shapes/IText/IText.ts:147
Inherited from
Section titled “Inherited from”compositionStart
Section titled “compositionStart”compositionStart:
number
Defined in: src/shapes/IText/IText.ts:145
Inherited from
Section titled “Inherited from”controls
Section titled “controls”controls:
TControlSet
Defined in: src/shapes/Object/InteractiveObject.ts:118
holds the controls for the object. controls are added by default_controls.js
Inherited from
Section titled “Inherited from”cornerColor
Section titled “cornerColor”cornerColor:
string
Defined in: src/shapes/Object/InteractiveObject.ts:68
Color of controlling corners of an object (when it’s active)
Default
Section titled “Default”rgb(178,204,255)
Inherited from
Section titled “Inherited from”cornerDashArray
Section titled “cornerDashArray”cornerDashArray:
null
|number
[]
Defined in: src/shapes/Object/InteractiveObject.ts:71
Array specifying dash pattern of an object’s control (hasBorder must be true)
1.6.2
Default
Section titled “Default”null
Inherited from
Section titled “Inherited from”cornerSize
Section titled “cornerSize”cornerSize:
number
Defined in: src/shapes/Object/InteractiveObject.ts:65
Size of object’s controlling corners (in pixels)
Default
Section titled “Default”13
Inherited from
Section titled “Inherited from”cornerStrokeColor
Section titled “cornerStrokeColor”cornerStrokeColor:
string
Defined in: src/shapes/Object/InteractiveObject.ts:69
Color of controlling corners of an object (when it’s active and transparentCorners false)
1.6.2
Default
Section titled “Default”''
Inherited from
Section titled “Inherited from”cornerStyle
Section titled “cornerStyle”cornerStyle:
"circle"
|"rect"
Defined in: src/shapes/Object/InteractiveObject.ts:70
Specify style of control, ‘rect’ or ‘circle’ This is deprecated. In the future there will be a standard control render And you can swap it with one of the alternative proposed with the control api
1.6.2
Default
Section titled “Default”'rect'
Inherited from
Section titled “Inherited from”ctrlKeysMapDown
Section titled “ctrlKeysMapDown”ctrlKeysMapDown:
TKeyMapIText
Defined in: src/shapes/IText/ITextKeyBehavior.ts:42
For functionalities on keyDown + ctrl || cmd
Inherited from
Section titled “Inherited from”ctrlKeysMapUp
Section titled “ctrlKeysMapUp”ctrlKeysMapUp:
TKeyMapIText
Defined in: src/shapes/IText/ITextKeyBehavior.ts:37
For functionalities on keyUp + ctrl || cmd
Inherited from
Section titled “Inherited from”cursorColor
Section titled “cursorColor”cursorColor:
string
Defined in: src/shapes/IText/IText.ts:192
Color of text cursor color in editing mode. if not set (default) will take color from the text. if set to a color value that fabric can understand, it will be used instead of the color of the text at the current position.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”cursorDelay
Section titled “cursorDelay”cursorDelay:
number
Defined in: src/shapes/IText/IText.ts:199
Delay between cursor blink (in ms)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”cursorDuration
Section titled “cursorDuration”cursorDuration:
number
Defined in: src/shapes/IText/IText.ts:206
Duration of cursor fade in (in ms)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”cursorWidth
Section titled “cursorWidth”cursorWidth:
number
Defined in: src/shapes/IText/IText.ts:182
Width of cursor (in px)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”deltaY
Section titled “deltaY”deltaY:
number
Defined in: src/shapes/Text/Text.ts:354
Baseline shift, styles only, keep at 0 for the main text object
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”direction
Section titled “direction”direction:
CanvasDirection
Defined in: src/shapes/Text/Text.ts:367
WARNING: EXPERIMENTAL. NOT SUPPORTED YET determine the direction of the text. This has to be set manually together with textAlign and originX for proper experience. some interesting link for the future https://www.w3.org/International/questions/qa-bidi-unicode-controls
4.5.0
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”dirty:
boolean
Defined in: src/shapes/Object/Object.ts:242
When set to true
, object’s cache will be rerendered next render call.
since 1.7.0
Default
Section titled “Default”true
Inherited from
Section titled “Inherited from”dynamicMinWidth
Section titled “dynamicMinWidth”dynamicMinWidth:
number
Defined in: src/shapes/Textbox.ts:76
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.
Default
Section titled “Default”
Implementation of
Section titled “Implementation of”UniqueTextboxProps.dynamicMinWidth
editable
Section titled “editable”editable:
boolean
Defined in: src/shapes/IText/IText.ts:168
Indicates whether a text can be edited
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”editingBorderColor
Section titled “editingBorderColor”editingBorderColor:
string
Defined in: src/shapes/IText/IText.ts:175
Border color of text object while it’s in editing mode
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”evented
Section titled “evented”evented:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:82
When set to false
, an object can not be a target of events. All events propagate through it. Introduced in v1.3.4
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”excludeFromExport
Section titled “excludeFromExport”excludeFromExport:
boolean
Defined in: src/shapes/Object/Object.ts:209
When true
, object is not exported in OBJECT/JSON
1.6.3
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”fill:
null
|string
|TFiller
Defined in: src/shapes/Object/Object.ts:192
Inherited from
Section titled “Inherited from”fillRule
Section titled “fillRule”fillRule:
CanvasFillRule
Defined in: src/shapes/Object/Object.ts:193
Fill rule used to fill an object
accepted values are nonzero, evenodd
Backwards incompatibility note: This property was used for setting globalCompositeOperation until v1.4.12 (use globalCompositeOperation
instead)
Default
Section titled “Default”nonzero
Inherited from
Section titled “Inherited from”flipX:
boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:569
When true, an object is rendered as flipped horizontally
Default
Section titled “Default”false
Inherited from
Section titled “Inherited from”flipY:
boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:570
When true, an object is rendered as flipped vertically
Default
Section titled “Default”false
Inherited from
Section titled “Inherited from”fontFamily
Section titled “fontFamily”fontFamily:
string
Defined in: src/shapes/Text/Text.ts:188
Font family
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”fontSize
Section titled “fontSize”fontSize:
number
Defined in: src/shapes/Text/Text.ts:174
Font size (in pixels)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”fontStyle
Section titled “fontStyle”fontStyle:
string
Defined in: src/shapes/Text/Text.ts:224
Font style . Possible values: "", “normal”, “italic” or “oblique”.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”fontWeight
Section titled “fontWeight”fontWeight:
string
|number
Defined in: src/shapes/Text/Text.ts:181
Font weight (e.g. bold, normal, 400, 600, 800)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”globalCompositeOperation
Section titled “globalCompositeOperation”globalCompositeOperation:
GlobalCompositeOperation
Defined in: src/shapes/Object/Object.ts:201
Composite rule used for canvas globalCompositeOperation
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”IText
.globalCompositeOperation
hasBorders
Section titled “hasBorders”hasBorders:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:78
When set to false
, object’s controlling borders are not rendered
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”hasControls
Section titled “hasControls”hasControls:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:72
When set to false
, object’s controls are not displayed and can not be used to manipulate object
Default
Section titled “Default”true
Inherited from
Section titled “Inherited from”height
Section titled “height”height:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:568
Object height
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”hiddenTextarea
Section titled “hiddenTextarea”hiddenTextarea:
null
|HTMLTextAreaElement
Defined in: src/shapes/IText/ITextKeyBehavior.ts:44
Inherited from
Section titled “Inherited from”hiddenTextareaContainer?
Section titled “hiddenTextareaContainer?”
optional
hiddenTextareaContainer:null
|HTMLElement
Defined in: src/shapes/IText/ITextKeyBehavior.ts:54
DOM container to append the hiddenTextarea. An alternative to attaching to the document.body. Useful to reduce laggish redraw of the full document.body tree and also with modals event capturing that won’t let the textarea take focus.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”hoverCursor
Section titled “hoverCursor”hoverCursor:
null
|string
Defined in: src/shapes/Object/InteractiveObject.ts:86
Default cursor value used when hovering over this object on canvas
Default
Section titled “Default”null
Inherited from
Section titled “Inherited from”includeDefaultValues
Section titled “includeDefaultValues”includeDefaultValues:
boolean
Defined in: src/shapes/Object/Object.ts:208
When false
, default object’s values are not included in its serialization
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”initialized?
Section titled “initialized?”
optional
initialized:true
Defined in: src/shapes/Text/Text.ts:413
Inherited from
Section titled “Inherited from”inverted
Section titled “inverted”inverted:
boolean
Defined in: src/shapes/Object/Object.ts:214
Meaningful ONLY when the object is used as clipPath. if true, the clipPath will make the object clip to the outside of the clipPath since 2.4.0
Default
Section titled “Default”false
Inherited from
Section titled “Inherited from”isEditing
Section titled “isEditing”isEditing:
boolean
Defined in: src/shapes/IText/IText.ts:161
Indicates whether text is in editing mode
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”isMoving?
Section titled “isMoving?”
optional
isMoving:boolean
Defined in: src/shapes/Object/InteractiveObject.ts:124
internal boolean to signal the code that the object is part of the move action.
Inherited from
Section titled “Inherited from”isWrapping
Section titled “isWrapping”isWrapping:
boolean
Defined in: src/shapes/Textbox.ts:90
keysMap
Section titled “keysMap”keysMap:
TKeyMapIText
Defined in: src/shapes/IText/ITextKeyBehavior.ts:30
For functionalities on keyDown Map a special key to a function of the instance/prototype If you need different behavior for ESC or TAB or arrows, you have to change this map setting the name of a function that you build on the IText or your prototype. the map change will affect all Instances unless you need for only some text Instances in that case you have to clone this object and assign your Instance. this.keysMap = Object.assign({}, this.keysMap); The function must be in IText.prototype.myFunction And will receive event as args[0]
Inherited from
Section titled “Inherited from”keysMapRtl
Section titled “keysMapRtl”keysMapRtl:
TKeyMapIText
Defined in: src/shapes/IText/ITextKeyBehavior.ts:32
Inherited from
Section titled “Inherited from”left:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:566
Left position of an object. Note that by default it’s relative to object left. You can change this by setting FabricObject#originX
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”lineHeight
Section titled “lineHeight”lineHeight:
number
Defined in: src/shapes/Text/Text.ts:231
Line height
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”linethrough
Section titled “linethrough”linethrough:
boolean
Defined in: src/shapes/Text/Text.ts:209
Text decoration linethrough.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockMovementX
Section titled “lockMovementX”lockMovementX:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:56
When true
, object horizontal movement is locked
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockMovementY
Section titled “lockMovementY”lockMovementY:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:57
When true
, object vertical movement is locked
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockRotation
Section titled “lockRotation”lockRotation:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:58
When true
, object rotation is locked
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockScalingFlip
Section titled “lockScalingFlip”lockScalingFlip:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:63
When true
, object cannot be flipped by scaling into negative values
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockScalingX
Section titled “lockScalingX”lockScalingX:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:59
When true
, object horizontal scaling is locked
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockScalingY
Section titled “lockScalingY”lockScalingY:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:60
When true
, object vertical scaling is locked
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockSkewingX
Section titled “lockSkewingX”lockSkewingX:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:61
When true
, object horizontal skewing is locked
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”lockSkewingY
Section titled “lockSkewingY”lockSkewingY:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:62
When true
, object vertical skewing is locked
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”matrixCache?
Section titled “matrixCache?”
optional
matrixCache:TMatrixCache
Defined in: src/shapes/Object/ObjectGeometry.ts:73
storage cache for object full transform matrix
Inherited from
Section titled “Inherited from”MIN_TEXT_WIDTH
Section titled “MIN_TEXT_WIDTH”MIN_TEXT_WIDTH:
number
Defined in: src/shapes/Text/Text.ts:391
contains the min text width to avoid getting 0
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”minScaleLimit
Section titled “minScaleLimit”minScaleLimit:
number
Defined in: src/shapes/Object/Object.ts:187
Minimum allowed scale value of an object
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”minWidth
Section titled “minWidth”minWidth:
number
Defined in: src/shapes/Textbox.ts:67
Minimum width of textbox, in pixels.
Default
Section titled “Default”
Implementation of
Section titled “Implementation of”UniqueTextboxProps.minWidth
moveCursor
Section titled “moveCursor”moveCursor:
null
|string
Defined in: src/shapes/Object/InteractiveObject.ts:87
Default cursor value used when moving this object on canvas
Default
Section titled “Default”null
Inherited from
Section titled “Inherited from”noScaleCache
Section titled “noScaleCache”noScaleCache:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:51
When true
, cache does not get updated during scaling. The picture will get blocky if scaled
too much and will be redrawn with correct details at the end of scaling.
this setting is performance and application dependant.
default to true
since 1.7.0
Default
Section titled “Default”true
Inherited from
Section titled “Inherited from”objectCaching
Section titled “objectCaching”objectCaching:
boolean
Defined in: src/shapes/Object/Object.ts:211
When true
, object is cached on an additional canvas.
When false
, object is not cached unless necessary ( clipPath )
default to true
1.7.0
Default
Section titled “Default”true
Inherited from
Section titled “Inherited from”oCoords
Section titled “oCoords”oCoords:
Record
<string
,TOCoord
>
Defined in: src/shapes/Object/InteractiveObject.ts:95
The object’s controls’ position in viewport coordinates
Calculated by Control#positionHandler and Control#calcCornerCoords, depending on padding.
corner/touchCorner
describe the 4 points forming the interactive area of the corner.
Used to draw and locate controls.
Inherited from
Section titled “Inherited from”opacity
Section titled “opacity”opacity:
number
Defined in: src/shapes/Object/Object.ts:189
Opacity of an object
Default
Section titled “Default”1
Inherited from
Section titled “Inherited from”originX
Section titled “originX”originX:
TOriginX
Defined in: src/shapes/Object/ObjectGeometry.ts:578
Inherited from
Section titled “Inherited from”originY
Section titled “originY”originY:
TOriginY
Defined in: src/shapes/Object/ObjectGeometry.ts:582
Inherited from
Section titled “Inherited from”overline
Section titled “overline”overline:
boolean
Defined in: src/shapes/Text/Text.ts:202
Text decoration overline.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”ownMatrixCache?
Section titled “ownMatrixCache?”
optional
ownMatrixCache:TMatrixCache
Defined in: src/shapes/Object/ObjectGeometry.ts:68
storage cache for object transform matrix
Inherited from
Section titled “Inherited from”padding
Section titled “padding”padding:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:53
Padding between object and its controlling borders (in pixels)
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”paintFirst
Section titled “paintFirst”paintFirst:
"fill"
|"stroke"
Defined in: src/shapes/Object/Object.ts:191
Determines if the fill or the stroke is drawn first (one of “fill” or “stroke”)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”parent?
Section titled “parent?”
optional
parent:Group
Defined in: src/shapes/Object/Object.ts:1606
A reference to the parent of the object
Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the group
ref
Inherited from
Section titled “Inherited from”
optional
path:Path
<Partial
<PathProps
>,SerializedPathProps
,ObjectEvents
>
Defined in: src/shapes/Text/Text.ts:296
Path that the text should follow. since 4.6.0 the path will be drawn automatically. if you want to make the path visible, give it a stroke and strokeWidth or fill value if you want it to be hidden, assign visible = false to the path. This feature is in BETA, and SVG import/export is not yet supported.
Example
Section titled “Example”const textPath = new Text('Text on a path', { top: 150, left: 150, textAlign: 'center', charSpacing: -50, path: new Path('M 0 0 C 50 -100 150 -100 200 0', { strokeWidth: 1, visible: false }), pathSide: 'left', pathStartOffset: 0});
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”pathAlign
Section titled “pathAlign”pathAlign:
TPathAlign
Defined in: src/shapes/Text/Text.ts:322
How text is aligned to the path. This property determines the perpendicular position of each character relative to the path. (one of “baseline”, “center”, “ascender”, “descender”) This feature is in BETA, and its behavior may change
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”pathSide
Section titled “pathSide”pathSide:
TPathSide
Defined in: src/shapes/Text/Text.ts:312
Which side of the path the text should be drawn on. Only used when text has a path
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”pathStartOffset
Section titled “pathStartOffset”pathStartOffset:
number
Defined in: src/shapes/Text/Text.ts:304
Offset amount for text path starting position Only used when text has a path
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”perPixelTargetFind
Section titled “perPixelTargetFind”perPixelTargetFind:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:83
When set to true
, objects are “found” on canvas on per-pixel basis rather than according to bounding box
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”scaleX
Section titled “scaleX”scaleX:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:571
Object scale factor (horizontal)
Default
Section titled “Default”1
Inherited from
Section titled “Inherited from”scaleY
Section titled “scaleY”scaleY:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:572
Object scale factor (vertical)
Default
Section titled “Default”1
Inherited from
Section titled “Inherited from”selectable
Section titled “selectable”selectable:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:81
When set to false
, an object can not be selected for modification (using either point-click-based or group-based selection).
But events still fire on it.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”selectionBackgroundColor
Section titled “selectionBackgroundColor”selectionBackgroundColor:
string
Defined in: src/shapes/Object/InteractiveObject.ts:79
Selection Background color of an object. colored layer behind the object when it is active. does not mix good with globalCompositeOperation methods.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”IText
.selectionBackgroundColor
selectionColor
Section titled “selectionColor”selectionColor:
string
Defined in: src/shapes/IText/IText.ts:154
Color of text selection
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”selectionEnd
Section titled “selectionEnd”selectionEnd:
number
Defined in: src/shapes/IText/IText.ts:143
Index where text selection ends
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”selectionStart
Section titled “selectionStart”selectionStart:
number
Defined in: src/shapes/IText/IText.ts:136
Index where text selection starts (or where cursor is when there is no selection)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”shadow
Section titled “shadow”shadow:
null
|Shadow
Defined in: src/shapes/Object/Object.ts:204
Inherited from
Section titled “Inherited from”skewX:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:573
Angle of skew on x axes of an object (in degrees)
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”skewY:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:574
Angle of skew on y axes of an object (in degrees)
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”snapAngle?
Section titled “snapAngle?”
optional
snapAngle:TDegree
Defined in: src/shapes/Object/InteractiveObject.ts:53
The angle that an object will lock to while rotating.
Inherited from
Section titled “Inherited from”snapThreshold?
Section titled “snapThreshold?”
optional
snapThreshold:TDegree
Defined in: src/shapes/Object/InteractiveObject.ts:54
The angle difference from the current snapped angle in which snapping should occur. When undefined, the snapThreshold will default to the snapAngle.
Inherited from
Section titled “Inherited from”splitByGrapheme
Section titled “splitByGrapheme”splitByGrapheme:
boolean
Defined in: src/shapes/Textbox.ts:84
Use this boolean property in order to split strings that have no white space concept. this is a cheap way to help with chinese/japanese
2.6.0
Implementation of
Section titled “Implementation of”UniqueTextboxProps.splitByGrapheme
stroke
Section titled “stroke”stroke:
null
|string
|TFiller
Defined in: src/shapes/Object/Object.ts:194
Inherited from
Section titled “Inherited from”strokeDashArray
Section titled “strokeDashArray”strokeDashArray:
null
|number
[]
Defined in: src/shapes/Object/Object.ts:195
Array specifying dash pattern of an object’s stroke (stroke must be defined)
Default
Section titled “Default”null;
Inherited from
Section titled “Inherited from”strokeDashOffset
Section titled “strokeDashOffset”strokeDashOffset:
number
Defined in: src/shapes/Object/Object.ts:196
Line offset of an object’s stroke
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”strokeLineCap
Section titled “strokeLineCap”strokeLineCap:
CanvasLineCap
Defined in: src/shapes/Object/Object.ts:197
Line endings style of an object’s stroke (one of “butt”, “round”, “square”)
Default
Section titled “Default”butt
Inherited from
Section titled “Inherited from”strokeLineJoin
Section titled “strokeLineJoin”strokeLineJoin:
CanvasLineJoin
Defined in: src/shapes/Object/Object.ts:198
Corner style of an object’s stroke (one of “bevel”, “round”, “miter”)
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”strokeMiterLimit
Section titled “strokeMiterLimit”strokeMiterLimit:
number
Defined in: src/shapes/Object/Object.ts:199
Maximum miter length (used for strokeLineJoin = “miter”) of an object’s stroke
Default
Section titled “Default”4
Inherited from
Section titled “Inherited from”strokeUniform
Section titled “strokeUniform”strokeUniform:
boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:585
When false
, the stoke width will scale with the object.
When true
, the stroke will always match the exact pixel size entered for stroke width.
this Property does not work on Text classes or drawing call that uses strokeText,fillText methods
default to false
2.6.0
Default
Section titled “Default”false
Default
Section titled “Default”false
Inherited from
Section titled “Inherited from”strokeWidth
Section titled “strokeWidth”strokeWidth:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:584
Width of a stroke used to render this object
Default
Section titled “Default”1
Inherited from
Section titled “Inherited from”styles
Section titled “styles”styles:
TextStyle
Defined in: src/shapes/Text/Text.ts:272
Inherited from
Section titled “Inherited from”subscript
Section titled “subscript”subscript:
object
Defined in: src/shapes/Text/Text.ts:252
Subscript schema object (minimum overlap)
baseline
Section titled “baseline”baseline:
number
baseline-shift factor (downwards)
Default
Section titled “Default”0.11
size:
number
fontSize factor
Default
Section titled “Default”0.6
Inherited from
Section titled “Inherited from”superscript
Section titled “superscript”superscript:
object
Defined in: src/shapes/Text/Text.ts:236
Superscript schema object (minimum overlap)
baseline
Section titled “baseline”baseline:
number
baseline-shift factor (upwards)
Default
Section titled “Default”-0.35
size:
number
fontSize factor
Default
Section titled “Default”0.6
Inherited from
Section titled “Inherited from”text:
string
Defined in: src/shapes/Text/Text.ts:167
Inherited from
Section titled “Inherited from”textAlign
Section titled “textAlign”textAlign:
string
Defined in: src/shapes/Text/Text.ts:217
Text alignment. Possible values: “left”, “center”, “right”, “justify”, “justify-left”, “justify-center” or “justify-right”.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”textBackgroundColor
Section titled “textBackgroundColor”textBackgroundColor:
string
Defined in: src/shapes/Text/Text.ts:270
Background color of text lines
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”textLines
Section titled “textLines”textLines:
string
[]
Defined in: src/shapes/Text/Text.ts:399
contains the the text of the object, divided in lines as they are displayed on screen. Wrapping will divide the text independently of line breaks
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”top:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:565
Top position of an object. Note that by default it’s relative to object top. You can change this by setting FabricObject#originY
Default
Section titled “Default”0
Inherited from
Section titled “Inherited from”touchCornerSize
Section titled “touchCornerSize”touchCornerSize:
number
Defined in: src/shapes/Object/InteractiveObject.ts:66
Size of object’s controlling corners when touch interaction is detected
Default
Section titled “Default”24
Inherited from
Section titled “Inherited from”transparentCorners
Section titled “transparentCorners”transparentCorners:
boolean
Defined in: src/shapes/Object/InteractiveObject.ts:67
When true, object’s controlling corners are rendered as transparent inside (i.e. stroke instead of fill)
Default
Section titled “Default”true
Inherited from
Section titled “Inherited from”underline
Section titled “underline”underline:
boolean
Defined in: src/shapes/Text/Text.ts:195
Text decoration underline.
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”visible
Section titled “visible”visible:
boolean
Defined in: src/shapes/Object/Object.ts:206
When set to false
, an object is not rendered on canvas
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”width:
number
Defined in: src/shapes/Object/ObjectGeometry.ts:567
Object width
Default
Section titled “Default”
Inherited from
Section titled “Inherited from”_styleProperties
Section titled “_styleProperties”
static
_styleProperties: readonlyStylePropertiesType
[] =styleProperties
Defined in: src/shapes/Text/StyledText.ts:30
Inherited from
Section titled “Inherited from”ATTRIBUTE_NAMES
Section titled “ATTRIBUTE_NAMES”
static
ATTRIBUTE_NAMES:string
[]
Defined in: src/shapes/Text/Text.ts:1826
List of attribute names to account for when parsing SVG element (used by FabricText.fromElement)
Static
Section titled “Static”Member Of
Section titled “Member Of”Text @see: http://www.w3.org/TR/SVG/text.html#TextElement
Inherited from
Section titled “Inherited from”cacheProperties
Section titled “cacheProperties”
static
cacheProperties:string
[]
Defined in: src/shapes/Text/Text.ts:415
List of properties to consider when checking if cache needs refresh Those properties are checked by calls to Object.set(key, value). If the key is in this list, the object is marked as dirty and refreshed at the next render
Inherited from
Section titled “Inherited from”colorProperties
Section titled “colorProperties”
static
colorProperties:string
[]
Defined in: src/shapes/Object/Object.ts:1513
List of properties to consider for animating colors.
Inherited from
Section titled “Inherited from”customProperties
Section titled “customProperties”
static
customProperties:string
[] =[]
Defined in: src/shapes/Object/Object.ts:1754
Define a list of custom properties that will be serialized when instance.toObject() gets called
Inherited from
Section titled “Inherited from”genericFonts
Section titled “genericFonts”
static
genericFonts:string
[]
Defined in: src/shapes/Text/Text.ts:1802
List of generic font families
https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name
Inherited from
Section titled “Inherited from”ownDefaults
Section titled “ownDefaults”
static
ownDefaults:Partial
<TClassProperties
<Textbox
<Partial
<TextboxProps
>,SerializedTextboxProps
,ITextEvents
>>> =textboxDefaultValues
Defined in: src/shapes/Textbox.ts:96
Overrides
Section titled “Overrides”stateProperties
Section titled “stateProperties”
static
stateProperties:string
[]
Defined in: src/shapes/Object/Object.ts:225
This list of properties is used to check if the state of an object is changed. This state change now is only used for children of groups to understand if a group needs its cache regenerated during a .set call
Inherited from
Section titled “Inherited from”
static
type:string
='Textbox'
Defined in: src/shapes/Textbox.ts:92
Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get type():
string
Defined in: src/shapes/IText/IText.ts:225
Legacy identifier of the class. Prefer using utils like isType or instanceOf Will be removed in fabric 7 or 8. The setter exists to avoid type errors in old code and possibly current deserialization code. DO NOT build new code around this type value
add sustainable warning message
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_drawClipPath()
Section titled “_drawClipPath()”_drawClipPath(
ctx
,clipPath
,context
):void
Defined in: src/shapes/Object/Object.ts:884
Prepare clipPath state and cache and draw it on instance’s cache
Parameters
Section titled “Parameters”CanvasRenderingContext2D
clipPath
Section titled “clipPath”undefined
| BaseFabricObject
<Partial
<ObjectProps
>, SerializedObjectProps
, ObjectEvents
>
context
Section titled “context”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_getFontDeclaration()
Section titled “_getFontDeclaration()”_getFontDeclaration(
__namedParameters?
,forMeasuring?
):string
Defined in: src/shapes/Text/Text.ts:1661
return font declaration string for canvas context
Parameters
Section titled “Parameters”__namedParameters?
Section titled “__namedParameters?”Partial
<Pick
<Partial
<CompleteTextStyleDeclaration
>, "fontFamily"
| "fontSize"
| "fontStyle"
| "fontWeight"
>> = {}
forMeasuring?
Section titled “forMeasuring?”boolean
Returns
Section titled “Returns”string
font declaration formatted for canvas context.
Inherited from
Section titled “Inherited from”_getGraphemeBox()
Section titled “_getGraphemeBox()”_getGraphemeBox(
grapheme
,lineIndex
,charIndex
,prevGrapheme?
,skipLeft?
):GraphemeBBox
Defined in: src/shapes/Text/Text.ts:983
Parameters
Section titled “Parameters”grapheme
Section titled “grapheme”string
to be measured
lineIndex
Section titled “lineIndex”number
index of the line where the char is
charIndex
Section titled “charIndex”number
position in the line
prevGrapheme?
Section titled “prevGrapheme?”string
character preceding the one to be measured
skipLeft?
Section titled “skipLeft?”boolean
Returns
Section titled “Returns”grapheme bbox
Inherited from
Section titled “Inherited from”_getSelectionForOffset()
Section titled “_getSelectionForOffset()”_getSelectionForOffset(
e
,isRight
):number
Defined in: src/shapes/IText/ITextKeyBehavior.ts:383
private Helps finding if the offset should be counted from Start or End
Parameters
Section titled “Parameters”KeyboardEvent
Event object
isRight
Section titled “isRight”boolean
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”_getWidthOfCharSpacing()
Section titled “_getWidthOfCharSpacing()”_getWidthOfCharSpacing():
number
Defined in: src/shapes/Text/Text.ts:1528
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”_limitCacheSize()
Section titled “_limitCacheSize()”_limitCacheSize(
dims
):any
Defined in: src/shapes/Object/Object.ts:403
Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal and each side do not cross fabric.cacheSideLimit those numbers are configurable so that you can get as much detail as you want making bargain with performances.
Parameters
Section titled “Parameters”any
Returns
Section titled “Returns”any
.width width of canvas
Inherited from
Section titled “Inherited from”_measureLine()
Section titled “_measureLine()”_measureLine(
lineIndex
):object
Defined in: src/shapes/Text/Text.ts:891
measure every grapheme of a line, populating __charBounds
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
Returns
Section titled “Returns”object
object.width total width of characters
numOfSpaces
Section titled “numOfSpaces”numOfSpaces:
number
=0
width:
number
Inherited from
Section titled “Inherited from”_measureWord()
Section titled “_measureWord()”_measureWord(
word
,lineIndex
,charOffset
):number
Defined in: src/shapes/Textbox.ts:389
Helper function to measure a string of text, given its lineIndex and charIndex offset It gets called when charBounds are not available yet. Override if necessary Use with Textbox#wordSplit
Parameters
Section titled “Parameters”string
[]
lineIndex
Section titled “lineIndex”number
charOffset
Section titled “charOffset”number
= 0
Returns
Section titled “Returns”number
_mouseDownHandler()
Section titled “_mouseDownHandler()”_mouseDownHandler(
__namedParameters
):void
Defined in: src/shapes/IText/ITextClickBehavior.ts:98
Default event handler for the basic functionalities needed on _mouseDown can be overridden to do something different. Scope of this implementation is: find the click position, set selectionStart find selectionEnd, initialize the drawing of either cursor or selection area initializing a mousedDown on a text area will cancel fabricjs knowledge of current compositionMode. It will be set to false.
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”TPointerEventInfo
<TPointerEvent
> & TPointerEventInfo
<TPointerEvent
> & object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_moveCursorLeftOrRight()
Section titled “_moveCursorLeftOrRight()”_moveCursorLeftOrRight(
direction
,e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:645
Moves cursor right or Left, fires event
Parameters
Section titled “Parameters”direction
Section titled “direction”‘Left’, ‘Right’
"Left"
| "Right"
KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_moveCursorUpOrDown()
Section titled “_moveCursorUpOrDown()”_moveCursorUpOrDown(
direction
,e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:483
Moves cursor up or down, fires the events
Parameters
Section titled “Parameters”direction
Section titled “direction”‘Up’ or ‘Down’
"Up"
| "Down"
KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_removeCacheCanvas()
Section titled “_removeCacheCanvas()”_removeCacheCanvas():
void
Defined in: src/shapes/Object/Object.ts:720
Remove cacheCanvas and its dimensions from the objects
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_renderControls()
Section titled “_renderControls()”_renderControls(
ctx
,styleOverride?
):void
Defined in: src/shapes/Object/InteractiveObject.ts:435
Renders controls and borders for the object the context here is not transformed
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context to render on
styleOverride?
Section titled “styleOverride?”TStyleOverride
= {}
properties to override the object style
Returns
Section titled “Returns”void
move to interactivity
Inherited from
Section titled “Inherited from”_renderCursor()
Section titled “_renderCursor()”_renderCursor(
ctx
,boundaries
,selectionStart
):void
Defined in: src/shapes/IText/IText.ts:615
Render the cursor at the given selectionStart.
Parameters
Section titled “Parameters”CanvasRenderingContext2D
transformed context to draw on
boundaries
Section titled “boundaries”selectionStart
Section titled “selectionStart”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_setClippingProperties()
Section titled “_setClippingProperties()”_setClippingProperties(
ctx
):void
Defined in: src/shapes/Object/Object.ts:1029
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”_setFillStyles()
Section titled “_setFillStyles()”_setFillStyles(
ctx
,style
):object
Defined in: src/shapes/Text/Text.ts:1341
This function prepare the canvas for a ill style, and fill need to be sent in as defined
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Pick
<Textbox
<Props
, SProps
, EventSpec
>, "fill"
>
with ill defined
Returns
Section titled “Returns”object
offsetX
Section titled “offsetX”offsetX:
number
offsetY
Section titled “offsetY”offsetY:
number
Inherited from
Section titled “Inherited from”_setStrokeStyles()
Section titled “_setStrokeStyles()”_setStrokeStyles(
ctx
,style
):object
Defined in: src/shapes/Text/Text.ts:1319
This function prepare the canvas for a stroke style, and stroke and strokeWidth need to be sent in as defined
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Pick
<CompleteTextStyleDeclaration
, "stroke"
| "strokeWidth"
>
with stroke and strokeWidth defined
Returns
Section titled “Returns”object
offsetX
Section titled “offsetX”offsetX:
number
offsetY
Section titled “offsetY”offsetY:
number
Inherited from
Section titled “Inherited from”_setupCompositeOperation()
Section titled “_setupCompositeOperation()”_setupCompositeOperation(
ctx
):void
Defined in: src/shapes/Object/Object.ts:1488
Sets canvas globalCompositeOperation for specific object custom composition operation for the particular object can be specified using globalCompositeOperation property
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Rendering canvas context
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”IText
._setupCompositeOperation
_splitTextIntoLines()
Section titled “_splitTextIntoLines()”_splitTextIntoLines(
text
):TextLinesInfo
Defined in: src/shapes/Textbox.ts:533
Gets lines of text to render in the Textbox. This function calculates text wrapping on the fly every time it is called.
Parameters
Section titled “Parameters”string
text to split
Returns
Section titled “Returns”TextLinesInfo
Array of lines in the Textbox.
Overrides
Section titled “Overrides”_toSVG()
Section titled “_toSVG()”_toSVG(
_reviver?
):string
[]
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:121
Returns svg representation of an instance This function is implemented in each subclass This is just because typescript otherwise cryies all the time
Parameters
Section titled “Parameters”_reviver?
Section titled “_reviver?”Returns
Section titled “Returns”string
[]
an array of strings with the specific svg representation of the instance
Inherited from
Section titled “Inherited from”_wrapText()
Section titled “_wrapText()”_wrapText(
lines
,desiredWidth
):string
[][]
Defined in: src/shapes/Textbox.ts:324
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
Section titled “Parameters”string
[]
The string array of text that is split into lines
desiredWidth
Section titled “desiredWidth”number
width you want to wrap to
Returns
Section titled “Returns”string
[][]
Array of lines
abortCursorAnimation()
Section titled “abortCursorAnimation()”abortCursorAnimation():
void
Defined in: src/shapes/IText/ITextBehavior.ts:182
Aborts cursor animation, clears all timeouts and clear textarea context if necessary
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”addPaintOrder()
Section titled “addPaintOrder()”addPaintOrder(
this
):string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:250
Parameters
Section titled “Parameters”FabricObjectSVGExportMixin
& FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”animate()
Section titled “animate()”animate<
T
>(animatable
,options?
):Record
<string
,TAnimation
<T
>>
Defined in: src/shapes/Object/Object.ts:1527
Animates object’s properties
Type Parameters
Section titled “Type Parameters”T
extends number
| number
[] | TColorArg
Parameters
Section titled “Parameters”animatable
Section titled “animatable”Record
<string
, T
>
map of keys and end values
options?
Section titled “options?”Partial
<AnimationOptions
<T
>>
Returns
Section titled “Returns”Record
<string
, TAnimation
<T
>>
map of animation contexts
As object — multiple properties
object.animate({ left: …, top: … }); object.animate({ left: …, top: … }, { duration: … });
Tutorial
Section titled “Tutorial”http://fabricjs.com/fabric-intro-part-2#animation
Inherited from
Section titled “Inherited from”blur()
Section titled “blur()”blur():
void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:106
Override this method to customize cursor behavior on textbox blur
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”calcACoords()
Section titled “calcACoords()”calcACoords():
TCornerPoint
Defined in: src/shapes/Object/ObjectGeometry.ts:429
Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates. those never change with zoom or viewport changes.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”calcOCoords()
Section titled “calcOCoords()”calcOCoords():
Record
<string
,TOCoord
>
Defined in: src/shapes/Object/InteractiveObject.ts:255
Calculates the coordinates of the center of each control plus the corners of the control itself This basically just delegates to each control positionHandler WARNING: changing what is passed to positionHandler is a breaking change, since position handler is a public api and should be done just if extremely necessary
Returns
Section titled “Returns”Record
<string
, TOCoord
>
Inherited from
Section titled “Inherited from”calcOwnMatrix()
Section titled “calcOwnMatrix()”calcOwnMatrix():
TMat2D
Defined in: src/shapes/Object/ObjectGeometry.ts:515
calculate transform matrix that represents the current transformations from the object’s properties, this matrix does not include the group transformation
Returns
Section titled “Returns”transform matrix for the object
Inherited from
Section titled “Inherited from”calcTextHeight()
Section titled “calcTextHeight()”calcTextHeight():
number
Defined in: src/shapes/Text/Text.ts:1044
Calculate text box height
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”calcTransformMatrix()
Section titled “calcTransformMatrix()”calcTransformMatrix(
skipGroup?
):TMat2D
Defined in: src/shapes/Object/ObjectGeometry.ts:487
calculate transform matrix that represents the current transformations from the object’s properties.
Parameters
Section titled “Parameters”skipGroup?
Section titled “skipGroup?”boolean
= false
return transform matrix for object not counting parent transformations There are some situation in which this is useful to avoid the fake rotation.
Returns
Section titled “Returns”transform matrix for the object
Inherited from
Section titled “Inherited from”canDrop()
Section titled “canDrop()”canDrop(
e
):boolean
Defined in: src/shapes/IText/ITextClickBehavior.ts:64
override this method to control whether instance should/shouldn’t become a drop target
Parameters
Section titled “Parameters”DragEvent
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”cleanStyle()
Section titled “cleanStyle()”cleanStyle(
property
):undefined
|false
Defined in: src/shapes/Text/StyledText.ts:101
Check if characters in a text have a value for a property whose value matches the textbox’s value for that property. If so, the character-level property is deleted. If the character has no other properties, then it is also deleted. Finally, if the line containing that character has no other characters then it also is deleted.
Parameters
Section titled “Parameters”property
Section titled “property”StylePropertiesType
Returns
Section titled “Returns”undefined
| false
Inherited from
Section titled “Inherited from”clearContextTop()
Section titled “clearContextTop()”clearContextTop(
restoreManually?
):undefined
|CanvasRenderingContext2D
Defined in: src/shapes/Object/InteractiveObject.ts:627
Clears the canvas.contextTop in a specific area that corresponds to the object’s bounding box that is in the canvas.contextContainer. This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object. Example: blinking cursor text selection, drag effects.
Parameters
Section titled “Parameters”restoreManually?
Section titled “restoreManually?”boolean
When true won’t restore the context after clear, in order to draw something else.
Returns
Section titled “Returns”undefined
| CanvasRenderingContext2D
canvas.contextTop that is either still transformed with the object transformMatrix, or restored to neutral transform
discuss swapping restoreManually with a renderCallback, but think of async issues
Inherited from
Section titled “Inherited from”clone()
Section titled “clone()”clone(
propertiesToInclude?
):Promise
<Textbox
<Props
,SProps
,EventSpec
>>
Defined in: src/shapes/Object/Object.ts:1255
Clones an instance.
Parameters
Section titled “Parameters”propertiesToInclude?
Section titled “propertiesToInclude?”string
[]
Any properties that you might want to additionally include in the output
Returns
Section titled “Returns”Promise
<Textbox
<Props
, SProps
, EventSpec
>>
Inherited from
Section titled “Inherited from”cloneAsImage()
Section titled “cloneAsImage()”cloneAsImage(
options?
):FabricImage
Defined in: src/shapes/Object/Object.ts:1281
Creates an instance of Image out of an object makes use of toCanvasElement. Once this method was based on toDataUrl and loadImage, so it also had a quality and format option. toCanvasElement is faster and produce no loss of quality. If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it. toCanvasElement and then toBlob from the obtained canvas is also a good option.
Parameters
Section titled “Parameters”options?
Section titled “options?”ObjectToCanvasElementOptions
for clone as image, passed to toDataURL
Returns
Section titled “Returns”Object cloned as image.
fix the export type, it could not be Image but the type that getClass return for ‘image’.
Inherited from
Section titled “Inherited from”cmdAll()
Section titled “cmdAll()”cmdAll():
void
Defined in: src/shapes/IText/ITextBehavior.ts:229
Selects entire text and updates the visual state
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”complexity()
Section titled “complexity()”complexity():
number
Defined in: src/shapes/Text/Text.ts:1794
Returns complexity of an instance
Returns
Section titled “Returns”number
complexity
Inherited from
Section titled “Inherited from”containsPoint()
Section titled “containsPoint()”containsPoint(
point
):boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:284
Checks if point is inside the object
Parameters
Section titled “Parameters”Point to check against
Returns
Section titled “Returns”boolean
true if point is inside the object
Inherited from
Section titled “Inherited from”copy()
Section titled “copy()”copy():
void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:301
Copies selected text
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”dispose()
Section titled “dispose()”dispose():
void
Defined in: src/shapes/IText/IText.ts:787
cancel instance’s running animations
override if necessary to dispose artifacts such as clipPath
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”doubleClickHandler()
Section titled “doubleClickHandler()”doubleClickHandler(
options
):void
Defined in: src/shapes/IText/ITextClickBehavior.ts:71
Default handler for double click, select a word
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”drawBorders()
Section titled “drawBorders()”drawBorders(
ctx
,options
,styleOverride?
):void
Defined in: src/shapes/Object/InteractiveObject.ts:478
Draws borders of an object’s bounding box. Requires public properties: width, height Requires public options: padding, borderColor
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context to draw on
options
Section titled “options”Required
object representing current object parameters
styleOverride?
Section titled “styleOverride?”TStyleOverride
object to override the object style
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”drawCacheOnCanvas()
Section titled “drawCacheOnCanvas()”drawCacheOnCanvas(
this
,ctx
):void
Defined in: src/shapes/Object/Object.ts:906
Paint the cached copy of the object on the target context.
Parameters
Section titled “Parameters”TCachedFabricObject
CanvasRenderingContext2D
Context to render on
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”drawClipPathOnCache()
Section titled “drawClipPathOnCache()”drawClipPathOnCache(
ctx
,clipPath
,canvasWithClipPath
):void
Defined in: src/shapes/Object/Object.ts:812
Execute the drawing operation for an object clipPath
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context to render on
clipPath
Section titled “clipPath”canvasWithClipPath
Section titled “canvasWithClipPath”HTMLCanvasElement
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”drawControls()
Section titled “drawControls()”drawControls(
ctx
,styleOverride
):void
Defined in: src/shapes/Object/InteractiveObject.ts:550
Draws corners of an object’s bounding box. Requires public properties: width, height Requires public options: cornerSize, padding Be aware that since fabric 6.0 this function does not call setCoords anymore. setCoords needs to be called manually if the object of which we are rendering controls is outside the standard selection and transform process.
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context to draw on
styleOverride
Section titled “styleOverride”Partial
= {}
object to override the object style
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”drawControlsConnectingLines()
Section titled “drawControlsConnectingLines()”drawControlsConnectingLines(
ctx
,size
):void
Defined in: src/shapes/Object/InteractiveObject.ts:517
Draws lines from a borders of an object’s bounding box to controls that have withConnection
property set.
Requires public properties: width, height
Requires public options: padding, borderColor
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context to draw on
object size x = width, y = height
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”IText
.drawControlsConnectingLines
drawObject()
Section titled “drawObject()”drawObject(
ctx
,forClipping
,context
):void
Defined in: src/shapes/Object/Object.ts:836
Execute the drawing operation for an object on a specified context
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context to render on
forClipping
Section titled “forClipping”apply clipping styles
undefined
| boolean
context
Section titled “context”additional context for rendering
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”drawSelectionBackground()
Section titled “drawSelectionBackground()”drawSelectionBackground(
ctx
):void
Defined in: src/shapes/Object/InteractiveObject.ts:375
Draws a colored layer behind the object, inside its selection borders. Requires public options: padding, selectionBackgroundColor this function is called when the context is transformed has checks to be skipped when the object is on a staticCanvas
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context to draw on
Returns
Section titled “Returns”void
evaluate if make this disappear in favor of a pre-render hook for objects this was added by Andrea Bogazzi to make possible some feature for work reasons it seemed a good option, now is an edge case
Inherited from
Section titled “Inherited from”enlargeSpaces()
Section titled “enlargeSpaces()”enlargeSpaces():
void
Defined in: src/shapes/Text/Text.ts:491
Enlarge space boxes and shift the others
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”enterEditing()
Section titled “enterEditing()”enterEditing(
e?
):void
Defined in: src/shapes/IText/ITextBehavior.ts:391
Enters editing state
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”enterEditingImpl()
Section titled “enterEditingImpl()”enterEditingImpl():
void
Defined in: src/shapes/IText/ITextBehavior.ts:410
runs the actual logic that enter from editing state, see enterEditing
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”exitEditing()
Section titled “exitEditing()”exitEditing():
Textbox
<Props
,SProps
,EventSpec
>
Defined in: src/shapes/IText/ITextBehavior.ts:720
Exits from editing state and fires relevant events
Returns
Section titled “Returns”Textbox
<Props
, SProps
, EventSpec
>
Inherited from
Section titled “Inherited from”exitEditingImpl()
Section titled “exitEditingImpl()”exitEditingImpl():
void
Defined in: src/shapes/IText/ITextBehavior.ts:707
runs the actual logic that exits from editing state, see exitEditing But it does not fire events
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”findAncestorsWithClipPath()
Section titled “findAncestorsWithClipPath()”findAncestorsWithClipPath():
FabricObject
<Partial
<FabricObjectProps
>,SerializedObjectProps
,ObjectEvents
>[]
Defined in: src/shapes/IText/IText.ts:452
Finds and returns an array of clip paths that are applied to the parent
group(s) of the current FabricObject instance. The object’s hierarchy is
traversed upwards (from the current object towards the root of the canvas),
checking each parent object for the presence of a clipPath
that is not
absolutely positioned.
Returns
Section titled “Returns”FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>[]
Inherited from
Section titled “Inherited from”IText
.findAncestorsWithClipPath
findCommonAncestors()
Section titled “findCommonAncestors()”findCommonAncestors<
T
>(other
):AncestryComparison
Defined in: src/shapes/Object/Object.ts:1645
Compare ancestors
Type Parameters
Section titled “Type Parameters”T
extends Textbox
<Props
, SProps
, EventSpec
>
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”AncestryComparison
an object that represent the ancestry situation.
Inherited from
Section titled “Inherited from”findLineBoundaryLeft()
Section titled “findLineBoundaryLeft()”findLineBoundaryLeft(
startFrom
):number
Defined in: src/shapes/IText/ITextBehavior.ts:295
Find new selection index representing start of current line according to current selection index
Parameters
Section titled “Parameters”startFrom
Section titled “startFrom”number
Current selection index
Returns
Section titled “Returns”number
New selection index
Inherited from
Section titled “Inherited from”findLineBoundaryRight()
Section titled “findLineBoundaryRight()”findLineBoundaryRight(
startFrom
):number
Defined in: src/shapes/IText/ITextBehavior.ts:312
Find new selection index representing end of current line according to current selection index
Parameters
Section titled “Parameters”startFrom
Section titled “startFrom”number
Current selection index
Returns
Section titled “Returns”number
New selection index
Inherited from
Section titled “Inherited from”findWordBoundaryLeft()
Section titled “findWordBoundaryLeft()”findWordBoundaryLeft(
startFrom
):number
Defined in: src/shapes/IText/ITextBehavior.ts:247
Find new selection index representing start of current word according to current selection index
Parameters
Section titled “Parameters”startFrom
Section titled “startFrom”number
Current selection index
Returns
Section titled “Returns”number
New selection index
Inherited from
Section titled “Inherited from”findWordBoundaryRight()
Section titled “findWordBoundaryRight()”findWordBoundaryRight(
startFrom
):number
Defined in: src/shapes/IText/ITextBehavior.ts:271
Find new selection index representing end of current word according to current selection index
Parameters
Section titled “Parameters”startFrom
Section titled “startFrom”number
Current selection index
Returns
Section titled “Returns”number
New selection index
Inherited from
Section titled “Inherited from”fire()
Section titled “fire()”fire<
K
>(eventName
,options?
):void
Defined in: src/Observable.ts:167
Fires event with an optional options object
Type Parameters
Section titled “Type Parameters”K
extends string
| number
| symbol
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
Event name to fire
options?
Section titled “options?”EventSpec
[K
]
Options object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”forEachControl()
Section titled “forEachControl()”forEachControl(
fn
):void
Defined in: src/shapes/Object/InteractiveObject.ts:353
Calls a function for each control. The function gets called, with the control, the control’s key and the object that is calling the iterator
Parameters
Section titled “Parameters”(control
, key
, fabricObject
) => any
function to iterate over the controls over
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”fromGraphemeToStringSelection()
Section titled “fromGraphemeToStringSelection()”fromGraphemeToStringSelection(
start
,end
,graphemes
):object
Defined in: src/shapes/IText/ITextBehavior.ts:503
convert from fabric to textarea values
Parameters
Section titled “Parameters”number
number
graphemes
Section titled “graphemes”string
[]
Returns
Section titled “Returns”object
selectionEnd
Section titled “selectionEnd”selectionEnd:
number
=graphemeStart
selectionStart
Section titled “selectionStart”selectionStart:
number
=graphemeStart
Inherited from
Section titled “Inherited from”IText
.fromGraphemeToStringSelection
fromStringToGraphemeSelection()
Section titled “fromStringToGraphemeSelection()”fromStringToGraphemeSelection(
start
,end
,text
):object
Defined in: src/shapes/IText/ITextBehavior.ts:486
convert from textarea to grapheme indexes
Parameters
Section titled “Parameters”number
number
string
Returns
Section titled “Returns”object
selectionEnd
Section titled “selectionEnd”selectionEnd:
number
=graphemeStart
selectionStart
Section titled “selectionStart”selectionStart:
number
=graphemeStart
Inherited from
Section titled “Inherited from”IText
.fromStringToGraphemeSelection
get(
property
):any
Defined in: src/CommonMethods.ts:59
Basic getter
Parameters
Section titled “Parameters”property
Section titled “property”string
Property name
Returns
Section titled “Returns”any
value of a property
Inherited from
Section titled “Inherited from”get2DCursorLocation()
Section titled “get2DCursorLocation()”get2DCursorLocation(
selectionStart?
,skipWrapping?
):object
Defined in: src/shapes/IText/IText.ts:351
Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)
Parameters
Section titled “Parameters”selectionStart?
Section titled “selectionStart?”number
= ...
Optional index. When not given, current selectionStart is used.
skipWrapping?
Section titled “skipWrapping?”boolean
consider the location for unwrapped lines. useful to manage styles.
Returns
Section titled “Returns”object
charIndex
Section titled “charIndex”charIndex:
number
=selectionStart
lineIndex
Section titled “lineIndex”lineIndex:
number
=i
Inherited from
Section titled “Inherited from”getActiveControl()
Section titled “getActiveControl()”getActiveControl():
undefined
| {control
:Control
;coord
:TOCoord
;key
:string
; }
Defined in: src/shapes/Object/InteractiveObject.ts:194
Returns
Section titled “Returns”undefined
| { control
: Control
; coord
: TOCoord
; key
: string
; }
Inherited from
Section titled “Inherited from”getAncestors()
Section titled “getAncestors()”getAncestors():
Ancestors
Defined in: src/shapes/Object/Object.ts:1628
Returns
Section titled “Returns”Ancestors
ancestors (excluding ActiveSelection
) from bottom to top
Inherited from
Section titled “Inherited from”getBoundingRect()
Section titled “getBoundingRect()”getBoundingRect():
TBBox
Defined in: src/shapes/Object/ObjectGeometry.ts:345
Returns coordinates of object’s bounding rectangle (left, top, width, height) the box is intended as aligned to axis of canvas.
Returns
Section titled “Returns”Object with left, top, width, height properties
Inherited from
Section titled “Inherited from”getCanvasRetinaScaling()
Section titled “getCanvasRetinaScaling()”getCanvasRetinaScaling():
number
Defined in: src/shapes/Object/ObjectGeometry.ts:402
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”getCenterPoint()
Section titled “getCenterPoint()”getCenterPoint():
Point
Defined in: src/shapes/Object/ObjectGeometry.ts:735
Returns the center coordinates of the object relative to canvas
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getCompleteStyleDeclaration()
Section titled “getCompleteStyleDeclaration()”getCompleteStyleDeclaration(
lineIndex
,charIndex
):CompleteTextStyleDeclaration
Defined in: src/shapes/Text/StyledText.ts:276
return a new object that contains all the style property for a character the object returned is newly created
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
of the line where the character is
charIndex
Section titled “charIndex”number
position of the character on the line
Returns
Section titled “Returns”style object
Inherited from
Section titled “Inherited from”IText
.getCompleteStyleDeclaration
getCoords()
Section titled “getCoords()”getCoords():
Point
[]
Defined in: src/shapes/Object/ObjectGeometry.ts:204
Returns
Section titled “Returns”Point
[]
[tl, tr, br, bl] in the scene plane
Inherited from
Section titled “Inherited from”getCurrentCharColor()
Section titled “getCurrentCharColor()”getCurrentCharColor():
null
|string
|TFiller
Defined in: src/shapes/IText/IText.ts:771
High level function to know the color of the cursor. the currentChar is the one that precedes the cursor Returns color (fill) of char at the current cursor if the text object has a pattern or gradient for filler, it will return that. Unused by the library, is for the end user
Returns
Section titled “Returns”null
| string
| TFiller
Character color (fill)
Inherited from
Section titled “Inherited from”getCurrentCharFontSize()
Section titled “getCurrentCharFontSize()”getCurrentCharFontSize():
number
Defined in: src/shapes/IText/IText.ts:758
High level function to know the height of the cursor. the currentChar is the one that precedes the cursor Returns fontSize of char at the current cursor Unused from the library, is for the end user
Returns
Section titled “Returns”number
Character font size
Inherited from
Section titled “Inherited from”getCursorRenderingData()
Section titled “getCursorRenderingData()”getCursorRenderingData(
selectionStart
,boundaries
):CursorRenderingData
Defined in: src/shapes/IText/IText.ts:581
Return the data needed to render the cursor for given selection start The left,top are relative to the object, while width and height are prescaled to look think with canvas zoom and object scaling, so they depend on canvas and object scaling
Parameters
Section titled “Parameters”selectionStart
Section titled “selectionStart”number
= ...
boundaries
Section titled “boundaries”CursorBoundaries
= ...
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getDownCursorOffset()
Section titled “getDownCursorOffset()”getDownCursorOffset(
e
,isRight
):number
Defined in: src/shapes/IText/ITextKeyBehavior.ts:351
Gets start offset of a selection
Parameters
Section titled “Parameters”KeyboardEvent
Event object
isRight
Section titled “isRight”boolean
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”getGraphemeDataForRender()
Section titled “getGraphemeDataForRender()”getGraphemeDataForRender(
lines
):GraphemeData
Defined in: src/shapes/Textbox.ts:343
For each line of text terminated by an hard line stop, measure each word width and extract the largest word from all. The returned words here are the one that at the end will be rendered.
Parameters
Section titled “Parameters”string
[]
the lines we need to measure
Returns
Section titled “Returns”getHeightOfChar()
Section titled “getHeightOfChar()”getHeightOfChar(
line
,_char
):number
Defined in: src/shapes/Text/Text.ts:866
Computes height of character at given position
Parameters
Section titled “Parameters”number
the line index number
number
the character index number
Returns
Section titled “Returns”number
fontSize of the character
Inherited from
Section titled “Inherited from”getHeightOfLine()
Section titled “getHeightOfLine()”getHeightOfLine(
lineIndex
):number
Defined in: src/shapes/Text/Text.ts:1025
Calculate height of line at ‘lineIndex’
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
index of line to calculate
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”getMinWidth()
Section titled “getMinWidth()”getMinWidth():
number
Defined in: src/shapes/Textbox.ts:545
Returns
Section titled “Returns”number
getObjectOpacity()
Section titled “getObjectOpacity()”getObjectOpacity():
number
Defined in: src/shapes/Object/Object.ts:571
Return the object opacity counting also the group property
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”getObjectScaling()
Section titled “getObjectScaling()”getObjectScaling():
Point
Defined in: src/shapes/Object/Object.ts:540
Return the object scale factor counting also the group scaling
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getPointByOrigin()
Section titled “getPointByOrigin()”getPointByOrigin(
originX
,originY
):Point
Defined in: src/shapes/Object/ObjectGeometry.ts:765
Returns the position of the object as if it has a different origin. Take an object that has left, top set to 100, 100 with origin ‘left’, ‘top’. Return the values of left top ( wrapped in a point ) that you would need to keep the same position if origin where different. Alternatively you can use this to also find which point in the parent plane is a specific origin ( where is the bottom right corner of my object? )
Parameters
Section titled “Parameters”originX
Section titled “originX”Horizontal origin: ‘left’, ‘center’ or ‘right’
originY
Section titled “originY”Vertical origin: ‘top’, ‘center’ or ‘bottom’
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getRelativeCenterPoint()
Section titled “getRelativeCenterPoint()”getRelativeCenterPoint():
Point
Defined in: src/shapes/Object/ObjectGeometry.ts:746
Returns the center coordinates of the object relative to it’s parent
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getRelativeX()
Section titled “getRelativeX()”getRelativeX():
number
Defined in: src/shapes/Object/ObjectGeometry.ts:115
Returns
Section titled “Returns”number
x position according to object’s FabricObject#originX property in parent’s coordinate plane
if parent is canvas then this property is identical to getX
Inherited from
Section titled “Inherited from”getRelativeXY()
Section titled “getRelativeXY()”getRelativeXY():
Point
Defined in: src/shapes/Object/ObjectGeometry.ts:176
Returns
Section titled “Returns”x,y position according to object’s FabricObject#originX FabricObject#originY properties in parent’s coordinate plane
Inherited from
Section titled “Inherited from”getRelativeY()
Section titled “getRelativeY()”getRelativeY():
number
Defined in: src/shapes/Object/ObjectGeometry.ts:131
Returns
Section titled “Returns”number
y position according to object’s FabricObject#originY property in parent’s coordinate plane
if parent is canvas then this property is identical to getY
Inherited from
Section titled “Inherited from”getScaledHeight()
Section titled “getScaledHeight()”getScaledHeight():
number
Defined in: src/shapes/Object/ObjectGeometry.ts:363
Returns height of an object bounding box counting transformations
Returns
Section titled “Returns”number
height value
shouldn’t this account for group transform and return the actual size in canvas coordinate plane?
Inherited from
Section titled “Inherited from”getScaledWidth()
Section titled “getScaledWidth()”getScaledWidth():
number
Defined in: src/shapes/Object/ObjectGeometry.ts:354
Returns width of an object’s bounding box counting transformations
Returns
Section titled “Returns”number
width value
shouldn’t this account for group transform and return the actual size in canvas coordinate plane?
Inherited from
Section titled “Inherited from”getSelectedText()
Section titled “getSelectedText()”getSelectedText():
string
Defined in: src/shapes/IText/ITextBehavior.ts:238
Returns selected text
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”getSelectionStartFromPointer()
Section titled “getSelectionStartFromPointer()”getSelectionStartFromPointer(
e
):number
Defined in: src/shapes/IText/ITextClickBehavior.ts:193
Returns index of a character corresponding to where an object was clicked
Parameters
Section titled “Parameters”Event object
Returns
Section titled “Returns”number
Index of a character
Inherited from
Section titled “Inherited from”IText
.getSelectionStartFromPointer
getSelectionStyles()
Section titled “getSelectionStyles()”getSelectionStyles(
startIndex
,endIndex
,complete?
):Partial
<CompleteTextStyleDeclaration
>[]
Defined in: src/shapes/IText/IText.ts:324
Gets style of a current selection/cursor (at the start position) if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.
Parameters
Section titled “Parameters”startIndex
Section titled “startIndex”number
= ...
Start index to get styles at
endIndex
Section titled “endIndex”number
= ...
End index to get styles at, if not specified selectionEnd or startIndex + 1
complete?
Section titled “complete?”boolean
get full style or not
Returns
Section titled “Returns”Partial
<CompleteTextStyleDeclaration
>[]
styles an array with one, zero or more Style objects
Inherited from
Section titled “Inherited from”getSvgCommons()
Section titled “getSvgCommons()”getSvgCommons(
this
):string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:85
Returns id attribute for svg output
Parameters
Section titled “Parameters”FabricObjectSVGExportMixin
& FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
> & object
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”getSvgFilter()
Section titled “getSvgFilter()”getSvgFilter(
this
):string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:77
Returns filter for svg shadow
Parameters
Section titled “Parameters”FabricObjectSVGExportMixin
& FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”getSvgStyles()
Section titled “getSvgStyles()”getSvgStyles(
this
,skipShadow?
):string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:22
Returns styles-string for svg-export
Parameters
Section titled “Parameters”FabricObjectSVGExportMixin
& FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>
skipShadow?
Section titled “skipShadow?”boolean
a boolean to skip shadow filter output
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”getSvgTransform()
Section titled “getSvgTransform()”getSvgTransform(
this
,full?
,additionalTransform?
):string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:104
Returns transform-string for svg-export
Parameters
Section titled “Parameters”FabricObjectSVGExportMixin
& FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>
boolean
additionalTransform?
Section titled “additionalTransform?”string
= ''
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”getTotalAngle()
Section titled “getTotalAngle()”getTotalAngle():
TDegree
Defined in: src/shapes/Object/ObjectGeometry.ts:410
Returns the object angle relative to canvas counting also the group property
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getTotalObjectScaling()
Section titled “getTotalObjectScaling()”getTotalObjectScaling():
Point
Defined in: src/shapes/Object/Object.ts:557
Return the object scale factor counting also the group scaling, zoom and retina
Returns
Section titled “Returns”object with scaleX and scaleY properties
Inherited from
Section titled “Inherited from”getUpCursorOffset()
Section titled “getUpCursorOffset()”getUpCursorOffset(
e
,isRight
):number
Defined in: src/shapes/IText/ITextKeyBehavior.ts:396
Parameters
Section titled “Parameters”KeyboardEvent
Event object
isRight
Section titled “isRight”boolean
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”getValueOfPropertyAt()
Section titled “getValueOfPropertyAt()”getValueOfPropertyAt<
T
>(lineIndex
,charIndex
,property
):Textbox
<Props
,SProps
,EventSpec
>[T
]
Defined in: src/shapes/Text/Text.ts:1542
Retrieves the value of property at given character position
Type Parameters
Section titled “Type Parameters”T
extends StylePropertiesType
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
the line number
charIndex
Section titled “charIndex”number
the character number
property
Section titled “property”T
the property name
Returns
Section titled “Returns”Textbox
<Props
, SProps
, EventSpec
>[T
]
the value of ‘property’
Inherited from
Section titled “Inherited from”getViewportTransform()
Section titled “getViewportTransform()”getViewportTransform():
TMat2D
Defined in: src/shapes/Object/ObjectGeometry.ts:420
Retrieves viewportTransform from Object’s canvas if available
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getX()
Section titled “getX()”getX():
number
Defined in: src/shapes/Object/ObjectGeometry.ts:86
Returns
Section titled “Returns”number
x position according to object’s FabricObject#originX property in canvas coordinate plane
Inherited from
Section titled “Inherited from”getXY()
Section titled “getXY()”getXY():
Point
Defined in: src/shapes/Object/ObjectGeometry.ts:146
Returns
Section titled “Returns”x position according to object’s FabricObject#originX FabricObject#originY properties in canvas coordinate plane
Inherited from
Section titled “Inherited from”getY()
Section titled “getY()”getY():
number
Defined in: src/shapes/Object/ObjectGeometry.ts:100
Returns
Section titled “Returns”number
y position according to object’s FabricObject#originY property in canvas coordinate plane
Inherited from
Section titled “Inherited from”graphemeSplit()
Section titled “graphemeSplit()”graphemeSplit(
value
):string
[]
Defined in: src/shapes/Text/Text.ts:1720
Override this method to customize grapheme splitting
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string
[]
array of graphemes
the util graphemeSplit
needs to be injectable in some way.
is more comfortable to inject the correct util rather than having to override text
in the middle of the prototype chain
Inherited from
Section titled “Inherited from”handleFiller()
Section titled “handleFiller()”handleFiller<
T
>(ctx
,property
,filler
):object
Defined in: src/shapes/Text/Text.ts:1279
Type Parameters
Section titled “Type Parameters”T
extends "fill"
| "stroke"
Parameters
Section titled “Parameters”CanvasRenderingContext2D
property
Section titled “property”`${T}Style`
filler
Section titled “filler”string
| TFiller
Returns
Section titled “Returns”object
offsetX
Section titled “offsetX”offsetX:
number
offsetY
Section titled “offsetY”offsetY:
number
Inherited from
Section titled “Inherited from”hasCommonAncestors()
Section titled “hasCommonAncestors()”hasCommonAncestors<
T
>(other
):boolean
Defined in: src/shapes/Object/Object.ts:1710
Type Parameters
Section titled “Type Parameters”T
extends Textbox
<Props
, SProps
, EventSpec
>
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”hasFill()
Section titled “hasFill()”hasFill():
null
|boolean
|""
Defined in: src/shapes/Object/Object.ts:751
return true if the object will draw a fill Does not consider text styles. This is just a shortcut used at rendering time We want it to be an approximation and be fast. wrote to avoid extra caching, it has to return true when fill happens, can guess when it will not happen at 100% chance, does not matter if it misses some use case where the fill is invisible.
Returns
Section titled “Returns”null
| boolean
| ""
Boolean
3.0.0
Inherited from
Section titled “Inherited from”hasStroke()
Section titled “hasStroke()”hasStroke():
null
|boolean
|""
Defined in: src/shapes/Object/Object.ts:735
return true if the object will draw a stroke Does not consider text styles. This is just a shortcut used at rendering time We want it to be an approximation and be fast. wrote to avoid extra caching, it has to return true when stroke happens, can guess when it will not happen at 100% chance, does not matter if it misses some use case where the stroke is invisible.
Returns
Section titled “Returns”null
| boolean
| ""
Boolean
3.0.0
Inherited from
Section titled “Inherited from”initBehavior()
Section titled “initBehavior()”initBehavior():
void
Defined in: src/shapes/IText/ITextClickBehavior.ts:26
Initializes all the interactive behavior of IText
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”initDelayedCursor()
Section titled “initDelayedCursor()”initDelayedCursor(
restart?
):void
Defined in: src/shapes/IText/ITextBehavior.ts:174
Initializes delayed cursor
Parameters
Section titled “Parameters”restart?
Section titled “restart?”boolean
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”initHiddenTextarea()
Section titled “initHiddenTextarea()”initHiddenTextarea():
void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:63
Initializes hidden textarea (needed to bring up keyboard in iOS)
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”insertChars()
Section titled “insertChars()”insertChars(
text
,style
,start
,end
):void
Defined in: src/shapes/IText/ITextBehavior.ts:1056
insert characters at start position, before start position. start equal 1 it means the text get inserted between actual grapheme 0 and 1 if style array is provided, it must be as the same length of text in graphemes if end is provided and is bigger than start, old text is replaced. start/end ar per grapheme position in _text array.
Parameters
Section titled “Parameters”string
text to insert
array of style objects
undefined
| Partial
<CompleteTextStyleDeclaration
>[]
number
number
= start
default to start + 1
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”insertCharStyleObject()
Section titled “insertCharStyleObject()”insertCharStyleObject(
lineIndex
,charIndex
,quantity
,copiedStyle?
):void
Defined in: src/shapes/IText/ITextBehavior.ts:906
Inserts style object for a given line/char index
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
Index of a line
charIndex
Section titled “charIndex”number
Index of a char
quantity
Section titled “quantity”number
number Style object to insert, if given
copiedStyle?
Section titled “copiedStyle?”Partial
<CompleteTextStyleDeclaration
>[]
array of style objects
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”insertNewlineStyleObject()
Section titled “insertNewlineStyleObject()”insertNewlineStyleObject(
lineIndex
,charIndex
,qty
,copiedStyle?
):void
Defined in: src/shapes/IText/ITextBehavior.ts:837
Handle insertion of more consecutive style lines for when one or more newlines gets added to the text. Since current style needs to be shifted first we shift the current style of the number lines needed, then we add new lines from the last to the first.
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
Index of a line
charIndex
Section titled “charIndex”number
Index of a char
number
number of lines to add
copiedStyle?
Section titled “copiedStyle?”Array of objects styles
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”IText
.insertNewlineStyleObject
insertNewStyleBlock()
Section titled “insertNewStyleBlock()”insertNewStyleBlock(
insertedText
,start
,copiedStyle?
):void
Defined in: src/shapes/IText/ITextBehavior.ts:964
Inserts style object(s)
Parameters
Section titled “Parameters”insertedText
Section titled “insertedText”string
[]
Characters at the location where style is inserted
number
cursor index for inserting style
copiedStyle?
Section titled “copiedStyle?”Partial
<CompleteTextStyleDeclaration
>[]
array of style objects to insert.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”intersectsWithObject()
Section titled “intersectsWithObject()”intersectsWithObject(
other
):boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:234
Checks if object intersects with another object
Parameters
Section titled “Parameters”ObjectGeometry
Object to test
Returns
Section titled “Returns”boolean
true if object intersects with another object
Inherited from
Section titled “Inherited from”intersectsWithRect()
Section titled “intersectsWithRect()”intersectsWithRect(
tl
,br
):boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:220
Checks if object intersects with the scene rect formed by TL and BR In this case the rect is meant aligned with the axis of the canvas. TL is the TOP LEFT point while br is the BOTTOM RIGHT point
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”isCacheDirty()
Section titled “isCacheDirty()”isCacheDirty(
skipCanvas
):boolean
Defined in: src/shapes/Object/Object.ts:923
Check if cache is dirty and if is dirty clear the context. This check has a big side effect, it changes the underlying cache canvas if necessary. Do not call this method on your own to check if the cache is dirty, because if it is, it is also going to wipe the cache. This is badly designed and needs to be fixed.
Parameters
Section titled “Parameters”skipCanvas
Section titled “skipCanvas”boolean
= false
skip canvas checks because this object is painted on parent canvas.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”isContainedWithinObject()
Section titled “isContainedWithinObject()”isContainedWithinObject(
other
):boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:253
Checks if object is fully contained within area of another object
Parameters
Section titled “Parameters”ObjectGeometry
Object to test
Returns
Section titled “Returns”boolean
true if object is fully contained within area of another object
Inherited from
Section titled “Inherited from”isContainedWithinRect()
Section titled “isContainedWithinRect()”isContainedWithinRect(
tl
,br
):boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:261
Checks if object is fully contained within the scene rect formed by TL and BR
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”isControlVisible()
Section titled “isControlVisible()”isControlVisible(
controlKey
):boolean
Defined in: src/shapes/Object/InteractiveObject.ts:584
Returns true if the specified control is visible, false otherwise.
Parameters
Section titled “Parameters”controlKey
Section titled “controlKey”string
The key of the control. Possible values are usually ‘tl’, ‘tr’, ‘br’, ‘bl’, ‘ml’, ‘mt’, ‘mr’, ‘mb’, ‘mtr’, but since the control api allow for any control name, can be any string.
Returns
Section titled “Returns”boolean
true if the specified control is visible, false otherwise
Inherited from
Section titled “Inherited from”isDescendantOf()
Section titled “isDescendantOf()”isDescendantOf(
target
):boolean
Defined in: src/shapes/Object/Object.ts:1614
Checks if object is descendant of target Should be used instead of Group.contains or StaticCanvas.contains for performance reasons
Parameters
Section titled “Parameters”target
Section titled “target”TAncestor
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”isEmptyStyles()
Section titled “isEmptyStyles()”isEmptyStyles(
lineIndex
):boolean
Defined in: src/shapes/Textbox.ts:208
Returns true if object has no styling or no styling in a line
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
, lineIndex is on wrapped lines.
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”isEndOfWrapping()
Section titled “isEndOfWrapping()”isEndOfWrapping(
lineIndex
):boolean
Defined in: src/shapes/Textbox.ts:500
Detect if the text line is ended with an hard break text and itext do not have wrapping, return false
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
text to split
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”isInFrontOf()
Section titled “isInFrontOf()”isInFrontOf<
T
>(other
):undefined
|boolean
Defined in: src/shapes/Object/Object.ts:1720
Type Parameters
Section titled “Type Parameters”T
extends Textbox
<Props
, SProps
, EventSpec
>
Parameters
Section titled “Parameters”T
object to compare against
Returns
Section titled “Returns”undefined
| boolean
if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns undefined
Inherited from
Section titled “Inherited from”isNotVisible()
Section titled “isNotVisible()”isNotVisible():
boolean
Defined in: src/shapes/Object/Object.ts:650
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”isOnScreen()
Section titled “isOnScreen()”isOnScreen():
boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:293
Checks if object is contained within the canvas with current viewportTransform the check is done stopping at first point that appears on screen
Returns
Section titled “Returns”boolean
true if object is fully or partially contained within canvas
Inherited from
Section titled “Inherited from”isOverlapping()
Section titled “isOverlapping()”isOverlapping<
T
>(other
):boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:271
Type Parameters
Section titled “Type Parameters”T
extends ObjectGeometry
<ObjectEvents
>
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”isPartiallyOnScreen()
Section titled “isPartiallyOnScreen()”isPartiallyOnScreen():
boolean
Defined in: src/shapes/Object/ObjectGeometry.ts:323
Checks if object is partially contained within the canvas with current viewportTransform
Returns
Section titled “Returns”boolean
true if object is partially contained within canvas
Inherited from
Section titled “Inherited from”isType()
Section titled “isType()”isType(…
types
):boolean
Defined in: src/shapes/Object/Object.ts:1419
Returns true if any of the specified types is identical to the type of an instance
Parameters
Section titled “Parameters”…string
[]
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”measureLine()
Section titled “measureLine()”measureLine(
lineIndex
):object
Defined in: src/shapes/Text/Text.ts:874
measure a text line measuring all characters.
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
line number
Returns
Section titled “Returns”object
numOfSpaces
Section titled “numOfSpaces”numOfSpaces:
number
=0
width:
number
Inherited from
Section titled “Inherited from”missingNewlineOffset()
Section titled “missingNewlineOffset()”missingNewlineOffset(
lineIndex
,skipWrapping?
):0
|1
Defined in: src/shapes/Textbox.ts:519
Detect if a line has a linebreak and so we need to account for it when moving and counting style. This is important only for splitByGrapheme at the end of wrapping. If we are not wrapping the offset is always 1
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
skipWrapping?
Section titled “skipWrapping?”boolean
Returns
Section titled “Returns”0
| 1
Number
Overrides
Section titled “Overrides”moveCursorDown()
Section titled “moveCursorDown()”moveCursorDown(
e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:457
Moves cursor down
Parameters
Section titled “Parameters”KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”moveCursorLeft()
Section titled “moveCursorLeft()”moveCursorLeft(
e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:542
Moves cursor left
Parameters
Section titled “Parameters”KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”moveCursorLeftWithoutShift()
Section titled “moveCursorLeftWithoutShift()”moveCursorLeftWithoutShift(
e
):boolean
Defined in: src/shapes/IText/ITextKeyBehavior.ts:594
Moves cursor left without keeping selection
Parameters
Section titled “Parameters”KeyboardEvent
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”IText
.moveCursorLeftWithoutShift
moveCursorLeftWithShift()
Section titled “moveCursorLeftWithShift()”moveCursorLeftWithShift(
e
):undefined
|boolean
Defined in: src/shapes/IText/ITextKeyBehavior.ts:614
Moves cursor left while keeping selection
Parameters
Section titled “Parameters”KeyboardEvent
Returns
Section titled “Returns”undefined
| boolean
Inherited from
Section titled “Inherited from”moveCursorRight()
Section titled “moveCursorRight()”moveCursorRight(
e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:630
Moves cursor right
Parameters
Section titled “Parameters”KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”moveCursorRightWithoutShift()
Section titled “moveCursorRightWithoutShift()”moveCursorRightWithoutShift(
e
):boolean
Defined in: src/shapes/IText/ITextKeyBehavior.ts:680
Moves cursor right without keeping selection
Parameters
Section titled “Parameters”KeyboardEvent
Event object
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”IText
.moveCursorRightWithoutShift
moveCursorRightWithShift()
Section titled “moveCursorRightWithShift()”moveCursorRightWithShift(
e
):undefined
|boolean
Defined in: src/shapes/IText/ITextKeyBehavior.ts:664
Moves cursor right while keeping selection
Parameters
Section titled “Parameters”KeyboardEvent
Returns
Section titled “Returns”undefined
| boolean
Inherited from
Section titled “Inherited from”IText
.moveCursorRightWithShift
moveCursorUp()
Section titled “moveCursorUp()”moveCursorUp(
e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:471
Moves cursor up
Parameters
Section titled “Parameters”KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”moveCursorWithoutShift()
Section titled “moveCursorWithoutShift()”moveCursorWithoutShift(
offset
):boolean
Defined in: src/shapes/IText/ITextKeyBehavior.ts:527
Moves cursor up without shift
Parameters
Section titled “Parameters”offset
Section titled “offset”number
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”moveCursorWithShift()
Section titled “moveCursorWithShift()”moveCursorWithShift(
offset
):boolean
Defined in: src/shapes/IText/ITextKeyBehavior.ts:510
Moves cursor with shift
Parameters
Section titled “Parameters”offset
Section titled “offset”number
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”needsItsOwnCache()
Section titled “needsItsOwnCache()”needsItsOwnCache():
boolean
Defined in: src/shapes/Object/Object.ts:763
When returns true
, force the object to have its own cache, even if it is inside a group
it may be needed when your object behave in a particular way on the cache and always needs
its own isolated canvas to render correctly.
Created to be overridden
since 1.7.12
Returns
Section titled “Returns”boolean
Boolean
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”off<
K
>(eventName
):void
Defined in: src/Observable.ts:122
Unsubscribe all event listeners for eventname. Do not use this pattern. You could kill internal fabricJS events. We know we should have protected events for internal flows, but we don’t have yet
Type Parameters
Section titled “Type Parameters”K
extends string
| number
| symbol
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
event name (eg. ‘after:render’)
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”off<
K
>(eventName
,handler
):void
Defined in: src/Observable.ts:128
unsubscribe an event listener
Type Parameters
Section titled “Type Parameters”K
extends string
| number
| symbol
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
event name (eg. ‘after:render’)
handler
Section titled “handler”TEventCallback
event listener to unsubscribe
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”off(
handlers
):void
Defined in: src/Observable.ts:133
unsubscribe event listeners
Parameters
Section titled “Parameters”handlers
Section titled “handlers”EventRegistryObject
<EventSpec
>
handlers key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”off():
void
Defined in: src/Observable.ts:137
unsubscribe all event listeners
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”on<
K
,E
>(eventName
,handler
):VoidFunction
Defined in: src/Observable.ts:23
Observes specified event
Type Parameters
Section titled “Type Parameters”K
extends string
| number
| symbol
E
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
Event name (eg. ‘after:render’)
handler
Section titled “handler”TEventCallback
<E
>
Function that receives a notification when an event of the specified type occurs
Returns
Section titled “Returns”VoidFunction
disposer
on
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”on(
handlers
):VoidFunction
Defined in: src/Observable.ts:27
Observes specified event
Parameters
Section titled “Parameters”handlers
Section titled “handlers”EventRegistryObject
<EventSpec
>
key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})
Returns
Section titled “Returns”VoidFunction
disposer
on
Inherited from
Section titled “Inherited from”once()
Section titled “once()”Call Signature
Section titled “Call Signature”once<
K
,E
>(eventName
,handler
):VoidFunction
Defined in: src/Observable.ts:62
Observes specified event once
Type Parameters
Section titled “Type Parameters”K
extends string
| number
| symbol
E
Parameters
Section titled “Parameters”eventName
Section titled “eventName”K
Event name (eg. ‘after:render’)
handler
Section titled “handler”TEventCallback
<E
>
Function that receives a notification when an event of the specified type occurs
Returns
Section titled “Returns”VoidFunction
disposer
once
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”once(
handlers
):VoidFunction
Defined in: src/Observable.ts:66
Observes specified event once
Parameters
Section titled “Parameters”handlers
Section titled “handlers”EventRegistryObject
<EventSpec
>
key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})
Returns
Section titled “Returns”VoidFunction
disposer
once
Inherited from
Section titled “Inherited from”onCompositionEnd()
Section titled “onCompositionEnd()”onCompositionEnd():
void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:287
Composition end
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”onCompositionStart()
Section titled “onCompositionStart()”onCompositionStart():
void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:280
Composition start
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”onCompositionUpdate()
Section titled “onCompositionUpdate()”onCompositionUpdate(
__namedParameters
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:291
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”CompositionEvent
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”onDeselect()
Section titled “onDeselect()”onDeselect(
options?
):boolean
Defined in: src/shapes/IText/ITextBehavior.ts:110
This callback function is called every time _discardActiveObject or _setActiveObject try to to deselect this object. If the function returns true, the process is cancelled
Parameters
Section titled “Parameters”options?
Section titled “options?”event if the process is generated by an event
object?
Section titled “object?”FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>
next object we are setting as active, and reason why this is being deselected
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”onDragStart()
Section titled “onDragStart()”onDragStart(
e
):boolean
Defined in: src/shapes/IText/ITextClickBehavior.ts:57
override this method to control whether instance should/shouldn’t become a drag source,
Parameters
Section titled “Parameters”DragEvent
Returns
Section titled “Returns”boolean
should handle event
also DraggableTextDelegate#isActive To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false
Inherited from
Section titled “Inherited from”onInput()
Section titled “onInput()”onInput(
this
,e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:174
Handles onInput event
Parameters
Section titled “Parameters”Textbox
<Props
, SProps
, EventSpec
> & object
Event
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”onKeyDown()
Section titled “onKeyDown()”onKeyDown(
e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:115
Handles keydown event only used for arrows and combination of modifier keys.
Parameters
Section titled “Parameters”KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”onKeyUp()
Section titled “onKeyUp()”onKeyUp(
e
):void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:151
Handles keyup event We handle KeyUp because ie11 and edge have difficulties copy/pasting if a copy/cut event fired, keyup is dismissed
Parameters
Section titled “Parameters”KeyboardEvent
Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”onSelect()
Section titled “onSelect()”onSelect(
_options?
):boolean
Defined in: src/shapes/Object/InteractiveObject.ts:672
This callback function is called every time _discardActiveObject or _setActiveObject try to to select this object. If the function returns true, the process is cancelled
Parameters
Section titled “Parameters”_options?
Section titled “_options?”options sent from the upper functions
event if the process is generated by an event
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”paste()
Section titled “paste()”paste():
void
Defined in: src/shapes/IText/ITextKeyBehavior.ts:323
Pastes text
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”removeChars()
Section titled “removeChars()”removeChars(
start
,end
):void
Defined in: src/shapes/IText/ITextBehavior.ts:1034
Removes characters from start/end start/end ar per grapheme position in _text array.
Parameters
Section titled “Parameters”number
number
= ...
default to start + 1
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”removeStyle()
Section titled “removeStyle()”removeStyle(
property
):void
Defined in: src/shapes/Text/StyledText.ts:162
Remove a style property or properties from all individual character styles in a text object. Deletes the character style object if it contains no other style props. Deletes a line style object if it contains no other character styles.
Parameters
Section titled “Parameters”property
Section titled “property”StylePropertiesType
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”removeStyleFromTo()
Section titled “removeStyleFromTo()”removeStyleFromTo(
start
,end
):void
Defined in: src/shapes/IText/ITextBehavior.ts:752
remove and reflow a style block from start to end.
Parameters
Section titled “Parameters”number
linear start position for removal (included in removal)
number
linear end position for removal ( excluded from removal )
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderCache()
Section titled “renderCache()”renderCache(
this
,options?
):void
Defined in: src/shapes/Object/Object.ts:696
Parameters
Section titled “Parameters”TCachedFabricObject
options?
Section titled “options?”any
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderCursor()
Section titled “renderCursor()”renderCursor(
ctx
,boundaries
):void
Defined in: src/shapes/IText/IText.ts:571
Renders cursor
Parameters
Section titled “Parameters”CanvasRenderingContext2D
transformed context to draw on
boundaries
Section titled “boundaries”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderCursorAt()
Section titled “renderCursorAt()”renderCursorAt(
selectionStart
):void
Defined in: src/shapes/IText/IText.ts:558
Renders cursor on context Top, outside the animation cycle, on request Used for the drag/drop effect. If contextTop is not available, do nothing.
Parameters
Section titled “Parameters”selectionStart
Section titled “selectionStart”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderCursorOrSelection()
Section titled “renderCursorOrSelection()”renderCursorOrSelection():
void
Defined in: src/shapes/IText/IText.ts:386
Renders cursor or selection (depending on what exists) it does on the contextTop. If contextTop is not available, do nothing.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderDragSourceEffect()
Section titled “renderDragSourceEffect()”renderDragSourceEffect():
void
Defined in: src/shapes/IText/IText.ts:647
Renders drag start text selection
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderDropTargetEffect()
Section titled “renderDropTargetEffect()”renderDropTargetEffect(
e
):void
Defined in: src/shapes/IText/IText.ts:657
Override to customize drag and drop behavior render a specific effect when an object is the target of a drag event used to show that the underly object can receive a drop, or to show how the object will change when dropping. example: show the cursor where the text is about to be dropped
Parameters
Section titled “Parameters”DragEvent
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderSelection()
Section titled “renderSelection()”renderSelection(
ctx
,boundaries
):void
Defined in: src/shapes/IText/IText.ts:632
Renders text selection
Parameters
Section titled “Parameters”CanvasRenderingContext2D
transformed context to draw on
boundaries
Section titled “boundaries”Object with left/top/leftOffset/topOffset
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”restartCursorIfNeeded()
Section titled “restartCursorIfNeeded()”restartCursorIfNeeded():
void
Defined in: src/shapes/IText/ITextBehavior.ts:205
Restart tue cursor animation if either is in complete state ( between animations ) or if it never started before
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”rotate()
Section titled “rotate()”rotate(
angle
):void
Defined in: src/shapes/Object/Object.ts:1447
Sets “angle” of an instance with centered rotation
Parameters
Section titled “Parameters”Angle value (in degrees)
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”scale()
Section titled “scale()”scale(
value
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:372
Scales an object (equally by x and y)
Parameters
Section titled “Parameters”number
Scale factor
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”scaleToHeight()
Section titled “scaleToHeight()”scaleToHeight(
value
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:395
Scales an object to a given height, with respect to bounding box (scaling by x/y equally)
Parameters
Section titled “Parameters”number
New height value
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”scaleToWidth()
Section titled “scaleToWidth()”scaleToWidth(
value
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:383
Scales an object to a given width, with respect to bounding box (scaling by x/y equally)
Parameters
Section titled “Parameters”number
New width value
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”searchWordBoundary()
Section titled “searchWordBoundary()”searchWordBoundary(
selectionStart
,direction
):number
Defined in: src/shapes/IText/ITextBehavior.ts:330
Finds index corresponding to beginning or end of a word
Parameters
Section titled “Parameters”selectionStart
Section titled “selectionStart”number
Index of a character
direction
Section titled “direction”1 or -1
-1
| 1
Returns
Section titled “Returns”number
Index of the beginning or end of a word
Inherited from
Section titled “Inherited from”selectAll()
Section titled “selectAll()”selectAll():
Textbox
<Props
,SProps
,EventSpec
>
Defined in: src/shapes/IText/ITextBehavior.ts:218
Selects entire text
Returns
Section titled “Returns”Textbox
<Props
, SProps
, EventSpec
>
Inherited from
Section titled “Inherited from”selectLine()
Section titled “selectLine()”selectLine(
selectionStart?
):void
Defined in: src/shapes/IText/ITextBehavior.ts:377
Selects the line that contains selectionStart
Parameters
Section titled “Parameters”selectionStart?
Section titled “selectionStart?”number
Index of a character
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”selectWord()
Section titled “selectWord()”selectWord(
selectionStart?
):void
Defined in: src/shapes/IText/ITextBehavior.ts:355
Selects the word that contains the char at index selectionStart
Parameters
Section titled “Parameters”selectionStart?
Section titled “selectionStart?”number
Index of a character
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”set(
key
,value?
):Textbox
<Props
,SProps
,EventSpec
>
Defined in: src/shapes/Text/Text.ts:1763
Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) set
does not update position of object’s borders/controls. If you need to update those, call setCoords()
.
Parameters
Section titled “Parameters”any
Property name or object (if object, iterate over the object properties)
value?
Section titled “value?”any
Property value (if function, the value is passed into it and its return value is used as a new one)
Returns
Section titled “Returns”Textbox
<Props
, SProps
, EventSpec
>
Inherited from
Section titled “Inherited from”setControlsVisibility()
Section titled “setControlsVisibility()”setControlsVisibility(
options?
):void
Defined in: src/shapes/Object/InteractiveObject.ts:611
Sets the visibility state of object controls, this is just a bulk option for setControlVisible;
Parameters
Section titled “Parameters”options?
Section titled “options?”Record
<string
, boolean
> = {}
with an optional key per control example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setControlVisible()
Section titled “setControlVisible()”setControlVisible(
controlKey
,visible
):void
Defined in: src/shapes/Object/InteractiveObject.ts:599
Sets the visibility of the specified control. please do not use.
Parameters
Section titled “Parameters”controlKey
Section titled “controlKey”string
The key of the control. Possible values are ‘tl’, ‘tr’, ‘br’, ‘bl’, ‘ml’, ‘mt’, ‘mr’, ‘mb’, ‘mtr’. but since the control api allow for any control name, can be any string.
visible
Section titled “visible”boolean
true to set the specified control visible, false otherwise
Returns
Section titled “Returns”void
discuss this overlap of priority here with the team. Andrea Bogazzi for details
Inherited from
Section titled “Inherited from”setCoords()
Section titled “setCoords()”setCoords():
void
Defined in: src/shapes/Object/InteractiveObject.ts:343
set controls’ coordinates as well See https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords and http://fabricjs.com/fabric-gotchas
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setCursorByClick()
Section titled “setCursorByClick()”setCursorByClick(
e
):void
Defined in: src/shapes/IText/ITextClickBehavior.ts:172
Changes cursor location in a text depending on passed pointer (x/y) object
Parameters
Section titled “Parameters”Event object
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setOnGroup()
Section titled “setOnGroup()”setOnGroup():
void
Defined in: src/shapes/Object/Object.ts:1479
This callback function is called by the parent group of an object every time a non-delegated property changes on the group. It is passed the key and value as parameters. Not adding in this function’s signature to avoid Travis build error about unused variables.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setPathInfo()
Section titled “setPathInfo()”setPathInfo():
void
Defined in: src/shapes/Text/Text.ts:445
If text has a path, it will add the extra information needed for path and text calculations
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setPositionByOrigin()
Section titled “setPositionByOrigin()”setPositionByOrigin(
pos
,originX
,originY
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:780
Sets the position of the object taking into consideration the object’s origin
Parameters
Section titled “Parameters”The new position of the object
originX
Section titled “originX”Horizontal origin: ‘left’, ‘center’ or ‘right’
originY
Section titled “originY”Vertical origin: ‘top’, ‘center’ or ‘bottom’
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setRelativeX()
Section titled “setRelativeX()”setRelativeX(
value
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:123
Parameters
Section titled “Parameters”number
x position according to object’s FabricObject#originX property in parent’s coordinate plane
if parent is canvas then this method is identical to setX
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setRelativeXY()
Section titled “setRelativeXY()”setRelativeXY(
point
,originX?
,originY?
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:186
As setXY, but in current parent’s coordinate plane (the current group if any or the canvas)
Parameters
Section titled “Parameters”position according to object’s FabricObject#originX FabricObject#originY properties in parent’s coordinate plane
originX?
Section titled “originX?”TOriginX
= ...
Horizontal origin: ‘left’, ‘center’ or ‘right’
originY?
Section titled “originY?”TOriginY
= ...
Vertical origin: ‘top’, ‘center’ or ‘bottom’
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setRelativeY()
Section titled “setRelativeY()”setRelativeY(
value
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:139
Parameters
Section titled “Parameters”number
y position according to object’s FabricObject#originY property in parent’s coordinate plane
if parent is canvas then this property is identical to setY
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setSelectionEnd()
Section titled “setSelectionEnd()”setSelectionEnd(
index
):void
Defined in: src/shapes/IText/IText.ts:274
Sets selection end (right boundary of a selection)
Parameters
Section titled “Parameters”number
Index to set selection end to
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setSelectionStart()
Section titled “setSelectionStart()”setSelectionStart(
index
):void
Defined in: src/shapes/IText/IText.ts:265
Sets selection start (left boundary of a selection)
Parameters
Section titled “Parameters”number
Index to set selection start to
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setSelectionStartEndWithShift()
Section titled “setSelectionStartEndWithShift()”setSelectionStartEndWithShift(
start
,end
,newSelection
):void
Defined in: src/shapes/IText/ITextBehavior.ts:1083
Set the selectionStart and selectionEnd according to the new position of cursor mimic the key - mouse navigation when shift is pressed.
Parameters
Section titled “Parameters”number
number
newSelection
Section titled “newSelection”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”IText
.setSelectionStartEndWithShift
setSelectionStyles()
Section titled “setSelectionStyles()”setSelectionStyles(
styles?
,startIndex?
,endIndex?
):void
Defined in: src/shapes/IText/IText.ts:338
Sets style of a current selection, if no selection exist, do not set anything.
Parameters
Section titled “Parameters”styles?
Section titled “styles?”object
Styles object
startIndex?
Section titled “startIndex?”number
= ...
Start index to get styles at
endIndex?
Section titled “endIndex?”number
= ...
End index to get styles at, if not specified selectionEnd or startIndex + 1
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setSubscript()
Section titled “setSubscript()”setSubscript(
start
,end
):void
Defined in: src/shapes/Text/Text.ts:1420
Turns the character into an ‘inferior figure’ (i.e. ‘subscript’)
Parameters
Section titled “Parameters”number
selection start
number
selection end
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setSuperscript()
Section titled “setSuperscript()”setSuperscript(
start
,end
):void
Defined in: src/shapes/Text/Text.ts:1411
Turns the character into a ‘superior figure’ (i.e. ‘superscript’)
Parameters
Section titled “Parameters”number
selection start
number
selection end
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setX()
Section titled “setX()”setX(
value
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:93
Parameters
Section titled “Parameters”number
x position according to object’s FabricObject#originX property in canvas coordinate plane
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setXY()
Section titled “setXY()”setXY(
point
,originX?
,originY?
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:163
Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate. You can specify FabricObject#originX and FabricObject#originY values, that otherwise are the object’s current values.
Parameters
Section titled “Parameters”position in scene coordinate plane
originX?
Section titled “originX?”Horizontal origin: ‘left’, ‘center’ or ‘right’
originY?
Section titled “originY?”Vertical origin: ‘top’, ‘center’ or ‘bottom’
Returns
Section titled “Returns”void
Example
Section titled “Example”object.setXY(new Point(5, 5), 'left', 'bottom').
Inherited from
Section titled “Inherited from”setY()
Section titled “setY()”setY(
value
):void
Defined in: src/shapes/Object/ObjectGeometry.ts:107
Parameters
Section titled “Parameters”number
y position according to object’s FabricObject#originY property in canvas coordinate plane
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”shiftLineStyles()
Section titled “shiftLineStyles()”shiftLineStyles(
lineIndex
,offset
):void
Defined in: src/shapes/IText/ITextBehavior.ts:814
Shifts line styles up or down
Parameters
Section titled “Parameters”lineIndex
Section titled “lineIndex”number
Index of a line
offset
Section titled “offset”number
Can any number?
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”shouldCache()
Section titled “shouldCache()”shouldCache():
boolean
Defined in: src/shapes/Object/Object.ts:788
Decide if the object should cache or not. Create its own cache level objectCaching is a global flag, wins over everything needsItsOwnCache should be used when the object drawing method requires a cache step. Generally you do not cache objects in groups because the group outside is cached. Read as: cache if is needed, or if the feature is enabled but we are not already caching.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”shouldStartDragging()
Section titled “shouldStartDragging()”shouldStartDragging():
boolean
Defined in: src/shapes/IText/ITextClickBehavior.ts:47
If this method returns true a mouse move operation over a text selection will not prevent the native mouse event allowing the browser to start a drag operation. shouldStartDragging can be read ‘do not prevent default for mouse move event’ To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”strokeBorders()
Section titled “strokeBorders()”strokeBorders(
ctx
,size
):void
Defined in: src/shapes/Object/InteractiveObject.ts:399
override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.
Parameters
Section titled “Parameters”CanvasRenderingContext2D
ctx is rotated and translated so that (0,0) is at object’s center
the control box size used
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”styleHas()
Section titled “styleHas()”styleHas(
property
,lineIndex
):boolean
Defined in: src/shapes/Textbox.ts:193
Returns true if object has a style property or has it on a specified line
Parameters
Section titled “Parameters”property
Section titled “property”StylePropertiesType
lineIndex
Section titled “lineIndex”number
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”toBlob()
Section titled “toBlob()”toBlob(
options
):Promise
<null
|Blob
>
Defined in: src/shapes/Object/Object.ts:1406
Parameters
Section titled “Parameters”options
Section titled “options”toDataURLOptions
= {}
Returns
Section titled “Returns”Promise
<null
| Blob
>
Inherited from
Section titled “Inherited from”toCanvasElement()
Section titled “toCanvasElement()”toCanvasElement(
options?
):HTMLCanvasElement
Defined in: src/shapes/IText/IText.ts:374
block cursor/selection logic while rendering the exported canvas
Parameters
Section titled “Parameters”options?
Section titled “options?”ObjectToCanvasElementOptions
Returns
Section titled “Returns”HTMLCanvasElement
this workaround should be replaced with a more robust solution
Inherited from
Section titled “Inherited from”toClipPathSVG()
Section titled “toClipPathSVG()”toClipPathSVG(
this
,reviver?
):string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:144
Returns svg clipPath representation of an instance
Parameters
Section titled “Parameters”FabricObjectSVGExportMixin
& FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>
reviver?
Section titled “reviver?”Method for further parsing of svg representation.
Returns
Section titled “Returns”string
svg representation of an instance
Inherited from
Section titled “Inherited from”toDatalessObject()
Section titled “toDatalessObject()”toDatalessObject(
propertiesToInclude?
):any
Defined in: src/shapes/Object/Object.ts:1854
Returns (dataless) object representation of an instance
Parameters
Section titled “Parameters”propertiesToInclude?
Section titled “propertiesToInclude?”any
[]
Any properties that you might want to additionally include in the output
Returns
Section titled “Returns”any
Object representation of an instance
Inherited from
Section titled “Inherited from”toDataURL()
Section titled “toDataURL()”toDataURL(
options
):string
Defined in: src/shapes/Object/Object.ts:1399
Converts an object into a data-url-like string
Parameters
Section titled “Parameters”options
Section titled “options”toDataURLOptions
= {}
Options object
Returns
Section titled “Returns”string
Returns a data: URL containing a representation of the object in the format specified by options.format
Inherited from
Section titled “Inherited from”toggle()
Section titled “toggle()”toggle(
property
):Textbox
<Props
,SProps
,EventSpec
>
Defined in: src/CommonMethods.ts:46
Toggles specified property from true
to false
or from false
to true
Parameters
Section titled “Parameters”property
Section titled “property”string
Property to toggle
Returns
Section titled “Returns”Textbox
<Props
, SProps
, EventSpec
>
Inherited from
Section titled “Inherited from”toJSON()
Section titled “toJSON()”toJSON():
any
Defined in: src/shapes/Object/Object.ts:1438
Returns a JSON representation of an instance
Returns
Section titled “Returns”any
JSON
Inherited from
Section titled “Inherited from”toObject()
Section titled “toObject()”toObject<
T
,K
>(propertiesToInclude?
):Pick
<T
,K
> &SProps
Defined in: src/shapes/Textbox.ts:571
Returns object representation of an instance
Type Parameters
Section titled “Type Parameters”T
extends Omit
<Props
& TClassProperties
<Textbox
<Props
, SProps
, EventSpec
>>, keyof SProps
>
K
extends string
| number
| symbol
= never
Parameters
Section titled “Parameters”propertiesToInclude?
Section titled “propertiesToInclude?”K
[] = []
Any properties that you might want to additionally include in the output
Returns
Section titled “Returns”Pick
<T
, K
> & SProps
object representation of an instance
Method
Section titled “Method”toObject
Overrides
Section titled “Overrides”toString()
Section titled “toString()”toString():
string
Defined in: src/shapes/Text/Text.ts:581
Returns string representation of an instance
Returns
Section titled “Returns”string
String representation of text object
Inherited from
Section titled “Inherited from”toSVG()
Section titled “toSVG()”toSVG(
this
,reviver?
):string
Defined in: src/shapes/Object/FabricObjectSVGExportMixin.ts:130
Returns svg representation of an instance
Parameters
Section titled “Parameters”FabricObjectSVGExportMixin
& FabricObject
<Partial
<FabricObjectProps
>, SerializedObjectProps
, ObjectEvents
>
reviver?
Section titled “reviver?”Method for further parsing of svg representation.
Returns
Section titled “Returns”string
svg representation of an instance
Inherited from
Section titled “Inherited from”transform()
Section titled “transform()”transform(
ctx
):void
Defined in: src/shapes/Object/Object.ts:528
Transforms context when rendering an object
Parameters
Section titled “Parameters”CanvasRenderingContext2D
Context
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”transformMatrixKey()
Section titled “transformMatrixKey()”transformMatrixKey(
skipGroup
):number
[]
Defined in: src/shapes/Object/ObjectGeometry.ts:455
Parameters
Section titled “Parameters”skipGroup
Section titled “skipGroup”boolean
= false
Returns
Section titled “Returns”number
[]
Inherited from
Section titled “Inherited from”translateToCenterPoint()
Section titled “translateToCenterPoint()”translateToCenterPoint(
point
,originX
,originY
):Point
Defined in: src/shapes/Object/ObjectGeometry.ts:685
Translates the coordinates from origin to center coordinates (based on the object’s dimensions)
Parameters
Section titled “Parameters”The point which corresponds to the originX and originY params
originX
Section titled “originX”Horizontal origin: ‘left’, ‘center’ or ‘right’
originY
Section titled “originY”Vertical origin: ‘top’, ‘center’ or ‘bottom’
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”translateToGivenOrigin()
Section titled “translateToGivenOrigin()”translateToGivenOrigin(
point
,fromOriginX
,fromOriginY
,toOriginX
,toOriginY
):Point
Defined in: src/shapes/Object/ObjectGeometry.ts:657
Translates the coordinates from a set of origin to another (based on the object’s dimensions)
Parameters
Section titled “Parameters”The point which corresponds to the originX and originY params
fromOriginX
Section titled “fromOriginX”Horizontal origin: ‘left’, ‘center’ or ‘right’
fromOriginY
Section titled “fromOriginY”Vertical origin: ‘top’, ‘center’ or ‘bottom’
toOriginX
Section titled “toOriginX”Horizontal origin: ‘left’, ‘center’ or ‘right’
toOriginY
Section titled “toOriginY”Vertical origin: ‘top’, ‘center’ or ‘bottom’
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”translateToOriginPoint()
Section titled “translateToOriginPoint()”translateToOriginPoint(
center
,originX
,originY
):Point
Defined in: src/shapes/Object/ObjectGeometry.ts:713
Translates the coordinates from center to origin coordinates (based on the object’s dimensions)
Parameters
Section titled “Parameters”center
Section titled “center”The point which corresponds to center of the object
originX
Section titled “originX”Horizontal origin: ‘left’, ‘center’ or ‘right’
originY
Section titled “originY”Vertical origin: ‘top’, ‘center’ or ‘bottom’
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”tripleClickHandler()
Section titled “tripleClickHandler()”tripleClickHandler(
options
):void
Defined in: src/shapes/IText/ITextClickBehavior.ts:82
Default handler for triple click, select a line
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”updateSelectionOnMouseMove()
Section titled “updateSelectionOnMouseMove()”updateSelectionOnMouseMove(
e
):void
Defined in: src/shapes/IText/ITextBehavior.ts:432
called by Canvas#textEditingManager
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”IText
.updateSelectionOnMouseMove
willDrawShadow()
Section titled “willDrawShadow()”willDrawShadow():
boolean
Defined in: src/shapes/Object/Object.ts:801
Check if this object will cast a shadow with an offset. used by Group.shouldCache to know if child has a shadow recursively
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”wordSplit()
Section titled “wordSplit()”wordSplit(
value
):string
[]
Defined in: src/shapes/Textbox.ts:413
Override this method to customize word splitting Use with Textbox#_measureWord
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string
[]
array of words
_fromObject()
Section titled “_fromObject()”
static
_fromObject<S
>(__namedParameters
,__namedParameters
):Promise
<S
>
Defined in: src/shapes/Object/Object.ts:1907
Type Parameters
Section titled “Type Parameters”S
extends BaseFabricObject
<Partial
<ObjectProps
>, SerializedObjectProps
, ObjectEvents
>
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”Record
<string
, unknown
>
__namedParameters
Section titled “__namedParameters”Abortable
& object
= {}
Returns
Section titled “Returns”Promise
<S
>
Inherited from
Section titled “Inherited from”createControls()
Section titled “createControls()”
static
createControls():object
Defined in: src/shapes/Textbox.ts:119
Creates the default control object. If you prefer to have on instance of controls shared among all objects make this function return an empty object and add controls to the ownDefaults object
Returns
Section titled “Returns”object
controls
Section titled “controls”controls:
Record
<string
,Control
>
Overrides
Section titled “Overrides”fromElement()
Section titled “fromElement()”
static
fromElement(element
,options?
,cssRules?
):Promise
<FabricText
<{fontSize
:number
;left
:number
;linethrough
:boolean
;overline
:boolean
;signal?
:AbortSignal
;strokeWidth
:number
;top
:number
;underline
:boolean
; },SerializedTextProps
,ObjectEvents
>>
Defined in: src/shapes/Text/Text.ts:1847
Returns FabricText instance from an SVG element (not yet implemented)
Parameters
Section titled “Parameters”element
Section titled “element”HTMLElement
Element to parse
options?
Section titled “options?”Options object
cssRules?
Section titled “cssRules?”CSSRules
Returns
Section titled “Returns”Promise
<FabricText
<{ fontSize
: number
; left
: number
; linethrough
: boolean
; overline
: boolean
; signal?
: AbortSignal
; strokeWidth
: number
; top
: number
; underline
: boolean
; }, SerializedTextProps
, ObjectEvents
>>
Static
Section titled “Static”Member Of
Section titled “Member Of”Text
Inherited from
Section titled “Inherited from”fromObject()
Section titled “fromObject()”
static
fromObject<T
,S
>(object
):Promise
<S
>
Defined in: src/shapes/Text/Text.ts:1924
Returns FabricText instance from an object representation
Type Parameters
Section titled “Type Parameters”T
extends TOptions
<SerializedTextProps
>
S
extends FabricText
<Partial
<TextProps
>, SerializedTextProps
, ObjectEvents
>
Parameters
Section titled “Parameters”object
Section titled “object”T
plain js Object to create an instance from
Returns
Section titled “Returns”Promise
<S
>
Inherited from
Section titled “Inherited from”getDefaults()
Section titled “getDefaults()”
static
getDefaults():Record
<string
,any
>
Defined in: src/shapes/Textbox.ts:98
Returns
Section titled “Returns”Record
<string
, any
>