1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-12 08:18:07 +00:00
bramw_baserow/web-frontend/modules/database/components/view/grid/fields/FunctionalGridViewFieldRichText.vue
2024-04-05 15:25:38 +00:00

37 lines
1.1 KiB
Vue

<!-- eslint-disable vue/no-v-html -->
<template functional>
<div
class="field-rich-text--preview grid-view__cell grid-field-rich-text__cell"
v-html="$options.methods.renderFormattedValue(parent, props)"
></div>
</template>
<script>
import { parseMarkdown } from '@baserow/modules/core/editor/markdown'
export default {
name: 'FunctionalGridViewFieldRichText',
methods: {
renderFormattedValue(parent, props) {
const maxLen = 200
const { value, workspaceId } = props
// Take only a part of the text as a preview to avoid rendering a huge amount of
// HTML that could slow down the page and won't be visible anyway
let preview = value || ''
if (preview.length > maxLen) {
preview = value.substring(0, maxLen) + '...'
}
const workspace = parent.$store.getters['workspace/get'](workspaceId)
const loggedUserId = parent.$store.getters['auth/getUserId']
return parseMarkdown(preview, {
openLinkOnClick: false,
workspaceUsers: workspace.users,
loggedUserId,
})
},
},
}
</script>