@univerjscoreclassesTextstylebuilder

@univerjs/core v0.5.4


Class: TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:262

Builder class for creating and modifying font styles. Extends TextStyleValue to provide setter methods for all style properties.

Extends

Constructors

new TextStyleBuilder()

new TextStyleBuilder(style): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:286

Creates a new TextStyleBuilder instance

Parameters

ParameterTypeDescription
styleITextStyleThe initial style object

Returns

TextStyleBuilder

Example

const style = new TextStyleBuilder({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style);

Overrides

TextStyleValue.constructor

Properties

PropertyModifierTypeInherited fromDefined in
_styleprotectedITextStyleTextStyleValue._stylepackages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:32

Accessors

background

Get Signature

get background(): Nullable<IColorStyle>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:174

Gets the background color

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.background);
Returns

Nullable<IColorStyle>

The background color or null/undefined

Inherited from

TextStyleValue.background


bold

Get Signature

get bold(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:109

Gets whether the text is bold

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.bold);
Returns

boolean

True if bold, false otherwise

Inherited from

TextStyleValue.bold


border

Get Signature

get border(): Nullable<IBorderData>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:187

Gets the border settings

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.border);
Returns

Nullable<IBorderData>

The border settings or null/undefined

Inherited from

TextStyleValue.border


bottomBorderLine

Get Signature

get bottomBorderLine(): undefined | TextDecorationBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:135

Gets the bottom border line decoration

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.bottomBorderLine);
Returns

undefined | TextDecorationBuilder

The bottom border line decoration or undefined

Inherited from

TextStyleValue.bottomBorderLine


color

Get Signature

get color(): Nullable<IColorStyle>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:200

Gets the text color

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.color);
Returns

Nullable<IColorStyle>

The text color or null/undefined

Inherited from

TextStyleValue.color


fontFamily

Get Signature

get fontFamily(): Nullable<string>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:70

Gets the font family

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.fontFamily);
Returns

Nullable<string>

The font family name or undefined

Inherited from

TextStyleValue.fontFamily


fontSize

Get Signature

get fontSize(): undefined | number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:83

Gets the font size in points

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.fontSize);
Returns

undefined | number

The font size or undefined

Inherited from

TextStyleValue.fontSize


italic

Get Signature

get italic(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:96

Gets whether the text is italic

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.italic);
Returns

boolean

True if italic, false otherwise

Inherited from

TextStyleValue.italic


numberFormat

Get Signature

get numberFormat(): Nullable<{
  pattern: string;
}>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:226

Gets the number format pattern

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.numberFormat);
Returns

Nullable<{ pattern: string; }>

The number format pattern or null/undefined

Inherited from

TextStyleValue.numberFormat


overline

Get Signature

get overline(): undefined | TextDecorationBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:161

Gets the overline decoration

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.overline);
Returns

undefined | TextDecorationBuilder

The overline decoration or undefined

Inherited from

TextStyleValue.overline


strikethrough

Get Signature

get strikethrough(): undefined | TextDecorationBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:148

Gets the strikethrough decoration

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.strikethrough);
Returns

undefined | TextDecorationBuilder

The strikethrough decoration or undefined

Inherited from

TextStyleValue.strikethrough


underline

Get Signature

get underline(): undefined | TextDecorationBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:122

Gets the underline decoration

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.underline);
Returns

undefined | TextDecorationBuilder

The underline decoration or undefined

Inherited from

TextStyleValue.underline


verticalAlign

Get Signature

get verticalAlign(): Nullable<BaselineOffset>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:213

Gets the vertical alignment (subscript/superscript)

Example
const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.verticalAlign);
Returns

Nullable<BaselineOffset>

The vertical alignment or null/undefined

Inherited from

TextStyleValue.verticalAlign

Methods

build()

build(): ITextStyle

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:458

Builds and returns the final style object

Returns

ITextStyle

The complete style object


copy()

copy(): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:450

Creates a copy of this font style builder

Returns

TextStyleBuilder

A new TextStyleBuilder instance with the same style

Overrides

TextStyleValue.copy


getValue()

getValue(): ITextStyle

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:253

Gets the raw style object

Returns

ITextStyle

The underlying style object

Example

const style = TextStyleValue.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style.getValue());

Inherited from

TextStyleValue.getValue


setBackground()

setBackground(color): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:411

Sets the background color

Parameters

ParameterTypeDescription
colornull | IColorStyleThe background color or null to remove

Returns

TextStyleBuilder

The builder instance for chaining


setBold()

setBold(value): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:349

Sets the bold style

Parameters

ParameterTypeDescription
valuebooleanTrue to make bold, false otherwise

Returns

TextStyleBuilder

The builder instance for chaining

Example

const style = TextStyleBuilder.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
style.setBold(true);
console.log(style.bold);

setBorder()

setBorder(border): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:421

Sets the border settings

Parameters

ParameterTypeDescription
bordernull | IBorderDataThe border settings or null to remove

Returns

TextStyleBuilder

The builder instance for chaining


setBottomBorderLine()

setBottomBorderLine(decoration): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:381

Sets the bottom border line decoration

Parameters

ParameterTypeDescription
decorationTextDecorationBuilderThe bottom border line decoration settings

Returns

TextStyleBuilder

The builder instance for chaining

Example

const style = TextStyleBuilder.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
style.setBottomBorderLine({ type: 'single', color: '#FF0000' });
console.log(style.bottomBorderLine);

setColor()

setColor(color): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:431

Sets the text color

Parameters

ParameterTypeDescription
colornull | IColorStyleThe text color or null to remove

Returns

TextStyleBuilder

The builder instance for chaining


setFontFamily()

setFontFamily(family): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:301

Sets the font family

Parameters

ParameterTypeDescription
familystringThe font family name

Returns

TextStyleBuilder

The builder instance for chaining

Example

const style = TextStyleBuilder.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
style.setFontFamily('Times New Roman');
console.log(style.fontFamily);

setFontSize()

setFontSize(size): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:317

Sets the font size in points

Parameters

ParameterTypeDescription
sizenumberThe font size

Returns

TextStyleBuilder

The builder instance for chaining

Example

const style = TextStyleBuilder.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
style.setFontSize(14);
console.log(style.fontSize);

setItalic()

setItalic(value): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:333

Sets the italic style

Parameters

ParameterTypeDescription
valuebooleanTrue to make italic, false otherwise

Returns

TextStyleBuilder

The builder instance for chaining

Example

const style = TextStyleBuilder.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
style.setItalic(true);
console.log(style.italic);

setOverline()

setOverline(decoration): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:401

Sets the overline decoration

Parameters

ParameterTypeDescription
decorationTextDecorationBuilderThe overline decoration settings

Returns

TextStyleBuilder

The builder instance for chaining


setStrikethrough()

setStrikethrough(decoration): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:391

Sets the strikethrough decoration

Parameters

ParameterTypeDescription
decorationTextDecorationBuilderThe strikethrough decoration settings

Returns

TextStyleBuilder

The builder instance for chaining


setUnderline()

setUnderline(decoration): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:365

Sets the underline decoration

Parameters

ParameterTypeDescription
decorationTextDecorationBuilderThe underline decoration settings

Returns

TextStyleBuilder

The builder instance for chaining

Example

const style = TextStyleBuilder.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
style.setUnderline({ type: 'single', color: '#FF0000' });
console.log(style.underline);

setVerticalAlign()

setVerticalAlign(offset): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:441

Sets the vertical alignment (subscript/superscript)

Parameters

ParameterTypeDescription
offsetnull | BaselineOffsetThe vertical alignment or null to remove

Returns

TextStyleBuilder

The builder instance for chaining


create()

static create(style): TextStyleBuilder

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:273

Creates a new TextStyleBuilder instance

Parameters

ParameterTypeDescription
styleITextStyleInitial style object

Returns

TextStyleBuilder

A new TextStyleBuilder instance

Example

const style = TextStyleBuilder.create({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style);

Overrides

TextStyleValue.create