Frame out note rendering
All checks were successful
/ docker (push) Successful in 2m0s

This commit is contained in:
Melody Becker 2025-07-13 22:23:35 +02:00
parent a3b3b73dab
commit 369453794b
Signed by: mstar
SSH key fingerprint: SHA256:vkXfS9FG2pVNVfvDrzd1VW9n8VJzqqdKQGljxxX8uK8
3 changed files with 65 additions and 4 deletions

View file

@ -0,0 +1,40 @@
<script setup lang="ts">
import PreviewHeader from '@/components/user/PreviewHeader.vue'
import type { Note as NoteData } from '@/stores/note.ts'
import { ref } from 'vue'
import FormattedText from '@/components/util/FormattedText.vue'
const props = defineProps<{
note: NoteData;
}>()
let collapsed = ref<boolean>(true);
function shortenContent(): string {
if (!collapsed.value) return props.note.rawContent;
if (props.note.rawContent.length > 200) {
const words = props.note.rawContent.split(' ');
let outString = '';
for (const word of words) {
if (outString.length > 200) {
return outString + '...';
}
outString += word + ' ';
}
return outString;
} else {
return props.note.rawContent;
}
}
</script>
<template>
<!-- Preview for reply here, decide if this component can also serve as such a preview -->
<PreviewHeader :user="props.note.owner" />
<FormattedText :raw-text="shortenContent" :hashtags="props.note.hashtags" :pinged="props.note.pings" />
</template>
<style scoped>
</style>

View file

@ -1,11 +1,21 @@
<script setup lang="ts">
import type { User } from '@/stores/userdata.ts'
const props = defineProps<{
rawText: string // Raw text (already pre-transformed by server into Linstrom format)
// User pings and hashtags not in here will not be highlighted
// Important for username rendering
pinged?: User[]
hashtags?: string[]
}>()
// TODO: Start figuring out how to format this stuff.
// Probably something akin to the treeificator. Marshal text into tree first,
// then adjust tree nodes to types that unmarshal into html
// TODO: Start figuring out how to format this stuff.
// Probably something akin to the treeificator. Marshal text into tree first,
// then adjust tree nodes to types that unmarshal into html
// Or single pass transform, keeping a stack of the current context
function render(): string {
return props.rawText
}
</script>
<template>
<p>{{props.rawText}}</p>
<div v-html="render" />
</template>

View file

@ -0,0 +1,11 @@
import type { User } from '@/stores/userdata.ts'
export interface Note {
id: string;
rawContent: string;
owner: User;
repliesTo?: Note;
quotes?: Note[];
pings: User[];
hashtags: string[];
}