---
title: "tinymce.dom.RangeUtils"
description: "This class contains a few utility methods for ranges."
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.dom.rangeutils/"
md_url: "https://www.tiny.cloud/docs/tinymce/6/apis/tinymce.dom.rangeutils/index.md"
version: "6"
last_updated: "2022-12-19T04:27:52Z"
tokens: 457
---
Important This page documents TinyMCE 6. For new projects, Tiny recommends using the latest, most up-to-date version. [See TinyMCE 8 documentation](../../../latest/apis/tinymce.dom.rangeutils/).
# tinymce.dom.RangeUtils

This class contains a few utility methods for ranges.

## Summary

### Methods

| Name | Summary | Defined by |
| --- | --- | --- |
| [compareRanges()](#compareRanges) | Compares two ranges and checks if they are equal. | `RangeUtils` |
| [expand()](#expand) | Returns a range expanded around the entire word the provided selection was collapsed within. | `RangeUtils` |
| [getCaretRangeFromPoint()](#getCaretRangeFromPoint) | Gets the caret range for the given x/y location. | `RangeUtils` |

## Methods

### compareRanges()

```javascript
compareRanges(rng1: RangeObject, rng2: RangeObject): Boolean
```
Compares two ranges and checks if they are equal.

#### Parameters

- `rng1 (RangeObject)` - First range to compare.
- `rng2 (RangeObject)` - First range to compare.

#### Return value

- `Boolean` - True or false if the ranges are equal.

### expand()

```javascript
expand(rng: Range, options: Object): Range
```
Returns a range expanded around the entire word the provided selection was collapsed within.

#### Parameters

- `rng (Range)` - The initial range to work from.
- `options (Object)` - Optional options provided to the expansion. Defaults to { type: 'word' }

#### Return value

- `Range` - Returns the expanded range.

### getCaretRangeFromPoint()

```javascript
getCaretRangeFromPoint(clientX: Number, clientY: Number, doc: Document): Range
```
Gets the caret range for the given x/y location.

#### Parameters

- `clientX (Number)` - X coordinate for range
- `clientY (Number)` - Y coordinate for range
- `doc (Document)` - Document that the x and y coordinates are relative to

#### Return value

- `Range` - Caret range
