aspnetcore-js-devexpress-dot-richedit-5073e3e4.md
Contains a set of methods and properties to work with the document selection.
export class RichEditSelection
An instance of the RichEditSelection object can be accessed by the selection property.
Gets a cursor position.
get active(): number
| Type | Description |
|---|---|
| number |
The active selection position (the cursor position).
|
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.
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
subDocument.insertText(position, 'text');
See Also
Returns the active sub-document.
get activeSubDocument(): SubDocumentBase
| Type | Description |
|---|---|
| SubDocumentBase |
The active sub-document.
|
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
subDocument.insertText(position, 'text');
See Also
Gets a position where a user starts the last selection.
get anchor(): number
| Type | Description |
|---|---|
| number |
The position of the selection anchor.
|
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.
Gets the end position of the last selected interval.
get end(): number
| Type | Description |
|---|---|
| number |
The end position.
|
Gets an array of document intervals in the selection.
get intervals(): Interval[]
| Type | Description |
|---|---|
| Interval[] |
An array of Interval objects.
|
See Also
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.
get showCursorAtEndOfLine(): boolean
set showCursorAtEndOfLine(value: boolean)
| Type | Description |
|---|---|
| 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.
|
Gets the start position of the last selected interval.
get start(): number
| Type | Description |
|---|---|
| number |
The start position.
|
Moves the cursor to the end of the active sub-document and allows you to extend the selection.
goToDocumentEnd(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
// 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');
Moves the cursor to the start of the active sub-document and allows you to extend the selection.
goToDocumentStart(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
// 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');
Moves the cursor to the end of the line and allows you to extend the selection.
goToLineEnd(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
richEdit.selection.goToLineEnd(true);
Moves the cursor to the start of the line and allows you to extend the selection.
goToLineStart(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
richEdit.selection.goToLineStart(true);
Moves the cursor to the next character and allows you to extend the selection.
goToNextCharacter(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
richEdit.selection.goToNextCharacter(true);
Moves the cursor to the next line and allows you to extend the selection.
goToNextLine(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
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.
// Moves the cursor to the start of the next line
richEdit.selection.goToNextLine(false);
richEdit.selection.goToLineStart(false);
Moves the cursor to the next page and allows you to extend the selection.
goToNextPage(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
Moves the cursor one page down. If the current page is the last one, moves the cursor to the end of the current page.
richEdit.selection.goToNextPage(true);
Moves the cursor to the start of the next page and allows you to extend the selection.
goToNextPageStart(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
richEdit.selection.goToNextPageStart(true);
Moves the cursor to the next word and allows you to extend the selection.
goToNextWord(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
This method treats most punctuation marks as separate words.
richEdit.selection.goToNextWord(true);
Moves the cursor to the end of the paragraph and allows you to extend the selection.
goToParagraphEnd(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
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.
richEdit.selection.goToParagraphEnd(true);
Moves the cursor to the start of the paragraph and allows you to extend the selection.
goToParagraphStart(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
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.
richEdit.selection.goToParagraphStart(true);
Moves the cursor to the previous character and allows you to extend the selection.
goToPreviousCharacter(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
richEdit.selection.goToPreviousCharacter(true);
Moves the cursor to the previous line and allows you to extend the selection.
goToPreviousLine(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
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.
// Moves the cursor to the start of the previous line
richEdit.selection.goToPreviousLine(false);
richEdit.selection.goToLineStart(false);
Moves the cursor to the previous page and allows you to extend the selection.
goToPreviousPage(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
Moves the cursor one page up. If the current page is the first one, moves the cursor to the start of the current page.
richEdit.selection.goToPreviousPage(true);
Moves the cursor to the start of the previous page and allows you to extend the selection.
goToPreviousPageStart(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
richEdit.selection.goToPreviousPageStart(true);
Moves the cursor to the previous word and allows you to extend the selection.
goToPreviousWord(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
This method treats most punctuation marks as separate words.
richEdit.selection.goToPreviousWord(true);
Moves the cursor to the end of the sub-document and allows you to extend the selection.
goToSubDocumentEnd(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true , to extend the selection; otherwise, false.
|
richEdit.selection.goToSubDocumentEnd();
Selects the current sub-document’s entire content.
selectAll(): void
richEdit.selection.selectAll();
See Also
Selects the line in which the cursor is located and allows you to extend the selection.
selectLine(
extendSelection?: boolean
): void
| Name | Type | Description |
|---|---|---|
| extendSelection | boolean |
true to extend the selection; otherwise, false.
|
When the end of the current line is already selected, the method selects the next line.
// Selects five lines
for(let i=0; i<5; i++)
richEdit.selection.selectLine(true);
Selects the paragraph in which the cursor is located.
selectParagraph(): void
richEdit.selection.selectParagraph();
Selects the entire table in which the cursor is located.
selectTable(): void
richEdit.selection.selectTable();
Selects the table cell in which the cursor is located.
selectTableCell(): void
richEdit.selection.selectTableCell();
Selects the table row in which the cursor is located.
selectTableRow(): void
richEdit.selection.selectTableRow();
Selects the specified interval(s).
setSelection(
position: number | IInterval | IInterval[]
): void
| Name | Type | Description |
|---|---|---|
| position | number | IInterval |
The interval(s) or position to select.
|
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