# Pimp my kotlin js. Help me rewrite this block to be more kotliny!

**URL:** <https://discuss.kotlinlang.org/t/pimp-my-kotlin-js-help-me-rewrite-this-block-to-be-more-kotliny/11305>\
**Category:** JavaScript\
**Created:** [January 24, 2019, 4:49pm UTC](https://discuss.kotlinlang.org/t/pimp-my-kotlin-js-help-me-rewrite-this-block-to-be-more-kotliny/11305 "2019-01-24T16:49:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![huggy](https://avatars.discourse-cdn.com/v4/letter/h/ed8c4c/32.png) [@huggy](https://discuss.kotlinlang.org/u/huggy)\
**Post date:** [January 24, 2019, 4:49pm UTC](https://discuss.kotlinlang.org/t/pimp-my-kotlin-js-help-me-rewrite-this-block-to-be-more-kotliny/11305/1 "2019-01-24T16:49:06Z")

</div>

Love writing my react in Kotlin. I am really struggling with creating js objects though so i have been cheating using the js() call…

Using the quill example i would like to get this replace the js() call with the Kotlin js equivalent.

```
reactQuill {
    attrs {
        value = state.text
        onChange = { handleChange(it) }
        modules = js("({'toolbar':[['bold', 'italic'],[{ 'header': 1 }, { 'header': 2 }], ['link', 'image']]})")
    }
}

```

How would i write something as complex as the following in kotlin JS

```
var toolbarOptions = {
  handlers: {
    // handlers object will be merged with default handlers object
    'link': function(value) {
      if (value) {
        var href = prompt('Enter the URL');
        this.quill.format('link', href);
      } else {
        this.quill.format('link', false);
      }
    }
  }
}

```

Ty in advance! Also are there any good articles on how to write custom wrappers for existing libraries like these : [kotlin-wrappers/Quill.kt at master · JetBrains/kotlin-wrappers · GitHub](https://github.com/JetBrains/kotlin-wrappers/blob/master/examples/src/main/kotlin/example/Quill.kt)
