Skip to content

BlockSuite API Documentation / @blocksuite/affine-block-surface / TextUtils

Variable: TextUtils

const TextUtils: object

Type declaration

getCursorByCoord()

getCursorByCoord: (model, coord) => number

Parameters

model: TextElementModel

coord

coord.x: number

coord.y: number

Returns

number

getFontFaces()

getFontFaces: () => FontFace[]

Returns

FontFace[]

getFontFacesByFontFamily()

getFontFacesByFontFamily: (fontFamily) => FontFace[]

Parameters

fontFamily: string

Returns

FontFace[]

getLineHeight()

getLineHeight: (fontFamily, fontSize, fontWeight) => number

Parameters

fontFamily: string

fontSize: number

fontWeight: string

Returns

number

isFontStyleSupported()

isFontStyleSupported: (fontFamily, style) => boolean

Parameters

fontFamily: string

style: FontStyle

Returns

boolean

isFontWeightSupported()

isFontWeightSupported: (fontFamily, weight) => boolean

Parameters

fontFamily: string

weight: FontWeight

Returns

boolean

isSameFontFamily()

isSameFontFamily: (fontFamily) => (fontFace) => boolean

Parameters

fontFamily: string

Returns

Function

Parameters

fontFace: FontFace

Returns

boolean

normalizeTextBound()

normalizeTextBound: (__namedParameters, bound, dragging) => Bound

Parameters

__namedParameters

__namedParameters.fontFamily: FontFamily

__namedParameters.fontSize: number

__namedParameters.fontStyle: FontStyle

__namedParameters.fontWeight: FontWeight

__namedParameters.hasMaxWidth?: boolean

__namedParameters.maxWidth?: number

__namedParameters.yText: YText

bound: Bound

dragging: boolean = false

Returns

Bound

splitIntoLines()

splitIntoLines: (text) => string[]

Parameters

text: string

Returns

string[]

wrapFontFamily()

wrapFontFamily: (fontFamily) => string

Parameters

fontFamily: string

Returns

string

Defined in

packages/affine/block-surface/src/index.ts:102