---
title: BETextDocumentContext
framework: browserenginekit
role: symbol
role_heading: Class
path: browserenginekit/betextdocumentcontext
---

# BETextDocumentContext

Information about the text surrounding a selection in a document.

## Declaration

```swift
class BETextDocumentContext
```

## Mentioned in

Integrating custom browser text views with UIKit

## Overview

Overview The BETextInput protocol’s requestDocumentContext(_:completionHandler:) and requestTextContextForAutocorrection(completionHandler:) methods provide an instance of this class to their completion handlers.

## Topics

### Creating a text document context

- [init(attributedSelectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:)](browserenginekit/betextdocumentcontext/init(attributedselectedtext:contextbefore:contextafter:markedtext:selectedrangeinmarkedtext:).md)
- [init(selectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:)](browserenginekit/betextdocumentcontext/init(selectedtext:contextbefore:contextafter:markedtext:selectedrangeinmarkedtext:).md)

### Accessing autocorrected ranges

- [autocorrectedRanges](browserenginekit/betextdocumentcontext/autocorrectedranges.md)

### Adding text rectangles

- [addTextRect(_:forCharacterRange:)](browserenginekit/betextdocumentcontext/addtextrect(_:forcharacterrange:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Replacements and AutoFill

- [BEAutoFillTextSuggestion](browserenginekit/beautofilltextsuggestion.md)
- [BETextAlternatives](browserenginekit/betextalternatives.md)
- [BETextDocumentRequest](browserenginekit/betextdocumentrequest.md)
- [BETextDocumentRequest.Options](browserenginekit/betextdocumentrequest/options-swift.struct.md)
- [BETextSuggestion](browserenginekit/betextsuggestion.md)
- [BETextReplacementOptions](browserenginekit/betextreplacementoptions.md)
