aspnetcore-js-devexpress-dot-richedit-eba4eb98.md
Defines a document in the Rich Text Editor.
export class RichEditDocumentBase
RichEditDocumentBase RichEditDocument
Provide access to the document’s collection of bookmarks.
get bookmarks(): BookmarkCollection<Bookmark>
| Type | Description |
|---|---|
| BookmarkCollection<Bookmark> |
A collection of bookmarks.
|
Provides access to the document’s collection of fields.
get fields(): FieldCollection
| Type | Description |
|---|---|
| FieldCollection |
A collection of fields.
|
var doInAllSubDocuments = true;
var updateTocFields = true;
var options = new DevExpress.RichEdit.UpdateFieldsOptions(doInAllSubDocuments, updateTocFields);
richEdit.document.fields.updateAllFields(function() {
console.log('Updated');
}, options);
Provide access to the document’s collection of fonts.
get fonts(): FontCollection
| Type | Description |
|---|---|
| FontCollection |
A collection of fonts.
|
Use this property to access the fonts available in the document.
//reduces the document's font collection to the specified fonts
var myFonts = ['Arial', 'Calibri'];
richEdit.document.fonts.getAllFontNames().forEach(fontName =>
myFonts.find(myFontName =>
myFontName == fontName) ? null : richEdit.document.fonts.getByName(fontName).delete());
Provides access to the document’s collection of hyperlinks.
get hyperlinks(): HyperlinkCollection
| Type | Description |
|---|---|
| HyperlinkCollection |
A collection of hyperlinks.
|
var text = "Visit our site";
var url = "https://www.devexpress.com/";
var tooltip = "DevExpress site";
richEdit.beginUpdate();
richEdit.history.beginTransaction();
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
position = subDocument.insertParagraph(position).interval.end;
position = subDocument.hyperlinks.create(position, new DevExpress.RichEdit.HyperlinkInfo(text, url, "", tooltip)).interval.end;
subDocument.insertParagraph(position);
richEdit.endUpdate();
richEdit.history.endTransaction();
Gets the text buffer interval that contains the document.
get interval(): Interval
| Type | Description |
|---|---|
| Interval |
The text buffer interval.
|
Indicates whether the document is protected.
get isProtected(): boolean
| Type | Description |
|---|---|
| boolean |
true if the document is protected; otherwise, false.
|
function ProtectDocument() {
if (!richEdit.document.isProtected) {
const password = window.prompt('enter new password(optional):', '');
if (password != undefined && password != null)
richEdit.document.protect(password);
}
}
function UnprotectDocument() {
const password = window.prompt('enter password:', '');
if (password != undefined && password != null) {
if (richEdit.document.checkProtectionPassword(password))
richEdit.document.unprotect();
else
window.alert('The password incorrect!');
}
}
Refer to the following help topic for more information: Document Protection.
Gets the character length of the document.
get length(): number
| Type | Description |
|---|---|
| number |
The number of character positions in the sub-document.
|
var subDocument = richEdit.document.subDocuments.main;
subDocument.insertText(subDocument.length - 1, 'text');
// or
richEdit.document.insertText(richEdit.document.length - 1, 'text');
See Also
Provide access to the document’s collection of lists.
get lists(): ListCollection
| Type | Description |
|---|---|
| ListCollection |
A collection of lists.
|
Provide access to the document’s collection of paragraphs.
get paragraphs(): ParagraphCollection
| Type | Description |
|---|---|
| ParagraphCollection |
A collection of paragraphs.
|
Provides access to the document’s collection of range permissions.
get rangePermissions(): RangePermissionCollection
| Type | Description |
|---|---|
| RangePermissionCollection |
A collection of range permissions.
|
Refer to the following help topic for more information: Document Protection.
Provide access to the document’s collection of sections.
get sections(): SectionCollection
| Type | Description |
|---|---|
| SectionCollection |
A collection of sections.
|
var createHeaderIfNotExist = true;
var section = richEdit.document.sections.getByIndex(0);
var subDocument = section.getHeader(DevExpress.RichEdit.HeaderFooterType.Primary, createHeaderIfNotExist);
var position = 0;
subDocument.insertText(position, 'text');
See Also
Provide access to the document’s collection of sub-documents.
get subDocuments(): SubDocumentCollection<SubDocument>
| Type | Description |
|---|---|
| SubDocumentCollection<SubDocument> |
A collection of sub-documents.
|
See Also
Provide access to the document’s collection of tables.
get tables(): TableCollection
| Type | Description |
|---|---|
| TableCollection |
A collection of tables.
|
var columnCount = 5;
var rowCount = 5;
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
var table = subDocument.tables.create(position, columnCount, rowCount);
Checks whether the specified password was used to protect the document.
checkProtectionPassword(
password: string
): boolean
| Name | Type | Description |
|---|---|---|
| password | string |
The password to check.
|
| Type | Description |
|---|---|
| boolean |
true , if the document is protected with the specified password; otherwise, false.
|
The protect(password) method allows you to protect a document with a password. To check whether a password was used to protect the document, use the checkProtectionPassword method.
function ProtectDocument() {
if (!richEdit.document.isProtected) {
const password = window.prompt('enter new password(optional):', '');
if (password != undefined && password != null)
richEdit.document.protect(password);
}
}
function UnprotectDocument() {
const password = window.prompt('enter password:', '');
if (password != undefined && password != null) {
if (richEdit.document.checkProtectionPassword(password))
richEdit.document.unprotect();
else
window.alert('The password incorrect!');
}
}
Refer to the following help topic for more information: Document Protection.
Deletes the specified text interval.
deleteText(
interval: IInterval
): void
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
The text interval to delete.
|
richEdit.document.deleteText(new DevExpress.RichEdit.Interval(0, 5));
Returns character properties of the specified text interval.
getCharacterProperties(
interval: IInterval
): CharacterProperties
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
An object that contains information about a text interval.
|
| Type | Description |
|---|---|
| CharacterProperties |
An object that contains the character properties.
|
Gets the document’s default character properties.
getDefaultCharacterProperties(): CharacterProperties
| Type | Description |
|---|---|
| CharacterProperties |
An object that contains the character properties.
|
const charProps = richEdit.document.getDefaultCharacterProperties();
charProps.fontName = "Segoe UI";
richEdit.document.setDefaultCharacterProperties(charProps);
Returns paragraph properties of the specified text interval.
getParagraphProperties(
interval: IInterval
): ParagraphProperties
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
An object that contains information about a text interval.
|
| Type | Description |
|---|---|
| ParagraphProperties |
An object that contains the paragraph properties.
|
Return the document’s textual representation contained in the specified interval.
getText(
interval?: Interval
): string
| Name | Type | Description |
|---|---|---|
| interval | Interval |
A document interval.
|
| Type | Description |
|---|---|
| string |
The text contained in the specified interval.
|
var mainSubDocumentText = richEdit.document.getText();
See Also
Inserts the column break at the specified position in the main sub-document.
insertColumnBreak(
position: number
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
The position in the main sub-document.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted column break.
|
Inserts the line break at the specified position in the document.
insertLineBreak(
position: number
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
A position in the document.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted line break.
|
Inserts the page break at the specified position in the main sub-document.
insertPageBreak(
position: number
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
The position in the main sub-document.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted page break.
|
Inserts a paragraph mark to the specified position.
insertParagraph(
position: number
): Paragraph
| Name | Type | Description |
|---|---|---|
| position | number |
The position in the document.
|
| Type | Description |
|---|---|
| Paragraph |
The newly created paragraph.
|
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();
Inserts a picture to the document.
insertPicture(
position: number,
base64: string,
size?: Size,
callback?: (interval: Interval) => void
): void
| Name | Type | Description |
|---|---|---|
| position | number |
A position in the document.
| | base64 | string |
The picture in string representation that is encoded with base-64 digits.
| | size | Size |
The image size.
| | callback | (interval: Interval) => void |
A function that is called after the picture is inserted.
|
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
var image = "your-image-URL"; // base64 or url
var width = richEdit.unitConverter.pixelsToTwips(100);
var height = richEdit.unitConverter.pixelsToTwips(100);
var size = new DevExpress.RichEdit.Size(width, height);
subDocument.insertPicture(position, image, size, function(interval) { console.log("Picture loaded"); });
Inserts the section break at the specified position in the document.
insertSectionBreak(
position: number,
type: SectionBreakType
): Section
| Name | Type | Description |
|---|---|---|
| position | number |
A position in the document.
| | type | SectionBreakType |
The type of a section break.
|
| Type | Description |
|---|---|
| Section |
The newly created section
|
Inserts the specified text at the specified position.
insertText(
position: number,
text: string
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
A position to insert the text.
| | text | string |
The text to insert.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted text.
|
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
subDocument.insertText(position, 'text');
var subDocument = richEdit.selection.activeSubDocument;
var position = subDocument.length - 1;
subDocument.insertText(position, 'text');
var createHeaderIfNotExist = true;
var section = richEdit.document.sections.getByIndex(0);
var subDocument = section.getHeader(DevExpress.RichEdit.HeaderFooterType.Primary, createHeaderIfNotExist);
var position = 0;
subDocument.insertText(position, 'text');
Protects the document with the specified password.
protect(
password: string
): void
| Name | Type | Description |
|---|---|---|
| password | string |
The password.
|
Use the checkProtectionPassword(password) and unprotect methods to authenticate the password and unprotect the document.
function ProtectDocument() {
if (!richEdit.document.isProtected) {
const password = window.prompt('enter new password(optional):', '');
if (password != undefined && password != null)
richEdit.document.protect(password);
}
}
function UnprotectDocument() {
const password = window.prompt('enter password:', '');
if (password != undefined && password != null) {
if (richEdit.document.checkProtectionPassword(password))
richEdit.document.unprotect();
else
window.alert('The password incorrect!');
}
}
Refer to the following help topic for more information: Document Protection.
Applies character properties to a text interval.
setCharacterProperties(
interval: IInterval,
characterProperties: ICharacterProperties
): void
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
An object that contains information about a text interval.
| | characterProperties | ICharacterProperties |
A CharacterProperties object that implements the ICharacterProperties interface and contains character properties.
|
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
var characterProperties = {
bold: true,
fontName: richEdit.document.fonts.getByIndex(0).name,
highlightColor: "ffff00",
};
richEdit.history.beginTransaction();
richEdit.beginUpdate();
var interval = subDocument.insertText(position, "text");
subDocument.setCharacterProperties(interval, characterProperties);
richEdit.endUpdate();
richEdit.history.endTransaction();
Sets the document’s default character properties.
setDefaultCharacterProperties(
characterProperties: ICharacterProperties
): void
| Name | Type | Description |
|---|---|---|
| characterProperties | ICharacterProperties |
A CharacterProperties object that implements the ICharacterProperties interface and contains character properties.
|
const charProps = richEdit.document.getDefaultCharacterProperties();
charProps.fontName = "Segoe UI";
richEdit.document.setDefaultCharacterProperties(charProps);
Applies paragraph properties to a text interval.
setParagraphProperties(
interval: IInterval,
paragraphProperties: IParagraphProperties
): void
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
An object that contains information about a text interval.
| | paragraphProperties | IParagraphProperties |
A ParagraphProperties object that implements the IParagraphProperties interface and contains paragraph properties.
|
Unprotects the document.
unprotect(): void
function ProtectDocument() {
if (!richEdit.document.isProtected) {
const password = window.prompt('enter new password(optional):', '');
if (password != undefined && password != null)
richEdit.document.protect(password);
}
}
function UnprotectDocument() {
const password = window.prompt('enter password:', '');
if (password != undefined && password != null) {
if (richEdit.document.checkProtectionPassword(password))
richEdit.document.unprotect();
else
window.alert('The password incorrect!');
}
}
Refer to the following help topic for more information: Document Protection.