diff --git a/app/components/AttachmentItem.vue b/app/components/AttachmentItem.vue index 7b507ba..3d3fcde 100644 --- a/app/components/AttachmentItem.vue +++ b/app/components/AttachmentItem.vue @@ -45,7 +45,11 @@ import { computed, ref, onMounted, watch } from "vue" import { decode } from "blurhash" import type { SnAttachment } from "~/types/api" -const props = defineProps<{ item: SnAttachment; maxHeight?: string }>() +const props = defineProps<{ + item: SnAttachment + original?: boolean + maxHeight?: string +}>() const itemType = computed(() => props.item.mimeType.split("/")[0] ?? "unknown") const blurhash = computed(() => props.item.fileMeta?.blur) @@ -65,7 +69,7 @@ const router = useRouter() function openExternally() { // Capture image position for transition const img = event?.target as HTMLImageElement - if (img && itemType.value === 'image') { + if (img && itemType.value === "image") { const rect = img.getBoundingClientRect() const transitionData = { src: remoteSource.value, @@ -77,16 +81,20 @@ function openExternally() { } // Store transition data - sessionStorage.setItem('imageTransition', JSON.stringify(transitionData)) + sessionStorage.setItem("imageTransition", JSON.stringify(transitionData)) } - router.push('/files/' + props.item.id) + router.push("/files/" + props.item.id) } const blurCanvas = ref(null) const apiBase = useSolarNetworkUrl() -const remoteSource = computed(() => `${apiBase}/drive/files/${props.item.id}`) +const remoteSource = computed( + () => + `${apiBase}/drive/files/${props.item.id}` + + (props.original ? "?original=true" : "") +) const blurhashContainerStyle = computed(() => { return { diff --git a/app/components/AttachmentList.vue b/app/components/AttachmentList.vue index edae593..7a313d8 100644 --- a/app/components/AttachmentList.vue +++ b/app/components/AttachmentList.vue @@ -14,7 +14,7 @@ class="carousel-container rounded-lg overflow-hidden" :style="carouselStyle" > - + + > + + diff --git a/app/composables/useMarkdownProcessor.ts b/app/composables/useMarkdownProcessor.ts index 40b36aa..443e66a 100644 --- a/app/composables/useMarkdownProcessor.ts +++ b/app/composables/useMarkdownProcessor.ts @@ -9,13 +9,46 @@ export function useMarkdownProcessor() { html: true, linkify: true, typographer: true - // @ts-ignore + // @ts-ignore }).use(texmath, { engine: katex, - delimiters: 'dollars', + delimiters: "dollars", katexOptions: { macros: { "\\RR": "\\mathbb{R}" } } }) + const defaultParagraphRenderer = + processor.renderer.rules.paragraph_open || + ((tokens, idx, options, env, self) => + self.renderToken(tokens, idx, options)) + processor.renderer.rules.paragraph_open = function ( + tokens, + idx, + options, + env, + self + ) { + let result = "" + if (idx > 1) { + const inline = tokens[idx - 2] + const paragraph = tokens[idx] + if ( + inline && + inline.type === "inline" && + inline.map && + inline.map[1] && + paragraph && + paragraph.map && + paragraph.map[0] + ) { + const diff = paragraph.map[0] - inline.map[1] + if (diff > 0) { + result = "
".repeat(diff) + } + } + } + return result + defaultParagraphRenderer(tokens, idx, options, env, self) + } + return { render: (content: string) => processor.render(content) } diff --git a/app/pages/files/[id].vue b/app/pages/files/[id].vue index 00d0f40..daba55b 100644 --- a/app/pages/files/[id].vue +++ b/app/pages/files/[id].vue @@ -13,19 +13,57 @@
- mdi-file - {{ fileInfo.name || "File" }} + + + + + + + +
+ + mdi-download + + + mdi-information + +
- +
- {{ fileInfo.mimeType }} ({{ fileType }}) {{ formatBytes(fileInfo.size) }} {{ new Date(fileInfo.createdAt).toLocaleString() }} - + mdi-download - + mdi-information
@@ -61,7 +99,6 @@ v-if="fileType === 'image'" :src="fileSource" class="preview-image" - contain />