q-editor; insert markup at carat position, after losing focus



  • I had insert working well for some hardcoded markup, using code like the following:

      const caretRange = this.$refs['q-editor'].caret.range
      const imgMarkup = this.inlineImageMarkup(image.masterImage.publicUrl)
      const htmlFrag = caretRange.createContextualFragment(imgMarkup)
      caretRange.insertNode(htmlFrag)
      caretRange.collapse(false)
    

    Once I added an image select modal into the mix, I’d lose focus, and carat position. Though I can clone the carat info, I don’t see a way to set it & Vue complained when I tried.

    How can I insert markup in q-editor, at a specific position, after losing focus there?

    Thanks! 🙂