'How to convert markdown to HTML automatically in TinyMCE after copy and paste?

In the text editor, when the content with syntax is pasted, the conversion from markdown to HTML doesn't occur automatically. Instead, the enter key should be hit for each line before conversion.

For example, when I copy the text shown below and paste it to the TinyMCE text editor. Nothing really happens. I have to go through each line of text and hit enter to trigger the conversion.

What's shown in text editor:

# Middleware

# Fundamentals

## Basis

What I expect to see in text editor:

Middleware

Fundamentals

Basis

Setup

 tinymce.init({
        selector: '#summary',
        resize:false,
        branding: false,
        removed_menuitems: 'print',
        plugins:'wordcount autosave quickbars link textpattern',
        textpattern_patterns:[
          {start: '*', end: '*', format: 'italic'},
          {start: '**', end: '**', format: 'bold'},
          {start: '#', format: 'h1'},
          {start: '##', format: 'h2'},
          {start: '###', format: 'h3'},
          {start: '####', format: 'h4'},
          {start: '#####', format: 'h5'},
          {start: '######', format: 'h6'},
          {start: '1. ', cmd: 'InsertOrderedList'},
          {start: '* ', cmd: 'InsertUnorderedList'},
          {start: '- ', cmd: 'InsertUnorderedList'},
          {start: '//brb', replacement: 'Be Right Back'}
        ],
        toolbar: "undo redo | blocks | bold italic |alignleft aligncenter alignright alignjustify | indent outdent |import"
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source