I do this for emails
I use unlayer for the drag and drop email builder but you can do something similar with text editor and just plain text.
I’d save the input when the variable is selected in the dropdown, then append it to the end of the input
not sure if you’ll be able to insert it at a specific location in the input - a way to do this would be to copy it to the clipboard and then the user could paste it at the cursor in the text.
to replace the variables with actual data I run a backend workflow that does a bunch of regex to find and replace the variables with data. toolbox plugin is the best here since it can be done in 1 step instead of 1 step per variable (although that is also a valid way to do it - just higher wu)