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


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 : https://github.com/JetBrains/kotlin-wrappers/blob/master/examples/src/main/kotlin/example/Quill.kt