2022-01-27 22:55:25 -08:00
|
|
|
<template>
|
2022-10-12 05:06:28 -07:00
|
|
|
<n8n-text size="small" color="text-base" tag="div" v-if="hint">
|
2023-05-10 01:32:09 -07:00
|
|
|
<div v-if="!renderHTML" :class="classes"><span v-html="simplyText"></span></div>
|
2022-10-24 01:48:33 -07:00
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
ref="hint"
|
2023-02-26 22:25:57 -08:00
|
|
|
:class="{ [$style.singleline]: singleLine, [$style.highlight]: highlight }"
|
2022-10-24 01:48:33 -07:00
|
|
|
v-html="sanitizeHtml(hint)"
|
|
|
|
></div>
|
2022-10-12 05:06:28 -07:00
|
|
|
</n8n-text>
|
2022-01-27 22:55:25 -08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-04-21 08:51:08 -07:00
|
|
|
import { defineComponent } from 'vue';
|
2023-11-28 03:15:08 -08:00
|
|
|
import { sanitizeHtml } from '@/utils/htmlUtils';
|
2022-01-27 22:55:25 -08:00
|
|
|
|
2023-04-21 08:51:08 -07:00
|
|
|
export default defineComponent({
|
2022-01-27 22:55:25 -08:00
|
|
|
name: 'InputHint',
|
2022-10-12 05:06:28 -07:00
|
|
|
props: {
|
|
|
|
hint: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
highlight: {
|
|
|
|
type: Boolean,
|
|
|
|
},
|
2023-02-26 22:25:57 -08:00
|
|
|
singleLine: {
|
|
|
|
type: Boolean,
|
|
|
|
},
|
2022-10-24 01:48:33 -07:00
|
|
|
renderHTML: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
sanitizeHtml,
|
2022-10-12 05:06:28 -07:00
|
|
|
},
|
2023-05-03 00:41:40 -07:00
|
|
|
computed: {
|
|
|
|
classes() {
|
|
|
|
return {
|
|
|
|
[this.$style.singleline]: this.singleLine,
|
|
|
|
[this.$style.highlight]: this.highlight,
|
|
|
|
};
|
|
|
|
},
|
2023-05-10 01:32:09 -07:00
|
|
|
simplyText(): string {
|
|
|
|
if (this.hint) {
|
|
|
|
return String(this.hint)
|
|
|
|
.replace(/&/g, '&') // allows us to keep spaces at the beginning of an expression
|
|
|
|
.replace(/</g, '<') // prevent XSS exploits since we are rendering HTML
|
|
|
|
.replace(/>/g, '>')
|
|
|
|
.replace(/"/g, '"')
|
|
|
|
.replace(/ /g, ' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
},
|
2023-05-03 00:41:40 -07:00
|
|
|
},
|
2022-01-27 22:55:25 -08:00
|
|
|
mounted() {
|
|
|
|
if (this.$refs.hint) {
|
|
|
|
(this.$refs.hint as Element).querySelectorAll('a').forEach((a) => (a.target = '_blank'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2022-10-12 05:06:28 -07:00
|
|
|
<style lang="scss" module>
|
2023-02-26 22:25:57 -08:00
|
|
|
.singleline {
|
2022-10-12 05:06:28 -07:00
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
.highlight {
|
|
|
|
color: var(--color-secondary);
|
|
|
|
}
|
|
|
|
</style>
|