跳转到内容

Textbox

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

  • IText<Props, SProps, EventSpec>

Type Parameters

Props extends TOptions<TextboxProps> = Partial<TextboxProps>

SProps extends SerializedTextboxProps = SerializedTextboxProps

EventSpec extends ITextEvents = ITextEvents

Implements

  • UniqueTextboxProps

Constructors

new Textbox()

new Textbox<Props, SProps, EventSpec>(text, options?): Textbox<Props, SProps, EventSpec>

Constructor

Parameters

text: string

Text string

options?: Props

Options object

Returns

Textbox<Props, SProps, EventSpec>

Overrides

IText.constructor

Defined in

src/shapes/Textbox.ts:110

Properties

MIN_TEXT_WIDTH

MIN_TEXT_WIDTH: number

contains the min text width to avoid getting 0

Default

Inherited from

IText.MIN_TEXT_WIDTH

Defined in

src/shapes/Text/Text.ts:391


__corner?

optional __corner: string

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

IText.__corner

Defined in

src/shapes/Object/InteractiveObject.ts:105


__lineHeights

__lineHeights: number[]

Inherited from

IText.__lineHeights

Defined in

src/shapes/Text/Text.ts:411


__lineWidths

__lineWidths: number[]

Inherited from

IText.__lineWidths

Defined in

src/shapes/Text/Text.ts:412


_controlsVisibility

_controlsVisibility: Record<string, boolean>

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

IText._controlsVisibility

Defined in

src/shapes/Object/InteractiveObject.ts:112


_fontSizeMult

_fontSizeMult: number

Text Line proportion to font Size (in pixels)

Default

Inherited from

IText._fontSizeMult

Defined in

src/shapes/Text/Text.ts:339


_scaling?

optional _scaling: boolean

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

TODO

use git blame to investigate why it was added DON’T USE IT. WE WILL TRY TO REMOVE IT

Inherited from

IText._scaling

Defined in

src/shapes/Object/InteractiveObject.ts:134


_styleMap

_styleMap: StyleMap

Defined in

src/shapes/Textbox.ts:88


_text

_text: string[]

Inherited from

IText._text

Defined in

src/shapes/Text/Text.ts:409


_textLines

_textLines: string[][]

same as textlines, but each line is an array of graphemes as split by splitByGrapheme

Default

Inherited from

IText._textLines

Defined in

src/shapes/Text/Text.ts:406


_unwrappedTextLines

_unwrappedTextLines: string[][]

Inherited from

IText._unwrappedTextLines

Defined in

src/shapes/Text/Text.ts:408


_wordJoiners

_wordJoiners: RegExp

Implementation of

UniqueTextboxProps._wordJoiners

Defined in

src/shapes/Textbox.ts:86


aCoords

aCoords: TCornerPoint

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

IText.aCoords

Defined in

src/shapes/Object/ObjectGeometry.ts:63


absolutePositioned

absolutePositioned: boolean

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

false

Inherited from

IText.absolutePositioned

Defined in

src/shapes/Object/Object.ts:218


angle

angle: TDegree

Angle of rotation of an object (in degrees)

Default

0

Inherited from

IText.angle

Defined in

src/shapes/Object/ObjectGeometry.ts:581


backgroundColor

backgroundColor: string

Background color of an object. takes css colors https://www.w3.org/TR/css-color-3/

Default

Inherited from

IText.backgroundColor

Defined in

src/shapes/Object/Object.ts:205


borderColor

borderColor: string

Color of controlling borders of an object (when it’s active)

Default

rgb(178,204,255)

Inherited from

IText.borderColor

Defined in

src/shapes/Object/InteractiveObject.ts:74


borderDashArray

borderDashArray: null | number[]

Array specifying dash pattern of an object’s borders (hasBorder must be true)

Since

1.6.2

Inherited from

IText.borderDashArray

Defined in

src/shapes/Object/InteractiveObject.ts:75


borderOpacityWhenMoving

borderOpacityWhenMoving: number

Opacity of object’s controlling borders when object is active and moving

Default

0.4

Inherited from

IText.borderOpacityWhenMoving

Defined in

src/shapes/Object/InteractiveObject.ts:76


borderScaleFactor

borderScaleFactor: number

Scale factor of object’s controlling borders bigger number will make a thicker border border is 1, so this is basically a border thickness since there is no way to change the border itself.

Default

1

Inherited from

IText.borderScaleFactor

Defined in

src/shapes/Object/InteractiveObject.ts:77


caching

caching: boolean

Indicates whether internal text char widths can be cached

Default

Inherited from

IText.caching

Defined in

src/shapes/IText/IText.ts:212


centeredRotation

centeredRotation: boolean

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.

Since

1.3.4

Default

Inherited from

IText.centeredRotation

Defined in

src/shapes/Object/Object.ts:219


centeredScaling

centeredScaling: boolean

When true, this object will use center point as the origin of transformation when being scaled via the controls.

Since

1.3.4

Default

Inherited from

IText.centeredScaling

Defined in

src/shapes/Object/Object.ts:220


charSpacing

charSpacing: number

additional space between characters expressed in thousands of em unit

Default

Inherited from

IText.charSpacing

Defined in

src/shapes/Text/Text.ts:347


clipPath?

optional clipPath: BaseFabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>

Inherited from

IText.clipPath

Defined in

src/shapes/Object/Object.ts:216


clipPathId?

optional clipPathId: string

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

IText.clipPathId

Defined in

src/shapes/Object/FabricObjectSVGExportMixin.ts:14


compositionColor

compositionColor: string

Inherited from

IText.compositionColor

Defined in

src/shapes/IText/IText.ts:205


compositionEnd

compositionEnd: number

Inherited from

IText.compositionEnd

Defined in

src/shapes/IText/IText.ts:144


compositionStart

compositionStart: number

Inherited from

IText.compositionStart

Defined in

src/shapes/IText/IText.ts:142


controls

controls: TControlSet

holds the controls for the object. controls are added by default_controls.js

Inherited from

IText.controls

Defined in

src/shapes/Object/InteractiveObject.ts:118


cornerColor

cornerColor: string

Color of controlling corners of an object (when it’s active)

Default

rgb(178,204,255)

Inherited from

IText.cornerColor

Defined in

src/shapes/Object/InteractiveObject.ts:68


cornerDashArray

cornerDashArray: null | number[]

Array specifying dash pattern of an object’s control (hasBorder must be true)

Since

1.6.2

Default

null

Inherited from

IText.cornerDashArray

Defined in

src/shapes/Object/InteractiveObject.ts:71


cornerSize

cornerSize: number

Size of object’s controlling corners (in pixels)

Default

13

Inherited from

IText.cornerSize

Defined in

src/shapes/Object/InteractiveObject.ts:65


cornerStrokeColor

cornerStrokeColor: string

Color of controlling corners of an object (when it’s active and transparentCorners false)

Since

1.6.2

Default

''

Inherited from

IText.cornerStrokeColor

Defined in

src/shapes/Object/InteractiveObject.ts:69


cornerStyle

cornerStyle: "circle" | "rect"

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

Since

1.6.2

Default

'rect'

Inherited from

IText.cornerStyle

Defined in

src/shapes/Object/InteractiveObject.ts:70


ctrlKeysMapDown

ctrlKeysMapDown: TKeyMapIText

For functionalities on keyDown + ctrl || cmd

Inherited from

IText.ctrlKeysMapDown

Defined in

src/shapes/IText/ITextKeyBehavior.ts:42


ctrlKeysMapUp

ctrlKeysMapUp: TKeyMapIText

For functionalities on keyUp + ctrl || cmd

Inherited from

IText.ctrlKeysMapUp

Defined in

src/shapes/IText/ITextKeyBehavior.ts:37


cursorColor

cursorColor: string

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

Inherited from

IText.cursorColor

Defined in

src/shapes/IText/IText.ts:189


cursorDelay

cursorDelay: number

Delay between cursor blink (in ms)

Default

Inherited from

IText.cursorDelay

Defined in

src/shapes/IText/IText.ts:196


cursorDuration

cursorDuration: number

Duration of cursor fade in (in ms)

Default

Inherited from

IText.cursorDuration

Defined in

src/shapes/IText/IText.ts:203


cursorWidth

cursorWidth: number

Width of cursor (in px)

Default

Inherited from

IText.cursorWidth

Defined in

src/shapes/IText/IText.ts:179


deltaY

deltaY: number

Baseline shift, styles only, keep at 0 for the main text object

Default

Inherited from

IText.deltaY

Defined in

src/shapes/Text/Text.ts:354


direction

direction: CanvasDirection

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

Since

4.5.0

Default

Inherited from

IText.direction

Defined in

src/shapes/Text/Text.ts:367


dirty

dirty: boolean

When set to true, object’s cache will be rerendered next render call. since 1.7.0

Default

true

Inherited from

IText.dirty

Defined in

src/shapes/Object/Object.ts:245


dynamicMinWidth

dynamicMinWidth: number

Minimum calculated width of a textbox, in pixels. fixed to 2 so that an empty textbox cannot go to 0 and is still selectable without text.

Default

Implementation of

UniqueTextboxProps.dynamicMinWidth

Defined in

src/shapes/Textbox.ts:76


editable

editable: boolean

Indicates whether a text can be edited

Default

Inherited from

IText.editable

Defined in

src/shapes/IText/IText.ts:165


editingBorderColor

editingBorderColor: string

Border color of text object while it’s in editing mode

Default

Inherited from

IText.editingBorderColor

Defined in

src/shapes/IText/IText.ts:172


evented

evented: boolean

When set to false, an object can not be a target of events. All events propagate through it. Introduced in v1.3.4

Default

Inherited from

IText.evented

Defined in

src/shapes/Object/InteractiveObject.ts:82


excludeFromExport

excludeFromExport: boolean

When true, object is not exported in OBJECT/JSON

Since

1.6.3

Default

Inherited from

IText.excludeFromExport

Defined in

src/shapes/Object/Object.ts:212


fill

fill: null | string | TFiller

Inherited from

IText.fill

Defined in

src/shapes/Object/Object.ts:195


fillRule

fillRule: CanvasFillRule

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

nonzero

Inherited from

IText.fillRule

Defined in

src/shapes/Object/Object.ts:196


flipX

flipX: boolean

When true, an object is rendered as flipped horizontally

Default

false

Inherited from

IText.flipX

Defined in

src/shapes/Object/ObjectGeometry.ts:567


flipY

flipY: boolean

When true, an object is rendered as flipped vertically

Default

false

Inherited from

IText.flipY

Defined in

src/shapes/Object/ObjectGeometry.ts:568


fontFamily

fontFamily: string

Font family

Default

Inherited from

IText.fontFamily

Defined in

src/shapes/Text/Text.ts:188


fontSize

fontSize: number

Font size (in pixels)

Default

Inherited from

IText.fontSize

Defined in

src/shapes/Text/Text.ts:174


fontStyle

fontStyle: string

Font style . Possible values: "", “normal”, “italic” or “oblique”.

Default

Inherited from

IText.fontStyle

Defined in

src/shapes/Text/Text.ts:224


fontWeight

fontWeight: string | number

Font weight (e.g. bold, normal, 400, 600, 800)

Default

Inherited from

IText.fontWeight

Defined in

src/shapes/Text/Text.ts:181


globalCompositeOperation

globalCompositeOperation: GlobalCompositeOperation

Composite rule used for canvas globalCompositeOperation

Default

Inherited from

IText.globalCompositeOperation

Defined in

src/shapes/Object/Object.ts:204


hasBorders

hasBorders: boolean

When set to false, object’s controlling borders are not rendered

Default

Inherited from

IText.hasBorders

Defined in

src/shapes/Object/InteractiveObject.ts:78


hasControls

hasControls: boolean

When set to false, object’s controls are not displayed and can not be used to manipulate object

Default

true

Inherited from

IText.hasControls

Defined in

src/shapes/Object/InteractiveObject.ts:72


height

height: number

Object height

Default

Inherited from

IText.height

Defined in

src/shapes/Object/ObjectGeometry.ts:566


hiddenTextarea

hiddenTextarea: null | HTMLTextAreaElement

Inherited from

IText.hiddenTextarea

Defined in

src/shapes/IText/ITextKeyBehavior.ts:44


hiddenTextareaContainer?

optional hiddenTextareaContainer: null | HTMLElement

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

Inherited from

IText.hiddenTextareaContainer

Defined in

src/shapes/IText/ITextKeyBehavior.ts:54


hoverCursor

hoverCursor: null | string

Default cursor value used when hovering over this object on canvas

Default

null

Inherited from

IText.hoverCursor

Defined in

src/shapes/Object/InteractiveObject.ts:86


includeDefaultValues

includeDefaultValues: boolean

When false, default object’s values are not included in its serialization

Default

Inherited from

IText.includeDefaultValues

Defined in

src/shapes/Object/Object.ts:211


initialized?

optional initialized: true

Inherited from

IText.initialized

Defined in

src/shapes/Text/Text.ts:413


inverted

inverted: boolean

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

false

Inherited from

IText.inverted

Defined in

src/shapes/Object/Object.ts:217


isEditing

isEditing: boolean

Indicates whether text is in editing mode

Default

Inherited from

IText.isEditing

Defined in

src/shapes/IText/IText.ts:158


isMoving?

optional isMoving: boolean

internal boolean to signal the code that the object is part of the move action.

Inherited from

IText.isMoving

Defined in

src/shapes/Object/InteractiveObject.ts:124


isWrapping

isWrapping: boolean

Defined in

src/shapes/Textbox.ts:90


keysMap

keysMap: TKeyMapIText

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

IText.keysMap

Defined in

src/shapes/IText/ITextKeyBehavior.ts:30


keysMapRtl

keysMapRtl: TKeyMapIText

Inherited from

IText.keysMapRtl

Defined in

src/shapes/IText/ITextKeyBehavior.ts:32


left

left: number

Left position of an object. Note that by default it’s relative to object left. You can change this by setting originX

Default

0

Inherited from

IText.left

Defined in

src/shapes/Object/ObjectGeometry.ts:564


lineHeight

lineHeight: number

Line height

Default

Inherited from

IText.lineHeight

Defined in

src/shapes/Text/Text.ts:231


linethrough

linethrough: boolean

Text decoration linethrough.

Default

Inherited from

IText.linethrough

Defined in

src/shapes/Text/Text.ts:209


lockMovementX

lockMovementX: boolean

When true, object horizontal movement is locked

Default

Inherited from

IText.lockMovementX

Defined in

src/shapes/Object/InteractiveObject.ts:56


lockMovementY

lockMovementY: boolean

When true, object vertical movement is locked

Default

Inherited from

IText.lockMovementY

Defined in

src/shapes/Object/InteractiveObject.ts:57


lockRotation

lockRotation: boolean

When true, object rotation is locked

Default

Inherited from

IText.lockRotation

Defined in

src/shapes/Object/InteractiveObject.ts:58


lockScalingFlip

lockScalingFlip: boolean

When true, object cannot be flipped by scaling into negative values

Default

Inherited from

IText.lockScalingFlip

Defined in

src/shapes/Object/InteractiveObject.ts:63


lockScalingX

lockScalingX: boolean

When true, object horizontal scaling is locked

Default

Inherited from

IText.lockScalingX

Defined in

src/shapes/Object/InteractiveObject.ts:59


lockScalingY

lockScalingY: boolean

When true, object vertical scaling is locked

Default

Inherited from

IText.lockScalingY

Defined in

src/shapes/Object/InteractiveObject.ts:60


lockSkewingX

lockSkewingX: boolean

When true, object horizontal skewing is locked

Default

Inherited from

IText.lockSkewingX

Defined in

src/shapes/Object/InteractiveObject.ts:61


lockSkewingY

lockSkewingY: boolean

When true, object vertical skewing is locked

Default

Inherited from

IText.lockSkewingY

Defined in

src/shapes/Object/InteractiveObject.ts:62


matrixCache?

optional matrixCache: TMatrixCache

storage cache for object full transform matrix

Inherited from

IText.matrixCache

Defined in

src/shapes/Object/ObjectGeometry.ts:73


minScaleLimit

minScaleLimit: number

Minimum allowed scale value of an object

Default

0

Inherited from

IText.minScaleLimit

Defined in

src/shapes/Object/Object.ts:190


minWidth

minWidth: number

Minimum width of textbox, in pixels.

Default

Implementation of

UniqueTextboxProps.minWidth

Defined in

src/shapes/Textbox.ts:67


moveCursor

moveCursor: null | string

Default cursor value used when moving this object on canvas

Default

null

Inherited from

IText.moveCursor

Defined in

src/shapes/Object/InteractiveObject.ts:87


noScaleCache

noScaleCache: boolean

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

true

Inherited from

IText.noScaleCache

Defined in

src/shapes/Object/InteractiveObject.ts:51


oCoords

oCoords: Record<string, TOCoord>

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

IText.oCoords

Defined in

src/shapes/Object/InteractiveObject.ts:95


objectCaching

objectCaching: boolean

When true, object is cached on an additional canvas. When false, object is not cached unless necessary ( clipPath ) default to true

Since

1.7.0

Default

true

Inherited from

IText.objectCaching

Defined in

src/shapes/Object/Object.ts:214


opacity

opacity: number

Opacity of an object

Default

1

Inherited from

IText.opacity

Defined in

src/shapes/Object/Object.ts:192


originX

originX: TOriginX

Inherited from

IText.originX

Defined in

src/shapes/Object/ObjectGeometry.ts:576


originY

originY: TOriginY

Inherited from

IText.originY

Defined in

src/shapes/Object/ObjectGeometry.ts:580


overline

overline: boolean

Text decoration overline.

Default

Inherited from

IText.overline

Defined in

src/shapes/Text/Text.ts:202


ownMatrixCache?

optional ownMatrixCache: TMatrixCache

storage cache for object transform matrix

Inherited from

IText.ownMatrixCache

Defined in

src/shapes/Object/ObjectGeometry.ts:68


padding

padding: number

Padding between object and its controlling borders (in pixels)

Default

0

Inherited from

IText.padding

Defined in

src/shapes/Object/ObjectGeometry.ts:53


paintFirst

paintFirst: "fill" | "stroke"

Determines if the fill or the stroke is drawn first (one of “fill” or “stroke”)

Default

Inherited from

IText.paintFirst

Defined in

src/shapes/Object/Object.ts:194


parent?

optional parent: Group

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

IText.parent

Defined in

src/shapes/Object/Object.ts:1636


path?

optional path: Path<Partial<PathProps>, SerializedPathProps, ObjectEvents>

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

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

Inherited from

IText.path

Defined in

src/shapes/Text/Text.ts:296


pathAlign

pathAlign: TPathAlign

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

Inherited from

IText.pathAlign

Defined in

src/shapes/Text/Text.ts:322


pathSide

pathSide: TPathSide

Which side of the path the text should be drawn on. Only used when text has a path

Default

Inherited from

IText.pathSide

Defined in

src/shapes/Text/Text.ts:312


pathStartOffset

pathStartOffset: number

Offset amount for text path starting position Only used when text has a path

Default

Inherited from

IText.pathStartOffset

Defined in

src/shapes/Text/Text.ts:304


perPixelTargetFind

perPixelTargetFind: boolean

When set to true, objects are “found” on canvas on per-pixel basis rather than according to bounding box

Default

Inherited from

IText.perPixelTargetFind

Defined in

src/shapes/Object/InteractiveObject.ts:83


scaleX

scaleX: number

Object scale factor (horizontal)

Default

1

Inherited from

IText.scaleX

Defined in

src/shapes/Object/ObjectGeometry.ts:569


scaleY

scaleY: number

Object scale factor (vertical)

Default

1

Inherited from

IText.scaleY

Defined in

src/shapes/Object/ObjectGeometry.ts:570


selectable

selectable: boolean

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

Inherited from

IText.selectable

Defined in

src/shapes/Object/InteractiveObject.ts:81


selectionBackgroundColor

selectionBackgroundColor: string

Selection Background color of an object. colored layer behind the object when it is active. does not mix good with globalCompositeOperation methods.

Default

Inherited from

IText.selectionBackgroundColor

Defined in

src/shapes/Object/InteractiveObject.ts:79


selectionColor

selectionColor: string

Color of text selection

Default

Inherited from

IText.selectionColor

Defined in

src/shapes/IText/IText.ts:151


selectionEnd

selectionEnd: number

Index where text selection ends

Default

Inherited from

IText.selectionEnd

Defined in

src/shapes/IText/IText.ts:140


selectionStart

selectionStart: number

Index where text selection starts (or where cursor is when there is no selection)

Default

Inherited from

IText.selectionStart

Defined in

src/shapes/IText/IText.ts:133


shadow

shadow: null | Shadow

Inherited from

IText.shadow

Defined in

src/shapes/Object/Object.ts:207


skewX

skewX: number

Angle of skew on x axes of an object (in degrees)

Default

0

Inherited from

IText.skewX

Defined in

src/shapes/Object/ObjectGeometry.ts:571


skewY

skewY: number

Angle of skew on y axes of an object (in degrees)

Default

0

Inherited from

IText.skewY

Defined in

src/shapes/Object/ObjectGeometry.ts:572


snapAngle?

optional snapAngle: TDegree

The angle that an object will lock to while rotating.

Inherited from

IText.snapAngle

Defined in

src/shapes/Object/InteractiveObject.ts:53


snapThreshold?

optional snapThreshold: TDegree

The angle difference from the current snapped angle in which snapping should occur. When undefined, the snapThreshold will default to the snapAngle.

Inherited from

IText.snapThreshold

Defined in

src/shapes/Object/InteractiveObject.ts:54


splitByGrapheme

splitByGrapheme: boolean

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

Since

2.6.0

Implementation of

UniqueTextboxProps.splitByGrapheme

Defined in

src/shapes/Textbox.ts:84


stroke

stroke: null | string | TFiller

Inherited from

IText.stroke

Defined in

src/shapes/Object/Object.ts:197


strokeDashArray

strokeDashArray: null | number[]

Array specifying dash pattern of an object’s stroke (stroke must be defined)

Default

null;

Inherited from

IText.strokeDashArray

Defined in

src/shapes/Object/Object.ts:198


strokeDashOffset

strokeDashOffset: number

Line offset of an object’s stroke

Default

0

Inherited from

IText.strokeDashOffset

Defined in

src/shapes/Object/Object.ts:199


strokeLineCap

strokeLineCap: CanvasLineCap

Line endings style of an object’s stroke (one of “butt”, “round”, “square”)

Default

butt

Inherited from

IText.strokeLineCap

Defined in

src/shapes/Object/Object.ts:200


strokeLineJoin

strokeLineJoin: CanvasLineJoin

Corner style of an object’s stroke (one of “bevel”, “round”, “miter”)

Default

Inherited from

IText.strokeLineJoin

Defined in

src/shapes/Object/Object.ts:201


strokeMiterLimit

strokeMiterLimit: number

Maximum miter length (used for strokeLineJoin = “miter”) of an object’s stroke

Default

4

Inherited from

IText.strokeMiterLimit

Defined in

src/shapes/Object/Object.ts:202


strokeUniform

strokeUniform: boolean

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

Since

2.6.0

Default

false

Default

false

Inherited from

IText.strokeUniform

Defined in

src/shapes/Object/ObjectGeometry.ts:583


strokeWidth

strokeWidth: number

Width of a stroke used to render this object

Default

1

Inherited from

IText.strokeWidth

Defined in

src/shapes/Object/ObjectGeometry.ts:582


styles

styles: TextStyle

Inherited from

IText.styles

Defined in

src/shapes/Text/Text.ts:272


subscript

subscript: object

Subscript schema object (minimum overlap)

baseline

baseline: number

baseline-shift factor (downwards)

Default
0.11

size

size: number

fontSize factor

Default
0.6

Inherited from

IText.subscript

Defined in

src/shapes/Text/Text.ts:252


superscript

superscript: object

Superscript schema object (minimum overlap)

baseline

baseline: number

baseline-shift factor (upwards)

Default
-0.35

size

size: number

fontSize factor

Default
0.6

Inherited from

IText.superscript

Defined in

src/shapes/Text/Text.ts:236


text

text: string

Inherited from

IText.text

Defined in

src/shapes/Text/Text.ts:167


textAlign

textAlign: string

Text alignment. Possible values: “left”, “center”, “right”, “justify”, “justify-left”, “justify-center” or “justify-right”.

Default

Inherited from

IText.textAlign

Defined in

src/shapes/Text/Text.ts:217


textBackgroundColor

textBackgroundColor: string

Background color of text lines

Default

Inherited from

IText.textBackgroundColor

Defined in

src/shapes/Text/Text.ts:270


textLines

textLines: string[]

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

Inherited from

IText.textLines

Defined in

src/shapes/Text/Text.ts:399


top

top: number

Top position of an object. Note that by default it’s relative to object top. You can change this by setting originY

Default

0

Inherited from

IText.top

Defined in

src/shapes/Object/ObjectGeometry.ts:563


touchCornerSize

touchCornerSize: number

Size of object’s controlling corners when touch interaction is detected

Default

24

Inherited from

IText.touchCornerSize

Defined in

src/shapes/Object/InteractiveObject.ts:66


transparentCorners

transparentCorners: boolean

When true, object’s controlling corners are rendered as transparent inside (i.e. stroke instead of fill)

Default

true

Inherited from

IText.transparentCorners

Defined in

src/shapes/Object/InteractiveObject.ts:67


underline

underline: boolean

Text decoration underline.

Default

Inherited from

IText.underline

Defined in

src/shapes/Text/Text.ts:195


visible

visible: boolean

When set to false, an object is not rendered on canvas

Default

Inherited from

IText.visible

Defined in

src/shapes/Object/Object.ts:209


width

width: number

Object width

Default

Inherited from

IText.width

Defined in

src/shapes/Object/ObjectGeometry.ts:565


ATTRIBUTE_NAMES

static ATTRIBUTE_NAMES: string[]

List of attribute names to account for when parsing SVG element (used by FabricText.fromElement)

Static

Member Of

Text @see: http://www.w3.org/TR/SVG/text.html#TextElement

Inherited from

IText.ATTRIBUTE_NAMES

Defined in

src/shapes/Text/Text.ts:1826


_styleProperties

static _styleProperties: readonly StylePropertiesType[] = styleProperties

Inherited from

IText._styleProperties

Defined in

src/shapes/Text/StyledText.ts:30


cacheProperties

static cacheProperties: string[]

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

IText.cacheProperties

Defined in

src/shapes/Text/Text.ts:415


colorProperties

static colorProperties: string[]

List of properties to consider for animating colors.

Inherited from

IText.colorProperties

Defined in

src/shapes/Object/Object.ts:1543


customProperties

static customProperties: string[] = []

Define a list of custom properties that will be serialized when instance.toObject() gets called

Inherited from

IText.customProperties

Defined in

src/shapes/Object/Object.ts:1784


genericFonts

static genericFonts: string[]

List of generic font families

See

https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name

Inherited from

IText.genericFonts

Defined in

src/shapes/Text/Text.ts:1802


ownDefaults

static ownDefaults: Partial<TClassProperties<Textbox<Partial<TextboxProps>, SerializedTextboxProps, ITextEvents>>> = textboxDefaultValues

Overrides

IText.ownDefaults

Defined in

src/shapes/Textbox.ts:96


stateProperties

static stateProperties: string[]

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

IText.stateProperties

Defined in

src/shapes/Object/Object.ts:228


type

static type: string = 'Textbox'

Overrides

IText.type

Defined in

src/shapes/Textbox.ts:92

Accessors

type

get type(): string

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

TODO

add sustainable warning message

Returns

string

Inherited from

IText.type

Defined in

src/shapes/IText/IText.ts:222

Methods

_drawClipPath()

_drawClipPath(ctx, clipPath, context): void

Prepare clipPath state and cache and draw it on instance’s cache

Parameters

ctx: CanvasRenderingContext2D

clipPath: undefined | BaseFabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>

context: DrawContext

Returns

void

Inherited from

IText._drawClipPath

Defined in

src/shapes/Object/Object.ts:920


_getFontDeclaration()

_getFontDeclaration(__namedParameters?, forMeasuring?): string

return font declaration string for canvas context

Parameters

__namedParameters?: Partial<Pick<Partial<CompleteTextStyleDeclaration>, "fontFamily" | "fontSize" | "fontStyle" | "fontWeight">> = {}

forMeasuring?: boolean

Returns

string

font declaration formatted for canvas context.

Inherited from

IText._getFontDeclaration

Defined in

src/shapes/Text/Text.ts:1661


_getGraphemeBox()

_getGraphemeBox(grapheme, lineIndex, charIndex, prevGrapheme?, skipLeft?): GraphemeBBox

Parameters

grapheme: string

to be measured

lineIndex: number

index of the line where the char is

charIndex: number

position in the line

prevGrapheme?: string

character preceding the one to be measured

skipLeft?: boolean

Returns

GraphemeBBox

grapheme bbox

Inherited from

IText._getGraphemeBox

Defined in

src/shapes/Text/Text.ts:983


_getSelectionForOffset()

_getSelectionForOffset(e, isRight): number

private Helps finding if the offset should be counted from Start or End

Parameters

e: KeyboardEvent

Event object

isRight: boolean

Returns

number

Inherited from

IText._getSelectionForOffset

Defined in

src/shapes/IText/ITextKeyBehavior.ts:377


_getWidthOfCharSpacing()

_getWidthOfCharSpacing(): number

Returns

number

Inherited from

IText._getWidthOfCharSpacing

Defined in

src/shapes/Text/Text.ts:1528


_limitCacheSize()

_limitCacheSize(dims): any

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

dims: any

Returns

any

.width width of canvas

.height height of canvas

.zoomX zoomX zoom value to unscale the canvas before drawing cache

.zoomY zoomY zoom value to unscale the canvas before drawing cache

Inherited from

IText._limitCacheSize

Defined in

src/shapes/Object/Object.ts:406


_measureLine()

_measureLine(lineIndex): object

measure every grapheme of a line, populating __charBounds

Parameters

lineIndex: number

Returns

object

object.width total width of characters

object.numOfSpaces length of chars that match this._reSpacesAndTabs

numOfSpaces

numOfSpaces: number = 0

width

width: number

Inherited from

IText._measureLine

Defined in

src/shapes/Text/Text.ts:891


_measureWord()

_measureWord(word, lineIndex, charOffset): number

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

word: string[]

lineIndex: number

charOffset: number = 0

Returns

number

Defined in

src/shapes/Textbox.ts:389


_mouseDownHandler()

_mouseDownHandler(__namedParameters): void

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

__namedParameters: TPointerEventInfo<TPointerEvent>

Returns

void

Inherited from

IText._mouseDownHandler

Defined in

src/shapes/IText/ITextClickBehavior.ts:136


_mouseDownHandlerBefore()

_mouseDownHandlerBefore(__namedParameters): void

Default event handler for the basic functionalities needed on mousedown:before can be overridden to do something different. Scope of this implementation is: verify the object is already selected when mousing down

Parameters

__namedParameters: TPointerEventInfo<TPointerEvent>

Returns

void

Inherited from

IText._mouseDownHandlerBefore

Defined in

src/shapes/IText/ITextClickBehavior.ts:171


_moveCursorLeftOrRight()

_moveCursorLeftOrRight(direction, e): void

Moves cursor right or Left, fires event

Parameters

direction: "Left" | "Right"

‘Left’, ‘Right’

e: KeyboardEvent

Event object

Returns

void

Inherited from

IText._moveCursorLeftOrRight

Defined in

src/shapes/IText/ITextKeyBehavior.ts:639


_moveCursorUpOrDown()

_moveCursorUpOrDown(direction, e): void

Moves cursor up or down, fires the events

Parameters

direction: "Up" | "Down"

‘Up’ or ‘Down’

e: KeyboardEvent

Event object

Returns

void

Inherited from

IText._moveCursorUpOrDown

Defined in

src/shapes/IText/ITextKeyBehavior.ts:477


_removeCacheCanvas()

_removeCacheCanvas(): void

Remove cacheCanvas and its dimensions from the objects

Returns

void

Inherited from

IText._removeCacheCanvas

Defined in

src/shapes/Object/Object.ts:756


_renderControls()

_renderControls(ctx, styleOverride?): void

Renders controls and borders for the object the context here is not transformed

Parameters

ctx: CanvasRenderingContext2D

Context to render on

styleOverride?: TStyleOverride = {}

properties to override the object style

Returns

void

Todo

move to interactivity

Inherited from

IText._renderControls

Defined in

src/shapes/Object/InteractiveObject.ts:435


_renderCursor()

_renderCursor(ctx, boundaries, selectionStart): void

Render the cursor at the given selectionStart.

Parameters

ctx: CanvasRenderingContext2D

boundaries: CursorBoundaries

selectionStart: number

Returns

void

Inherited from

IText._renderCursor

Defined in

src/shapes/IText/IText.ts:550


_setClippingProperties()

_setClippingProperties(ctx): void

Parameters

ctx: CanvasRenderingContext2D

Returns

void

Inherited from

IText._setClippingProperties

Defined in

src/shapes/Object/Object.ts:1062


_setFillStyles()

_setFillStyles(ctx, style): object

This function prepare the canvas for a ill style, and fill need to be sent in as defined

Parameters

ctx: CanvasRenderingContext2D

style: Pick<Textbox<Props, SProps, EventSpec>, "fill">

with ill defined

Returns

object

offsetX

offsetX: number

offsetY

offsetY: number

Inherited from

IText._setFillStyles

Defined in

src/shapes/Text/Text.ts:1341


_setStrokeStyles()

_setStrokeStyles(ctx, style): object

This function prepare the canvas for a stroke style, and stroke and strokeWidth need to be sent in as defined

Parameters

ctx: CanvasRenderingContext2D

style: Pick<CompleteTextStyleDeclaration, "stroke" | "strokeWidth">

with stroke and strokeWidth defined

Returns

object

offsetX

offsetX: number

offsetY

offsetY: number

Inherited from

IText._setStrokeStyles

Defined in

src/shapes/Text/Text.ts:1319


_setupCompositeOperation()

_setupCompositeOperation(ctx): void

Sets canvas globalCompositeOperation for specific object custom composition operation for the particular object can be specified using globalCompositeOperation property

Parameters

ctx: CanvasRenderingContext2D

Rendering canvas context

Returns

void

Inherited from

IText._setupCompositeOperation

Defined in

src/shapes/Object/Object.ts:1518


_splitTextIntoLines()

_splitTextIntoLines(text): TextLinesInfo

Gets lines of text to render in the Textbox. This function calculates text wrapping on the fly every time it is called.

Parameters

text: string

text to split

Returns

TextLinesInfo

Array of lines in the Textbox.

Overrides

IText._splitTextIntoLines

Defined in

src/shapes/Textbox.ts:533


_toSVG()

_toSVG(_reviver?): string[]

Returns svg representation of an instance This function is implemented in each subclass This is just because typescript otherwise cryies all the time

Parameters

_reviver?: TSVGReviver

Returns

string[]

an array of strings with the specific svg representation of the instance

Inherited from

IText._toSVG

Defined in

src/shapes/Object/FabricObjectSVGExportMixin.ts:120


_wrapText()

_wrapText(lines, desiredWidth): string[][]

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

lines: string[]

The string array of text that is split into lines

desiredWidth: number

width you want to wrap to

Returns

string[][]

Array of lines

Defined in

src/shapes/Textbox.ts:324


abortCursorAnimation()

abortCursorAnimation(): void

Aborts cursor animation, clears all timeouts and clear textarea context if necessary

Returns

void

Inherited from

IText.abortCursorAnimation

Defined in

src/shapes/IText/ITextBehavior.ts:183


addPaintOrder()

addPaintOrder(this): string

Parameters

this: FabricObjectSVGExportMixin & FabricObject<Partial<FabricObjectProps>, SerializedObjectProps, ObjectEvents>

Returns

string

Inherited from

IText.addPaintOrder

Defined in

src/shapes/Object/FabricObjectSVGExportMixin.ts:249


animate()

animate<T>(animatable, options?): Record<string, TAnimation<T>>

Animates object’s properties

Type Parameters

T extends number | number[] | TColorArg

Parameters

animatable: Record<string, T>

map of keys and end values

options?: Partial<AnimationOptions<T>>

Returns

Record<string, TAnimation<T>>

map of animation contexts

As object — multiple properties

object.animate({ left: …, top: … }); object.animate({ left: …, top: … }, { duration: … });

Tutorial

http://fabricjs.com/fabric-intro-part-2#animation

Inherited from

IText.animate

Defined in

src/shapes/Object/Object.ts:1557


blur()

blur(): void

Override this method to customize cursor behavior on textbox blur

Returns

void

Inherited from

IText.blur

Defined in

src/shapes/IText/ITextKeyBehavior.ts:106


calcACoords()

calcACoords(): TCornerPoint

Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates. those never change with zoom or viewport changes.

Returns

TCornerPoint

Inherited from

IText.calcACoords

Defined in

src/shapes/Object/ObjectGeometry.ts:427


calcOCoords()

calcOCoords(): Record<string, TOCoord>

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

Record<string, TOCoord>

Inherited from

IText.calcOCoords

Defined in

src/shapes/Object/InteractiveObject.ts:255


calcOwnMatrix()

calcOwnMatrix(): TMat2D

calculate transform matrix that represents the current transformations from the object’s properties, this matrix does not include the group transformation

Returns

TMat2D

transform matrix for the object

Inherited from

IText.calcOwnMatrix

Defined in

src/shapes/Object/ObjectGeometry.ts:513


calcTextHeight()

calcTextHeight(): number

Calculate text box height

Returns

number

Inherited from

IText.calcTextHeight

Defined in

src/shapes/Text/Text.ts:1044


calcTransformMatrix()

calcTransformMatrix(skipGroup?): TMat2D

calculate transform matrix that represents the current transformations from the object’s properties.

Parameters

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

TMat2D

transform matrix for the object

Inherited from

IText.calcTransformMatrix

Defined in

src/shapes/Object/ObjectGeometry.ts:485


canDrop()

canDrop(e): boolean

override this method to control whether instance should/shouldn’t become a drop target

Parameters

e: DragEvent

Returns

boolean

Inherited from

IText.canDrop

Defined in

src/shapes/IText/ITextClickBehavior.ts:75


cleanStyle()

cleanStyle(property): undefined | false

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

property: StylePropertiesType

The property to compare between characters and text.

Returns

undefined | false

Inherited from

IText.cleanStyle

Defined in

src/shapes/Text/StyledText.ts:103


clearContextTop()

clearContextTop(restoreManually?): undefined | CanvasRenderingContext2D

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

restoreManually?: boolean

When true won’t restore the context after clear, in order to draw something else.

Returns

undefined | CanvasRenderingContext2D

canvas.contextTop that is either still transformed with the object transformMatrix, or restored to neutral transform

Todo

discuss swapping restoreManually with a renderCallback, but think of async issues

Inherited from

IText.clearContextTop

Defined in

src/shapes/Object/InteractiveObject.ts:627


clone()

clone(propertiesToInclude?): Promise<Textbox<Props, SProps, EventSpec>>

Clones an instance.

Parameters

propertiesToInclude?: string[]

Any properties that you might want to additionally include in the output

Returns

Promise<Textbox<Props, SProps, EventSpec>>

Inherited from

IText.clone

Defined in

src/shapes/Object/Object.ts:1292


cloneAsImage()

cloneAsImage(options?): FabricImage<Partial<ImageProps>, SerializedImageProps, ObjectEvents>

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

options?: ObjectToCanvasElementOptions

for clone as image, passed to toDataURL

Returns

FabricImage<Partial<ImageProps>, SerializedImageProps, ObjectEvents>

Object cloned as image.

Todo

fix the export type, it could not be Image but the type that getClass return for ‘image’.

Inherited from

IText.cloneAsImage

Defined in

src/shapes/Object/Object.ts:1318


complexity()

complexity(): number

Returns complexity of an instance

Returns

number

complexity

Inherited from

IText.complexity

Defined in

src/shapes/Text/Text.ts:1794


containsPoint()

containsPoint(point): boolean

Checks if point is inside the object

Parameters

point: Point

Point to check against

Returns

boolean

true if point is inside the object

Inherited from

IText.containsPoint

Defined in

src/shapes/Object/ObjectGeometry.ts:282


copy()

copy(): void

Copies selected text

Returns

void

Inherited from

IText.copy

Defined in

src/shapes/IText/ITextKeyBehavior.ts:295


dispose()

dispose(): void

cancel instance’s running animations override if necessary to dispose artifacts such as clipPath

Returns

void

Inherited from

IText.dispose

Defined in

src/shapes/IText/IText.ts:722


doubleClickHandler()

doubleClickHandler(options): void

Default handler for double click, select a word

Parameters

options: TPointerEventInfo<TPointerEvent>

Returns

void

Inherited from

IText.doubleClickHandler

Defined in

src/shapes/IText/ITextClickBehavior.ts:111


drawBorders()

drawBorders(ctx, options, styleOverride?): void

Draws borders of an object’s bounding box. Requires public properties: width, height Requires public options: padding, borderColor

Parameters

ctx: CanvasRenderingContext2D

Context to draw on

options: Required<Omit<TComposeMatrixArgs, "flipX" | "flipY">>

object representing current object parameters

styleOverride?: TStyleOverride

object to override the object style

Returns

void

Inherited from

IText.drawBorders

Defined in

src/shapes/Object/InteractiveObject.ts:478


drawCacheOnCanvas()

drawCacheOnCanvas(this, ctx): void

Paint the cached copy of the object on the target context.

Parameters

this: TCachedFabricObject<BaseFabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>>

ctx: CanvasRenderingContext2D

Context to render on

Returns

void

Inherited from

IText.drawCacheOnCanvas

Defined in

src/shapes/Object/Object.ts:942


drawClipPathOnCache()

drawClipPathOnCache(ctx, clipPath, canvasWithClipPath): void

Execute the drawing operation for an object clipPath

Parameters

ctx: CanvasRenderingContext2D

Context to render on

clipPath: BaseFabricObject<Partial<ObjectProps>, SerializedObjectProps, ObjectEvents>

canvasWithClipPath: HTMLCanvasElement

Returns

void

Inherited from

IText.drawClipPathOnCache

Defined in

src/shapes/Object/Object.ts:847


drawControls()

drawControls(ctx, styleOverride): void

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

ctx: CanvasRenderingContext2D

Context to draw on

styleOverride: Partial<Pick<InteractiveFabricObject<Partial<FabricObjectProps>, SerializedObjectProps, ObjectEvents>, "cornerStyle" | "cornerSize" | "cornerColor" | "cornerStrokeColor" | "cornerDashArray" | "transparentCorners">> = {}

object to override the object style

Returns

void

Inherited from

IText.drawControls

Defined in

src/shapes/Object/InteractiveObject.ts:550


drawControlsConnectingLines()

drawControlsConnectingLines(ctx, size): void

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

ctx: CanvasRenderingContext2D

Context to draw on

size: Point

object size x = width, y = height

Returns

void

Inherited from

IText.drawControlsConnectingLines

Defined in

src/shapes/Object/InteractiveObject.ts:517


drawObject()

drawObject(ctx, forClipping, context): void

Execute the drawing operation for an object on a specified context

Parameters

ctx: CanvasRenderingContext2D

Context to render on

forClipping: undefined | boolean

apply clipping styles

context: DrawContext

additional context for rendering

Returns

void

Inherited from

IText.drawObject

Defined in

src/shapes/Object/Object.ts:872


drawSelectionBackground()

drawSelectionBackground(ctx): void

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

ctx: CanvasRenderingContext2D

Context to draw on

Returns

void

Todo

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

IText.drawSelectionBackground

Defined in

src/shapes/Object/InteractiveObject.ts:375


enlargeSpaces()

enlargeSpaces(): void

Enlarge space boxes and shift the others

Returns

void

Inherited from

IText.enlargeSpaces

Defined in

src/shapes/Text/Text.ts:491


enterEditing()

enterEditing(e?): void

Enters editing state

Parameters

e?: TPointerEvent

Returns

void

Inherited from

IText.enterEditing

Defined in

src/shapes/IText/ITextBehavior.ts:386


enterEditingImpl()

enterEditingImpl(): void

runs the actual logic that enter from editing state, see enterEditing

Returns

void

Inherited from

IText.enterEditingImpl

Defined in

src/shapes/IText/ITextBehavior.ts:405


exitEditing()

exitEditing(): Textbox<Props, SProps, EventSpec>

Exits from editing state and fires relevant events

Returns

Textbox<Props, SProps, EventSpec>

Inherited from

IText.exitEditing

Defined in

src/shapes/IText/ITextBehavior.ts:715


exitEditingImpl()

exitEditingImpl(): void

runs the actual logic that exits from editing state, see exitEditing But it does not fire events

Returns

void

Inherited from

IText.exitEditingImpl

Defined in

src/shapes/IText/ITextBehavior.ts:702


findCommonAncestors()

findCommonAncestors<T>(other): AncestryComparison

Compare ancestors

Type Parameters

T extends Textbox<Props, SProps, EventSpec>

Parameters

other: T

Returns

AncestryComparison

an object that represent the ancestry situation.

Inherited from

IText.findCommonAncestors

Defined in

src/shapes/Object/Object.ts:1675


findLineBoundaryLeft()

findLineBoundaryLeft(startFrom): number

Find new selection index representing start of current line according to current selection index

Parameters

startFrom: number

Current selection index

Returns

number

New selection index

Inherited from

IText.findLineBoundaryLeft

Defined in

src/shapes/IText/ITextBehavior.ts:288


findLineBoundaryRight()

findLineBoundaryRight(startFrom): number

Find new selection index representing end of current line according to current selection index

Parameters

startFrom: number

Current selection index

Returns

number

New selection index

Inherited from

IText.findLineBoundaryRight

Defined in

src/shapes/IText/ITextBehavior.ts:305


findWordBoundaryLeft()

findWordBoundaryLeft(startFrom): number

Find new selection index representing start of current word according to current selection index

Parameters

startFrom: number

Current selection index

Returns

number

New selection index

Inherited from

IText.findWordBoundaryLeft

Defined in

src/shapes/IText/ITextBehavior.ts:240


findWordBoundaryRight()

findWordBoundaryRight(startFrom): number

Find new selection index representing end of current word according to current selection index

Parameters

startFrom: number

Current selection index

Returns

number

New selection index

Inherited from

IText.findWordBoundaryRight

Defined in

src/shapes/IText/ITextBehavior.ts:264


fire()

fire<K>(eventName, options?): void

Fires event with an optional options object

Type Parameters

K extends string | number | symbol

Parameters

eventName: K

Event name to fire

options?: EventSpec[K]

Options object

Returns

void

Inherited from

IText.fire

Defined in

src/Observable.ts:167


forEachControl()

forEachControl(fn): void

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

fn

function to iterate over the controls over

Returns

void

Inherited from

IText.forEachControl

Defined in

src/shapes/Object/InteractiveObject.ts:353


fromGraphemeToStringSelection()

fromGraphemeToStringSelection(start, end, graphemes): object

convert from fabric to textarea values

Parameters

start: number

end: number

graphemes: string[]

Returns

object

selectionEnd

selectionEnd: number = graphemeStart

selectionStart

selectionStart: number = graphemeStart

Inherited from

IText.fromGraphemeToStringSelection

Defined in

src/shapes/IText/ITextBehavior.ts:498


fromStringToGraphemeSelection()

fromStringToGraphemeSelection(start, end, text): object

convert from textarea to grapheme indexes

Parameters

start: number

end: number

text: string

Returns

object

selectionEnd

selectionEnd: number = graphemeStart

selectionStart

selectionStart: number = graphemeStart

Inherited from

IText.fromStringToGraphemeSelection

Defined in

src/shapes/IText/ITextBehavior.ts:481


get()

get(property): any

Basic getter

Parameters

property: string

Property name

Returns

any

value of a property

Inherited from

IText.get

Defined in

src/CommonMethods.ts:59


get2DCursorLocation()

get2DCursorLocation(selectionStart?, skipWrapping?): object

Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)

Parameters

selectionStart?: number = ...

Optional index. When not given, current selectionStart is used.

skipWrapping?: boolean

consider the location for unwrapped lines. useful to manage styles.

Returns

object

charIndex

charIndex: number = selectionStart

lineIndex

lineIndex: number = i

Inherited from

IText.get2DCursorLocation

Defined in

src/shapes/IText/IText.ts:348


getActiveControl()

getActiveControl(): undefined | object

Returns

undefined | object

Inherited from

IText.getActiveControl

Defined in

src/shapes/Object/InteractiveObject.ts:194


getAncestors()

getAncestors(): Ancestors

Returns

Ancestors

ancestors (excluding ActiveSelection) from bottom to top

Inherited from

IText.getAncestors

Defined in

src/shapes/Object/Object.ts:1658


getBoundingRect()

getBoundingRect(): TBBox

Returns coordinates of object’s bounding rectangle (left, top, width, height) the box is intended as aligned to axis of canvas.

Returns

TBBox

Object with left, top, width, height properties

Inherited from

IText.getBoundingRect

Defined in

src/shapes/Object/ObjectGeometry.ts:343


getCanvasRetinaScaling()

getCanvasRetinaScaling(): number

Returns

number

Inherited from

IText.getCanvasRetinaScaling

Defined in

src/shapes/Object/ObjectGeometry.ts:400


getCenterPoint()

getCenterPoint(): Point

Returns the center coordinates of the object relative to canvas

Returns

Point

Inherited from

IText.getCenterPoint

Defined in

src/shapes/Object/ObjectGeometry.ts:732


getCompleteStyleDeclaration()

getCompleteStyleDeclaration(lineIndex, charIndex): CompleteTextStyleDeclaration

return a new object that contains all the style property for a character the object returned is newly created

Parameters

lineIndex: number

of the line where the character is

charIndex: number

position of the character on the line

Returns

CompleteTextStyleDeclaration

style object

Inherited from

IText.getCompleteStyleDeclaration

Defined in