add vue-3-sanitize and linkifyjs to allow safe link formatting in notes

This commit is contained in:
Joshua Taillon
2022-11-05 00:53:54 -06:00
parent da5f7d12e7
commit fb10a87444
5 changed files with 62 additions and 16 deletions

View File

@ -3,30 +3,31 @@
<Card>
<template #title>{{ $t('workouts.NOTES') }}</template>
<template #content>
{{ notes && notes !== '' ? notes : $t('workouts.NO_NOTES') }}
<span v-html="notes !== '' ? $sanitize(linkifyStr(notes, { target: '_blank' })) : $t('workouts.NO_NOTES')" />
</template>
</Card>
</div>
</template>
<script setup lang="ts">
import { toRefs, withDefaults } from 'vue'
import linkifyStr from 'linkify-string'
import { toRefs, withDefaults } from 'vue'
interface Props {
notes?: string | null
}
const props = withDefaults(defineProps<Props>(), {
notes: () => null,
})
interface Props {
notes?: string | null
}
const props = withDefaults(defineProps<Props>(), {
notes: () => null,
})
const { notes } = toRefs(props)
const { notes } = toRefs(props)
</script>
<style lang="scss" scoped>
#workout-note {
::v-deep(.card-content) {
font-style: italic;
white-space: pre-wrap;
}
#workout-note {
::v-deep(.card-content) {
font-style: italic;
white-space: pre-wrap;
}
}
</style>

View File

@ -14,6 +14,7 @@ import {
} from 'chart.js'
import ChartDataLabels from 'chartjs-plugin-datalabels'
import { createApp } from 'vue'
import Vue3Sanitize from "vue-3-sanitize"
import VueFullscreen from 'vue-fullscreen'
import './registerServiceWorker'
@ -47,6 +48,7 @@ const app = createApp(App)
.use(store)
.use(router)
.use(VueFullscreen, { name: 'VFullscreen' })
.use(Vue3Sanitize, { allowedTags: ['a'] })
.directive('click-outside', clickOutsideDirective)
customComponents.forEach((component) => {

View File

@ -0,0 +1 @@
declare module 'vue-3-sanitize';