# Rich Text / Redactor Editor API access

**URL:** <https://forums.knack.com/t/rich-text-redactor-editor-api-access/8347>\
**Category:** API & Custom Code\
**Created:** [September 13, 2020, 12:46am UTC](https://forums.knack.com/t/rich-text-redactor-editor-api-access/8347 "2020-09-13T00:46:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BradStevens](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/bradstevens/32/140_2.png) [@BradStevens](https://forums.knack.com/u/BradStevens)\
**Post date:** [September 13, 2020, 12:46am UTC](https://forums.knack.com/t/rich-text-redactor-editor-api-access/8347/1 "2020-09-13T00:46:42Z")

</div>

With a large project that revolves around extensive Rich Text, we needed Javascript access to the Redactor control that Knack uses for rich text fields.&nbsp; After lots of research and hacking attempts this might be a starting point for others.

**To gain access to the core redactor object**

```
var redactor = $('field_XX').redactor('core.getObject')
```

In testing using any other selector than the field resulted in the control being duplicated.

**Examples**

```
redactor.insert.html(htmlstring)    //Inserts html at the selection
redactor.focus.setEnd()
redactor.selection.save()
redactor.selection.restore()  //handy if a modal form causes the control to lose focus and default to the start.
```

**More documentation**

See [https://imperavi.com/assets/pdf/redactor-documentation-10.pdf](https://imperavi.com/assets/pdf/redactor-documentation-10.pdf)

Cheers

---

<div class="post-metadata">

**Author:** ![BradStevens](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/bradstevens/32/140_2.png) [@BradStevens](https://forums.knack.com/u/BradStevens)\
**Post date:** [September 21, 2020, 10:17am UTC](https://forums.knack.com/t/rich-text-redactor-editor-api-access/8347/2 "2020-09-21T10:17:04Z")

</div>

Hey Taylor,

I can outline our use case briefly - built a helpdesk with major reliance on Rich Text fields and needed a way to insert images and files stored in Knack, therefore needing access to the redactor control for direct control of html inserts.

---

<div class="post-metadata">

**Author:** ![Taylor\_KnackPlugins](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/taylor_knackplugins/32/4462_2.png) [@Taylor\_KnackPlugins](https://forums.knack.com/u/Taylor_KnackPlugins)\
**Post date:** [September 18, 2020, 3:42am UTC](https://forums.knack.com/t/rich-text-redactor-editor-api-access/8347/3 "2020-09-18T03:42:18Z")

</div>

Hey Brad,&nbsp;

Could you provide some example use cases of where and how you used applied this?&nbsp;
