inhaus-plugin-gruppen/resources/js/components/RichText.vue
Friederich Loheide 5bdfb8a082 Gruppen-Plugin 1.0.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 17:17:10 +00:00

23 lines
1.1 KiB
Vue

<script setup>
import { computed, ref } from 'vue';
import { linkify } from '../lib/format';
/** Text mit Links; lange Texte werden gekürzt („Mehr anzeigen“) */
const props = defineProps({
text: { type: String, default: '' },
limit: { type: Number, default: 600 },
});
const expanded = ref(false);
const long = computed(() => props.text.length > props.limit);
const shown = computed(() => (long.value && !expanded.value ? `${props.text.slice(0, props.limit).trimEnd()} …` : props.text));
</script>
<template>
<p class="ih:break-words ih:whitespace-pre-wrap">
<template v-for="(part, i) in linkify(shown)" :key="i">
<a v-if="part.href" :href="part.href" target="_blank" rel="noopener noreferrer" class="ih:text-brand-text ih:underline ih:underline-offset-2">{{ part.text }}</a>
<template v-else>{{ part.text }}</template>
</template>
<button v-if="long" type="button" class="ih:ml-1 ih:font-medium ih:text-brand-text ih:hover:underline" @click="expanded = !expanded">{{ expanded ? 'Weniger' : 'Mehr anzeigen' }}</button>
</p>
</template>