As you can see, this data entry has a boolean flag, which should indicate if this is the first data or not, if true, then I want to wrap the title in h1, else (false) wrap into h2.
This is a really cool question. I’m glad to see a great usecase for symbols and input! Plus, including the links and screenshots made understanding this question really easy, so thank you for that.
For the input of the title itself, you won’t need a rich text / HTML input. Setting this to a short text input will prevent your editors from accidentally pasting unwanted styles or tags.
When calling the text for the title, bind this to a Custom Code block, rather than a text box.
Finally, in the code itself, you want to return a string. You can reduce the binding code you wrote down to this single line:
Here is my recreation of this question in a Fiddle. The only difference is that I named the boolean data.isHero when creating the symbol. Styles are coming from the Data > Edit Content JS + CSS panel.
I hope this is helpful for you, and have a great weekend!