@univerjscoreclassesRichtextbuilder

@univerjs/core v0.5.4


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

ParameterType
dataIDocumentData

Returns

RichTextBuilder

Overrides

RichTextValue.constructor

Properties

PropertyModifierTypeInherited fromDefined in
_dataprotectedIDocumentDataRichTextValue._datapackages/api/tmp/univer-pro/submodules/univer/packages/core/src/docs/data-model/rich-text-builder.ts:1463

Methods

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
ParameterTypeDescription
linkIdstringThe id of the link to cancel
Returns

RichTextBuilder

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
ParameterTypeDescription
startnumberThe start position of the text to cancel the link
endnumberThe end position of the text to cancel the link
Returns

RichTextBuilder

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

RichTextBuilder

A new instance of RichTextValue with the same data

Inherited from

RichTextValue.copy


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
ParameterTypeDescription
countnumberThe number of characters to delete (optional)
Returns

RichTextBuilder

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
ParameterTypeDescription
startnumberThe start position of the text to delete
count?numberThe number of characters to delete (optional)
Returns

RichTextBuilder

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

IDocumentData

The data of the current RichTextValue instance

Inherited from

RichTextValue.getData


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

ICustomRange[]

The links of the current RichTextValue instance

Inherited from

RichTextValue.getLinks


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

RichTextValue[]

The paragraphs of the current RichTextValue instance

Inherited from

RichTextValue.getParagraphs


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

ParagraphStyleValue

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

RichTextValue.getTextRuns


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
ParameterType
textstring
urlstring
Returns

RichTextBuilder

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
ParameterType
startnumber
textstring
urlstring
Returns

RichTextBuilder


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
ParameterTypeDescription
paragraphStyle?ParagraphStyleBuilderThe style of the paragraph to insert
Returns

RichTextBuilder

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
ParameterTypeDescription
startnumberThe start position of the paragraph to insert
paragraphStyleParagraphStyleBuilderThe style of the paragraph to insert
Returns

RichTextBuilder

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
ParameterTypeDescription
richText| IDocumentData | RichTextValueThe rich text to insert
Returns

RichTextBuilder

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
ParameterTypeDescription
startnumberThe start position of the text to insert
richText| IDocumentData | RichTextValueThe rich text to insert
Returns

RichTextBuilder

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
ParameterTypeDescription
startstringThe start position of the text to insert
style?| ITextStyle | TextStyleBuilderThe style of the text to insert
Returns

RichTextBuilder

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
ParameterTypeDescription
startnumberThe start position of the text to insert
textstringThe text to insert
style?| ITextStyle | TextStyleBuilderThe style of the text to insert
Returns

RichTextBuilder

The current RichTextBuilder instance

Example
const richText = RichTextValue.create({ body: { dataStream: 'Hello' } });
const newRichText = richText.insertText(5, 'World', { ff: 'Arial', fs: 12 });

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

ParameterTypeDescription
startnumberThe start position of the text to set the link
endnumberThe end position of the text to set the link
linkstringThe link to set

Returns

RichTextBuilder

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

ParameterTypeDescription
startnumberThe start position of the text to set the style
endnumberThe end position of the text to set the style
style| ITextStyle | TextStyleBuilderThe style to set

Returns

RichTextBuilder

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

ParameterTypeDescription
startnumberThe start index
endnumberThe end index

Returns

RichTextBuilder

A new instance of RichTextBuilder with the sliced data

Inherited from

RichTextValue.slice


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

RichTextValue.toPlainText


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

ParameterType
idstring
urlstring

Returns

RichTextBuilder


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

ParameterTypeDescription
data?IDocumentDataThe initial data for the rich text builder

Returns

RichTextBuilder

A new RichTextBuilder instance

Overrides

RichTextValue.create


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

ParameterTypeDescription
dataIDocumentBodyThe initial data for the rich text value

Returns

RichTextValue

A new RichTextValue instance

Inherited from

RichTextValue.createByBody


newEmptyData()

static newEmptyData(): IDocumentData

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

Returns

IDocumentData