RangeElement

A wrapper around an `https://developers.google.com/apps-script/reference/document/element` with a possible start and end offset. These offsets allow a
range of characters within a `https://developers.google.com/apps-script/reference/document/text`
element to be represented in search results, document selections, and named ranges.

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/document/range-element#getElement()` | `https://developers.google.com/apps-script/reference/document/element` | Gets the `https://developers.google.com/apps-script/reference/document/element` that corresponds to this `RangeElement`. |
| `https://developers.google.com/apps-script/reference/document/range-element#getEndOffsetInclusive()` | `Integer` | Gets the position of the end of a partial range within the range element. |
| `https://developers.google.com/apps-script/reference/document/range-element#getStartOffset()` | `Integer` | Gets the position of the start of a partial range within the range element. |
| `https://developers.google.com/apps-script/reference/document/range-element#isPartial()` | `Boolean` | Determines whether this range element covers the entire element or a partial selection of the element's characters. |

## Detailed documentation

### `getElement()`

Gets the `https://developers.google.com/apps-script/reference/document/element` that corresponds to this `RangeElement`.

```javascript
const rangeElement = DocumentApp.getActiveDocument().getSelection().getRangeElements()[0];

// Log debug information about a range element.
Logger.log(`Element type: ${rangeElement.getElement().getType()}`);
if (rangeElement.isPartial()) {
  Logger.log(`The character range begins at ${rangeElement.getStartOffset()}`);
  Logger.log(
      `The character range ends at ${rangeElement.getEndOffsetInclusive()}`,
  );
} else {
  Logger.log('The entire range element is included.');
}
```

#### Return


`https://developers.google.com/apps-script/reference/document/element` --- the element that corresponds to this `RangeElement`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getEndOffsetInclusive()`

Gets the position of the end of a partial range within the range element. If the element is a
`https://developers.google.com/apps-script/reference/document/text` element and `https://developers.google.com/apps-script/reference/document/range-element#isPartial()` returns `true`, the offset is the number of characters before the last
character in the range (that is, the index of the last character in the range); in any other
case, this method returns `-1`.

#### Return


`Integer` --- for `https://developers.google.com/apps-script/reference/document/text` elements, the
number of character before the last character in the range; for other elements, `-1`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getStartOffset()`

Gets the position of the start of a partial range within the range element. If the element is a
`https://developers.google.com/apps-script/reference/document/text` element and `https://developers.google.com/apps-script/reference/document/range-element#isPartial()` returns `true`, the offset is the number of characters before the start of
the range (that is, the index of the first character in the range); in any other case, this
method returns `-1`.

#### Return


`Integer` --- for `https://developers.google.com/apps-script/reference/document/text` elements, the
number of characters before the start of the range; for other elements, `-1`

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `isPartial()`

Determines whether this range element covers the entire element or a partial selection of the
element's characters. The beginning and end of a partial range element's range can be
determined using `https://developers.google.com/apps-script/reference/document/range-element#getStartOffset()` and `https://developers.google.com/apps-script/reference/document/range-element#getEndOffsetInclusive()`, respectively.

#### Return


`Boolean` --- `true` if the element is partially included; `false` if not

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`