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
Parameter | Type | Description |
---|---|---|
style | ITextStyle | The initial style object |
Returns
Example
const style = new TextStyleBuilder({ ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE });
console.log(style);
Overrides
Properties
Property | Modifier | Type | Inherited from | Defined in |
---|---|---|---|---|
_style | protected | ITextStyle | TextStyleValue ._style | packages/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
The background color or null/undefined
Inherited from
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
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
The border settings or null/undefined
Inherited from
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
The text color or null/undefined
Inherited from
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
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
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
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
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
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
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
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
The vertical alignment or null/undefined
Inherited from
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
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
A new TextStyleBuilder instance with the same style
Overrides
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
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
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
Parameter | Type | Description |
---|---|---|
color | null | IColorStyle | The background color or null to remove |
Returns
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
Parameter | Type | Description |
---|---|---|
value | boolean | True to make bold, false otherwise |
Returns
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
Parameter | Type | Description |
---|---|---|
border | null | IBorderData | The border settings or null to remove |
Returns
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
Parameter | Type | Description |
---|---|---|
decoration | TextDecorationBuilder | The bottom border line decoration settings |
Returns
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
Parameter | Type | Description |
---|---|---|
color | null | IColorStyle | The text color or null to remove |
Returns
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
Parameter | Type | Description |
---|---|---|
family | string | The font family name |
Returns
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
Parameter | Type | Description |
---|---|---|
size | number | The font size |
Returns
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
Parameter | Type | Description |
---|---|---|
value | boolean | True to make italic, false otherwise |
Returns
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
Parameter | Type | Description |
---|---|---|
decoration | TextDecorationBuilder | The overline decoration settings |
Returns
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
Parameter | Type | Description |
---|---|---|
decoration | TextDecorationBuilder | The strikethrough decoration settings |
Returns
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
Parameter | Type | Description |
---|---|---|
decoration | TextDecorationBuilder | The underline decoration settings |
Returns
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
Parameter | Type | Description |
---|---|---|
offset | null | BaselineOffset | The vertical alignment or null to remove |
Returns
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
Parameter | Type | Description |
---|---|---|
style | ITextStyle | Initial style object |
Returns
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);