Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui-buttongroup: html option labels #1567

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/nodes/widgets/ui-button-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ props:
Appearance: Specify whether the shape of the widget should be rectangular or have rounded corners.
Use theme colors: Specify whether the theme colors should be used. If not active, custom colors can be specified for each option separately.
Options:
description: Specify which options need to be displayed. Each option can specify a label, icon, value and color.
description: Specify which options need to be displayed. Each option can specify a label, icon, value and color. Html content is allowed for the labels.
dynamic: true
Topic: The text that needs to be send in the msg.topic field.
Passthrough: Specify whether input messages should be passed through as output messages.
Expand Down
2 changes: 1 addition & 1 deletion nodes/widgets/locales/en-US/ui_button_group.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h3>Properties</h3>
<p><strong>Options:</strong><br/>
Specify which options need to be displayed:
<ul>
<li><i>Label: </i>(optional) The description that will be displayed.</li>
<li><i>Label: </i>(optional) The description that will be displayed. Html content is allowed</li>
<li><i>Icon: </i>(optional) The icon to display for the given option. We use the Material Design Icons, you can see a full list of the available icons <a href="https://pictogrammers.com/library/mdi/">here</a>. There is no need to include the "mdi-" prefix, just the name of the icon.</li>
<li><i>Value: </i>The value that will be send in input and output messages.</li>
<li><i>Color: </i>The color of the option in the switch.</li>
Expand Down
6 changes: 4 additions & 2 deletions ui/src/widgets/ui-button-group/UIButtonGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<v-icon size="x-large" :icon="`mdi-${option.icon.replace(/^mdi-/, '')}`" />
</template>
<v-icon v-if="option.icon && !option.label" :icon="`mdi-${option.icon.replace(/^mdi-/, '')}`" size="x-large" />
{{ option.label }}
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="option.label" />
</v-btn>
</v-btn-toggle>
</div>
Expand Down Expand Up @@ -47,8 +48,9 @@ export default {
if (options) {
return options.map(option => {
if (typeof option === 'string') {
return { label: option, value: option }
return { label: DOMPurify.sanitize(option), value: option }
} else {
option.label = DOMPurify.sanitize(option.label)
return option
}
})
Expand Down
Loading