N00ts/vue3-treeview

Feature request: HTML parsing a node

GoProduction opened this issue · 2 comments

Hey there! I love this tree-view package you've created! It's sophisticated, yet very simple to use.

An idea that crossed my mind is the ability to enable HTML parsing within a node. You could create a config property that could be set to true, such as: parseHTML: true , and then inside of the TreeNode.vue component, you could use v-html conditionally based on the config value. Something like this could work:

<div v-else class="node-text"
     @dblclick="focusInput">
     <span v-if="parseHTML" v-html="text"></span>
     <span v-else>{{ text }}</span>
</div>
N00ts commented

Hey thank you for considering my component. I'm completely open to enhancements. What do you exactly have in mind ? What is your usecase ?
I think you can do it in "slots" (before - after), be carefull to xss attacks !

Ah, yes that actually is perfect for my use case, thank you!

For context, the tree-view will be used as a Table of Contents for a document editor. When the editor is loaded, an imported word document is converted into a readable JSON file, where the sections are loaded into the tree view. We essentially needed to separate the section number and title to format them differently. XSS attacks wouldn't be an issue since the user has no control over the content being imported.

However, since you have implemented named slots before and after the node text, it allows me to do just that. Thanks a lot for your help!