# Custom insertText event

Here is an example of using **customInsertText** event for managing the insert text mechanism flexibly.

```javascript
var container = document.querySelector('.container'); // Get the main editable container.

container.addEventListener('customInsertText', function(event) {
    // Call 'preventDefault' to prevent WProofreader from replacing text.
    // After that the text replacent mechanism can be handled manually.
    event.preventDefault();

    // Obtain text for replacing from 'detail' field of the 'event' object.
    var text = event.detail.text;

    // Get the selection for the text insertion.
    // The text that is to be replaced are already in the browser Selection.
    var selection = window.getSelection();

    // Keep the error highlighting if needed.
    event.keepHighlight = true;
});

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wproofreader.com/v6.12.0/integrations/how-tos/custom-inserttext-event.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
