Class: RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1582
Represents a rich text builder
Extends
Constructors
new RichTextBuilder()
new RichTextBuilder(data): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1612
Parameters
Parameter | Type |
---|---|
data | IDocumentData |
Returns
Overrides
Properties
Property | Modifier | Type | Inherited from | Defined in |
---|---|---|---|---|
_data | protected | IDocumentData | RichTextValue ._data | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1463 |
Methods
cancelLink()
Call Signature
cancelLink(linkId): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1845
Cancels the link of the text at the specified start and end positions
Parameters
Parameter | Type | Description |
---|---|---|
linkId | string | The id of the link to cancel |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({
body: {
dataStream: 'Hello World',
customRanges: [
{
rangeType: CustomRangeType.HYPERLINK,
rangeId: 'linkId',
properties: { url: 'https://www.example.com' },
startIndex: 0,
endIndex: 5
}]
}
});
const newRichText = richText.cancelLink('linkId');
Call Signature
cancelLink(start, end): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1869
Cancels the link of the text at the specified start and end positions
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start position of the text to cancel the link |
end | number | The end position of the text to cancel the link |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({
body: {
dataStream: 'Hello World',
customRanges: [
{
rangeType: CustomRangeType.HYPERLINK,
rangeId: 'linkId',
properties: { url: 'https://www.example.com' },
startIndex: 0,
endIndex: 5
}]
}
});
const newRichText = richText.cancelLink(0, 10);
copy()
copy(): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1494
Creates a copy of the current RichTextValue instance
Returns
A new instance of RichTextValue with the same data
Inherited from
delete()
Call Signature
delete(count): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1745
Deletes text from the rich text builder from the end.
Parameters
Parameter | Type | Description |
---|---|---|
count | number | The number of characters to delete (optional) |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello World' } });
const newRichText = richText.delete(5);
Call Signature
delete(start, count?): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1757
Deletes text from the rich text builder at the specified start position
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start position of the text to delete |
count ? | number | The number of characters to delete (optional) |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello World' } });
const newRichText = richText.delete(5, 5);
getData()
getData(): IDocumentData
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1574
Gets the data of the current RichTextValue instance
Returns
The data of the current RichTextValue instance
Inherited from
getLinks()
getLinks(): ICustomRange[]
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1566
Gets the links of the current RichTextValue instance
Returns
The links of the current RichTextValue instance
Inherited from
getParagraphBullet()
getParagraphBullet(): undefined | IBullet
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1532
Gets the paragraph bullet of the current RichTextValue instance
Returns
undefined
| IBullet
The paragraph bullet of the current RichTextValue instance
Inherited from
RichTextValue
.getParagraphBullet
getParagraphs()
getParagraphs(): RichTextValue[]
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1540
Gets the paragraphs of the current RichTextValue instance
Returns
The paragraphs of the current RichTextValue instance
Inherited from
getParagraphStyle()
getParagraphStyle(): ParagraphStyleValue
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1524
Gets the paragraph style of the current RichTextValue instance
Returns
The paragraph style of the current RichTextValue instance
Inherited from
RichTextValue
.getParagraphStyle
getTextRuns()
getTextRuns(): {
ed: number;
sId: string;
st: number;
ts: null | TextStyleValue;
}[]
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1555
Gets the text runs of the current RichTextValue instance
Returns
{
ed
: number
;
sId
: string
;
st
: number
;
ts
: null
| TextStyleValue
;
}[]
The text runs of the current RichTextValue instance
Inherited from
insertLink()
Call Signature
insertLink(text, url): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1964
Inserts a new link
Parameters
Parameter | Type |
---|---|
text | string |
url | string |
Returns
Call Signature
insertLink(
start,
text,
url): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1965
Inserts a new link
Parameters
Parameter | Type |
---|---|
start | number |
text | string |
url | string |
Returns
insertParagraph()
Call Signature
insertParagraph(paragraphStyle?): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1918
Inserts a new paragraph at the specified start position
Parameters
Parameter | Type | Description |
---|---|---|
paragraphStyle ? | ParagraphStyleBuilder | The style of the paragraph to insert |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello World' } });
const newRichText = richText.insertParagraph();
Call Signature
insertParagraph(start, paragraphStyle): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1930
Inserts a new paragraph at the specified start position
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start position of the paragraph to insert |
paragraphStyle | ParagraphStyleBuilder | The style of the paragraph to insert |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello World' } });
const newRichText = richText.insertParagraph(5, { ff: 'Arial', fs: 12 });
insertRichText()
Call Signature
insertRichText(richText): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1698
Inserts rich text into the rich text builder at the specified start position
Parameters
Parameter | Type | Description |
---|---|---|
richText | | IDocumentData | RichTextValue | The rich text to insert |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello' } });
const newRichText = richText.insertRichText(RichTextValue.create({ body: { dataStream: 'World' } }));
Call Signature
insertRichText(start, richText): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1710
Inserts rich text into the rich text builder at the specified start position
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start position of the text to insert |
richText | | IDocumentData | RichTextValue | The rich text to insert |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello' } });
const newRichText = richText.insertRichText(5, RichTextValue.create({ body: { dataStream: 'World' } }));
insertText()
Call Signature
insertText(start, style?): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1629
Inserts text into the rich text builder at the specified start position
Parameters
Parameter | Type | Description |
---|---|---|
start | string | The start position of the text to insert |
style ? | | ITextStyle | TextStyleBuilder | The style of the text to insert |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello' } });
const newRichText = richText.insertText(0, 'World');
Call Signature
insertText(
start,
text,
style?): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1642
Inserts text into the rich text builder at the specified start position
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start position of the text to insert |
text | string | The text to insert |
style ? | | ITextStyle | TextStyleBuilder | The style of the text to insert |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello' } });
const newRichText = richText.insertText(5, 'World', { ff: 'Arial', fs: 12 });
setLink()
setLink(
start,
end,
link): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1806
Sets the link of the text at the specified start and end positions
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start position of the text to set the link |
end | number | The end position of the text to set the link |
link | string | The link to set |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello World' } });
const newRichText = richText.setLink(5, 10, 'https://www.example.com');
setStyle()
setStyle(
start,
end,
style): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1780
Sets the style of the text at the specified start and end positions
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start position of the text to set the style |
end | number | The end position of the text to set the style |
style | | ITextStyle | TextStyleBuilder | The style to set |
Returns
The current RichTextBuilder instance
Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello World' } });
const newRichText = richText.setStyle(5, 10, { ff: 'Arial', fs: 12 });
slice()
slice(start, end): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1504
Slices the current RichTextValue instance
Parameters
Parameter | Type | Description |
---|---|---|
start | number | The start index |
end | number | The end index |
Returns
A new instance of RichTextBuilder with the sliced data
Inherited from
toPlainText()
toPlainText(): string
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1516
Converts the current RichTextValue instance to plain text
Returns
string
The plain text representation of the current RichTextValue instance
Inherited from
updateLink()
updateLink(id, url): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1897
Parameters
Parameter | Type |
---|---|
id | string |
url | string |
Returns
create()
static create(data?): RichTextBuilder
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1606
Creates a new RichTextBuilder instance
Parameters
Parameter | Type | Description |
---|---|---|
data ? | IDocumentData | The initial data for the rich text builder |
Returns
A new RichTextBuilder instance
Overrides
createByBody()
static createByBody(data): RichTextValue
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1479
Creates a new RichTextValue instance
Parameters
Parameter | Type | Description |
---|---|---|
data | IDocumentBody | The initial data for the rich text value |
Returns
A new RichTextValue instance
Inherited from
newEmptyData()
static newEmptyData(): IDocumentData
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1583