mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* WIP * Remove formula conversion related changes * Move the file input click guard to formatted text component * Move format types into their own components * Use a shared markdown-it instance * Move the formatter into data explorer * Move minification logic into BaserowFormulaMinified * Renderer should own the root element * Ensure long choice names are truncated * Ensure line height doesn't grow for paragraphs * Add tests * Add changelog * Add specific tests for choice element
46 lines
1.1 KiB
Vue
46 lines
1.1 KiB
Vue
<template>
|
|
<span v-if="isInline">{{ value }}</span>
|
|
<div v-else>
|
|
<ABParagraph v-for="paragraph in paragraphs" :key="paragraph.id">
|
|
{{ paragraph.content }}
|
|
</ABParagraph>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import formattedTextRenderer from '@baserow/modules/builder/mixins/formattedTextRenderer'
|
|
import { generateHash } from '@baserow/modules/core/utils/hashing'
|
|
|
|
/**
|
|
* @typedef Paragraph
|
|
* @property {string} content - The text of the paragraph
|
|
* @property {string} id - A hash identifying the paragraph
|
|
*/
|
|
|
|
/**
|
|
* The plain text renderer of `ABFormattedText`: the value as it is in a `span`
|
|
* in the inline profile, one paragraph per line in a `div` in the block
|
|
* profile.
|
|
*/
|
|
export default {
|
|
name: 'ABPlainText',
|
|
mixins: [formattedTextRenderer],
|
|
computed: {
|
|
/**
|
|
* The value split into paragraphs, for the block profile.
|
|
* @returns {Array.<Paragraph>}
|
|
*/
|
|
paragraphs() {
|
|
return this.value
|
|
.split('\n')
|
|
.map((line) => line.trim())
|
|
.filter((line) => line)
|
|
.map((line, index) => ({
|
|
content: line,
|
|
id: generateHash(line + index),
|
|
}))
|
|
},
|
|
},
|
|
}
|
|
</script>
|