Templater: open file in new tab and append to end of file

Looking at the solutions from @AlanG and @gino_m, I am curious whether a modified version of this script could be used to accomplish what these threads are looking for:

Essentially, the goal would be to take the text that is selected in the current source note, cut it, prompt the user for a destination note, then prompt the user for a heading name. Upon entering the heading name, the script would create a heading based on the entered heading name at the end of the destination note, and paste the selected(cut) text within the heading. In place of the selected text in the source note would be an embed to the heading added to the destination note.

This method is just how I imagine it. But anything that could accomplish this type of thing would be amazing. For example, maybe it would be easier if the user was required to have already cut the selection before triggering the script.

Here’s a relevant feature request: Extract to specified heading with Note Composer

Thanks!