aspnetcore-js-devexpress-dot-richedit-e6e203ea.md
A collection of RangePermission objects.
export class RangePermissionCollection extends Collection<RangePermission>
Range permissions are in effect when a document is protected. To protect a document, use the protect(password) method.
Collection<T> RangePermissionCollection
Creates a range permission that allows a user/group to edit the specified interval.
create(
interval: IInterval,
userName?: string,
group?: string
): RangePermission
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
An object that specifies the permitted range.
| | userName | string |
The name of the user with edit permission.
| | group | string |
The name of the user group with edit permission.
|
| Type | Description |
|---|---|
| RangePermission |
The newly created range permission.
|
richEdit.document.rangePermissions.create({ start: 0, length: richEdit.document.paragraphs.getByIndex(5).interval.end}, '[email protected]');
richEdit.document.rangePermissions.create(richEdit.document.paragraphs.getByIndex(6).interval, '', 'editors');
richEdit.document.rangePermissions.create(richEdit.document.interval, '[email protected]');
richEdit.document.rangePermissions.create(richEdit.document.interval, '', 'owners');
Use the everyone predefined group to allow every user to edit the specified range.
richEdit.document.rangePermissions.create(richEdit.document.paragraphs.getByIndex(10).interval, '', 'everyone');
// or
richEdit.document.rangePermissions.create(richEdit.document.paragraphs.getByIndex(10).interval);
Refer to the following help topic for more information: Document Protection.
Returns a range permission array that matches the specified options.
find(
options: IRangePermissionSearchOptions
): RangePermission[]
| Name | Type | Description |
|---|---|---|
| options | IRangePermissionSearchOptions |
An object that specifies range permission options.
|
| Type | Description |
|---|---|
| RangePermission[] |
An array of range permissions.
|
var everyoneRangePermissions = richEdit.document.rangePermissions.find({group: 'everyone'});
Indicates whether the specified range can be edited.
isAllowEdit(
position: number | IInterval | IInterval[]
): boolean
| Name | Type | Description |
|---|---|---|
| position | number | IInterval |
A document position, an interval, or an array of intervals.
|
| Type | Description |
|---|---|
| boolean |
true , if the specified range can be edited; false if the specified range is protected or contains protected intervals.
|
richEdit.document.rangePermissions.isAllowEdit(richEdit.selection.active);
richEdit.document.rangePermissions.isAllowEdit(richEdit.document.paragraphs.getByIndex(4).interval);
Creates range permissions that protect the specified interval from being edited.
protectRange(
intervals: IInterval[],
userName?: string,
group?: string
): RangePermission[]
| Name | Type | Description |
|---|---|---|
| intervals | IInterval[] |
An object that specifies the protected range.
| | userName | string |
The name of the user who is prohibited from editing the range.
| | group | string |
The name of the user group that is prohibited from editing the range.
|
| Type | Description |
|---|---|
| RangePermission[] |
An array of newly created range permissions.
|
The protectRange method creates range permissions (objects of the RangePermission type) that prevent the specified document range from being edited. You can specify the user or a group of users who are prohibited from editing the range.
Call the protect(password) method to enable document protection.
A RangePermission object specifies a permissions rule. When you call the protectRange method, RichEdit creates range permissions that allow a user/group to edit a document outside of the specified range.
richEdit.document.rangePermissions.protectRange([{ start: 10, length: 20}]);
// equals
richEdit.document.rangePermissions.create({ start: 0, length: 10});
richEdit.document.rangePermissions.create({ start: 30, length: richEdit.document.interval.end});
To protect multiple ranges, call the protectRange method once with an array of protected intervals as a parameter. Otherwise, if you call the method several times for one user/group, the allowed intervals can overlap and the range permissions do not work.
// protects fields from being edited
var protectedRanges = [];
var count = document.fields.count;
for (var i = 0; i < count; i++) {
var field = document.fields.getByIndex(i);
protectedRanges.push(field.interval);
}
document.rangePermissions.protectRange(protectedRanges);
richEdit.document.rangePermissions.protectRange([{ start: 0, length: 178}, { start: 325, length: 561}], '[email protected]');
richEdit.document.rangePermissions.protectRange([richEdit.document.paragraphs.getByIndex(6).interval], '', 'editors');
Use the everyone predefined group to prevent every user from editing the specified range.
richEdit.document.rangePermissions.protectRange([richEdit.document.paragraphs.getByIndex(10).interval], '', 'everyone');
// or
richEdit.document.rangePermissions.protectRange([richEdit.document.paragraphs.getByIndex(10).interval]);
Refer to the following help topic for more information: Document Protection.