How to make the widget store the value of a hidden field?

There is a requirement, after selecting a field, let it be displayed in the editor as a dom element. I have implemented this function with setbookmark, but I don’t know where to store the value of this field, because the name of the field is displayed. And there are quite a lot of such fields, all of which need to be done, but I don’t know what a good way is right now. Guys, please help me, thank you.
Below is the prototype


I also found two problems, that is, when the bookmark starts from the first character of the first line, it cannot be deleted by pressing the backspace key, and when multiple bookmarks are inserted continuously from other places, all the bookmarks will be deleted by pressing the backspace key, but I just want to To delete the one closest to the cursor, what should I do?


Maybe you can try the slatejs