This is a good use case for the JS version of the editor introduced in 4.8: https://make.wordpress.org/core/2017/05/20/editor-api-changes-in-4-8/
A new editor API was added in #35760. It makes it possible to
dynamically instantiate the editor from JS.
Here’s an example of how it’s used (stolen from Rheinard Korf’s example here):
// Remember to wp_enqueue_editor(); inside PHP.
// Add editor
wp.editor.initialize(
'test-editor',
{
tinymce: {
wpautop:true,
plugins : 'charmap colorpicker compat3x directionality fullscreen hr image lists media paste tabfocus textcolor wordpress wpautoresize wpdialogs wpeditimage wpemoji wpgallery wplink wptextpattern wpview',
toolbar1: 'formatselect bold italic | bullist numlist | blockquote | alignleft aligncenter alignright | link unlink | wp_more | spellchecker'
},
quicktags: true
}
);
Where test-editor
would be the ID of the textarea
you want to make an editor.