Back to Devexpress

RichEditSelection Class

aspnetcore-js-devexpress-dot-richedit-5073e3e4.md

latest16.9 KB
Original Source

RichEditSelection Class

Contains a set of methods and properties to work with the document selection.

Declaration

ts
export class RichEditSelection

Remarks

An instance of the RichEditSelection object can be accessed by the selection property.

Properties

active Property

Gets a cursor position.

Declaration

ts
get active(): number

Property Value

TypeDescription
number

The active selection position (the cursor position).

|

Remarks

Users can make a selection from left to right or from right to left. Use the anchor property to get the position where a user starts the selection. To get the position where the user ends the selection, use the active property.

javascript
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
subDocument.insertText(position, 'text');

See Also

Examples

Selection

activeSubDocument Property

Returns the active sub-document.

Declaration

ts
get activeSubDocument(): SubDocumentBase

Property Value

TypeDescription
SubDocumentBase

The active sub-document.

|

Remarks

javascript
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
subDocument.insertText(position, 'text');

See Also

Examples

Selection

anchor Property

Gets a position where a user starts the last selection.

Declaration

ts
get anchor(): number

Property Value

TypeDescription
number

The position of the selection anchor.

|

Remarks

Users can make a selection from left to right or from right to left. Use the anchor property to get the position where a user starts the selection. To get the position where the user ends the selection, use the active property.

end Property

Gets the end position of the last selected interval.

Declaration

ts
get end(): number

Property Value

TypeDescription
number

The end position.

|

intervals Property

Gets an array of document intervals in the selection.

Declaration

ts
get intervals(): Interval[]

Property Value

TypeDescription
Interval[]

An array of Interval objects.

|

See Also

Selection

showCursorAtEndOfLine Property

Specifies where to display the cursor when its position is on the border of two lines: at the end of the previous line or at the beginning of the new line.

Declaration

ts
get showCursorAtEndOfLine(): boolean
set showCursorAtEndOfLine(value: boolean)

Property Value

TypeDescription
boolean

true to display the cursor at the end of the previous line; false to display the cursor at the beginning of the new line.

|

start Property

Gets the start position of the last selected interval.

Declaration

ts
get start(): number

Property Value

TypeDescription
number

The start position.

|

Methods

goToDocumentEnd Method

Moves the cursor to the end of the active sub-document and allows you to extend the selection.

Declaration

ts
goToDocumentEnd(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
// Inserts text at the end of the active sub-document
richEdit.selection.goToDocumentEnd(false);
var position = richEdit.selection.active;
richEdit.selection.activeSubDocument.insertText(position, 'text');

goToDocumentStart Method

Moves the cursor to the start of the active sub-document and allows you to extend the selection.

Declaration

ts
goToDocumentStart(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
// Inserts text at the start of the active sub-document
richEdit.selection.goToDocumentStart(false);
var position = richEdit.selection.active;
richEdit.selection.activeSubDocument.insertText(position, 'text');

goToLineEnd Method

Moves the cursor to the end of the line and allows you to extend the selection.

Declaration

ts
goToLineEnd(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
richEdit.selection.goToLineEnd(true);

goToLineStart Method

Moves the cursor to the start of the line and allows you to extend the selection.

Declaration

ts
goToLineStart(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
richEdit.selection.goToLineStart(true);

goToNextCharacter Method

Moves the cursor to the next character and allows you to extend the selection.

Declaration

ts
goToNextCharacter(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
richEdit.selection.goToNextCharacter(true);

goToNextLine Method

Moves the cursor to the next line and allows you to extend the selection.

Declaration

ts
goToNextLine(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

Moves the cursor one line down. If the current line is the last one, moves the cursor to the end of the current line.

Use the goToLineStart/goToLineEnd method to move the cursor to the start/end of the line.

javascript
// Moves the cursor to the start of the next line
richEdit.selection.goToNextLine(false);
richEdit.selection.goToLineStart(false);

goToNextPage Method

Moves the cursor to the next page and allows you to extend the selection.

Declaration

ts
goToNextPage(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

Moves the cursor one page down. If the current page is the last one, moves the cursor to the end of the current page.

javascript
richEdit.selection.goToNextPage(true);

goToNextPageStart Method

Moves the cursor to the start of the next page and allows you to extend the selection.

Declaration

ts
goToNextPageStart(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
richEdit.selection.goToNextPageStart(true);

goToNextWord Method

Moves the cursor to the next word and allows you to extend the selection.

Declaration

ts
goToNextWord(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

This method treats most punctuation marks as separate words.

javascript
richEdit.selection.goToNextWord(true);

goToParagraphEnd Method

Moves the cursor to the end of the paragraph and allows you to extend the selection.

Declaration

ts
goToParagraphEnd(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

Moves the cursor to the end of the current paragraph. If the cursor is at the end of a paragraph, moves the cursor to the end of the next paragraph.

javascript
richEdit.selection.goToParagraphEnd(true);

goToParagraphStart Method

Moves the cursor to the start of the paragraph and allows you to extend the selection.

Declaration

ts
goToParagraphStart(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

Moves the cursor to the start of the current paragraph. If the cursor is at the start of a paragraph, moves the cursor to the start of the previous paragraph.

javascript
richEdit.selection.goToParagraphStart(true);

goToPreviousCharacter Method

Moves the cursor to the previous character and allows you to extend the selection.

Declaration

ts
goToPreviousCharacter(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
richEdit.selection.goToPreviousCharacter(true);

goToPreviousLine Method

Moves the cursor to the previous line and allows you to extend the selection.

Declaration

ts
goToPreviousLine(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

Moves the cursor one line up. If the current line is the first one, moves the cursor to the start of the current line.

Use the goToLineStart/goToLineEnd method to move the cursor to the start/end of the line.

javascript
// Moves the cursor to the start of the previous line
richEdit.selection.goToPreviousLine(false);
richEdit.selection.goToLineStart(false);

goToPreviousPage Method

Moves the cursor to the previous page and allows you to extend the selection.

Declaration

ts
goToPreviousPage(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

Moves the cursor one page up. If the current page is the first one, moves the cursor to the start of the current page.

javascript
richEdit.selection.goToPreviousPage(true);

goToPreviousPageStart Method

Moves the cursor to the start of the previous page and allows you to extend the selection.

Declaration

ts
goToPreviousPageStart(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

javascript
richEdit.selection.goToPreviousPageStart(true);

goToPreviousWord Method

Moves the cursor to the previous word and allows you to extend the selection.

Declaration

ts
goToPreviousWord(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

This method treats most punctuation marks as separate words.

javascript
richEdit.selection.goToPreviousWord(true);

goToSubDocumentEnd Method

Moves the cursor to the end of the sub-document and allows you to extend the selection.

Declaration

ts
goToSubDocumentEnd(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true , to extend the selection; otherwise, false.

|

Remarks

javascript
richEdit.selection.goToSubDocumentEnd();

selectAll Method

Selects the current sub-document’s entire content.

Declaration

ts
selectAll(): void

Remarks

javascript
richEdit.selection.selectAll();

See Also

Selection

selectLine Method

Selects the line in which the cursor is located and allows you to extend the selection.

Declaration

ts
selectLine(
    extendSelection?: boolean
): void

Parameters

NameTypeDescription
extendSelectionboolean

true to extend the selection; otherwise, false.

|

Remarks

When the end of the current line is already selected, the method selects the next line.

javascript
// Selects five lines
for(let i=0; i<5; i++)
  richEdit.selection.selectLine(true);

selectParagraph Method

Selects the paragraph in which the cursor is located.

Declaration

ts
selectParagraph(): void

Remarks

javascript
richEdit.selection.selectParagraph();

selectTable Method

Selects the entire table in which the cursor is located.

Declaration

ts
selectTable(): void

Remarks

javascript
richEdit.selection.selectTable();

selectTableCell Method

Selects the table cell in which the cursor is located.

Declaration

ts
selectTableCell(): void

Remarks

javascript
richEdit.selection.selectTableCell();

selectTableRow Method

Selects the table row in which the cursor is located.

Declaration

ts
selectTableRow(): void

Remarks

javascript
richEdit.selection.selectTableRow();

setSelection(position) Method

Selects the specified interval(s).

Declaration

ts
setSelection(
    position: number | IInterval | IInterval[]
): void

Parameters

NameTypeDescription
positionnumberIInterval

The interval(s) or position to select.

|

Remarks

javascript
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
var templateText = '[Type your text here]';

richEdit.beginUpdate();
richEdit.history.beginTransaction();

position = subDocument.insertParagraph(position).interval.end;
position = subDocument.insertParagraph(position).interval.end;
position = subDocument.insertText(position, 'Dear Mr Stanley,').end;
position = subDocument.insertParagraph(position).interval.end;
var tmpTextInterval = subDocument.insertText(position, templateText);
position = tmpTextInterval.end;
position = subDocument.insertParagraph(position).interval.end;

richEdit.endUpdate();
richEdit.history.endTransaction();

richEdit.selection.setSelection(tmpTextInterval);
richEdit.focus();

See Also

Selection