handleEvents() {
    this.formatOnNextChange = false

    // Change event triggers input validation
    this.editor.on('change', () => {
      this.validate()
      if (this.formatOnNextChange) {
        this.format()
        this.formatOnNextChange = false
      }
    })

    // Paste (Cmd / Cntrl + v) triggers input validation and auto-format
    this.editor.on('inputRead', (cm, e) => {
      if (e.origin === 'paste') {
        const pasted = e.text[0]

        // If pasted text looks like url, try to download it
        if (isUrl(pasted)) {
          superagent.get(pasted).end((err, res) => {
            if (!err && res.body) {
              this.formatOnNextChange = true
              this.editor.setValue(JSON.stringify(res.body))
            }
          })
        } else {

          // Validate and format the input
          this.validate()
          this.format()
        }
      }
    })

    // File drop event (editor's value has not been changed yet)
    this.editor.on('drop', () => {
      this.formatOnNextChange = true
    })

    // Run the filter as the user types
    this.filter.on('keyup', () => {
      this.runFilter()
    })
  }
Respond to editor and filter input